1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection...

70
1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment A segment is retransmitted if an acknowledgement is not received within ticks of a timer TCP upon receipt of data sends an ACK. Normally does not send this ACK immediately TCP reorders out of order data TCP uses flow control Chapter 17 and 18:

Transcript of 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection...

Page 1: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

1

TCP : Transmission Control Protocol( Stevens TCP/ IP Illustrated Volume 1)

• TCP is connection oriented

• Unit of information passed by TCP to IP is a segment

• A segment is retransmitted if an acknowledgement is not received within ticks of a timer

• TCP upon receipt of data sends an ACK. Normally does not send this ACK immediately

• TCP reorders out of order data

• TCP uses flow control

Chapter 17 and 18:

Page 2: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

2

TCP Connection Establishment And Termination

[ Fig 18.3] Use “tcpdump” to obtain data for this

• Clint sends a SYN with initial sequence number Notation 1415531521:1415531521 (0)

Number of Bytes sent

StartingSequenceNumber

Starting SequenceNumber PlusNumber of Bytes Sent

• Server responds with SYN• Client ACK the SYN from server• This is 3 way handshake.

It takes four segments to terminate and is called “ Half Close”

Page 3: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

3

Page 4: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

4

TCP Header :

15 31 ( 32 Bits)104Bit 0

20 B

YT

ES

SOURCE PORT DESTINATION PORT

SEQUENCE NUMBER

ACKNOWLEDGEMENT NUMBER

HEADER LENGTH

UNUSED

FLAGS

WINDOW

CHECKSUM URGENT POINTER

OPTIONS + PADDING

ACK

URG

RST

SYN

FIN

PSH

Page 5: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

5

• Maximum segment size (MSS) is largest amount of data each TCP sender is willing to receive

• Advertised by each end and can be different in different directions. It is not “negotiated.”

• If no MSS sent default 536 is used

• For ethernet 1460 bytes is the MSS.

[ Fig 18.12 and 18.13] State Diagram Of TCP • When TCP active close occurs and sends final Ack, connection stays in Time-Wait state for twice maximum segment lifetime (MSS) value.

1. In case must resend final ACK 2. In case attempt to reuse IP address and port again while old segments may still be in network.

• Reset segment RST is sent when error occurs.

Page 6: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

6

Page 7: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

7

Page 8: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

8

TCP Interactive Flow (TCP/IP Vol. 1, Stevens Chapter 19)

- Look at flow of data for rlogin connection which is a TCP application.- Each keystroke generates a data packet.

[ Fig 19.1]

- Modified TCP dump output for session with five characters date\n (connection establishment not shown in Fig 19.2).

[ Fig 19.2 ][ Fig 19.3 ] Time Line For Fig 19.2, much easier to follow

- ACK can be sent along with next data going in same direction called ACK piggyback.- ACK usually wait up to 200 ms delay to see if must travel alone or get to piggyback.- Notation in Fig 19.2/19.3 0:1(1) means sent (1) data byte with sequence number 0. The next starting sequence number will be 1.

Page 9: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

9

Page 10: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

10

Page 11: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

11

Page 12: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

12

Page 13: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

13

To prevent lots of very small data segments in a network:

Nagle Algorithm (For the sending TCP algorithm)

1. The sending TCP sends the (small) data even if it is only one byte.

2. After sending the first data segment, sending TCP accumulates data until receiver sends an ACK or until data accumulated is an MSS. At this point sender can send data.

3. Repeat step two for remainder of transmission.

This algorithm causes a fast application program on a slow network to accumulate and send larger (mss) segments. A slow application program on a fast network will send less than mss.

There are situations like x window mouse where small mouse movements need to immediately be sent, in that case would not want to use Nagle since want to sendsmall size data immediately.

Fig [19.5-19.8]

Page 14: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

14

Page 15: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

15

Page 16: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

16

Page 17: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

17

Page 18: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

18

Page 19: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

19

TCP Bulk Data Flow Chapter 20

Normal Data Flow Example Transfer of 8192 bytes of data from srv4 to bsdi [Fig 20.1] Warning: This example appears to not use slow start (discussed later).

- Sender transmits 3 data segments (4-6) - Next segment (7) acknowledges the first two data segments only. This is because of the following: - When TCP processes segment 4 the connection is marked to generate a delayed ACK - When segment 5 arrives TCP has two outstanding segments and immediately acknowledges.

* TCP Immediately ACK's two outstanding segments.

- Next segment (8) ACK's the third data segment due to ACK acknowledgement timer reaching a “ 200 ms Interval”. - Window of only 3072 advertised since 1024 bytes of data still in TCP receive buffer

