TCP in Wireless Mobile Networks - Stony Brook University
Transcript of TCP in Wireless Mobile Networks - Stony Brook University
TCP in Wireless Mobile Networks
1
Outline
� Introduction to transport layer
� Introduction to TCP (Internet) congestion control
� Congestion control in wireless networks
2
� Congestion control in wireless networks
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.
3
� 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.
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.
4
� 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.
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.
5
� 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.
Transport Layer vs. Network Layer
� Provide logical communicationbetween app’ processes
� Transport protocols run in end systems
� Transport vs. network layer services:
applicationtransportnetworkdata linkphysical
network
networkdata linkphysicalnetwork
data linkphysical
6
Transport vs. network layer services:� network layer
• data transfer between end systems
� transport layer• data transfer between
processes • relies on, enhances, network
layer services
applicationtransportnetworkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
Transport Layer Services and Protocols
�Transport services� multiplexing/demultiplexing
� flow control
� reliable data transfer
7
� reliable data transfer
� congestion control
�Transport protocols in the Internet� UDP
� TCP
Outline
� Introduction to transport layer
� Introduction to TCP (Internet) congestion control
� Congestion control in wireless networks
8
� Congestion control in wireless networks
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
9
• fixed window size W
� Congestion collapse in the mid-1980s� UCB ↔ LBL throughput dropped by 1000X!
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”
10
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)
flow 2 (5 Mbps)
flow 1
router 1 router 2
10 Mbps
Cause/Cost of Congestion: Scenario 1
�Flow 2 has a fixed sending rate of 5 Mbps
11
�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)
sending rate
by flow 1 (Mbps)
throughput of
flows 1 & 2 (Mbps)
5
10
50
sending rate
by flow 1 (Mbps)
delay at link 1
50
delay due to
randomness
flow 2 (5 Mbps)
flow 1
router 1
10 Mbps
Cause/Cost of Congestion: Scenario 2
�Assume
router 3
router 4
router 2
router 5
router 6
12
�Assume� no retransmission� the link from router 1 to router 2 has finite buffer
sending rate
by flow 1 (Mbps)
throughput of
flows 1 & 2 (Mbps)
5
10
5
� 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!0
Summary: The Cost of Congestion
Cost
� High delay
� Packet loss
� Wasted upstream bandwidth when a pkt
Th
rou
gh
pu
t knee cliff
congestioncollapse
packetloss
13
bandwidth when a pkt is discarded at downstream
� Wasted bandwidth due to retransmission (a pkt goes through a link multiple times)
Load
Load
De
lay
The Desired Properties of a Congestion Avoidance Scheme
� Efficiency (fully utilization)
� Fairness (resource sharing)
Distributedness (no central knowledge to achieve
14
� Distributedness (no central knowledge to achieve scalability)
� Convergence (fast convergence after disturbance, low oscillation)
TCP
� Reliable ordered delivery� Implements congestion avoidance and control� Reliability achieved by means of
retransmissions if necessaryEnd-to-end semantics
15
� 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
TCP Basics
� Cumulative acknowledgements
� An acknowledgement ack’s all contiguously received data
� TCP assigns byte sequence numbers
16
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
Cumulative Acknowledgements
� A new cumulative acknowledgement is generated only on receipt of a new in-sequence packet
40 39 3738
17
40 39 3738
3533
41 40 3839
35 37
3634
3634
i data acki
Delayed Acknowledgements
� An ack is delayed until� another packet is received, or
� delayed ack timer expires (200 ms typical)
� Reduces ack traffic New ack not produced
on receipt of packet 36,
but on receipt of 37
18
40 39 3738
3533
41 40 3839
35 37
but on receipt of 37
Duplicate Acknowledgements
� A dupack is generated whenever an
out-of-order segment arrives at the receiver
40 39 3738
19
3634
42 41 3940
36 36
Dupack
(Above example assumes delayed acks)On receipt of 38
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 3837
20
40 39 3837
3634
41 40 3739
36 36
DupackOn receipt of 38
Number of dupacks depends on how much OOO a packet is
40 39 3837
3634
41 40 3739
New AckNew Ack
21
41 40 3739
36 36
Dupack
42 41 3940
36 36 38
New Ack
New Ack
34
New Ack
DupackNew Ack
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 RTOdeviation, 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� 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
26
Packet
transmitted
Time-out occurs
before ack received,
packet retransmitted
Timeout interval doubled
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
� TCP sender assumes that a packet loss has occurred if it receives three dupacksconsecutively
28
12 8 7910113 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
TCP Congestion Control
� End-to-end, window-based congestion control
� Transmission rate limited by congestion window size, cwnd, over segments:
29
cwnd
w
Window-based Scheme
30
Window-based Congestion Control is Self Clocking!
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
31
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
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
32
� Two “phases”� slow-start
� congestion avoidance
� Important variables:� cwnd: congestion window size
� ssthresh: threshold between the slow-start phase and the congestion avoidance phase
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
33
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
Congestion Avoidance and ControlSlow Start� initially, congestion window size cwnd = 1
MSS (maximum segment size)� slow start phase ends when window size
reaches the slow-start thresholdreaches 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 send34
Congestion Avoidance
� On each new ack,
� cwnd increases linearly with time during congestion avoidancecongestion avoidance� 1/2 MSS per RTT if every other packet ack’d
� 1 MSS per RTT if every packet ack’d
35
4
6
8
10
12
14
Co
ng
esti
on
Win
do
w s
ize
(s
egm
en
ts)
Slow
start
Congestion
avoidance
Slow start
threshold
36
0
2
4
0 1 2 3 4 5 6 7 8
Time (round trips)
Co
ng
esti
on
Win
do
w s
ize
(s
egm
en
ts)
start
Example assumes that acks are not delayed
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 � 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 initiated38
15
20
25
Co
ng
esti
on
win
do
w (
seg
men
ts)
cwnd = 20
After timeout
0
5
10
0 3 6 9
12
15
20
22
25
Time (round trips)
Co
ng
esti
on
win
do
w (
seg
men
ts)
39
ssthresh = 8 ssthresh = 10
Congestion Control - Fast retransmit
� Fast retransmit occurs when multiple (>= 3) dupacks come back
� Fast recovery follows fast retransmit
Different from timeout : slow start follows � 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 dupackswhen a new ack comes: cwnd = ssthreh� when a new ack comes: cwnd = ssthreh� enter congestion avoidance
Congestion window cut into half
41
4
6
8
10
Win
do
w s
ize
(se
gm
en
ts)
Receiver’s advertized window
After fast recovery
42
0
2
0 2 4 6 8 10 12 14
Time (round trips)
Win
do
w s
ize
(se
gm
en
ts)
After fast retransmit and fast recovery window size is
reduced in half.
TCP/Reno: Big Picture
cwnd
TD
TO
TD
43
Timeslowstart
congestionavoidance
TD: Triple duplicate acknowledgements
TO: Timeout
TOssthresh
ssthresh ssthreshssthresh
congestionavoidance
congestionavoidance
slow start
congestionavoidance
Question: Why packet losses in Internet?
Question: Does TCP fully utilize bandwidth?
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
44
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
Discussion
� Why is TCP congestion control less effective in mobile wireless networks?
45
� How to improve the performance of TCP?
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
46
� 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.
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
47
network, TCP for mobility has to remain compatible
� the basic TCP mechanisms keep the whole Internet together.
Outline
� Indirect TCP
� Snooping TCP
� Mobile TCP
� Fast retransmission, fast recovery
48
� Fast retransmission, fast recovery
� Freezing
� Selective retransmission
Indirect-TCP
mobile hostaccess point
(foreign agent) „wired“ Internet
49
� 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
“wireless” TCP standard TCP
Indirect TCP
� The access point acts as proxy in both directions.
� AP acknowledges to both the sender and receiver.
50
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.
I-TCP Socket and State Migration
access point2
socket migration
51
mobile host
access point1
Internet
socket migration
and state transfer
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
52
� 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
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
53
without jeopardizing the stability of the Internet.
� It is easy to use different protocols for wired and wireless networks.
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.
54
� 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.