MẠNG MÁY TÍNH
(COMPUTER NETWORKING)
J.F Kurose and K.W. Ross. Computer
Networking A Top Down Approach.
6th edition, Addision Wesley, 2013
Nội dung môn học
Chapter 1: Computer Networks and the Internet
Chapter 2: Application Layer
Chapter 3: Transport Layer
Chapter 4: Network Layer
Chapter 5: The Link Layer and Local Area Network
Data Link
Chapter 6: Wireless and Mobile Networks
Chapter 7: Multimedia Networking
Chapter 8: Security in Computer Networks
Chapter 9: Network Management
1.2
Chapter 3: TRANSPORT
LAYER
Mục tiêu
Hiểu các nguyên tắc đằng sau các dịch vụ lớp transport
Multiplexing/ Demultiplexing
Truyền dữ liệu tin cậy
Điều khiển luồng
Điều khiển tắc nghẽn
Nghiên cứu các giao thức lớp transport trên Internet
UDP: vận chuyển không kết nối (connectionless)
TCP: vận chuyển hướng kết nối (connection-oriented)
Điều khiển tắc nghẽn TCP
1.4
Chapter 3 outline
3.1 Introduction and Transport-Layer Services
3.2 Multiplexing and Demultiplexing
3.3 Connectionless Transport: UDP
3.4 Principles of Reliable Data Transfer
3.5 Connection-Oriented Transport: TCP
Segment structure
Reliable data transfer
Flow control
Connection management
3.6 Principles of Congestion Control
3.7 TCP Congestion Control
1.5
Chapter 3 outline
3.1 Introduction and Transport-Layer Services
3.2 Multiplexing and Demultiplexing
3.3 Connectionless Transport: UDP
3.4 Principles of Reliable Data Transfer
3.5 Connection-Oriented Transport: TCP
Segment structure
Reliable data transfer
Flow control
Connection management
3.6 Principles of Congestion Control
3.7 TCP Congestion Control
1.6
1.7
3.1.1 Relationship between Transport and
Network Layers
Situation:
Network layer: logic
Cousins live in two different
houses try to send letter to each
others
communication among
hosts
Transport layer: logic
Application messages = letter
communication among
processes
in envelopes
Processes = cousins
Host = houses
Transport-layer protocol = Ann
and Bill
Network-layer protocol =
postal service
1.8
3.1.2 Overview of the Transport Layer in
the Internet
Unreliable, connectionless service to the invoking application (User
Datagram Protocol)
Reliable, connection-oriented service to the invoking application
(Transmission Control Protocol)
Reliable data transfer
Using flow control, sequence number, acknowledgments, and timer
Ensure data is delivered from sending process to receiving process,
correctly and in order
Provides congestion control
The most fundamental responsibility of UDP and TCP is to extend IP’s
delivery service between two end systems to a delivery service between two
processes running on the end systems
Extending host-to-host delivery to process-to-process delivery is called
transport-layer multiplexing and demultiplexing.
1.9
Chapter 3 outline
3.1 Introduction and Transport-Layer Services
3.2 Multiplexing and Demultiplexing
3.3 Connectionless Transport: UDP
3.4 Principles of Reliable Data Transfer
3.5 Connection-Oriented Transport: TCP
Segment structure
Reliable data transfer
Flow control
Connection management
3.6 Principles of Congestion Control
3.7 TCP Congestion Control
1.10
Multiplexing/demultiplexing
Demultiplexing at rcv host:
Delivering received segments
to correct socket
Multiplexing at send host:
Gathering data from multiple
sockets, enveloping data with
header (later used for
demultiplexing)
1.13
How demultiplexing works
16-bit# [0-65535]
Well-known port# [0-1023]
host receives IP datagrams
each datagram has source IP
address, destination IP address
each datagram carries 1
transport-layer segment
each segment has source,
destination port number
TCP/UDP segment format
host uses IP addresses & port
Well-known port number
[RFC 1700 & RFC 3232]
• HTTP: port # 80
• FTP: port #21, #20
numbers to direct segment to
appropriate socket
When we develop a new application, we must assign the
application a port number!!!!
1.14
Connectionless Demultiplexing
Create socket with port
When host receives UDP
numbers:
segment:
DatagramSocket mySocket1 = new
DatagramSocket(12534);
Check dest port number
in segment
DatagramSocket mySocket2 = new
DatagramSocket(12535)
Direct UDP segment to
socket with that port
number
UDP socket identified by two-
tuple:
(dest IP address, dest port
number)
1.15
IP datagrams with different
source IP addresses and/or
source port numbers
directed to same socket
Connectionless Demultiplexing
1.16
Connection-Oriented Demultiplexing
TCP socket được xác định bởi
bộ 4:
source IP address
source port number
dest IP address
dest port number
Server host có thể hỗ trợ
nhiều socket đồng thời
Mỗi socket được xác
định bởi bộ 4 của nó
Web servers có các socket
khác nhau cho mỗi kết nối
client
recv host sử dụng 4 giá trị để
điều hướng segment tới socket
thích hợp
1.17
non-persistent HTTP sẽ
có các socket khác nhau
cho từng yêu cầu
Connection-Oriented Demultiplexing
1.18
Connection-Oriented Demultiplexing:
Threaded Web Server
1.19
Chapter 3 outline
3.1 Introduction and Transport-Layer Services
3.2 Multiplexing and Demultiplexing
3.3 Connectionless Transport: UDP
3.4 Principles of Reliable Data Transfer
3.5 Connection-Oriented Transport: TCP
Segment structure
Reliable data transfer
Flow control
Connection management
3.6 Principles of Congestion Control
3.7 TCP Congestion Control
1.20
UDP: User Datagram Protocol [RFC 768]
Giao thức Internet transport “đơn
giản hóa”
“best effort” service, UDP
segment có thể
Bị mất
Vận chuyển không thứ tự đến
app
Connectionless: không kết nối
Không “handshaking” giữa
bên nhận và bên gởi
Mỗi UDP segment được quản
lý độc lập
1.21
Có UDP để làm gì?
- Khơng thiết lập kết nối
có thể add delay
- Đơn giản: không lưu
trạng thái kết nối tại
sender, receiver
- Segment header nhỏ
- Không điều khiển tắc
nghẽn: UDP có thể gởi
nhanh nhất theo mong
muốn
UDP: (tt)
Thường dùng cho các ứng dụng
streaming multimedia
Chịu mất mát (loss tolerant)
Tỷ lệ nhạy cảm (rate sensitive)
UDP khác dung
DNS
SNMP (Simple Network
Management Protocol)
Truyền tin cậy trên UDP: thêm khả
năng này tại application layer
Application-specific error
recovery
1.22
UDP checksum
Goal: kiểm tra các “lỗi” (các bit cờ đã bật lên) trong các segment đã
được truyền đi
Sender:
- đối xử với nội dung
segment như số nguyên
16-bit
- Checksum: bổ sung nội
dung segment (tổng bù
1)
- Sender đặt giá trị
checksum vào trường
UDP checksum
1.23
Receiver:
- Tính tốn checksum của
segment đã nhận
- Kiểm tra giá trị
checksum có bằng với
giá trị trường checksum
hay khơng
- NO: có lỗi xảy ra
- YES: khơng xảy ra
lỗi
Nhưng có thể có những
lỗi khác…(xem ở phần
sau)
Internet Checksum Example
Ghi chú:
Khi cộng các số, một bít nhớ ở phía cao nhất cần được thêm
vào kết quả
Kiểm tra checksum: Lấy tổng các số 16-bit (có nhớ) cộng với
checksum: Kết quả là 1111 1111 1111 1111 thì khơng có lỗi, nếu
khác là có lỗi.
Ví dụ: Cộng 2 số nguyên 16-bit
1.24
Chapter 3 outline
3.1 Introduction and Transport-Layer Services
3.2 Multiplexing and Demultiplexing
3.3 Connectionless Transport: UDP
3.4 Principles of Reliable Data Transfer
3.5 Connection-Oriented Transport: TCP
Segment structure
Reliable data transfer
Flow control
Connection management
3.6 Principles of Congestion Control
3.7 TCP Congestion Control
1.25
Principles of Reliable data transfer
Quan trọng trong các lớp application, transport, link
Nằm trong top-10 chủ đề quan trong của mạng
Đặc thù của kênh truyền không tin cậy sẽ xác định sự phức tạp của
giao thức truyền dữ liệu tin cậy (reliable data transfer protocol – rdt)
1.26
Principles of Reliable data transfer
1.27