tcp : transmission control protocol ( stevens tcp/ ip...

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 • 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:

Upload: vanhanh

Post on 06-Mar-2018

233 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

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: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

2

TCP Connection Establishment And Termination

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

• Client 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/ACK• Client ACKs the SYN from server• This is 3 way handshake.

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

Page 3: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

3

Page 4: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

4

TCP Header :

15 31 ( 32 Bits)104Bit 0

20 B

YTE

S

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: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

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: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

6

Page 7: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

7

Page 8: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

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: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

9

Page 10: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

10

Page 11: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

11

Page 12: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

12

Page 13: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

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 receiversends an ACK or until data accumulated is an MSS. At this point sender can senddata.

3. Repeat step two for remainder of transmission.

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

There are situations like x window mouse where small mouse movements need toimmediately 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: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

14

Page 15: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

15

Page 16: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

16

Page 17: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

17

Page 18: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

18

Page 19: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

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: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

20

Page 21: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

21

Page 22: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

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: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

23

Page 24: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

24

Page 25: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

25

Page 26: TCP : Transmission Control Protocol ( Stevens TCP/ IP ...users.ece.gatech.edu/dblough/4110/TCPIntroduction.pdf · 1 TCP : Transmission Control Protocol ( Stevens TCP/ IP Illustrated

26