TCP Adaptive Retransmission Algorithm - Original TCP Theory - - PDF document

tcp adaptive retransmission algorithm original tcp
SMART_READER_LITE
LIVE PREVIEW

TCP Adaptive Retransmission Algorithm - Original TCP Theory - - PDF document

TCP Adaptive Retransmission Algorithm - Original TCP Theory Estimate RTT Multiply by 2 to allow for variations Practice Use exponential moving average (A = 0.1 to 0.2) Estimate = (A) * measurement + (1- A) * estimate


slide-1
SLIDE 1

1

11/11/06 CS/ECE 438 - UIUC, Fall 2006 1

TCP

11/11/06 CS/ECE 438 - UIUC, Fall 2006 2

TCP Adaptive Retransmission Algorithm - Original

Theory

Estimate RTT

Multiply by 2 to allow for variations

Practice

Use exponential moving average (A = 0.1 to 0.2)

Estimate = (A) * measurement + (1- A) * estimate

Problem

Did not handle variations well

Ambiguity for retransmitted packets

Was ACK in response to first, second, etc transmission?

11/11/06 CS/ECE 438 - UIUC, Fall 2006 3

TCP Adaptive Retransmission Algorithm – Karn-Partridge

 Algorithm

Exclude retransmitted packets from RTT estimate

For each retransmission

Double RTT estimate

Exponential backoff from congestion  Problem

Still did not handle variations well

Did not solve network congestion problems as well as desired

11/11/06 CS/ECE 438 - UIUC, Fall 2006 4

TCP Adaptive Retransmission Algorithm – Jacobson

Algorithm

Estimate variance of RTT

Calculate mean interpacket RTT deviation to approximate variance

Use second exponential moving average

Deviation = (B) * |RTT_Estimate – Measurement| + (1–B) * deviation

B = 0.25, A = 0.125 for RTT_estimate

Use variance estimate as component of RTT estimate

Next_RTT = RTT_Estimate + 4 * Deviation

Protects against high jitter

Notes

Algorithm is only as good as the granularity of the clock

Accurate timeout mechanism is important for congestion control

11/11/06 CS/ECE 438 - UIUC, Fall 2006 5

TCP Connection Establishment

3-Way Handshake

Sequence Numbers

J,K

Message Types

Synchronize (SYN)

Acknowledge (ACK)

Passive Open

Server listens for connection from client

Active Open

Client initiates connection to server

S y n c h r

  • n

i z e ( S Y N ) J SYN K, acknowledge (ACK) J+1 A C K K + 1

Client Server

Time flows down

listen

11/11/06 CS/ECE 438 - UIUC, Fall 2006 6

TCP Connection Termination

 Message Types

Finished (FIN)

Acknowledge (ACK)

 Active Close

Sends no more data

 Passive close

Accepts no more data

F i n i s h e d ( F I N ) J ACK J+1 A C K K + 1

Client Server

Time flows down

FIN K

slide-2
SLIDE 2

2

11/11/06 CS/ECE 438 - UIUC, Fall 2006 7

TCP Connection Management (cont)

TCP client lifecycle TCP server lifecycle

11/11/06 CS/ECE 438 - UIUC, Fall 2006 8

TCP State Descriptions

Wait for network to discard related packets TIME_WAIT Connection closed by both sides simultaneously CLOSING Connection closed locally and ACK’d FIN_WAIT_2 Connection closed locally FIN_WAIT_1 Connection closed by peer, closed locally, await ACK LAST_ACK Connection closed by peer CLOSE_WAIT Connection ready for data transport ESTABLISHED Connection request sent SYN_SENT Connection request received SYN_RCVD Waiting for incoming connection LISTEN Disconnected CLOSED Wait for network to discard related packets TIME_WAIT Connection closed by both sides simultaneously CLOSING Connection closed locally and ACK’d FIN_WAIT_2 Connection closed locally FIN_WAIT_1 Connection closed by peer, closed locally, await ACK LAST_ACK Connection closed by peer CLOSE_WAIT Connection ready for data transport ESTABLISHED Connection request sent SYN_SENT Connection request received SYN_RCVD Waiting for incoming connection LISTEN Disconnected CLOSED Wait for network to discard related packets TIME_WAIT Connection closed by both sides simultaneously CLOSING Connection closed locally and ACK’d FIN_WAIT_2 Connection closed locally FIN_WAIT_1 Connection closed by peer, closed locally, await ACK LAST_ACK Connection closed by peer CLOSE_WAIT Connection ready for data transport ESTABLISHED Connection request sent SYN_SENT Connection request received SYN_RCVD Waiting for incoming connection LISTEN Disconnected CLOSED Wait for network to discard related packets TIME_WAIT Connection closed by both sides simultaneously CLOSING Connection closed locally and ACK’d FIN_WAIT_2 Connection closed locally FIN_WAIT_1 Connection closed by peer, closed locally, await ACK LAST_ACK Connection closed by peer CLOSE_WAIT Connection ready for data transport ESTABLISHED Connection request sent SYN_SENT Connection request received SYN_RCVD Waiting for incoming connection LISTEN Disconnected CLOSED