- In TCP ACK's are cumulative. They acknowledge receipt of up through ACK sequence number minus one.

Note in Fig. 20.1 that the FIN segment has no data and is 8193:8193(0). The ACK for this is an ACK8194 which is one more than the last data. This is always true. A FIN uses up one ACK number.

Page 20: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

20

Page 21: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

21

Page 22: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

22

Another Normal Data Flow Example:

[Fig 20.2] Same as before but data sent a bit different.

Warning: This example appears to not use slow start (discussed later).

Fast Sender, Slow Receiver Example:

[Fig 20.3] Warning: This example appears to not use slow start (discussed later).

- Sender transmits four back-to-back data segments (4-7) to fill receivers window.

- Receiver sends ACK but with advertised window 0. Application has not yet read

data

- Another ACK called a window update is sent later announcing some room at the

Inn.

Warning: Fig 20.3 does not follow the ack no more than every other segment rule.

Page 23: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

23

Page 24: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

24

Page 25: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

25

Page 26: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

26

Page 27: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

27

PUSH Flag

A notification from the sender to the receiver to pass all the data the receiver has to the receiving application.

Some implementations of TCP automatically set the push flag if the data in the segment being sent empties the send buffer.

These same implementations ignore a received PUSH flag because they normally deliver the received data to the application as soon as possible.

In Fig 20.3 missing 3 PSH because sends did not empty the send buffer. Application has already sent all of its data to the send buffer so only last write empties the send buffer.

We cannot manually set this flag through the Sockets Application Programming Interface.

Page 28: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

28

Sliding Windows

[Fig 20.4]

Sliding window example

[Fig 20.6] and [Fig 20.1]

Page 29: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

29

Page 30: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

30

Page 31: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

31

Page 32: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

32

Page 33: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

33

Slow Start

Steven’s examples did not use slow start up until now. All TCP implementations must now use the slow start algorithm. You must always use slow start in this class. Some examples in the book do not do this, in this class you must ALWAYS use slow start.

An Intermediate router queue may run out of space. Best not to send too much too fast. Slow start Algorithm notes that the rate it should inject new packets into the network is the rate at which acknowledgements are returned by the other end.

ADD A CONGESTION WINDOW “ cwnd ” on the SENDER side (Note different from (buffer) window discussed before.)

-In a new connection, the congestion window is initialized to one MSS announced by other end. - cwnd is maintained in bytes however cwnd is incremented by segment size.

- For each ACK received cwnd is increased by one segment.

Page 34: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

34

- Sender can transmit up to minimum of (the congestion window and the advertised window) (Congestion window cwnd is set by sender while advertised window is set by receiver).

-Sender starts by transmitting one segment and waiting for its ACK. When that ACK is acknowledged, congestion window is incremented from one to two and two segments can be sent.

-When each of those two segments acknowledged, congestion window set to four.

-This provides an exponential increase.

-At some point an intermediate router will discard packets. Congestion window cwnd is too large.

Page 35: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

35

[ Fig 20.8] MSS=512

Bulk data throughput - interaction of window size, windowed flow control, and slow start on the throughput of a TCP connection.

[Fig 20.9& 20.10]- At time 0 sender transmits one segment cwnd = 1, must wait for ACK.- At times 1, 2, 3, segment moves one time unit right.- At time 4 ACK generated.- At time 7 ACK received at sender.- At time 8 sender can transmit two segments, cwnd = 2 (we have round trip time = 8 ).- At times 12, 13 ACK 2 and ACK 3 generated.- At time 15, 16 ACK's RCVD and with cwnd = 4 sender transmits four segments.- At time 24 and on can always transmit.

Slow Start Example

Page 36: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

36

Page 37: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

37

Page 38: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

38

Page 39: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

39

Page 40: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

40

Bandwidth - Delay Product

In previous example sender needs to have 8 segments outstanding and unacknowledged for max throughput. Thus receivers advertised window must be at least that large so as not to limit throughput.

Capacity of pipe = bandwidth ( bits/ sec ) x round trip time ( sec ) ( also know as bandwidth-delay product)

Example:

What size should receivers advertised window be for a T1 Cross USA country phone line? = 1, 544, 000 Bits / Sec x 0.060 Sec round trip time. = 11,580 byte window

Congestion

The spacing of the ACKs will correspond to the bandwidth of the slowest links

[ Fig 20.13]

Page 41: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

41

Page 42: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

42

So what do mean by increase cwnd for each ACK received?

1) Stevens book says “Each time an ACK is received, the congestion window is increased by one segment”

