TCP Transport Layer vs Network Layer Transport protocols run in end systems data transfer between end systems transport layer data transfer between processes relies on enhances network layer services 2 network data link physical t or sp an tr network layer network data link physical network data link physical d en den al ic Transport vs network layer services application transport network data link physical g lo Provide logical communication between app processes network data link physical network data link physical application transport network data link physical Transport Layer Services and Protocols r Transport services m m m m multiplexing demultiplexing flow control reliable data transfer congestion rate control r Transport protocols in the Internet UDP m TCP m 3 Internet Protocol IP Packets may be delivered out of order Packets may be lost Packets may be duplicated 4 Transmission Control Protocol TCP Reliable ordered delivery Implements congestion avoidance and control Reliability achieved by means of retransmissions if necessary End to end semantics Acknowledgements sent to TCP sender confirm delivery of data received by TCP receiver Ack for data sent only after data has reached receiver 5 TCP Basics Cumulative acknowledgements An acknowledgement ack s all contiguously received data TCP assigns byte sequence numbers For simplicity we will assign packet sequence numbers Also we use slightly different syntax for acks than normal TCP syntax In our notation ack i acknowledges receipt of packets through packet i 6 Cumulative Acknowledgements A new cumulative acknowledgement is generated only on receipt of a new in sequence packet 40 39 33 41 38 34 40 37 35 39 34 35 i data 38 36 i 36 ack 37 7 Delayed Acknowledgements An ack is delayed until another packet is received or delayed ack timer expires 200 ms typical New ack not produced on receipt of packet 36 but on receipt of 37 Reduces ack traffic 40 39 38 33 41 37 35 40 39 35 38 37 8 Duplicate Acknowledgements A dupack is generated whenever an out of order segment arrives at the receiver 40 39 38 37 34 42 41 36 40 36 Above example assumes delayed acks 39 36 Dupack On receipt of 38 9 Duplicate Acknowledgements Duplicate acks are not delayed Duplicate acks may be generated when a packet is lost or a packet is delivered out of order OOO 40 39 37 38 34 41 40 36 39 37 36 36 Dupack On receipt of 38 10 Number of dupacks depends on how much OOO a packet is 40 39 37 34 41 36 New Ack 40 New Ack 39 34 37 36 36 New Ack New Ack 42 38 41 40 36 New Ack Dupack 39 36 Dupack 38 New Ack 11 Window Based Flow Control Sliding window protocol Window size minimum of receiver s advertised window determined by available buffer space at the receiver congestion window determined by the sender based on feedback from the network Sender s window 1 2 3 Acks received 4 5 6 7 8 9 10 11 12 13 Not transmitted 12 Window Based Flow Control Sender s window 1 2 3 4 5 6 7 8 9 10 11 12 13 7 8 9 10 11 12 13 Ack 5 1 2 3 4 5 6 Sender s window 13 Ack Clock TCP window flow control is self clocking New data sent when old data is ack d Helps maintain equilibrium 14 Window Based Flow Control Congestion window size bounds the amount of data that can be sent per round trip time Throughput W RTT 15 Ideal Window Size Ideal size delay bandwidth delay bandwidth product What if window size delay bw Inefficiency wasted bandwidth What if delay bw Queuing at intermediate routers increased RTT due to queuing delays Potentially packet loss 16 How does TCP detect a packet loss Retransmission timeout RTO Duplicate acknowledgements 17 Detecting Packet Loss Using Retransmission Timeout RTO At any time TCP sender sets retransmission timer for only one packet If acknowledgement for the timed packet is not received before timer goes off the packet is assumed to be lost RTO dynamically calculated 18 Retransmission Timeout RTO calculation RTO mean 4 mean deviation Standard deviation 2 average of sample mean 2 Mean deviation average of sample mean Mean deviation is more conservative Large variations in the RTT increase the deviation leading to larger RTO 19 Timeout Granularity RTT is measured as a discrete variable in multiples of a tick 1 tick 500 ms in many implementations smaller tick sizes in more recent implementations e g Solaris RTO is at least 2 clock ticks 20 Exponential Backoff Double RTO on each timeout T2 2 T1 T1 Timeout interval doubled Packet transmitted Time out occurs before ack received packet retransmitted 21 Fast Retransmission Timeouts can take too long how to initiate retransmission sooner Fast retransmit 22 Detecting Packet Loss Using Dupacks Fast Retransmit Mechanism Dupacks may be generated due to packet loss or out of order packet delivery TCP sender assumes that a packet loss has occurred if it receives three dupacks consecutively 12 8 11 10 9 7 3 dupacks are also generated if a packet is delivered at least 3 places beyond its in sequence location Fast retransmit useful only if lower layers deliver packets almost ordered otherwise unnecessary fast retransmit 23 Congestion Avoidance and Control Slow Start initially congestion window size cwnd 1 MSS maximum segment size slow start phase ends when window size reaches the slow start threshold cwnd grows exponentially with time during slow start factor of 1 5 per RTT if every other packet ack d factor of 2 per RTT if every packet ack d Could be less if sender does not always have data to send 24 Congestion Avoidance On each new ack cwnd increases linearly with time during congestion avoidance 1 2 MSS per RTT if every other packet ack d 1 MSS per RTT if every packet ack d 25 C o ng estion W indow size seg m ents 14 Congestion avoidance 12 10 8 Slow start threshold 6Slow start 4 2 0 0 1 2 3 4 5 6 7 8 Time round trips Example assumes that acks are not delayed 26 Congestion Control On detecting a packet loss TCP sender assumes that network congestion has occurred On detecting packet loss TCP sender drastically reduces the congestion window Reducing congestion window reduces amount of data that can be sent per RTT throughput may decrease 27 Congestion Control Timeout On a timeout the congestion window is reduced to the initial value of 1 MSS The slow start threshold is set to half the window size before packet loss more precisely ssthresh maximum of min cwnd receiver s advertised window 2 and 2 MSS Slow start is initiated 28 25 cwnd 20 20 15 10 ssthresh 10 ssthresh 8 5 25 22 20 15 12 9 6 3 0 0 Congestion window segments After timeout
View Full Document
Unlocking...