Académique Documents
Professionnel Documents
Culture Documents
- The bytes of data being transferred in each connection are numbered by TCP. - The numbering starts with a randomly generated number (ISN). - The value in the sequence number field of a segment defines the number of the first data byte contained in that segment. - The value of the acknowledgment field in a segment defines the number of the next byte the host expects to receive. - Receiver acknowledges in separate segment or piggyback on data segment. - Receiver has buffer and may receive segments out of order. - No negative acknowledgements unacknowledged segment = negative acknowledgement
5 - 61
- Selective retransmission: sender retransmits only the missing packets Uses of segments sequence numbers:1- Duplicate Detection: receiver can recognize duplicates and discard them 2- Ordered Delivery: if segments arrive out of order, receiving TCP will reorder the segments based on the sequence numbers 3- Identifiers to segments missing segments detect and re-transmit of
- Error detection is done using checksum and error correction is done by retransmission - Discard corrupted packets and let the sender resend unacknowledged packets when the timer expires.
5 - 62
Normal operation
5 - 64
Retransmission
- Sender sends segment, starts timer, and waits for ack. - A timer for each in-flight segment - No ack before timeout of a segment the sender will consider the segment is either corrupted or lost and the sender will retransmit the segment restart the timer - If the segment just delayed (not lost) retransmission will be duplicated, but use of sequence number handles this
5 - 65
Lost segment
Cumulative ACK scenario: this segment acks both 701-800 and 800-900 segments
5 - 66
Timeout
Timeout
Timeout
Timeout
Packet lost
Timeout
Timeout
excessive delays when packet lost - slow - Too long reaction to segment loss, poor performance. - TCP sets timeout as a function of the RTT SampleRTT: measured time from segment transmission until ACK receipt - Ignore retransmissions, cumulatively ACKed segments
tx Estimated RTT Too long retx Estimated RTT tx retx Too short ack 5 - 68
ack
- SampleRTT will vary average several recent measurements, not just current SampleRTT - Smooth estimate: keep a running average of the RTT EstimatedRTT = (1- ) x EstimatedRTT + x SampleRTT - Influence of past sample decreases exponentially fast - Typical value: = 0.125 - Timeout = EstimatedRTT + safety margin Timeout = EstimatedRTT + 4 x Deviation - Deviation is how much SampleRTT deviates from EstimatedRTT
Deviation = (1- ) x Deviation + x |SampleRTT-EstimatedRTT|
300
RTT (milliseconds)
250
200
150
5 - 70
Fast retransmission
5 - 71
- Detect lost segments via duplicate ACKs: - Sender often sends many segments back-to-back - If segment is lost, there will likely be many duplicate ACKs. - Although packet n might have been lost (e.g., due to congestion), packets n+1, n+2, and so on might get through - If sender receives 3 ACKs for the same segment, it supposes that segment was lost (not delayed) resend the segment - Fast retransmit: resend segment before timer expires - 1 or 2 ACKs means the segment may be delayed
5 - 72
- To alleviate congestion, the sending nodes should slow down the rate of transmission. - How? by reducing the window size because it will wait for data to be acknowledged more frequently. - The window size is the number of bytes that are allowed to be in flight simultaneously
5 - 73
Two broad approaches towards congestion control: 1- End-end congestion control: no explicit feedback from network - congestion inferred from end-system observed loss, delay - approach taken by TCP 2- Network-assisted congestion control: routers provide feedback to end systems indicating congestion, used in ATM - Receiver (or advertised) window (rwnd) is used to ensure that receivers buffer will not overflow (flow control) - Congestion window (cwnd) is used to ensure that the sender will not overflow the intermediate routers buffers between source and destination (congestion control) - The actual window size = min(rwnd, cwnd) to avoid overflowing the receiver or the routers - That means max-in-flight bytes min(rwnd, cwnd)
5 - 74
in
R/2
Maximum per-connection large delays as arrival rate, , in throughput: R/2 approaches capacity
- Sender retransmission of timed-out packet - Application-layer input = application-layer output: in = out - Transport-layer input includes retransmissions : in
in : original data 'in : original data + retransmitted data
Host B
in
Host A
out
5 - 76
R/2
1- Idealization (perfect knowledge): sender sends only when router buffers available. in = in or no packet drop or transmission 2- Perfect retransmission (only when loss) sender only resends if packet known to be lost
in
R/2
out
in
R/2
> out
in
R/2
when sending at R/2, some packets are retransmissions but asymptotic goodput is still R/2 (why?)
3- Realistic: duplicates - Retransmissions due to 1- Dropped packets 2- Delayed (not lost) packets: - Sender times out prematurely, in sending two copies, both are >> out delivered
in
out
R/2 when sending at R/2, some packets are retransmissions including duplicated that are delivered! R/2
out
5 - 77
out
Bs traffic
The traffic of host B and that of host A go through R4 Q: what happens to Bs traffic
out as
in
and
in
increase ? Host A
5 - 78
A: All arriving packets from host B will be dropped will take all the link capacity of the buffer
R/2
Bs arrived traffic
out
in
As sent traffic
Costs of congestion: - Dropped packets: More work (retransmissions) for given goodput - Duplicates: Unneeded retransmissions: link carries multiple copies of packets - When packet dropped, any upstream transmission capacity used for that packet was wasted!
5 - 79
Throughput (bps)
1- Arrow 1 - Arrival Rate << R - Low delay - Can accommodate more 2- Arrow 2 - Knee (congestion onset) - Arrival rate approaches R - Delay increases rapidly - Throughput begins to saturate 3- Arrow 3 - Congestion collapse - Arrival rate > R - Large delays, packet loss - Throughput drops
Arrival Rate
Delay (sec)
Arrival Rate
5 - 80
- Desired operating point: just before knee - Why? TCP sender should transmit as fast as possible, but without congesting network full make use of link capacity - How? Senders should control their sending rates so that the aggregate arrival rate is just before knee How?
1- Increase the sending rate (larger window), probe bandwidth 2- Once packet drops start (enter congestion area) rate 3- go to 1 again reduce
By this way: adapt dynamically to available bandwidth according to the most up-to-date state of the network - Receiving ACK is a good sign. Network is not congested, so increase sending rate - At congestion: lost packets large delay (retransmission timeouts) so decrease sending rate 5 - 81
Host A
Host B
- Increment cwnd by one segment whenever it receives ACK = Double cwnd every RTT exponential increase cwnd - Discover available bandwidth fast desirable to quickly ramp up to respectable rate - When cwnd > threshold, move to congestion avoidance phase to slow down the sending rate
8
time threshold
4 2 1
5 - 82
RTTs
2- Congestion avoidance phase - When Cwnd is above a threshold - Cwnd is incremented by one segment every RTT (= for every window of ACKs it receives) linear increase - Cwnd continues to increase (linearly) until loss is detected - TCP spends most of its time in this phase 3- Reaction to congestion phase - At any time, when congestion occurs, decrease the window size. How TCP recognizes congestion? - There are two congestion indication mechanisms 1- Three duplicated ACKs: - Duplicate ACKs means the receiver got all packets up to the gap and is actually receiving packets at least network capable of delivering some segments - Could be due to temporary congestion
5 - 83
- Reduce Cwnd but not aggressively - Congestion threshold = cwnd/2 and new cwnd = threshold - Stay in congestion avoidance phase 2- Timeout - No response from receiver - more likely due to significant congestion reduce cwnd aggressively - Congestion threshold = cwnd/2 and new cwnd = 1 max. segment size (MSS) - Go back to slow start phase - Most of the time the window will be like a sawtooth - Additive Increase/Multiplicative Decrease (AIMD): cwnd increases by 1 every RTT, cwnd decreases by a factor of two with every loss, and repeat
5 - 84
Examples
5 - 85
5 - 86
cwnd
- Increase transmission rate on receipt of ACK, until eventually loss occurs, then decrease transmission rate - Continue to increase on ACK, decrease on loss (since available bandwidth is changing, depending on other connections in network) - In absence of timeouts, cwnd will oscillate around optimal value the optimal value changes based on other connections
5 - 87
Avg. TCP throughput as function of window size and RTT - Roughly: send cwnd bytes, wait RTT for ACKS, then send more bytes - W: window size (measured in bytes) where loss occurs - Avg. window size (# in-flight bytes) is W
3 W bytes/sec Avg TCP throughput = 4 RTT
W/2
3-92
5 - 88
Example: 1500 byte segments, 100 ms RTT, want 10 Gbps throughput requires W = 83,333 in-flight segments to achieve 10 Gbps throughput, need a loss rate of L = 2 x 10-10 a very small loss rate
3-93
5 - 89
Fairness
- Fairness goal: if K TCP sessions share same bottleneck link of bandwidth R, each should have average rate of R/K In TCP, if a sender sends with high rate, it detects loss and decrease the sending rate. - In UDP, there is no congestion control do not want rate throttled by congestion control - Application can open multiple parallel TCP connections between two hosts Web browsers do this
TCP connection 1
3-94
TCP connection 2
5 - 90
Questions