Download presentation
Presentation is loading. Please wait.
Published byTracey Simon Modified over 9 years ago
1
TCP: flow and congestion control
2
Flow Control Flow Control is a technique for speed-matching of transmitter and receiver. Flow control ensures that a transmitting station does not overflow buffer of receiving station with data We will discuss two protocols for flow control: Stop-and-Wait Sliding Window (used by TCP) For the time being, we assume that we have a perfect channel (no errors) Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher
3
Stop-and-Wait Flow Control Simplest form of flow control In Stop-and-Wait flow control, the receiver indicates its readiness to receive next data frame Operations: 1. Sender: Transmit a single frame 2. Receiver: Transmit acknowledgment (ACK) 3. Goto 1. Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher
4
Analysis of Stop-and-Wait Efficiency = ? t prop t frame t ack ~0 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher
5
Analysis of Stop-and-Wait Efficiency = t prop t frame t ack ~0 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher
6
Sliding Window Flow Control Notion of window-based flow control: Sender can only transmits those bytes that are within its sliding window Every time an acknowledgement (ACK N) is received, window slides to N (and its size is notified by receiver). Copyright ©: Caccamo
7
How is “flow control” achieved? At any instant, the sender is permitted to send bytes with sequence numbers within sliding “advertised window” Receiver controls size of sliding window (by means of window field in TCP header) ACK N, window W: receiver acknowledges all bytes up to (but not including) sequence number N and sets new window size W starting point of sender window slides to position N (in data stream) with size W Sliding Window Flow Control Copyright ©: Caccamo
8
Flow Control example SenderReceiver SND_next=1 W=360 SeqNo=1 length=140 ACK=141 window=260 SND_next=141 W=260 SeqNo=141 length=180 ACK=321 window=80 SND_next=321 W=80 SeqNo=321 length=80 ACK=401 window=0 SND_next=401, W=0 Sender stops transmission!
9
Congestion control was introduced in the Internet roughly eight years after TCP/IP was introduced. In the early years Internet was suffering severe congestion problems: Host would send packets as fast as it could still honoring advertised receiver window If congestion would occur at some router, packets would get dropped At timeout, host would retransmit those packets again creating even more congestion TCP Congestion Control Copyright ©: Caccamo
10
Congestion control (at the sender side) tries to estimate available capacity in the network to prevent link congestion To implement congestion control, TCP introduces two new state variables for each connection Congestion window (cwnd): default 1 segment Slow start threshold size ssthresh: default 65535 bytes TCP Congestion Control Copyright ©: Caccamo
11
By introducing congestion window, the max number of unacknowledged bytes in transit on the network is: TCP Congestion Control Copyright ©: Caccamo
12
Quiz: How does the sender decide whether the network is congested or not? TCP Congestion Control Copyright ©: Caccamo
13
Quiz: How does the sender decide whether the network is congested or not? We assume that a packet loss (hence, resulting in an ack timeout) is caused by dropping (due to congestion) somewhere in the network It is assumed that probability of a transmission error is very low TCP interprets timeouts as sign of congestion and it slows down transmission rate by reducing cwnd TCP Congestion Control Copyright ©: Caccamo
14
Congestion window cannot fall below the size of a single segment (packet), called maximum segment size or MSS At start of a new connection the congestion window is initialized to one segment Each time an ACK is received, the congestion window is increased by one segment TCP slow start Copyright ©: Caccamo
15
Example: sender transmits one segment, after ACK is received cwnd is incremented from one to two, and two segments are sent. If both segments are acknowledged, the congestion window is increased to four (exponential growth) Exponential increase (not really “slow”), quickly increases window size up to network capacity TCP slow start Copyright ©: Caccamo
16
When congestion is detected by timeout ssthresh = ½ cwnd cwnd is set to one segment and connection restarts using slow start until ssthresh is reached (exponential increase) If cwnd ssthresh, TCP is in slow start. After the threshold, TCP switches to linear growth TCP Congestion Control Copyright ©: Caccamo
17
Exponential vs linear growth During exponential growth (slow start), contention window is doubled each RTT (round-trip time) until there is a loss During linear growth (additive increase) contention window is increased by at most one segment each round-trip time (regardless how many ACKs are received within RTT) assume each ack acknowledges reception of MSS bytes each time an ack is received a new increment is computed increment=MSS x (MSS/cwnd); cwnd = cwnd + increment Copyright ©: Caccamo
18
When congestion is detected by duplicate ACKs, it means that some but not all segments are received (moderate congestion) segments are out-of-order receiver acks each new packet. If packets are out-of-order, last ack is resent since new data cannot be acknowledged yet If 3 duplicate ACKs are received, assume that one segment has been lost and retransmit it immediately (fast retransmit) instead of waiting for timeout don’t reduce the flow drastically by using slow start: cwnd = ½ cwnd (fast recovery with linear growth) Fast retransmit and recovery Copyright ©: Caccamo
19
After ssthresh is reached, TCP switches to linear growth to exploit unused network bandwidth (additive increase) Each time an ack is received a new increment is computed Increment=MSS x (MSS/cwnd); cwnd = cwnd + increment If congestion is detected by duplicate acks, cwnd = ½ cwnd (fast recovery with linear growth) Plotting cwnd as function of time, you obtain a sawtooth behavior TCP Additive Increase/ Multiplicative Decrease KB time timeout fast recovery Copyright ©: Caccamo
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.