11/11/06 CS/ECE 438 - UIUC, Fall 2006 9

TCP State Transition Diagram

CLOSED CLOSED ESTABLISHED LISTEN SYN_RCVD SYN_SENT FIN_WAIT_1 FIN_WAIT_2 CLOSING TIME_WAIT CLOSE_WAIT LAST_ACK Passive open Close/FIN ACK SYN/SYN + ACK Active

  • pen/SYN

Close Close SYN/SYN + ACK Timeout FIN + ACK/ACK SYN + ACK/ACK Send/SYN ACK ACK ACK FIN/ACK Close/ACK FIN/ACK FIN/ACK Close/FIN

11/11/06 CS/ECE 438 - UIUC, Fall 2006 10

TCP State Transition Diagram

 Questions

State transitions

Describe the path taken by a server under normal conditions

Describe the path taken by a client under normal conditions

Describe the path taken assuming the client closes the connection first

TIME_WAIT state

What purpose does this state serve

Prove that at least one side of a connection enters this state

Explain how both sides might enter this state

11/11/06 CS/ECE 438 - UIUC, Fall 2006 11

TCP State Transition Diagram

CLOSED ESTABLISHED LISTEN SYN_RCVD SYN_SENT Passive open SYN/SYN + ACK Active

  • pen/SYN

Close Close SYN/SYN + ACK SYN + ACK/ACK ACK Passive open SYN/SYN + ACK ACK Active

  • pen/SYN

SYN + ACK/ACK Send/SYN Send/SYN SYN/SYN + ACK TCP A TCP B

  • 1. CLOSED

LISTEN

  • 2. SYN-SENT
  • -> <SEQ=100><CTL=SYN> -->

SYN-RECEIVED

  • 3. ESTABLISHED <-- <SEQ=300><ACK=101><CTL=SYN,ACK> <-- SYN-RECEIVED
  • 4. ESTABLISHED --> <SEQ=101><ACK=301><CTL=ACK> -->

ESTABLISHED

  • 5. ESTABLISHED --> <SEQ=101><ACK=301><CTL=ACK><DATA> --> ESTABLISHED

11/11/06 CS/ECE 438 - UIUC, Fall 2006 12

TCP State Transition Diagram

CLOSED CLOSED ESTABLISHED LISTEN SYN_RCVD SYN_SENT FIN_WAIT_1 FIN_WAIT_2 CLOSING TIME_WAIT CLOSE_WAIT LAST_ACK Passive open Close/FIN SYN/SYN + ACK Active

  • pen/SYN

Close Close SYN/SYN + ACK Timeout SYN + ACK/ACK ACK ACK ACK FIN/ACK Close/FIN FIN/ACK FIN/ACK Close/FIN ACK Send/SYN Close/FIN ACK FIN/ACK Timeout FIN/ACK Close/FIN ACK Close/FIN FIN/ACK ACK Timeout Close/FIN Timeout FIN + ACK/ACK FIN + ACK/ACK

slide-3
SLIDE 3

3

11/11/06 CS/ECE 438 - UIUC, Fall 2006 13

TCP Sliding Window Protocol

Sequence numbers

Indices into byte stream

ACK sequence number

Actually next byte expected as opposed to last byte received

Advertised window

Enables dynamic receive window size

