Bài giảng Mạng máy tính - Chapter 3: Transport Layer - Nguyễn Lê Duy Lai
Computer Networks
Lectured by:
Nguyen Le Duy Lai
(lai@hcmut.edu.vn)
Computer
Networking: A Top
Down Approach
7th Edition, Global Edition
Jim Kurose, Keith Ross
Pearson
April 2016
Introduction 1-1
Chapter 3
Transport Layer
Computer
Networking: A Top
Down Approach
7th Edition, Global Edition
Jim Kurose, Keith Ross
Pearson
April 2016
Transport Layer
2-2
Chapter 3: Transport Layer
our goals:
▪ understand
principles behind
transport layer
services:
▪ learn about Internet
transport layer protocols:
• UDP: connectionless
transport
• TCP: connection-oriented
• Multiplexing (mux),
demultiplexing
(demux)
reliable transport
• TCP flow control
• reliable data transfer
• TCP congestion control
(rdt)
• flow control
• congestion control
Transport Layer
3-3
Chapter 3: outline
3.5 connection-oriented
3.1 transport-layer
services
transport: TCP
• segment structure
• reliable data transfer
• flow control
3.2 multiplexing and
demultiplexing
3.3 connectionless
transport: UDP
3.4 principles of reliable
data transfer
• connection management
3.6 principles of congestion
control
3.7 TCP congestion control
Transport Layer
3-4
Transport services and protocols
application
transport
network
data k
phys
▪ provide logical communication
between app processes
running on different hosts
▪ transport protocols run in
end systems
• send side: breaks app
messages into segments,
passes to network layer
• receive side: reassembles
segments into messages,
passes to app layer
applcation
transport
network
data link
physical
▪ more than one transport
protocol available to apps
• Internet: TCP and UDP
Transport Layer
3-5
Transport vs. network layer
▪ network layer
household analogy:
▪ logical communication
between hosts
12 kids in Ann’s house sending
letters to 12 kids in Bill’s
house:
▪ transport layer
▪ logical communication
▪ hosts = houses
▪ processes = kids
between processes
▪ relies on, enhances,
▪ app messages = letters in
network layer services
envelopes
▪ transport protocol = Ann and
Bill who demux to in-house
siblings
▪ network-layer protocol =
postal service
Transport Layer
3-6
Internet transport-layer protocols
application
transport
network
data link
physical
▪ reliable, in-order delivery:
TCP
network
data link
physical
network
data link
physical
• connection setup
ork
dak
phys
• flow control
• congestion control
network
data link
physical
▪ possibly unreliable,
network
data link
physical
unordered delivery: UDP
network
data link
physical
• no-frills extension of
appcation
transport
network
data link
physical
network
data link
physical
“best-effort” IP
▪ services not available:
• delay guarantees
• bandwidth guarantees
Transport Layer
3-7
Chapter 3 outline
3.5 connection-oriented
transport: TCP
3.1 transport-layer
services
• segment structure
• reliable data transfer
• flow control
3.2 multiplexing and
demultiplexing
3.3 connectionless
transport: UDP
3.4 principles of reliable
data transfer
• connection management
3.6 principles of congestion
control
3.7 TCP congestion control
Transport Layer
3-8
Multiplexing/demultiplexing
multiplexing at sender:
demultiplexing at receiver:
handle data from multiple
sockets, add transport header
(later used for demultiplexing)
use header info to deliver
received segments to correct
socket
application
P1
P2
application
application
socket
P4
P3
transport
process
network
link
transport
transport
network
link
network
link
physical
physical
physical
Transport Layer
3-9
How demultiplexing works
▪ host receives IP datagrams
32 bits
source port # dest port #
• each datagram has source IP
address, destination IP address
• each datagram carries one
other header fields
transport-layer segment
• each segment has source,
destination port number
application data
(payload)
▪ host uses IP addresses &
port numbers to direct
segment to appropriate
socket
TCP/UDP segment format
Transport Layer
3-10
Connectionless demultiplexing
▪ recall: created socket has
▪ recall: when creating
datagram to send into
UDP socket, must specify
• destination IP address
• destination port #
host-local port #:
DatagramSocket mySocket1
= new
DatagramSocket(12534);
IP datagrams with same
dest. port #, but different
source IP addresses
▪ when host receives UDP
segment:
• checks destination port #
and/or source port
in segment
numbers will be directed
to same socket at dest
• directs UDP segment to
socket with that port #
Transport Layer
3-11
Connectionless demux: example
DatagramSocket
serverSocket = new
DatagramSocket
(6428);
DatagramSocket
mySocket2 = new
DatagramSocket
DatagramSocket
mySocket1 = new
DatagramSocket
(5775);
(9157);
application
application
application
P1
P3
P4
transport
transport
transport
network
link
network
link
network
link
physical
physical
physical
source port: 6428
dest port: 9157
source port: ?
dest port: ?
source port: ?
dest port: ?
source port: 9157
dest port: 6428
Transport Layer
3-12
Connection-oriented demux
▪ server host may support
▪ TCP socket identified
by 4-tuple:
many simultaneous TCP
sockets:
• source IP address
• source port number
• dest IP address
• each socket identified by its
own 4-tuple
▪ E.g., web servers have
different sockets for
each connecting client
• dest port number
▪ demux: receiver uses
all four values to direct
segment to appropriate
socket
• non-persistent HTTP will
have different socket for
each request
Transport Layer
3-13
Connection-oriented demux: example
application
application
application
P4
P5
P6
P3
P1
P2
transport
network
link
transport
transport
network
link
network
link
physical
physical
physical
server: IP
address B
host: IP
address C
host: IP
address A
source IP,port: B,80
dest IP,port: A,9157
source IP,port: C,5775
dest IP,port: B,80
source IP,port: A,9157
dest IP, port: B,80
source IP,port: C,9157
dest IP,port: B,80
three segments, all destined to IP address: B,
dest port: 80 are demultiplexed to different sockets
Transport Layer
3-14
Connection-oriented demux: example
threaded server
application
application
application
P4
P3
P3
P2
transport
network
link
transport
transport
network
link
network
link
physical
physical
physical
server: IP
address B
host: IP
address C
host: IP
address A
source IP,port: B,80
dest IP,port: A,9157
source IP,port: C,5775
dest IP,port: B,80
source IP,port: A,9157
dest IP, port: B,80
source IP,port: C,9157
dest IP,port: B,80
Transport Layer
3-15
Chapter 3 outline
3.5 connection-oriented
transport: TCP
3.1 transport-layer
services
• segment structure
• reliable data transfer
• flow control
3.2 multiplexing and
demultiplexing
3.3 connectionless
transport: UDP
3.4 principles of reliable
data transfer
• connection management
3.6 principles of congestion
control
3.7 TCP congestion control
Transport Layer
3-16
UDP: User Datagram Protocol [RFC 768]
▪ UDP use:
▪ “no frills,” “bare bones”
Internet transport
protocol
▪ streaming multimedia
apps (loss tolerant, rate
sensitive)
▪ “best effort” service,
UDP segments may be:
▪ DNS
▪ SNMP
• lost
• delivered out-of-order
▪ reliable transfer over
to app layer
UDP:
▪ connectionless:
▪ add reliability at
• no handshaking
between UDP sender,
receiver
• each UDP segment
handled independently
of others
application layer
▪ application-specific error
recovery!
Transport Layer
3-17
UDP: segment header
length (in bytes) of
32 bits
UDP segment,
including header
source port #
length
dest port #
checksum
why is there a UDP?
▪ no connection establishment
(which can add delay)
Application data
▪ simple: no connection
(payload)
state at sender, receiver
▪ small header size
▪ no congestion control: UDP
can blast away as fast as
desired
UDP segment format
Transport Layer
3-18
UDP checksum
Goal: detect “errors” (e.g., flipped bits) in transmitted
segment
sender:
receiver:
▪ treat segment contents,
including header fields,
as sequence of 16-bit
integers
▪ compute checksum of
received segment
▪ check if computed
checksum equals checksum
field value:
▪ checksum: addition
(one’s complement sum)
of segment contents
• NO - error detected
• YES - no error detected.
But maybe errors
nonetheless? More later
….
▪ sender puts checksum
value into UDP
checksum field
Transport Layer
3-19
Internet checksum: example
example: add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
wraparound
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
sum
checksum
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0
1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
Note: when adding numbers, a carryout from the most
significant bit needs to be added to the result
* Check out the online interactive exercises for more
examples: http://gaia.cs.umass.edu/kurose_ross/interactive/
Transport Layer
3-20
Tải về để xem bản đầy đủ
Bạn đang xem 20 trang mẫu của tài liệu "Bài giảng Mạng máy tính - Chapter 3: Transport Layer - Nguyễn Lê Duy Lai", để tải tài liệu gốc về máy hãy click vào nút Download ở trên
File đính kèm:
bai_giang_mang_may_tinh_chapter_3_transport_layer_nguyen_le.pdf