2) RFC2001 Network Working Group W. Stevens Request for Comments: 2001 January 1997 “TCP Slow Start, Congestion Avoidance, Fast Retransmit, and Fast Recovery Algorithms” : Each time an ACK is received, the congestion window is increased by one segment……..this provides an exponential growth, although it is not exactly exponential because the receiver may delay its ACKs, typically sending one ACK for every two segments that it receives. 

3) RFC 2581 TCP Congestion Control APRIL 1999 says “ During Slow start, TCP increments cwnd by at most mss bytes for each ACK received that acknowledges new data”

4) From: Internet Engineering Task Force , Mark Allman INTERNET DRAFT draft-allman-tcp-abc-00.txt July, 2000 Expires: January, 2001  TCP Congestion Control with Appropriate Byte Counting

Delayed ACKs [RFC1122,RFC2581] allow a TCP receiver to refrain from sending an ACK for each incoming segment. However, a receiver SHOULD send an ACK for every second full-sized segment that arrives. Furthermore, a receiver MUST NOT withhold an ACK for more than [200] ms. By reducing the number of ACKs sent to the data originator the receiver is slowing the growth of the congestion window under an ACK counting system.

Page 43: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

43

Conclusion: So clearly we are counting individual ACKS not the amount of data being ACKed. For this class always assume cwnd is incremented by only one MSS when an “ACK very other segment” is used and this ACK datagram contains an ACK for more than one segment.

Aside:

Is this definitely 100% for sure always true in the real world? Well …..

Forouzan in “TCP/IP Protocol Suite” McGraw Hill 2000 says “For each segment that is acknowledged, increase the congestion window by one maximum segment size until you reach a threshold of half the allowable window size.”

Lets stick with the ACK counting approach at the top of this slide.

Page 44: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

44

Congestion Example [Fig 21.6]

Starting sequence number versus time Retransmission is negative slope. Only 3 retransmissions occur. (one segment in each)

Look At The First Segment Loss At Time 10 [Fig 21.7] Zoom in at around 10 second point

This figure shows segments numbered according to their send or receive order with respect to host.

Removed unrelated segments 44,47, and 49; removed window advertisements slip=4096, vangogh=8192

Segment 45 gets lost and is not received.

ACK for up to 6657 is received in segment 58.

When vangogh receives segment 6913: 7169 ( 256) it repeats ACK for last received in sequence that is ACK 6657 again. This happens 9 times. On slip receipt of the third duplicate ACK for the same thing: a retransmission of the first (and in this case only) missing segment is done.

* Note in this case only the single segment that was not received is retransmitted. After retransmission of segment 63 which is 6657:6913 (256) sender keeps on going with segment 67 8961:9217 (256), segment 69 and segment 71. Continued….

Page 45: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

45

Page 46: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

46

Page 47: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

47

* TCP does not wait for the other end to acknowledge the retransmission.

- At the receiver (vangogh) normal data is received in sequence (segment 43)

- 256 bytes of data is passed up to the user process.

- Next received segment (segment 46) is out of order, it starts at 6913 but 6657 is expected.

- TCP saves out of order and immediately ACK’s with highest sequence number received in order plus 1 (6657)

- Next seven segments received by vangogh are also out of order but are saved. Duplicate ACK of 6657 sent for each.

- When missing data segment 63 6657: 6913 (256) arrives receiving TCP already has 6657 through 8960 so an ACK for 8960 + 1 is sent.

- Window of 5888 which is 8192 - 2304 is advertised since receiving process has not yet read the buffer.

Page 48: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

48

Congestion Avoidance Algorithm

Two possible indications of Packet Loss - Timeout occurring - Receipt of duplicate ACK’s

If congestion, we want to slow down transmission.

Congestion avoidance and slow start work together.

Congestion window cwnd Slow start threshold size ssthresh

Algorithms: 1. cwnd = 1 segment ssthresh = 65535 Bytes

Initially

So how do we decide how big the sliding window (cwnd) in the sender should be?

Page 49: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

49

2. TCP never sends more than minimum of [cwnd and receiver’s advertised window].

3. When congestion encountered set ssthresh = minimum of (1/2) (cwnd, receivers advertise window) or at least 2 segments. {Rounded down to a segment size multiple}

And if congestion seen by timeout set cwnd = one segment

4. For each ACK of new data (does not happen if a duplicate ACK) if cwnd < ssthresh use slow start which means increment cwnd by one segment for each ACK else increment cwnd by (This is not slow start so is congestion avoidance)

segsize * segsize + segsize cwnd 8

For each ACK received

Note: Maximum increment in congestion avoidance allowed is 1 MSS segment.

