Mô hình TCP/IP (Transmission Control Protocol/Internet Protocol) hay còn gọi là bộ giao thức Internet là một mô hình khái niệm và một tập hợp các giao thức truyền thông được sử dụng trong mạng Internet và các hệ thống mạng máy tính tương tự. Nó đóng vai trò như một ngôn ngữ chung cho phép các thiết bị khác nhau giao tiếp và trao đổi thông tin với nhau trên mạng.
Trang 1Chương 1: Tổng quan về mô hình
William Stallings, Data and Computer
Communications 8th edition , Prentice
-Hall Indernational Inc.
Trang 2Chương 1: Tổng quan về mô hình
truyền thông
1.1 Các thành phần chính của mạng máy tính.
1.3 Mô hình TCP/IP
1.4 Mô hình truyền thông từ máy đến máy.
1.5 Tiến trình phân phối gói tin.
1.7 IPv6.
1.8 Bài tập
Trang 31.1 Các thành phần chính của
mạng máy tính.
n
Trang 41.1 Các thành phần chính của
mạng máy tính.
n
Trang 61.2 Mô hình OSI.
Các công việc liên quan quá trình gửi 1 bức thư
Trang 71.2 Mô hình OSI.
n
Trang 81.2 Mô hình OSI.
n
Trang 91.2 Mô hình OSI.
Mô hình OSI 7 lớp: gồm 7 lớp riêng biệt nhưng có liên
hệ với nhau, mỗi lớp nhằm định nghĩa một phân đoạn trong quá trình di chuyển thông tin qua mạng.
Trang 101.2 Mô hình OSI.
Chức năng mỗi lớp trong mô hình OSI:
a) Lớp vật lý (Physical layer):Lớp vật lý chịu trách
nhiệm cho việc di chuyển các bit riêng lẻ từ 1 hop
(nút) đến nút kế tiếp Lớp này liên quan đến các đặc tính cơ, điện của giao diện thiết bị và môi trường
truyền.
Trang 111.2 Mô hình OSI.
Trang 131.2 Mô hình OSI.
b)Lớp liên kết dữ liệu (Data link layer): Lớp liên kết
dữ liệu chịu trách nhiệm chuyển các frame từ 1 hop (nút) đến hop khác.
Trang 141.2 Mô hình OSI.
14
Nhiệm vụ
Break L3 (Network) data into reasonable size (Frame)
Truyền khung/frame từ nút đến nút trong một mạng
Guarantee Node-to-Node delivery (Frame Error Free)
Service
Tạo khung (thêm header & trailer)
Định địa chỉ vật lý (MAC address: 12 digit hexadecimal ( e.g
080BF0AFDC09 ))
Same sender network: source & destination address
Outside sender network: source & connecting devices (bridge, router,
gateway) address
Điều khiển lưu lượng: frame acknowledgement, inform buffer size, etc.
Kiểm soát lỗi: error detection and error correction
Điều khiển truy cập: checking accessibility (ex Multipoint connection)
Trang 151.2 Mô hình OSI.
Phân phối hop đến hop
Trang 161.2 Mô hình OSI.
c) Lớp mạng (Network layer): Lớp mạng chịu trách nhiệm phân phối các gói tin riêng rẽ từ host nguồn đến host đích.
Trang 171.2 Mô hình OSI.
Nhiệm vụ
Bảo đảm phân phối gói tin/packet từ nguồn đến đích
có thể đi qua nhiều mạng
Service
Logical (Network) address (header):IP address
Định tuyến các gói tin đi qua thiết bị liên mạng
Router || Gateway
Trang 181.2 Mô hình OSI.
Phân phối từ nguồn đến đích
Trang 191.2 Mô hình OSI.
d)Lớp giao vận (Transport layer): Lớp giao vận chịu trách nhiệm phân phối message từ một quá
trình/process đến quá trình khác.
Trang 201.2 Mô hình OSI.
Nhiệm vụ
Đảm bảo phân phối toàn bộ từ nguồn đến đích cuối cùng
Service
Service-point addressing : Port address ( 16 bits: 0 – 65,535 ports )
Each application is assigned a specific port address
Segmentation and Reassembly
Source: segment L5 data into small segments
Destination: reassembly small segments into a whole
message
Điều khiển kết nối
Không kết nối/Connectionless
Hướng kết nối/Connection-oriented
Kiểm soát lỗi : dò và sửa sai toàn bộ message
Điều khiển luồng
Trang 211.2 Mô hình OSI.
e)Lớp phiên (Session layer): Lớp phiên chịu trách nhiệm điều khiển và đồng bộ dialog.
Trang 22 Traffic control & direction control
Đồng bộ thông điệp/Message synchronization
Adding checkpoints (synchronization points) in the message stream
Trang 231.2 Mô hình OSI.
f) Lớp trình diễn (Presentation layer): Lớp trình diễn chịu trách nhiệm biên dịch, nén và mã hóa
Trang 241.2 Mô hình OSI.
Nhiệm vụ
Manage syntax and semantics of different data format
between any two systems
Services
Dịch định dạng dữ liệu
Ex ASCII -> non ASCII system
Mã hóa (privacy & security)
Đối với các thông tin nhạy cảm: login-password, thẻ tín dung, tài khoản ngân hàng, thông tin cá nhân
Nén
Ex Zip, Gif, JPEG
Trang 251.2 Mô hình OSI.
g) Lớp ứng dụng (Application layer): Lớp ứng dụng chịu trách nhiệm cung cấp các dịch vụ đến người sử dụng
Trang 26 Network Virtual Terminal
Truyền , truy xuất và quản lý file/File transfer,
access, and management (FTAM)
Dịch vụ mail
Truy cập WWW
Trang 271.2 Mô hình OSI.
Giao tiếp giữa các lớp trong mô hình OSI
Trang 281.2 Mô hình OSI.
Trao đổi dữ liệu sử dụng mô hình OSI
Trang 291.3 Mô hình TCP/IP
The layers in the TCP/IP protocol suite do not exactly match those in the OSI model The original TCP/IP protocol suite was defined as having four layers: host- to-network , internet , transport , and application However, when TCP/IP is compared to OSI, we can say that the TCP/IP protocol suite is made of five layers: physical , data link , network , transport , and
application
Trang 301.3 Mô hình TCP/IP
Trang 311.3 Mô hình TCP/IP
Network Access
Trang 321.3 Mô hình TCP/IP
a) Physical and Data Link Layers:
At the physical and data link layers, TCP/IP does not
define any specific protocol It supports all the standard and proprietary protocols A network in a TCP/IP
internetwork can be a local-area network or a wide-area network
b) Network Layer :
At the network layer (or, more accurately, the
internetwork layer), TCP/IP supports the Internetworking Protocol lP, in turn, uses four supporting protocols:
ARP, RARP, ICMP, and IGMP
Trang 331.3 Mô hình TCP/IP
c) Transport Layer:
Traditionally the transport layer was represented in
TCP/IP by two protocols· TCP and UDP IP is a host protocol, meaning that it can deliver a packet from one physical device to another UDP and TCP are
host-to-transport level protocols responsible for delivery of a
message from a process (running program) to another process A new transport layer protocol, SCTP, has been devised to meet the needs of some newer applications
Trang 341.3 Mô hình TCP/IP
h
Trang 351.3 Mô hình TCP/IP
UDP protocol:
The User Datagram Protocol (UDP) is called a
connectionless, unreliable transport protocol It does not add anything to the services of lP except to
provide process-toprocess communication instead of host-to-host communication Also, it performs very limited error checking
Trang 36 Provides limited error checking
Provides best-effort delivery
Has no data-recovery features
UDP Characteristics
Trang 371.3 Mô hình TCP/IP
Well-Known Ports for UDP
Trang 381.3 Mô hình TCP/IP
Well-Known Ports for UDP
Trang 391.3 Mô hình TCP/IP
User Datagram: UDP packets, called user datagrams,
have a fixed-size header of 8 bytes
UDP length
= IP length – IP header’s length
Trang 401.3 Mô hình TCP/IP
Checksum
-The UDP checksum includes three sections: a
pseudoheader, the UDP header, and the data coming from the application layer
-The pseudoheader is the part of the header of the lP
packet in which the user datagram is to be
encapsulated with some fields filled with Os
Trang 411.3 Mô hình TCP/IP
Pseudoheader for checksum calculation
Trang 421.3 Mô hình TCP/IP
Example 23.2
Figure 23.11 shows the checksum calculation for a very small user datagram with only 7 bytes of data Because the number of bytes of data is odd, padding is added for checksum calculation The pseudoheader as well as the padding will be dropped when the user datagram is
delivered to lP
Trang 431.3 Mô hình TCP/IP
User
Trang 441.3 Mô hình TCP/IP
UDP Operation
-Connectionless Services: each user datagram sent by
UDP is an independent datagram There is no connection establishment and no connection termination
-Flow and Error Control:UDP is a very simple,
unreliable transport protocol There is no flow control
and hence no window mechanism The receiver may
overflow with incoming messages 44
Trang 451.3 Mô hình TCP/IP
-Encapsulation and Decapsulation: To send a message
from one process to another, the UDP protocol
encapsulates and decapsulates messages in an lP
datagram
-Queuing:
Trang 461.3 Mô hình TCP/IP
Use of UDP:
- UDP is suitable for a process that requires simple
request-response communication with little concern for flow and error control It is not usually used for a process such as FfP that
needs to send bulk data.
-UDP is suitable for a process with internal flow and error
control mechanisms For example, the Trivial File Transfer
Ptotocol (TFTP) process includes flow and error control It can easily use UDP.
Trang 471.3 Mô hình TCP/IP
- UDP is a suitable transport protocol for multicasting
Multicasting capability is embedded in the UDP software but not
in the TCP software.
- UDP is used for management processes.
- UDP is used for some route updating protocols such as Routing Information Protocol (RIP)
Trang 481.3 Mô hình TCP/IP
TCP (Transmission Control Protocol) protocol: TCP
is a connection-oriented protocol; it creates a virtual connection between two TCPs to send data In
addition, TCP uses flow and error control mechanisms
at the transport level Therefore, TCP is called a
connection-oriented, reliable transport protocol It
adds connection-oriented and reliability features to the services of lP
Trang 491.3 Mô hình TCP/IP TCP Characteristics
Transport layer of the TCP/IP stack
Access to the network layer for applications
Trang 501.3 Mô hình TCP/IP
TCP Services
Process-to-Process Communication: Like UDP, TCP
provides process-to-process communication using
port numbers
Trang 511.3 Mô hình TCP/IP
Well-known ports used by TCP
Trang 521.3 Mô hình TCP/IP
Stream Delivery Service: TCP, unlike UDP, is a
stream-oriented protocol TCP allows the sending
process to deliver data as a stream of bytes and allows the receiving process to obtain data as a stream of
bytes TCP creates an environment in which the two processes seem to be connected by an imaginary
"tube“ that carries their data across the Internet
Trang 531.3 Mô hình TCP/IP
Stream delivery
Trang 541.3 Mô hình TCP/IP
Sending and Receiving Buffers: Because the
sending and the receiving processes may not write or read data at the same speed, TCP needs buffers for
storage There are two buffers, the sending buffer and the receiving buffer, one for each direction
Trang 551.3 Mô hình TCP/IP
Sending and receiving buffers
Trang 561.3 Mô hình TCP/IP
Segments: The lP layer, as a service provider for TCP, needs
to send data in packets, not as a stream of bytes At the
transport layer, TCP groups a number of bytes together into a packet called a segment TCP adds a header to each segment (for control pruposes) and delivers the segment to the lP layer for transmission The segments are encapsulated in lP
datagrams and transmitted This entire operation is transparent
to the receiving process
Trang 571.3 Mô hình TCP/IP
TCP segments
Trang 581.3 Mô hình TCP/IP
Full-Duplex Communication: TCP offers full-duplex
service, in which data can flow in both directions at the same time Each TCP then has a sending and
receiving buffer, and segments move in both
directions
Trang 591.3 Mô hình TCP/IP
Connection-Oriented Service:
TCP, unlike UDP, is a connection-oriented protocol
When a process at site A wants to
send and receive data from another process at site B, the following occurs:
1 The two TCPs establish a connection between them
2 Data are exchanged in both directions
Trang 601.3 Mô hình TCP/IP
Reliable Service: TCP is a reliable transport protocol
It uses an acknowledgment mechanism to check
the safe and sound arrival of data
'I'CP Features
Numbering System:
-Byte Number: The bytes of data being transferred in
each connection are numbered by TCP The numbering starts with a randomly generated number 60
Trang 611.3 Mô hình TCP/IP
-Sequence Number: The value in the sequence number
field of a segment defines the number of the first data byte contained in that segment
-Acknowledgment Number: The value of the
acknowledgment field in a segment defines the number
of the next byte a party expects to receive The
acknowledgment number is cumulative
Trang 621.3 Mô hình TCP/IP
Flow Control : The receiver of the data controls the
amount of data that are to be sent by the sender This
is done to prevent the receiver from being
overwhelmed with data The numbering system
allows TCP to use a byte-oriented flow control
Error Control
Congestion Control
Trang 631.3 Mô hình TCP/IP
Segment
Format:
Trang 641.3 Mô hình TCP/IP
Control field
Trang 651.3 Mô hình TCP/IP
A TCP Connection
Connection Establishment: TCP transmits data in
full-duplex mode When two TCPs in two machines are connected, they are able to send segments to each other simultaneously This implies that each party
must initialize connnunication and get approval from the other party before any data are transferred
Trang 661.3 Mô hình TCP/IP
Establishing a Connection
Trang 671.3 Mô hình TCP/IP
-Three Way Handshaking: The connection establishment
in TCP is called three way handshaking
Trang 681.3 Mô hình TCP/IP
A SYN segment cannot carry data, but it consumes one sequence number
A SYN + ACK segment cannot carry data, but does
consume one sequence number
An ACK segment, if carrying no data, consumes no
sequence number
Trang 691.3 Mô hình TCP/IP
Data Transfer
Trang 701.3 Mô hình TCP/IP
Connection Termination
Connection termination using three-way handshaking
Trang 711.3 Mô hình TCP/IP
lhe FIN segment consumes one sequence number If It does not carry data
The FIN +ACK segment consumes one sequence
number If If does not carry data
Trang 721.3 Mô hình TCP/IP
Flow Control: TCP uses a sliding window to handle
flow control The sliding window protocol used by TCP, however, is something between the Go-Back-Nand Selective Repeat sliding window
Trang 731.3 Mô hình TCP/IP
Flow Control
Trang 741.3 Mô hình TCP/IP
TCP Acknowledgment
Trang 751.3 Mô hình TCP/IP
Fixed Windowing
Trang 761.3 Mô hình TCP/IP
Sliding window: A sliding window is used to make
transmission more efficient as well as to control the flow
of data so that the destination does not become
overwhelmed with data TCP sliding windows are byte oriented
Trang 771.3 Mô hình TCP/IP
TCP Sliding Windowing
Trang 781.3 Mô hình TCP/IP
Some points about TCP sliding windows:
-The size of the window is the lesser of rwnd and cwnd.
-The source does not have to send a full window's worth of data -The wmdow can be opened or closed by the receiver, but shouW not be shrunk.
-The destination can send an acknowledgment at any time as long
as it does not result in a shrinking window.
- The receiver can temporarily shut down the window; the sender, however, can always send a segment of 1 byte after the window is shut down
78
Trang 79What is the value of the receiver window (rwnd) for host A
if the receiver, host B, has a buffer size of 5000 bytes and
1000 bytes of received and unprocessed data ?
Example 23.4
Solution
The value of rwnd = 5000 − 1000 = 4000 Host B can receive only 4000 bytes of data before overflowing its buffer Host B advertises this value in its next segment to A.
Trang 801.3 Mô hình TCP/IP
TCP Sequence and Acknowledgment
Numbers
Trang 811.3 Mô hình TCP/IP
Error Control
Checksum:
-Each segment includes a checksum field which is used
to check for a corrupted segment If the segment is
corrupted, it is discarded by the destination TCP and is considered as lost
-TCP uses a 16-bit checksum that is mandatory in every
Trang 821.3 Mô hình TCP/IP
Acknowledgment: TCP uses acknowledgments to
confirm the receipt of data segments Control segments that carry no data but consume a sequence number are also acknowledged ACK segments
are never acknowledged
Retransmission: In modent implementations, a
retransmissimt occur s if the retransmission timer
expires or three duplicate ACK segments have arrived
Trang 831.3 Mô hình TCP/IP
Out-of-Order Segments: Data may arrive out of order
and be temporarily stored by the receiving TCP,
but TCP guarantees that no out-of-order segment is delivered to the process