Vous êtes sur la page 1sur 32

5.3.

4 TCP Reliable data transfer


- TCP reliable data transfer (error control): the data sent by the sending process will be delivered to the receiving process without error, loss, or duplication and in the same order they were sent by the sending process. - How reliable data transfer can be achieved? 1) Tracking transmitted data The sender keeps track of all the segments it sends and retransmits the segments that are not received. 2) Acknowledging received data The receiver should also track the segments as they are received, and acknowledge the receipt of them. Sender: keep track of transmitted data + retransmission Receiver: keep track of received data + ACK
5 - 60

- 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

ACK generation mechanism


1- When a segment arrives in order (no gap) and all previous data are acked, receiver waits for 500ms and sends ACK (delayed ACK) 2- When a segment arrives in order and there is one segment waiting for ACK, the ACK is sent immediately for the second segment. Cumulative ACK ACKing all previously received segments. 3- When a segment arrives out of order (gap detected), immediately send ACK with the next expected sequence number (can be duplicate ACK) 4- Arrival of segment that fills the gap. Immediately send ACK
5 - 63

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

Reasons for retransmission

Timeout

Timeout

Timeout

Timeout

Packet lost

ACK lost Duplicate segments

Timeout

Timeout

Premature timeout Duplicate segments


5 - 67

How to estimate good timeout?


- longer than Round Trip Time (RTT), but RTT varies - Too short timeout (premature timeout) retransmissions unnecessary

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|

- Typically, = 0.25 - Large variation in EstimatedRTT larger safety margin


5 - 69

Example of RTT estimation:


RTT: gaia.cs.umass.edu to fantasia.eurecom.fr
350

300

RTT (milliseconds)

250

200

150

100 1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106 time (seconnds) SampleRTT Estimated RTT

5 - 70

Fast retransmission

5 - 71

- Time-out period often relatively long resending lost packet

long delay before

- 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

- After retransmission, continue to send new data

5.3.5 TCP Congestion control


- Congestion: too many sources sending too much data too fast for network to handle - Congestion occurs when total arrival rate from all flows exceeds a routers output link capacity over a sustained period of time - Buffers at routers will overflow long delays causing packet drop and

- 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

Causes/costs of congestion: Scenario 1


- Two senders, two receivers -One router, infinite buffers no packet drop and thus no retransmission
Host B Host A in : original data Router with infinite buffer out

- R: output link capacity


R/2 out delay
- large delays when congested - maximum achievable throughput
in R/2 5 - 75

in

R/2

Maximum per-connection large delays as arrival rate, , in throughput: R/2 approaches capacity

Causes/costs of congestion: Scenario 2


- One router, finite buffers packet may be dropped

- 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

Router with finite buffer

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

Causes/costs of congestion: scenario 3


Host A

in : original data 'in : original data, plus retransmitted data

out

Bs traffic

finite shared output link buffers


Host B
R4 R4 R4 R4

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

oscillate around the knee (optimal point).

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

TCP Congestion Control


1- slow start phase - When congestion window (cwnd) is below the congestion threshold, window grows exponentially fast until reaching the threshold or loss event occur
RTT

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

ACKs being received, additively increase rate X


Slow Start Fast retransmit AI/MD

TCPs sawtooth behavior


Time

X loss so decrease rate

- 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

- Throughput in terms of segment loss probability, L [Mathis 1997]:

. MSS 1.22 TCP throughput = RTT L

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

bottleneck router capacity R

5 - 90

Questions

Mohamed Elsalih Mahmoud

Vous aimerez peut-être aussi