TCP in Wireless Mobile Networks - Stony Brook University

54
TCP in Wireless Mobile Networks 1

Transcript of TCP in Wireless Mobile Networks - Stony Brook University

Page 1: TCP in Wireless Mobile Networks - Stony Brook University

TCP in Wireless Mobile Networks

1

Page 2: TCP in Wireless Mobile Networks - Stony Brook University

Outline

� Introduction to transport layer

� Introduction to TCP (Internet) congestion control

� Congestion control in wireless networks

2

� Congestion control in wireless networks

Page 3: TCP in Wireless Mobile Networks - Stony Brook University

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.

Page 4: TCP in Wireless Mobile Networks - Stony Brook University

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.

Page 5: TCP in Wireless Mobile Networks - Stony Brook University

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.

Page 6: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 7: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 8: TCP in Wireless Mobile Networks - Stony Brook University

Outline

� Introduction to transport layer

� Introduction to TCP (Internet) congestion control

� Congestion control in wireless networks

8

� Congestion control in wireless networks

Page 9: TCP in Wireless Mobile Networks - Stony Brook University

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!

Page 10: TCP in Wireless Mobile Networks - Stony Brook University

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)

Page 11: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 12: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 13: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 14: TCP in Wireless Mobile Networks - Stony Brook University

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)

Page 15: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 16: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 17: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 18: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 19: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 20: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 21: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 22: TCP in Wireless Mobile Networks - Stony Brook University

How does TCP detect a packet loss?

� Retransmission timeout (RTO)

� Duplicate acknowledgements

22

Page 23: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 24: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 25: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 26: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 27: TCP in Wireless Mobile Networks - Stony Brook University

Fast Retransmission

� Timeouts can take too long� how to initiate retransmission sooner?

� Fast retransmit

27

Page 28: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 29: TCP in Wireless Mobile Networks - Stony Brook University

TCP Congestion Control

� End-to-end, window-based congestion control

� Transmission rate limited by congestion window size, cwnd, over segments:

29

cwnd

w

Page 30: TCP in Wireless Mobile Networks - Stony Brook University

Window-based Scheme

30

Window-based Congestion Control is Self Clocking!

Page 31: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 32: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 33: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 34: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 35: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 36: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 37: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 38: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 39: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 40: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 41: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 42: TCP in Wireless Mobile Networks - Stony Brook University

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.

Page 43: TCP in Wireless Mobile Networks - Stony Brook University

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?

Page 44: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 45: TCP in Wireless Mobile Networks - Stony Brook University

Discussion

� Why is TCP congestion control less effective in mobile wireless networks?

45

� How to improve the performance of TCP?

Page 46: TCP in Wireless Mobile Networks - Stony Brook University

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.

Page 47: TCP in Wireless Mobile Networks - Stony Brook University

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.

Page 48: TCP in Wireless Mobile Networks - Stony Brook University

Outline

� Indirect TCP

� Snooping TCP

� Mobile TCP

� Fast retransmission, fast recovery

48

� Fast retransmission, fast recovery

� Freezing

� Selective retransmission

Page 49: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 50: TCP in Wireless Mobile Networks - Stony Brook University

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.

Page 51: TCP in Wireless Mobile Networks - Stony Brook University

I-TCP Socket and State Migration

access point2

socket migration

51

mobile host

access point1

Internet

socket migration

and state transfer

Page 52: TCP in Wireless Mobile Networks - Stony Brook University

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

Page 53: TCP in Wireless Mobile Networks - Stony Brook University

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.

Page 54: TCP in Wireless Mobile Networks - Stony Brook University

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.