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

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

Normal operation 5 .64 .

and waits for ack.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 . but use of sequence number handles this 5 .65 . starts timer.Sender sends segment.If the segment just delayed (not lost) retransmission will be duplicated.A timer for each in-flight segment . .Retransmission .

Lost segment Cumulative ACK scenario: this segment acks both “701-800” and “800-900” segments 5 .66 .

67 .Reasons for retransmission Timeout Timeout Timeout Timeout Packet lost ACK lost Duplicate segments Timeout Timeout Premature timeout Duplicate segments 5 .

TCP sets timeout as a function of the RTT SampleRTT: measured time from segment transmission until ACK receipt .longer than Round Trip Time (RTT). . poor performance.slow .Too long reaction to segment loss.How to estimate good timeout? .68 ack .Ignore retransmissions.Too short timeout (premature timeout) retransmissions unnecessary excessive delays when packet lost . but RTT varies . cumulatively ACKed segments tx Estimated RTT Too long retx Estimated RTT tx retx Too short ack 5 .

not just current SampleRTT .Typical value: α = 0.Deviation is how much SampleRTT deviates from EstimatedRTT Deviation = (1.SampleRTT will vary average several recent measurements.25 .125 . β = 0.69 .β) x Deviation + β x |SampleRTT-EstimatedRTT| .Typically.Influence of past sample decreases exponentially fast .Timeout = EstimatedRTT + safety margin Timeout = EstimatedRTT + 4 x Deviation .α) x EstimatedRTT + α x SampleRTT .Large variation in EstimatedRTT larger safety margin 5 .Smooth estimate: keep a running average of the RTT EstimatedRTT = (1..

70 .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 .cs.umass.eurecom.edu to fantasia.Example of RTT estimation: RTT: gaia.

71 .Fast retransmission 5 .

due to congestion).Fast retransmit: resend segment before timer expires .Sender often sends many segments back-to-back .1 or 2 ACKs means the segment may be delayed 5 .72 . . continue to send new data .If sender receives 3 ACKs for the same segment.If segment is lost.Although packet n might have been lost (e.Detect lost segments via duplicate ACKs: . n+2. it supposes that segment was lost (not delayed) resend the segment . there will likely be many duplicate ACKs.g.Time-out period often relatively long resending lost packet long delay before . and so on might get through .. packets n+1.After retransmission..

How? by reducing the window size because it will wait for data to be acknowledged more frequently. .3.5 TCP Congestion control .To alleviate congestion.The window size is the number of bytes that are allowed to be in flight simultaneously 5 .Buffers at routers will overflow long delays causing packet drop and .Congestion occurs when total arrival rate from all flows exceeds a router’s output link capacity over a sustained period of time . the sending nodes should slow down the rate of transmission.5.73 . .Congestion: too many sources sending too much data too fast for network to handle .

cwnd) 5 .The actual window size = min(rwnd.approach taken by TCP 2.Network-assisted congestion control: routers provide feedback to end systems indicating congestion.End-end congestion control: no explicit feedback from network . delay . cwnd) to avoid overflowing the receiver or the routers .That means max-in-flight bytes ≤ min(rwnd.Receiver (or advertised) window (rwnd) is used to ensure that receiver’s buffer will not overflow (flow control) .Two broad approaches towards congestion control: 1.74 .congestion inferred from end-system observed loss. used in ATM .Congestion window (cwnd) is used to ensure that the sender will not overflow the intermediate routers’ buffers between source and destination (congestion control) .

75 λin R/2 Maximum per-connection large delays as arrival rate. in throughput: R/2 approaches capacity .R: output link capacity R/2 λout delay . infinite buffers no packet drop and thus no retransmission Host B Host A λin : original data Router with infinite buffer λout .maximum achievable throughput λin R/2 5 .Causes/costs of congestion: Scenario 1 . two receivers -One router. λ .large delays when congested .Two senders.

finite buffers packet may be dropped .One router.Causes/costs of congestion: Scenario 2 .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 .Application-layer input = application-layer output: λin = λout .Sender retransmission of timed-out packet .

Delayed (not lost) packets: . λin sending two copies.R/2 1.Realistic: duplicates . both are λ >> λ out delivered in λout R/2 when sending at R/2.77 .Dropped packets 2. some packets are retransmissions but asymptotic goodput is still R/2 (why?) 3.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.Retransmissions due to 1.Idealization (perfect knowledge): sender sends only when router buffers available. λin = λ’in or no packet drop or transmission 2. some packets are retransmissions including duplicated that are delivered! R/2 λout 5 .Sender times out prematurely.

78 A: All arriving packets from host B will be dropped will take all the link capacity of the buffer . plus retransmitted data λout B’s 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 B’s traffic λ out as λ in and λ in increase ? Host A 5 .Causes/costs of congestion: scenario 3 Host A λin : original data λ'in : original data.

79 .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 .R/2 B’s arrived traffic λout λin’ A’s sent traffic Costs of congestion: .

Throughput begins to saturate 3.Arrival rate > R .Knee (congestion onset) .Throughput drops R 1 2 3 Arrival Rate Delay (sec) 1 2 R 3 Arrival Rate 5 .Can accommodate more 2.Large delays.Delay increases rapidly .80 .Arrow 1 .Arrival Rate << R .Congestion collapse .Arrival rate approaches R .Low delay .Arrow 3 . packet loss .Throughput (bps) 1.Arrow 2 .

How? Senders should control their sending rates so that the aggregate arrival rate is just before knee How? 1.81 . but without congesting network full make use of link capacity .At congestion: lost packets – large delay (retransmission timeouts) so decrease sending rate 5 .Once packet drops start (enter congestion area) rate 3. Network is not congested.Why? TCP sender should transmit as fast as possible. so increase sending rate . probe bandwidth 2. By this way: adapt dynamically to available bandwidth according to the most up-to-date state of the network .Desired operating point: just before knee .go to 1 again reduce oscillate around the knee (optimal point)..Increase the sending rate (larger window).Receiving ACK is a good sign.

When cwnd > threshold.82 RTTs . move to congestion avoidance phase to slow down the sending rate 8 time threshold 4 2 1 5 . window grows exponentially fast until reaching the threshold or loss event occur RTT Host A Host B .When congestion window (cwnd) is below the congestion threshold.slow start phase .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 .TCP Congestion Control 1.

Congestion avoidance phase .When Cwnd is above a threshold .83 . decrease the window size.Cwnd continues to increase (linearly) until loss is detected .TCP spends most of its time in this phase 3. How TCP recognizes congestion? .Reaction to congestion phase .There are two congestion indication mechanisms 1.Cwnd is incremented by one segment every RTT (= for every window of ACKs it receives) linear increase .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 .2.At any time.Three duplicated ACKs: . when congestion occurs.

and repeat 5 .Additive Increase/Multiplicative Decrease (AIMD): cwnd increases by 1 every RTT.Stay in congestion avoidance phase 2. cwnd decreases by a factor of two with every loss.Timeout .Congestion threshold = cwnd/2 and new cwnd = threshold ..No response from receiver .Most of the time the window will be like a sawtooth . segment size (MSS) .Go back to slow start phase .84 .more likely due to significant congestion reduce cwnd aggressively .Reduce Cwnd but not aggressively .Congestion threshold = cwnd/2 and new cwnd = 1 max.

Examples 5 .85 .

5 .86 .

depending on other connections in network) .87 .In absence of timeouts. then decrease transmission rate .cwnd ACKs being received. decrease on loss (since available bandwidth is changing.Increase transmission rate on receipt of ACK. until eventually loss occurs.Continue to increase on ACK. cwnd will oscillate around optimal value – the optimal value changes based on other connections 5 . additively increase rate X Slow Start Fast retransmit AI/MD X TCP’s “sawtooth” behavior Time X loss so decrease rate .

W: window size (measured in bytes) where loss occurs .88 . wait RTT for ACKS.Avg. then send more bytes . TCP throughput as function of window size and RTT .Avg. window size (# in-flight bytes) is ¾ W 3 W bytes/sec Avg TCP throughput = 4 RTT W W/2 3-92 5 .Roughly: send cwnd bytes.

MSS 1. need a loss rate of L = 2 x 10-10 – a very small loss rate 3-93 5 .89 .22 TCP throughput = RTT L Example: 1500 byte segments.333 in-flight segments ➜ to achieve 10 Gbps throughput. 100 ms RTT.Throughput in terms of segment loss probability. want 10 Gbps throughput requires W = 83.. L [Mathis 1997]: .

there is no congestion control – do not want rate throttled by congestion control . each should have average rate of R/K In TCP. .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 .Fairness .Fairness goal: if K TCP sessions share same bottleneck link of bandwidth R.90 . it detects loss and decrease the sending rate.In UDP. if a sender sends with high rate.

Questions Mohamed Elsalih Mahmoud .

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.