4 1transport
4 1transport
4 1transport
1
Goals for Today’s Lecture
• Principles underlying transport-layer services
– (De)multiplexing
– Detecting corruption
– Reliable delivery
– Flow control
2
Role of Transport Layer
• Application layer
– Communication for specific applications
– E.g., HyperText Transfer Protocol (HTTP), File Transfer
Protocol (FTP), Network News Transfer Protocol (NNTP)
• Transport layer
– Communication between processes (e.g., socket)
– Relies on network layer and serves the application layer
– E.g., TCP and UDP
• Network layer
– Logical communication between nodes
– Hides details of the link technology
– E.g., IP 3
Transport Protocols
• Provide logical communication
between application processes
running on different hosts application
transport
network
data link
• Run on end hosts physical
network
data link
network physical
lo
– Sender: breaks application
gi
data link
ca
physical
l
messages into segments, network
en
data link
d-
physical network
and passes to network layer
en
data link
d
physical
tr
– Receiver: reassembles
an
network
sp
data link
or
segments into messages, physical
t
passes to application layer application
transport
network
available to applications
– Internet: TCP and UDP 4
Internet Transport Protocols
• Datagram messaging service (UDP)
– No-frills extension of “best-effort” IP
5
Multiplexing and Demultiplexing
• Host receives IP datagrams
32 bits
– Each datagram has source
and destination IP address, source port # dest port #
6
Unreliable Message Delivery Service
• Lightweight/connection less/ communication
between processes
– Avoid overhead and delays of ordered, reliable delivery
– Send messages to and receive them from a socket
checksum length
DATA
7
Why Would Anyone Use UDP?
• Finer control over what data is sent and when
– As soon as an application process writes into the socket
– … UDP will package the data and send the packet
• No connection state
– No allocation of buffers, parameters, sequence #s, etc.
– … making it easier to handle many active clients at once
“12.3.4.15” 9
Transmission Control Protocol (TCP)
• Connection oriented
– Explicit set-up and tear-down of TCP session
• Stream-of-bytes service
– Sends and receives a stream of bytes, not messages
• Reliable, in-order delivery
– Checksums to detect corrupted data
– Acknowledgments & retransmissions for reliable delivery
– Sequence numbers to detect losses and reorder data
• Flow control
– Prevent overflow of the receiver’s buffer space
• Congestion control
– Adapt to network congestion for the greater good 10
An Analogy: Talking on a Cell Phone
• Alice and Bob on their cell phones
– Both Alice and Bob are talking
11
Some Take-Aways from the Example
• Acknowledgments from receiver
– Positive: “okay” or “ACK”
– Negative: “please repeat that” or “NACK”
12
Challenges of Reliable Data Transfer
• Over a perfectly reliable channel
– All of the data arrives in order, just as it was sent
– Simple: sender sends data, and receiver receives data
14
TCP Segments
15
16
TCP “Stream of Bytes” Service
Byte 80
Byte 3
Byte 2
Byte 1
Byte 0
Byte 80
Byte 3
Byte 2
Byte 1
Byte 0
Host A
Host B
…Emulated Using TCP “Segments”
Host A
Byte 0
Byte 1
Byte 2
Byte 3
Byte 80
TCP Data
Host B
Byte 0
Byte 1
Byte 2
Byte 3
Byte 80
17
TCP Segment
IP Data
TCP Data (segment) TCP Hdr IP Hdr
• IP packet
– No bigger than Maximum Transmission Unit (MTU)
– E.g., up to 1500 bytes on an Ethernet
• TCP packet
– IP packet with a TCP header and data inside
– TCP header is typically 20 bytes long
• TCP segment
– No more than Maximum Segment Size (MSS) bytes
– E.g., up to 1460 consecutive bytes from the stream 18
Sequence Numbers
Host A
ISN (initial sequence number)
Sequence TCP
TCP Data
number = 1st HDR
19
Initial Sequence Number (ISN)
• Sequence number for the very first byte
– E.g., Why not a de facto ISN of 0?
• Practical issue
– IP addresses and port #s uniquely identify a connection
– Eventually, though, these port #s do get used again
– … and there is a chance an old packet is still in flight
– … and might be associated with the new connection
21
Establishing a TCP Connection
A B
SY N
Sequence number
Flags: SYN
Acknowledgment
FIN
RST HdrLen 0 Flags Advertised window
PSH
URG Checksum Urgent pointer
ACK Options (variable)
Data
23
Step 1: A’s Initial SYN Packet
24
Step 2: B’s SYN-ACK Packet
Sequence number
Flags: SYN
B’s ISN plus 1
FIN
RST 20 0 Flags Advertised window
PSH
URG Checksum Urgent pointer
ACK Options (variable)
27
SYN Loss and Web Downloads
• User clicks on a hypertext link
– Browser creates a socket and does a “connect”
– The “connect” triggers the OS to transmit a SYN
29
Automatic Repeat reQuest (ARQ)
Timeout
timeouts if it does not arrive
within some time period
ACK
• Simplest ARQ protocol
– Stop and wait Time
– Send a packet, stop and wait
until ACK arrives
30
Reasons for Retransmission
Timeout
Timeout
ACK C K
A
Packe
Packe Packe t
t t
Timeout
Timeout
Timeout
ACK
AC K ACK
33
Motivation for Sliding Window
• Stop-and-wait is inefficient
– Only one TCP segment is “in flight” at a time
– Especially bad when delay-bandwidth product is high
• Numerical example
– 1.5 Mbps link with a 45 msec round-trip time (RTT)
Delay-bandwidth product is 67.5 Kbits (or 8 KBytes)
– But, sender can send at most one packet per RTT
Assuming a segment size of 1 KB (8 Kbits)
… leads to 8 Kbits/segment / 45 msec/segment 182 Kbps
That’s just one-eighth of the 1.5 Mbps link capacity
34
Sliding Window
• Allow a larger amount of data “in flight”
– Allow sender to get ahead of the receiver
– … though not too far ahead
TCP TCP
Last byte written Last byte read
Sequence number
Flags: SYN
Acknowledgment
FIN
RST HdrLen 0 Flags Advertised window
PSH
URG Checksum Urgent pointer
ACK Options (variable)
Data
37
Fast Retransmission
38
Timeout is Inefficient
• Timeout-based retransmission
– Sender transmits a packet and waits until timer expires
– … and then retransmits from the lost packet onward
39
Fast Retransmission
• Better solution possible under sliding window
– Although packet n might have been lost
– … packets n+1, n+2, and so on might get through
• Fast retransmission
– Sender retransmits data after the triple duplicate ACK
40
Effectiveness of Fast Retransmit
• When does Fast Retransmit work best?
– Long data transfers
High likelihood of many packets in flight
– High window size
High likelihood of many packets in flight
– Low burstiness in packet losses
Higher likelihood that later packets arrive successfully
42
Tearing Down the Connection
SYN A
FIN A
ACK
ACK
ACK
SY N
FIN
FI N
Data
C
C
K
K
A
time
44
Conclusions
• Transport protocols
– Multiplexing and de-multiplexing
– Sequence numbers
– Window-based flow control
– Timer-based retransmission
– Checksum-based error detection
• Next lecture
– Congestion control
45