Page 50: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

50

Example : Assume congestion when cwnd was 32 segements so we will make ssthresh = 16

This is Fig 21.8 redrawn:

Segments

( Think Bytes)

ssthresh =

cwndsegments

But actuallystoredin bytes!

20

18

16

14

12

10

8

6

4

2

0

1 2 3 4 5 6 7

Round Trip Times

0

Page 51: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

51

- Send one segment at time 0

- If ACK received send 2 segments at time 1 (cwnd =2 )

- If two ACK’s received send 4 segments at time 2 ( cwnd = 4)

- At time 3 send 8 segments (cwnd =8)

- At time 4 send 16 segments (cwnd = 16)

-At time 5 gets incremented to above ssthresh so no longer in slow start region thus instead (in congestion avoidance region) increment cwnd by segsize x segsize + segsize cwnd 8Limit this increase to one segment maximum

NOTE: Stevens says segsize term should not be included but it is in some code. We will always use it also. 8NOTE: Congestion avoidance is flow control imposed by the sender based on network congestion Advertised window is flow control imposed by receiver based on available buffer space.

Example in a minute……

Page 52: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

52

Fast Retransmit and Fast Recovery Algorithms

TCP is required to generate an immediate acknowledgement ( a duplicate ACK ) when an out oforder segment is received.

It is sent with “No Delay”.

We wait for 3 or more received duplicate ACKS in a row to make sure its not just a temporary reordering.Note that 4 ACKs for the same segment is considered as an ACK and 3 duplicate ACKS = 4 total!

Then perform retransmission of what appears to be the missing segment without waiting for retransmission timer to expire

Called fast retransmit algorithm.

Next congestion avoidance not slow start is performed (well sort of, one slow start type increment and thenCongestion avoidance, see example later to see what this means).

Called fast recovery algorithm.

Since data must still be flowing through network if generating duplicate ACK’s do not go toslow start.

Page 53: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

53

Fast Recovery Algorithm :

1. When 3rd duplicate ACK received set ssthresh to (½)(cwnd) rounded down to a

segment size multiple.

2. Retransmit missing segment

3. Set cwnd to ssthresh plus (3 x segment size).

4. For each duplicate ACK received after the retransmitted segment,

increment cwnd by segment size and transmit another TCP segment

if allowed by new value of cwnd.

5. For first new ACK, set cwnd to ssthresh (ssthresh still has the value in step 1)

This should be ACK of retransmission from step 2. This ACK should acknowledge

all intermediate segments sent between lost TCP segment and receipt of

duplicate ACK.

This is congestion avoidance since slowing down to one - half

rate when packet lost.

Whew….need an example!

Page 54: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

54

Simple Example Of Slow Start

Given mss = 256 bytes cwnd = 256 bytes ssthresh = 65535 bytes

For each ACK received cwnd = cwnd + 1 segment cwnd = cwnd + 256

= 512, 768, 1024, 1280, etc

Assuming congestion does not occur, continue until advertised window (receiver buffer!) limits what sender can transmit

Congestion Example (Back to our chapter’s long example from several figures)

Assume advertised window = 8192 on vangogh[ Fig 21.9 ]

Initial SYN is lost (know by timeout) so retransmit cwnd = 256 (set cwnd = one segment we are slow start)=> ssthresh = min of ½ ( cwnd, advertised window) or at least 2 segments use 2 segments = 2 x 256 = 512 bytes

=> cwnd = one segment = 256

Page 55: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

55

Page 56: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

56

Second SYN is acknowledged

Next we have first data acknowledged ACK 257 and we have cwnd < ssthresh Since 256<= 512. Note test is performed before put new value on the line in Fig. 21.9

cwnd = cwnd + 1 segment = 512 bytes We now have second data segment acknowledged ACK 513and still cwnd < ssthresh

cwnd = cwnd + 1 segment = 768 bytes

Page 57: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

57

Now we have

cwnd > ssthresh

No longer in slow start

Third data segment acknowledged (ACK 769)

cwnd = cwnd + segsize x segsize + segsize

cwnd 8

cwnd = 768 + 256 x 256 + 256

768 8

cwnd = 885

Page 58: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

58

Look at places where congestion occurred and we enter fast retransmit.

[Fig 21.11] and [Fig 21.7] congestion shown

After 3 duplicate ACKs

1. ssthresh = ( ½ * cwnd) rounded down to a segment size multiple

= ½ * 2426 = 1,213 round down to 4 x 256 = 1024

2. cwnd = ssthresh + 3 x segment size

= 1024 + 3 x 256

= 1792