Receive buffers

Data ready for delivery to application until requested

Out-of-order data out to maximum buffer capacity

Sender buffers

Unacknowledged data

Unsent data out to maximum buffer capacity

11/11/06 CS/ECE 438 - UIUC, Fall 2006 14

TCP Sliding Window Protocol – Sender Side

LastByteAcked <= LastByteSent

LastByteSent <= LastByteWritten

Buffer bytes between LastByteAcked and LastByteWritten First unacknowledged byte Last byte sent Data available, but

  • utside window

Maximum buffer size Advertised window

11/11/06 CS/ECE 438 - UIUC, Fall 2006 15

TCP Sliding Window Protocol – Receiver Side

LastByteRead < NextByteExpected

NextByteExpected <= LastByteRcvd + 1

Buffer bytes between NextByteRead and LastByteRcvd Next byte to be read by application Next byte expected (ACK value) Buffered, out-of-order data Maximum buffer size Advertised window

11/11/06 CS/ECE 438 - UIUC, Fall 2006 16

TCP ACK generation - 1

 Arrival of in-order segment with expected seq #. All

data up to expected seq # already ACKed

 Delayed ACK. Wait up to 500ms for next segment.

Next byte to be read by application Next byte expected (ACK value) Maximum buffer size Available buffer size

11/11/06 CS/ECE 438 - UIUC, Fall 2006 17

TCP ACK generation - 2

 Arrival of in-order segment with expected seq #.

One other segment has ACK pending

 Immediately send single cumulative ACK, ACKing both in-

  • rder segments

Next byte to be read by application Next byte expected (ACK value) Maximum buffer size Available buffer size

11/11/06 CS/ECE 438 - UIUC, Fall 2006 18

TCP ACK generation - 3

 Arrival of out-of-order segment higher-than-expect

  • seq. # Gap detected

 Immediately send duplicate ACK, indicating seq. # of next

expected byte

Next byte to be read by application Next byte expected (ACK value) Maximum buffer size Available buffer size

slide-4
SLIDE 4

4

11/11/06 CS/ECE 438 - UIUC, Fall 2006 19

TCP ACK generation - 4

Arrival of segment that partially or completely fills gap

 Immediate send ACK, provided that segment starts at lower end

  • f gap

Next byte to be read by application Next byte expected (ACK value) Maximum buffer size Available buffer size

11/11/06 CS/ECE 438 - UIUC, Fall 2006 20

TCP ACK generation [RFC 1122, RFC

2581] Event at Receiver

Arrival of in-order segment with expected seq #. All data up to expected seq # already ACKed Arrival of in-order segment with expected seq #. One other segment has ACK pending Arrival of out-of-order segment higher-than-expect seq. # . Gap detected Arrival of segment that partially or completely fills gap

TCP Receiver action

Delayed ACK. Wait up to 500ms for next segment. If no next segment, send ACK Immediately send single cumulative ACK, ACKing both in-order segments Immediately send duplicate ACK, indicating seq. # of next expected byte Immediate send ACK, provided that segment starts at lower end of gap

11/11/06 CS/ECE 438 - UIUC, Fall 2006 21

Fast Retransmit

What’s the problem with time-out?

time-out period often relatively long

Detect lost segments via duplicate ACKs.

Sender often sends many segments back- to-back

If segment is lost, there will likely be many duplicate ACKs.  If sender receives 3

ACKs for the same data, it supposes that segment after ACKed data was lost:

fast retransmit: resend segment before timer expires

 Why 3?

11/11/06 CS/ECE 438 - UIUC, Fall 2006 22

event: ACK received, with ACK field value of y

