4-CN TCP CongesCntrlFnlShort
4-CN TCP CongesCntrlFnlShort
Unit-4
TCP Windows, Flow Control and Congestion Control
UNIT IV - TRANSPORT LAYER
• Transport Layer Services
• Connectionless and Connection Oriented Protocols
• User Datagram Protocol
• Transmission Control Protocol
• TCP Services
• TCP Features
• Segment
• TCP Connection Establishment and Termination
• TCP Congestion Control
Presentation Outline
• TCP Windows
• Flow Control
• Congestion Control
• TCP Congestion Control
• Slow Start, Exponential Increase
• Congestion Avoidance, Additive Increase
• FSM for Taho TCP
• FSM for Reno TCP
• Additive Increase, Multiplicative Decrease
• TCP Timers
Windows in TCP
TCP uses three windows (send window, receive window
and congestion window) for each direction of data
transfer, which means four windows for a bidirectional
communication.
The receive window size is then always smaller than or equal to the buffer size.
rwnd = buffer size - number of waiting bytes to be pulled
Example Window
First Send:
Sender → sends 1000 bytes (uses the entire window).
Receiver → buffer holds 1000 bytes.
After Receiver Processes 500 Bytes:
Receiver → processes 500 bytes, frees up space.
Receiver → sends acknowledgment, window size increases by 500 bytes.
Sender → can now send 500 more bytes.
Sender Sends More Data:
Sender → sends another 500 bytes, making the total data sent 1500 bytes.
Receiver → processes and frees space as it continues to receive and acknowledge data.
The Congestion Window
• In order to deal with congestion, a new state variable called
“CongestionWindow” is maintained by the source.
– Limits the amount of data that it has in transit at a given time.
• TCP sends no faster than what the slowest component -- the network or the
destination host --can accommodate.
• Decrease window when TCP perceives high congestion.
• Increase window when TCP knows that there is not much congestion.
• How ? Since increased congestion is more catastrophic, reduce it more
aggressively.
• Increase is additive, decrease is multiplicative -- called the Additive
Increase/Multiplicative Decrease (AIMD) behavior of TCP.
Receive Window Vs Congestion Window
When does a receiver generate acknowledgments? Several rules have been defined :
1. When end A sends a data segment to end B, it must include (piggyback) an acknowledgment that
gives the next sequence number it expects to receive.
2. When the receiver has no data to send and it receives an in-order segment (with expected sequence
number) and the previous segment has already been acknowledged, the receiver delays sending an
ACK segment until another segment arrives or until a period of time (normally 500 ms) has passed.
3. When a segment arrives with a sequence number that is expected by the receiver, and the previous
in-order segment has not been acknowledged, the receiver immediately sends an ACK segment.
Lost Segment
Rule 4: When a segment arrives with an out-of-order sequence number that is higher than expected, the
receiver immediately sends an ACK segment announcing the sequence number of the next expected
segment. This leads to the fast retransmission of missing segments.
Rule 5: When a missing segment arrives, the receiver sends an ACK segment to announce the next
sequence number expected. This informs the receiver that segments reported missing have been received.
Fast Retransmission
Most implementations today follow the three duplicate ACKs rule and retransmit the missing segment
immediately without waiting for the time-out. This feature is called fast retransmission.
Lost Acknowledgment
TCP uses cumulative acknowledgment. We can say that the next acknowledgment
automatically corrects the loss of the previous acknowledgment.
TCP Congestion Control
Two events to detect congestion (1) time-out(more severe)
(2) three dup. ACKs.
1 2 4 8
Src
D D D A A D D D D
A
A A A A
Dest
Congestion Avoidance, Additive Increase
(cwnd > ssthresh)
Each time the whole “window” of segments is acknowledged, the size of the congestion
window is increased by one. A window is the number of segments transmitted during RTT.
Additive Increase/Multiplicative Decrease (AIMD)
(cwnd > ssthresh)
• Each time congestion occurs - the congestion window
is halved. Source Destination
ssthresh=old_cwnd/2
–Example, if current window is 16 segments and a time-
out occurs (implies packet loss), reduce the window to 8.
–Finally window may be reduced to 1 segment.
• Window is not allowed to fall below 1 segment
(MSS).
• For each congestion window worth of packets that
has been sent out successfully (an ACK is received),
increase the congestion window by the size of a (one)
segment.
Fast Recovery (3 dup acks)
• Optional in TCP. The old version of TCP did not use it, but the
new versions try to use it.
• It starts when three duplicate ACKs arrive, which is interpreted as
light congestion in the network.
• Like congestion avoidance, this algorithm is also an additive
increase, but it increases the size of the congestion window when
a duplicate ACK arrives (after the three duplicate ACKs that
trigger the use of this algorithm).
• If a duplicate ACK arrives,
ssthresh=old_cwnd/2
TCP Congestion Control
• Tahoe (Jacobson 1988)
– Slow Start
– Congestion Avoidance
– Fast Retransmit
• Reno (Jacobson 1990)
– Tahoe +Fast Recovery
• New Reno (Fall & Floyd 1996)
– Partial Acks & Fast Recovery
TCP Tahoe-Algorithm
TCP Tahoe -Example
Summary: TCP Tahoe
• Thus:
– When cwnd is below the ssthresh, cwnd grows exponentially
– Upon time-out, set “new” ssthresh to half of current cwnd and the cwnd is reset to 1.
– Taho TCP treats the two signs used for congestion detection, time-out and three
duplicate ACKs, in the same way.
• Mechanism:
• Average Queue Size: RED monitors the
average queue size of the router. If the
average queue size exceeds a minimum
threshold, it starts dropping packets
randomly, with the probability of dropping
increasing as the queue length grows.
RED (Random Early Detection)
• Control Parameters:
• Min and Max Thresholds: These thresholds
define the point at which RED starts marking or
dropping packets. These values help control when
the congestion avoidance behavior should begin.
• Drop Probability: RED uses a drop probability
function to determine how likely it is that a packet
will be dropped based on the average queue size.
The more congested the router is, the higher the
drop probability.
Further Inquiries
Thank
ThankYou
You