CSC: Principles of Computer Networks: Demultiplexing
CSC: Principles of Computer Networks: Demultiplexing
Duties of Transport
• Demultiplexing:
– IP header points to protocol
– Transport header needs demultiplex further
• Port number
• well known ports and ephemeral ports
• Data reliability (if desired):
– UDP: checksum, but no data recovery
– TCP: checksum, sequence number, and data
recovery
TCP
• Services
– Point-to-point connection
– Guaranteed delivery of messages
– Same order as they’re sent
– Byte-stream, duplex
• Mechanisms
– Three-way handshaking
– Flow control
• Sender doesn’t overrun receiver
– Congestion control
• Sender doesn’t overrun the network (routers)
1
TCP Header
0 4 10 16 31
Source port Destination port
Sequence number
Acknowledgement
HdrLen Flags Advertised window
Checksum Urgent pointer
Options (variable)
Segment
• TCP breaks up the byte stream in segments.
– Limited to the Maximum Segment Size (default 536 bytes)
• Each segment has a sequence number.
– Indicates where it fits in the byte stream
SYN, SeqN
um =x
=x+1
y and Ack
K, SeqNum =
SYN and AC
ACK, Ack
=y +1
2
Reliable Transfer w/ Sliding Window
3
TCP Flow Control
• Make sure receiving end can handle data
• The receiver puts its available buffer size in
the TCP header as AdvertisedWindow.
• The sender should not send more data than
what AdvertisedWindow allows.
10
App write
11
• Two papers:
– Good science vs. Great engineering
12
4
Dangers of Increasing Load
packet
knee cliff
• Knee – point after which loss
Throughput
– Throughput increases very
slow congestion
– Delay increases fast collapse
Load
13
User 1 x1
x2
User 2 Σ Σxi>Xgoal
xn
User n
y
Possible Choices
& a + bI xi (t ) increase #
xi (t + 1) = % I "
$aD + bD xi (t ) decrease!
15
5
Multiplicative Increase, Additive
Decrease
• Fixed point at fairness
line
(bI (x1h+aD), bI (x2h+aD))
ba
x1h = x2 h = I D
1 ! bI (x1h,x2h)
• Fixed point is
User 2: x2
overload
underload
efficiency
line
User 1: x1 16
fairness
(x1h+aD+aI), line
x2h+aD+aI))
• Reaches stable
cycle, but does (x1h,x2h)
not converge to
User 2: x2
fairness (x1h+aD,x2h+aD)
efficiency
line
User 1: x1 17
Multiplicative Increase,
Multiplicative Decrease
fairness
line
(x1h,x2h)
• Reaches (bI b Dx1h,
stable cycle, bIb Dx2h)
but does not
User 2: x2
converge to
fairness (bd x 1h,bd x 2h)
efficiency
line
User 1: x1 18
6
Additive Increase,
Multiplicative Decrease
fairness
line
(x1h,x2h)
• Converges to (bDx1h+aI ,
bDx 2h+aI)
stable and fair
cycle
User 2: x2
(bDx1h,bDx2h)
efficiency
line
User 1: x1 19
21
7
Slow Start Example
• The congestion
window size grows segment 1
rapidly cwnd = 1
ACK 2
cwnd = 2 segment 2
segment 3
ACK 4
cwnd = 4 segment 4
• TCP will slow segment 5
down the increase segment 6
segment 7
of cwnd when
ACK8
cwnd = 8
cwnd >= ssthresh
22
23
Example
cwnd = 1
• Assume that ssthresh = 8
cwnd = 2
14 cwnd = 4
12
Cwnd (in segments)
10
cwnd = 8
8 ssthresh
6
4
2 cwnd = 9
0
2
0
6
t=
t=
t=
t=
Roundtrip times
cwnd = 10
24
8
Retransmission Timeout (RTO)
• Upon a retransmission timeout
– Assume packet loss due to congestion
– Cut window size drastically
ssthresh = cwnd/2;
cwnd = 1;
25
cwnd = 1;
26
cwnd
Timeout
Congestion
Avoidance
Slow Start
Time
27
9
Fast Retransmission
segment 1
• Don’t wait for cwnd = 1
28
Fast Recovery
• After a fast retransmission, set cwnd to cwnd/2
– i.e., don’t reset cwnd to 1
29
Loss detected:
ssthresh = cwnd/2; /* multiplicative decrease */
if (3 duplicated ACKs) /* fast retransmission */
cwnd = ssthresh; /* fast recovery*/
else
cwnd = 1;
30
10
Fast Retransmit and Fast Recovery
cwnd
Congestion
Avoidance
Slow Start
Time
31
32
Other Approaches
• Goals
– Throughput
– Fairness
– TCP-friendly
• Sender adaptation
– TCP Tahoe, Reno, Vegas, Westwood, …
• Router-assisted Approaches
– RED, REM
• Explicit Congestion Notification (ECN)
33
11