Fourth Data Segment Acknowledged

cwnd = 885 + 256 x 256 + 256 885 8cwnd = 991

[Fig 21.10] is plot of these results

Page 59: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

59

Page 60: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

60

Page 61: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

61

Fig. 21.7

Page 62: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

62

The Retransmission Is Now Sent

5 more duplicate ACK’s arrive, increment cwnd by segment size each time and transmit another TCPsegment if allowed by value of cwnd

cwnd = cwnd + 256

Segment 64 = 1792 + 256 = 2048 Segment 65 = 2048 + 256 = 2304 Segment 66 = 2304 + 256 = 2560 Segment 68 = 2560 + 256 = 2816 Segment 70 = 2816 + 256 = 3072

Now the new data ACK arrives, set cwnd to ssthresh = 1024 “Normal algorithm” takes over which means we must do the test

is cwnd < ssthresh ? since this is true we are in a slow start part 1024 < 1024 of the “normal algorithm”

This means we must increment cwnd by one segment for each ACK cwnd = cwnd + 256 = 1024 + 256 = 1280

Page 63: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

63

Not Shown In [Fig 21.11]

Next New ACK

Since cwnd < ssthresh is not true

1280 < 1024

Increment cwnd by

segsize x segsize + 256 cwnd 8

cwnd = cwnd + 256 x 256 + 256 = 1363 1280 8

Page 64: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

64

Comment on step 4 in fast recovery algorithm:

4. For each duplicate ACK received after the retransmitted segment,

increment cwnd by segment size and transmit another TCP segment

if allowed by new value of cwnd.

[Fig 21.7 and Fig 21.11]

After segment 64 received in Fig 21.7 cwnd = 2048 (see slide 31)

but we have 9 x 256 =2304 unacknowledged bytes (segments 45, 46, 48, 50, 52, 54, 55, 57, 59).

Since can only send the minimum of cwnd (2048) and advertised window (which is 8192 in this problem), can not send any more data.

Must wait until cwnd grows. cwnd grows upon receipt of every duplicate ack.

Segment 65 makes cwnd 2304, so we still cannot send a new segment.

Segment 66 makes cwnd 2560 , segment 67 is sent.

Page 65: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

65

PERSIST: THE SECOND TCP TIMERWhat happens if a non-zero window update is lost? How do we avoid deadlock?

[Fig 20.3] Window Update Review

Sender uses a persist time to cause sender to periodically probe to find out if window has increased => window probes

Example:

[Fig 22.1]

Segment 13 advertises a window of 0, causing sender to stop

After persist timer expires, send the next single byte (TCP is allowed to send 1 byte of data beyond end of a closed window)

ACK comes back with a window of 0 causing another wait

Persist timer uses TCP exponential back off but bounds of 5 to 60 seconds used if calculate values below 5 or above 60

Unlike retransmission timeout which has a total timeout value of 2 minutes (even though page 298-299 had 9 minutes), the persist probes never give up, thus 60 second intervals forever

Page 66: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

66

Page 67: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

67

Page 68: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

68

Page 69: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

69

SILLY WINDOW SYNDROME

If this happens (Silly Window Syndrome) small amounts of data flow instead of full size MSS

Receiver can cause by advertising small windows instead of waiting until a larger window

Sender can cause by not waiting to send more data

To prevent:

1. Receiver does not increase advertised window unless one full segment size (MSS) or one-half the receiver’s buffer space, which ever is smaller.

2. Sender does not transmit unless one of:

a. Full size MSS can be sent

b. We can send at least one-half of the maximum sized window that the other end has advertised

c. We can send everything we have and:

1. We have no outstanding unacknowledged data OR

2. Nagle is Disabled

Page 70: 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated Volume 1) TCP is connection oriented Unit of information passed by TCP to IP is a segment.

70

KEEPALIVE: TCP TIMER NUMBER THREE

No data flows across an idle TCP connection

Optional timer, not part of TCP specification but found in most implementations

Not really needed since “connection” defined by end points

“connection” is up as long as destination and source are alive

Typically used to detect half open connections and de-allocate server resources in for example an FTP session

Default value is two hours, after 2 hours server sends a probe to client, if no response after 10 probes at 75 seconds apart, server assumes client no longer there and closes connection.

2MSL TIMER: TCP TIMER NUMBER FOURMeasures time a connection has been in the TIME_WAIT state

MSL is defined as 2 minutes but is implementation specific

2MSL is twice the two minutes

ASIDE: RECALL 200 ms: TCP Timer, lets call that TCP timer number five.

200 ms: TCP TIMER NUMBER FIVE