TCP in Wireless Mobile Networks 1
Outline Introduction to transport layer Introduction to TCP (Internet) congestion control Congestion control in wireless networks 2
Transport Layer v.s. Network Layer Network layer: connection or no-connection. Connection-based: phone network Before end-to-end transmission, a call has to be setup. Resources are reserved for this session. After transmission, the call is hung up. Resources are released. Quality of service is guaranteed, e.g., delay. Good for continuous data rate. 3
Transport Layer v.s. Network Layer Network layer: connection or no-connection. Connection-less: IP No connection is established. Packets are routed independently. Packets may arrive out of order, lost, etc. Good for busty traffic, e.g., web browsing. Good for resource sharing. More reliable under link/router failures. Packets are re-routed. 4
Transport Layer v.s. Network Layer Network layer, e.g., IP Finding a route + delivering packets Obvious issues to be dealt with: Packets may get lost. Packets may arrive out-of-order. Packets may be corrupted. Other issues: Data rate? How fast should the source input packets to the network? Congestion control. 5
Transport Layer vs. Network Layer Provide logical communication between app processes Transport protocols run in end systems Transport vs. network layer services: network layer data transfer between end systems transport layer data transfer between processes relies on, enhances, network layer services application transport network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical application transport network data link physical 6
Transport Layer Services and Protocols Transport services multiplexing/demultiplexing flow control reliable data transfer congestion control Transport protocols in the Internet UDP TCP 7
Outline Introduction to transport layer Introduction to TCP (Internet) congestion control Congestion control in wireless networks 8
History TCP congestion control in mid-1980s sliding window congestion protocol use a sliding window to control the number of outstanding packets fixed window size W Congestion collapse in the mid-1980s UCB LBL throughput dropped by 1000X! 9
Principles of Congestion Control Big picture: How to determine a flow s sending rate? Congestion: informally: too many sources sending too much data too fast for the network to handle different from flow control! manifestations: lost packets (buffer overflow at routers) wasted bandwidth long delays (queueing in router buffers) 10
Cause/Cost of Congestion: Scenario 1 flow 1 10 Mbps flow 2 (5 Mbps) router 1 router 2 Flow 2 has a fixed sending rate of 5 Mbps We vary the sending rate of flow 1 from 0 to 20 Mbps Assume no retransmission the link from router 1 to router 2 has infinite buffer Performance metric: throughput (packets that go through in unit time) 10 throughput of flows 1 & 2 (Mbps) delay due to randomness delay at link 1 5 0 5 sending rate by flow 1 (Mbps) 0 5 sending rate by flow 1 (Mbps) 11
Cause/Cost of Congestion: Scenario 2 flow 1 router 3 router 5 10 Mbps flow 2 (5 Mbps) router 1 router 2 Assume router 4 router 6 no retransmission the link from router 1 to router 2 has finite buffer 10 5 throughput of flows 1 & 2 (Mbps) 0 5 sending rate by flow 1 (Mbps) when packet dropped at the link from router 2 to router 5, the upstream transmission from router 1 to router 2 used for that packet was wasted! 12
Summary: The Cost of Congestion Cost High delay Packet loss Wasted upstream bandwidth when a pkt is discarded at downstream Wasted bandwidth due to retransmission (a pkt goes through a link multiple times) Throughput Delay knee cliff Load packet loss congestion collapse Load 13
The Desired Properties of a Congestion Avoidance Scheme Efficiency (fully utilization) Fairness (resource sharing) Distributedness (no central knowledge to achieve scalability) Convergence (fast convergence after disturbance, low oscillation) 14
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 15
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 16
Cumulative Acknowledgements A new cumulative acknowledgement is generated only on receipt of a new insequence packet 40 39 38 37 33 34 35 36 41 40 39 38 34 35 36 37 i data i ack 17
Delayed Acknowledgements An ack is delayed until another packet is received, or delayed ack timer expires (200 ms typical) Reduces ack traffic 40 39 38 37 New ack not produced on receipt of packet 36, but on receipt of 37 33 35 41 40 39 38 35 37 18
Duplicate Acknowledgements A dupack is generated whenever an out-of-order segment arrives at the receiver 40 39 38 37 34 36 42 41 40 39 36 36 (Above example assumes delayed acks) Dupack On receipt of 38 19
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 36 41 40 39 37 36 36 Dupack On receipt of 38 20
Number of dupacks depends on how much OOO a packet is 40 39 37 38 34 New Ack 36 New Ack 41 40 39 37 34 New Ack New Ack 36 36 Dupack 42 41 40 39 36 36 38 New Ack Dupack New Ack 21
How does TCP detect a packet loss? Retransmission timeout (RTO) Duplicate acknowledgements 22
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 23
Retransmission Timeout (RTO) calculation RTO = mean + 4 mean deviation Standard deviation σ : σ 2 = average of (sample mean) 2 Large variations in the RTT increase the deviation, leading to larger RTO 24
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 25
Exponential Backoff Double RTO on each timeout T1 T2 = 2 * T1 Timeout interval doubled Packet transmitted Time-out occurs before ack received, packet retransmitted 26
Fast Retransmission Timeouts can take too long how to initiate retransmission sooner? Fast retransmit 27
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 are almost ordered ---- otherwise, unnecessary fast retransmit 28
TCP Congestion Control End-to-end, window-based congestion control Transmission rate limited by congestion window size, cwnd, over segments: cwnd w 29
Window-based Scheme Window-based Congestion Control is Self Clocking! 30
TCP Congestion Control Ideally, at equilibrium, we want to set the window size (approximately) to the product of available bandwidth (for this flow) and round-trip delay However, we don t know these parameters at the beginning of a flow further, the available bandwidth and round-trip are changing, because of competing flows 31
TCP Congestion Control: Basic Structure Many versions of TCP TCP/Tahoe: this is a less optimized version TCP/Reno: most OSs today implement TCP/Reno TCP/Vegas: not currently used Two phases slow-start congestion avoidance Important variables: cwnd: congestion window size ssthresh: threshold between the slow-start phase and the congestion avoidance phase 32
TCP slow start TCP slow-start algorithm sender calculates a congestion window for a receiver start with a congestion window size equal to one segment exponential increase of the congestion window up to the congestion threshold, then linear increase missing acknowledgement causes the reduction of the congestion threshold to one half of the current congestion window congestion window starts again with one segment 33
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 34
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 35
C ongestion W indow size (seg m ents) 14 12 10 8 6 4 2 0 Slow start Congestion avoidance Slow start threshold 0 1 2 3 4 5 6 7 8 Time (round trips) Example assumes that acks are not delayed 36
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 37
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 38
25 20 15 10 5 0 After timeout cwnd = 20 ssthresh = 8 ssthresh = 10 6 9 12 15 20 22 25 Time (round trips) 39 3 0 Congestion window (segments)
Congestion Control - Fast retransmit Fast retransmit occurs when multiple (>= 3) dupacks come back Fast recovery follows fast retransmit Different from timeout : slow start follows timeout timeout occurs when no more packets are getting across fast retransmit occurs when a packet is lost, but latter packets get through ack clock is still there when fast retransmit occurs no need to slow start 40
Fast Recovery ssthresh = min(cwnd, receiver s advertised window)/2 (at least 2 MSS) retransmit the missing segment (fast retransmit) cwnd = ssthresh + number of dupacks when a new ack comes: cwnd = ssthreh enter congestion avoidance Congestion window cut into half 41
After fast recovery W indow size (segm ents) 10 8 6 4 2 0 0 2 4 6 8 10 12 14 Time (round trips) Receiver s advertized window After fast retransmit and fast recovery window size is reduced in half. 42
TCP/Reno: Big Picture cwnd TD TD ssthresh TO ssthresh ssthresh ssthresh slow start congestion avoidance congestion avoidance congestion avoidance slow start congestion avoidance Time TD: Triple duplicate acknowledgements TO: Timeout Question: Why packet losses in Internet? Question: Does TCP fully utilize bandwidth? 43
TCP TCP congestion control packet loss in fixed networks typically due to (temporary) overload situations router have to discard packets as soon as the buffers are full TCP recognizes congestion only indirect via missing acknowledgements, retransmissions are unwise, they would only contribute to the congestion and make it even worse slow-start algorithm as reaction 44
Discussion Why is TCP congestion control less effective in mobile wireless networks? How to improve the performance of TCP? 45
TCP in wireless mobile networks TCP assumes congestion if packets are dropped typically wrong in wireless networks, here we often have packet loss due to transmission errors furthermore, mobility itself can cause packet loss, if e.g. a mobile node roams from one access point (e.g. foreign agent in Mobile IP) to another while there are still packets in transit to the wrong access point and forwarding is not possible. 46
TCP in wireless mobile networks The performance of an unchanged TCP degrades severely however, TCP cannot be changed fundamentally due to the large base of installation in the fixed network, TCP for mobility has to remain compatible the basic TCP mechanisms keep the whole Internet together. 47
Outline Indirect TCP Snooping TCP Mobile TCP Fast retransmission, fast recovery Freezing Selective retransmission 48
Indirect-TCP mobile host access point (foreign agent) wired Internet wireless TCP standard TCP Split a TCP connection at the foreign agent into 2 TCP connections hosts in the fixed part of the network do not notice the characteristics of the wireless part no changes to the TCP protocol for hosts connected to the wired Internet, millions of computers use (variants of) this protocol optimized TCP protocol for mobile hosts 49
Indirect TCP The access point acts as proxy in both directions. AP acknowledges to both the sender and receiver. Re-transmission on wireless links is handled locally. During handover, the buffered packets, as well as the system state (packet sequence number, acknowledgements, ports, etc), must migrate the new agent. 50
I-TCP Socket and State Migration access point 2 socket migration and state transfer Internet mobile host access point 1 51
Advantages of I-TCP No changes in the fixed network necessary, no changes for the hosts (TCP protocol) necessary, all current optimizations to TCP still work Simple to control, mobile TCP is used only for one hop between, e.g., a foreign agent and mobile host transmission errors on the wireless link do not propagate into the fixed network therefore, a very fast retransmission of packets is possible, the short delay on the mobile hop is known 52
Advantages of I-TCP It is always dangerous to introduce new mechanisms in a huge network without knowing exactly how they behave. New optimizations can be tested at the last hop, without jeopardizing the stability of the Internet. It is easy to use different protocols for wired and wireless networks. 53
Disadvantages of I-TCP Loss of end-to-end semantics an acknowledgement to a sender no longer means that a receiver really has received a packet --- foreign agents might crash. Higher latency possible due to buffering of data within the foreign agent and forwarding to a new foreign agent Security issue The foreign agent must be a trusted entity. 54