CS 31204: Computer Networks – Transport Layer Services
INDIAN INSTITUTE OF TECHNOLOGY
KHARAGPUR
Department of Computer Science and Engineering
Abhijnan Chakraborty
Protocol Stack Implementation in a Host
Software, Kernel
Firmware, Device Driver
Hardware
Physical
Data Link
Network
Transport
Application
Indian Institute of Technology Kharagpur
How Application Data Passes Through Different Layers
Physical
Data Link
Network
Transport
Application
HTTP Data
HTTP Header
Transport Layer Data
TCP Header
Network Layer Data
IP Header
Data Link Layer Data
MAC Header
HTTP Data
HTTP Header
TCP Header
IP Header
MAC Header
PHY Header
PHY Trailer
Indian Institute of Technology Kharagpur
Transport Layer Services
UDP
End to end packet delivery
TCP
Connection Establishment
Reliable Data Delivery
Flow and Congestion Control
Ordered Packet Delivery
Transport
Data Link
Datagram delivery (unreliable)
Network
Indian Institute of Technology Kharagpur
Transport Layer – Interfacing with Application and Network
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Port Number
IP Address
Indian Institute of Technology Kharagpur
Transport Layer – Interfacing with Application and Network
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Create a logical pipe between the sender and the receiver and monitor the data transmission through this pipe
Indian Institute of Technology Kharagpur
Transport Service Primitives
The transport layer needs to remember the state of the pipe, so that appropriate actions can be taken. We need a stateful protocol for transport layer.
Indian Institute of Technology Kharagpur
Transport Service Primitive – Connection Establishment
Client
Server
LISTEN
CONNECT
CONNECTION REQ
CONNECTION ACK
ESTABLISHED
ESTABLISHED
SEND
DATA
RECEIVE
DISCONNECT
DISCONNECTION REQ
DISCONNECTION ACK
The client and server needs to remember the state
Indian Institute of Technology Kharagpur
Transport Layer Protocol – State Diagram
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
SERVER
Indian Institute of Technology Kharagpur
Transport Layer Protocol – State Diagram
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
CLIENT
Indian Institute of Technology Kharagpur
Segment, Packet (or Datagram) and Frame
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
Connection Establishment
Client
Server
LISTEN
CONNECT
CONNECTION REQ
CONNECTION ACK
Indian Institute of Technology Kharagpur
Connection Establishment
Indian Institute of Technology Kharagpur
Connection Establishment
Client
Server
LISTEN
CONNECT
CONNECTION REQ - 1
CONNECTION REQ - 2
It may happen that the server has crashed and the client reinitiated the connection (with same ports). So distinguishing between these two is essential
Indian Institute of Technology Kharagpur
Connection Establishment
Indian Institute of Technology Kharagpur
Connection Establishment – Handling Delayed Duplicates
Indian Institute of Technology Kharagpur
Connection Establishment – Handling Delayed Duplicates
Indian Institute of Technology Kharagpur
Connection Establishment – Handling Delayed Duplicates
Indian Institute of Technology Kharagpur
Sequence Number Adjustment
Indian Institute of Technology Kharagpur
Why Initial Sequence Number is Important
Packet Lifetime T
Time
Sequence Numbers
Connection 1
Connection 2
Conn 1 crashed
Conn 2 initialized
Indian Institute of Technology Kharagpur
What We Ideally Want? Either …
Packet Lifetime T
Time
Sequence Numbers
Connection 1
Connection 2
Conn 1 crashed
Conn 2 initialized
Indian Institute of Technology Kharagpur
What We Ideally Want? Or …
Packet Lifetime T
Time
Sequence Numbers
Connection 1
Connection 2
Conn 1 crashed
Conn 2 initialized
Indian Institute of Technology Kharagpur
Connection Establishment – Handling Delayed Duplicates
Indian Institute of Technology Kharagpur
How do We Ensure that Packet Sequence Numbers are �Out of the Forbidden Region
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
Adjusting the Sending Rate based on Sequence Numbers
Indian Institute of Technology Kharagpur
Three Way Handshake
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
Three Way Handshake – CONNECTION REQUEST is a Delayed Duplicate
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
Three Way Handshake – CONNECTION REQUEST and ACKNOWLEDGEMENT both are Delayed Duplicates
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
Connection Release – Asymmetric Release
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
Connection Release – Symmetric Release
Indian Institute of Technology Kharagpur
The Two Army Problem
No protocol exists to solve this
Let every party take independent decisions
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
Connection Release
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
Connection Release – Final ACK Lost
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
Connection Release – Response Lost
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
Connection Release – Response Lost and Subsequent DRs Lost
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
Ensure Reliability at the Transport Layer
Source: Computer Networks, Kurose, Ross
Indian Institute of Technology Kharagpur
Error Control and Flow Control
Indian Institute of Technology Kharagpur
Flow Control Algorithms
Indian Institute of Technology Kharagpur
Flow Control Algorithms
Note: acknowledgement contains sequence no. of next expected frame in TCP actually
0
1
0
1
1
Indian Institute of Technology Kharagpur
Stop and Wait ARQ – Sender Implementation
Source: Computer Networks, Kurose, Ross
Indian Institute of Technology Kharagpur
Problem with Stop and Wait
Indian Institute of Technology Kharagpur
Stop and Wait versus Sliding Window (Pipelined)
Source: Computer Networks, Kurose, Ross
Indian Institute of Technology Kharagpur
Sliding Window Protocols
Indian Institute of Technology Kharagpur
Sliding Window Protocols – Sending Window and Receiving Window
Indian Institute of Technology Kharagpur
Sliding Window for a 3 bit Sequence Number
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
Sliding Window Protocols in Noisy Channels
(start of the sliding window) to segment N are retransmitted
Indian Institute of Technology Kharagpur
Go Back N ARQ – Sender Window Control
Source: Computer Networks, Kurose, Ross
Indian Institute of Technology Kharagpur
Go Back N ARQ
Indian Institute of Technology Kharagpur
Go Back N ARQ – Sender
Source: Computer Networks, Kurose, Ross
Indian Institute of Technology Kharagpur
Go Back N ARQ – Receiver
Source: Computer Networks, Kurose, Ross
Indian Institute of Technology Kharagpur
Go Back N ARQ – A Bound on Window Size
Indian Institute of Technology Kharagpur
Go Back N ARQ – A Bound on Window Size
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
Timeout
Indian Institute of Technology Kharagpur
Go Back N ARQ – A Bound on Window Size
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
0
Timeout
Discards the wrong frame correctly
Indian Institute of Technology Kharagpur
Selective Repeat (SR) – Window Control
Source: Computer Networks, Kurose, Ross
Indian Institute of Technology Kharagpur
Selective Repeat ARQ
Indian Institute of Technology Kharagpur
Selective Repeat – A Bound on Window Size
Indian Institute of Technology Kharagpur
Selective Repeat – A Bound on Window Size
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
0
Timeout
1
2
1
2
1
2
1
2
Indian Institute of Technology Kharagpur
Selective Repeat – A Bound on Window Size
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
2
3
0
0
1
0
Timeout
1
2
1
2
1
2
Discards the wrong frame correctly
Indian Institute of Technology Kharagpur
Bandwidth Delay Product
Indian Institute of Technology Kharagpur
Bandwidth Delay Product – Implication on Window Size
Indian Institute of Technology Kharagpur
Implication of BDP on Protocol Design Choice
Indian Institute of Technology Kharagpur
Application Transport Interfacing – Sender Side
APPLICATION
write(), send()
TportSend()
Send Data to IP
Transmission Rate Control
USER
KERNEL
Trigger Periodically
Function names are hypothetical
Indian Institute of Technology Kharagpur
Application Transport Interfacing – Sender Side
APPLICATION
write(), send()
TportSend()
Send Data to IP
Transmission Rate Control
USER
KERNEL
Trigger Periodically
Transport Buffer - Sender
Different connections are treated differently, so we need connection specific source buffering
write() call blocks the port until the complete data is written in the transport buffer
Function names are hypothetical
Indian Institute of Technology Kharagpur
Application Transport Interfacing – Receiver Side
APPLICATION
read(), recv()
CheckBuffer()
USER
KERNEL
Transport Buffer - Receiver
Interrupt
Data from IP
TportRecv()
read() call blocks the port until the data is received and the complete data is read from the transport buffer
Function names are hypothetical
Indian Institute of Technology Kharagpur
Application Transport Interfacing – Receiver Side (Alternate Implementation)
APPLICATION
read(), recv()
PollBuffer()
Data from IP
USER
KERNEL
Transport Buffer - Receiver
poll()
get()
TportRecv()
Function names are hypothetical
Indian Institute of Technology Kharagpur
Organizing Transport Buffer Pool
Indian Institute of Technology Kharagpur
Organizing Transport Buffer Pool
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
Dynamic Buffer Management for Window Based Flow Control
Free Space at Receiver Buffer
Segments awaiting at the buffer
Segments read by the application
Indian Institute of Technology Kharagpur
Dynamic Buffer Management for Window Based Flow Control
Ensure that the ACKs are flowing in the network continously
Indian Institute of Technology Kharagpur
Congestion Control in the Network
10
20
5
2
6
4
2
11
18
S
D
50
50
Apply Max Flow Min Cut Theorem !
But this is hard in a real network …
Indian Institute of Technology Kharagpur
Congestion Control in the Network
Changing Bandwidth Allocation over Time
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
Congestion Control in the Network
Sending Rate = minimum (network rate, Receiver rate)
Gradually increase the network rate and observe the effect on flow rates (packet loss)
Comes from flow control – receiver advertised window size for a sliding window flow control
Indian Institute of Technology Kharagpur
Principles of congestion control
Congestion:
congestion control: too many senders, sending too fast
flow control: one sender too fast for one receiver
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
Causes/Costs of Congestion: Scenario 1
Simplest scenario:
maximum per-connection throughput: R/2
Host A
Host B
throughput: λout
large delays as arrival rate λin approaches capacity
original data: λin
R
infinite shared output link buffers
R
R/2
delay
λin
R/2
R/2
λout
λin
throughput:
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Q: What happens as the arrival rate λin approaches R/2?
Indian Institute of Technology Kharagpur
Causes/Costs of Congestion: Scenario 2
Host A
Host B
λin : original data
λ'in: original data, plus retransmitted data
finite shared output link buffers
λout
R
R
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
Causes/Costs of Congestion: Scenario 2
Host A
Host B
λin : original data
λ'in: original data, plus retransmitted data
finite shared output link buffers
copy
free buffer space!
Idealization: Perfect knowledge
λout
R
R
R/2
λin
R/2
λout
throughput:
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
Causes/Costs of Congestion: Scenario 2
Host A
Host B
λin : original data
λ'in: original data, plus retransmitted data
finite shared output link buffers
R
R
copy
no buffer space!
Idealization: Some perfect knowledge
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
Causes/Costs of Congestion: Scenario 2
Host A
Host B
λin : original data
λ'in: original data, plus retransmitted data
finite shared output link buffers
R
R
free buffer space!
Idealization: Some perfect knowledge
when sending at R/2, some packets are needed retransmissions
λin
R/2
λout
throughput:
R/2
“wasted” capacity due to retransmissions
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
Causes/Costs of Congestion: Scenario 2
Host A
Host B
λin : original data
λ'in: original data, plus retransmitted data
finite shared output link buffers
R
R
copy
timeout
Realistic scenario: Un-needed duplicates
free buffer space!
when sending at R/2, some packets are retransmissions, including needed and un-needed duplicates, that are delivered!
“wasted” capacity due to un-needed retransmissions
λin
R/2
λout
throughput:
R/2
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
Causes/Costs of Congestion: Scenario 2
“costs” of congestion:
Realistic scenario: un-needed duplicates
when sending at R/2, some packets are retransmissions, including needed and un-needed duplicates, that are delivered!
“wasted” capacity due to un-needed retransmissions
λin
R/2
λout
throughput:
R/2
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
Causes/Costs of Congestion: Scenario 3
finite shared output link buffers
Host A
λout
Host B
Host C
Host D
λin : original data
λ'in: original data, plus retransmitted data
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Q: What happens when λin and λ'in increase?
A: As red λ'in increases, all arriving blue packets at upper queue are dropped, blue throughput -> 0
Indian Institute of Technology Kharagpur
Causes/Costs of Congestion: Scenario 3
Another “cost” of congestion:
R/2
R/2
λout
λin’
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
Congestion Control and Fairness
Indian Institute of Technology Kharagpur
Max-Min Fairness – An Example
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
AIMD – Efficient and Fair Operating Point for Congestion Control
Indian Institute of Technology Kharagpur
AIMD – Design Rationale (Two Flows Example)
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
AIMD – Design Rationale (Two Flows Example)
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
Let us look TCP design details …
Indian Institute of Technology Kharagpur