if (y > SendBase) { SendBase = y if (there are currently not-yet-acknowledged segments) start timer } else { increment count of dup ACKs received for y if (count of dup ACKs received for y = 3) { resend segment with sequence number y }

Fast retransmit algorithm:

a duplicate ACK for already ACKed segment fast retransmit

11/11/06 CS/ECE 438 - UIUC, Fall 2006 23

A 4th situation?

Next byte to be read by application Next byte expected (ACK value) Buffered, out-of-order data Maximum buffer size Available buffer size

What if?

 Receiver side

11/11/06 CS/ECE 438 - UIUC, Fall 2006 24

TCP Flow Control

Sender

First unacknowledged byte Last byte sent Data available, but

  • utside window

Maximum buffer size Sliding window Next byte to be read by application Next byte expected (ACK value) Buffered, out-of-order data Maximum buffer size Available buffer size

Receiver

Avoid?

slide-5
SLIDE 5

5

11/11/06 CS/ECE 438 - UIUC, Fall 2006 25

Flow Control vs. Congestion Control

 Flow control

Preventing senders from overrunning the capacity of the receivers

 Congestion control

Preventing too much data from being injected into the network, causing switches or links to become overloaded

 TCP provides both

flow control based on advertised window

congestion control discussed later in class

11/11/06 CS/ECE 438 - UIUC, Fall 2006 26

TCP Flow Control

Receiving side

Receive buffer size = MaxRcvBuffer

LastByteRcvd - LastByteRead < = MaxRcvBuffer

AdvertisedWindow = MaxRcvBuffer - (NextByteExpected - NextByteRead)

Shrinks as data arrives and

Grows as the application consumes data 

Sending side

Send buffer size = MaxSendBuffer

LastByteSent - LastByteAcked < = AdvertisedWindow

EffectiveWindow = AdvertisedWindow - (LastByteSent - LastByteAcked)

EffectiveWindow > 0 to send data

LastByteWritten - LastByteAcked < = MaxSendBuffer

block sender if (LastByteWritten - LastByteAcked) + y > MaxSenderBuffer

11/11/06 CS/ECE 438 - UIUC, Fall 2006 27

TCP Flow Control

Problem: Slow receiver application

Advertised window goes to 0

Sender cannot send more data

Non-data packets used to update window

Receiver may not spontaneously generate update or update may be lost

Solution

Sender periodically sends 1-byte segment, ignoring advertised window of 0

Eventually window opens

Sender learns of opening from next ACK of 1-byte segment

11/11/06 CS/ECE 438 - UIUC, Fall 2006 28

TCP Flow Control

Problem: Application delivers tiny pieces of data to TCP

Example: telnet in character mode

Each piece sent as a segment, returned as ACK

Very inefficient

Solution

Delay transmission to accumulate more data

Nagle’s algorithm

Send first piece of data

Accumulate data until first piece ACK’d

Send accumulated data and restart accumulation

Not ideal for some traffic (e.g. mouse motion)

11/11/06 CS/ECE 438 - UIUC, Fall 2006 29

TCP Flow Control

 Problem: Slow application reads data in tiny

pieces

Receiver advertises tiny window

Sender fills tiny window

Known as silly window syndrome

 Solution

Advertise window opening only when MSS or 1/2 of buffer is available

Sender delays sending until window is MSS or 1/2 of receiver’s buffer (estimated)

11/11/06 CS/ECE 438 - UIUC, Fall 2006 30

TCP Bit Allocation Limitations

 Sequence numbers vs. packet lifetime

Assumed that IP packets live less than 60 seconds

Can we send 232 bytes in 60 seconds?

Less than an STS-12 line

 Advertised window vs. delay-bandwidth

Only 16 bits for advertised window

Cross-country RTT = 100 ms

Adequate for only 5.24 Mbps!

slide-6
SLIDE 6

6

11/11/06 CS/ECE 438 - UIUC, Fall 2006 31

TCP Sequence Numbers – 32-bit

1.2 Gbps 622 Mbps 155 Mbps 100 Mbps 45 Mbps 10 Mbps 1.5 Mbps

Speed

13 minutes T3 6 minutes FDDI 4 minutes STS-3 57 minutes Ethernet 28 seconds STS-24 55 seconds STS-12 6.4 hours T1

Time until wrap around Bandwidth

11/11/06 CS/ECE 438 - UIUC, Fall 2006 32

TCP Advertised Window – 16-bit

1.2 Gbps 622 Mbps 155 Mbps 100 Mbps 45 Mbps 10 Mbps 1.5 Mbps

Speed

11.6 ms T3 5.2 ms FDDI 3.4 ms STS-3 52.4 ms Ethernet 437 µs STS-24 843 µs STS-12 350 ms T1

Max RTT Bandwidth