1 TCP: Reliable Transport Service. 2 Transmission Control Protocol (TCP) Major transport protocol used in Internet Heavily used Completely reliable transfer.

Post on 02-Jan-2016

218 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

Transcript

1

TCP: Reliable Transport Service

2

Transmission Control Protocol (TCP)

• Major transport protocol used in Internet

• Heavily used

• Completely reliable transfer

3

TCP Features

• Connection-oriented service

• Point-to-point

• Full-duplex communication

• Stream interface

• Stream divided into segments for transmission

• Each segment encapsulated in IP datagram

• Uses protocol ports to identify applications

4

TCP Feature Summary

• TCP provides a completely reliable (no data duplication or loss), connection-oriented, full-duplex stream transport service that allows two application programs to form a connection, send data in either direction, and then terminate the connection.

5

End-to-End Protocol

6

Apparent Contradiction

• IP offers best-effort (unreliable) delivery

• TCP uses IP

• TCP provides completely reliable transfer

• How is this possible?

7

Achieving Reliability

• Reliable connection startup

• Reliable data transmission

• Graceful connection shutdown

8

Reliable Data Transmission

• Positive acknowledgment– Receiver returns short message when data arrives– Called acknowledgment

• Retransmission– Sender starts timer whenever message is

transmitted– If timer expires before acknowledgment arrives,

sender retransmits message

9

Illustration Of Retransmission

10

How Long Should TCP WaitBefore Retransmitting?

• Time for acknowledgment to arrive depends on– Distance to destination– Current traffic conditions

• Multiple connections can be open simultaneously

• Traffic conditions change rapidly

11

Important Point

• The delay required for data to reach a destination and an acknowledgment to return depends on traffic in the internet as well as the distance to the destination. Because it allows multiple application programs to communicate with multiple destinations concurrently, TCP must handle a variety of delays that can change rapidly.

12

Solving The Retransmission Problem

• Keep estimate of round trip time on each connection

• Use current estimate to set retransmission timer

• Known as adaptive retransmission

• Key to TCP’s success

13

Illustration Of Adaptive Retransmission

• Timeout depends on current round-trip estimate

14

TCP Flow Control

• Receiver– Advertises available buffer space– Called window

• Sender– Can send up to entire window before ack arrives

15

Window Advertisement

• Each acknowledgment carries new window information– Called window advertisement– Can be zero (called closed window)

• Interpretation: have received up through X, and can take Y more octets

16

Illustration Of Window Advertisement

A TCP acknowledgement specifies the sequence number of the next octet that the receiver expects to receive

17

Startup And Shutdown

• Connection startup– Must be reliable

• Connection shutdown– Must be graceful

• Difficult

18

Why Startup And Shutdown Are Difficult

• Segments can be– Lost– Duplicated– Delayed– Delivered out of order– Either side can crash– Either side can reboot

• Need to avoid duplicate shutdown message from affecting later connection

19

TCP’s Solution For Startup/Shutdown

• Uses three-message exchange

• Known as 3-way handshake

• Necessary and sufficient for– Unambiguous, reliable startup– Unambiguous, graceful shutdown

• SYN used for startup

• FIN used for shutdown

20

Connection Establishment – Three-way Handshake

Active participant(client)

Passive participant(server)

SYN, SequenceNum = x

ACK, Acknowledgment =y+1

Acknowledgment =x+1

SYN+ACK,

SequenceNum=y,

21

Closing a TCP Connection

22

TCP Segment Format

• All TCP segments have same format– Data– Acknowledgment– SYN (startup)– FIN (shutdown)

• Segment divided into two parts– Header– Payload area (zero or more bytes of data)

23

TCP Segment Format(continued)

• Header contains– Protocol port numbers to identify

• Sending application• Receiving application

– Code bits to specify items such as• SYN• FIN• ACK

– Fields for window advertisement, acknowledgment, etc.

24

Illustration Of TCP Segment

• Sequence number specifies where in stream outgoing data belongs

• Acknowledgment number refers to incoming data• Few segments contain options

25

Checksum = 1s complement sum of the 1s complement of 4-bit quantities.

1s complement of 1111, 0000, 1100, 0101, 1000

is 0000, 1111, 0011, 1010, 0111.

1s complement sum: 0000 + 1111 = 1111.

1111 + 0011 = 0010 + 1 (carry) = 0011

0011 + 1010 = 1101

1101 + 0111 = 0100 + 1 (carry) = 0101

Ans: Checksum = 0101

Checksum - One Example

26

Flow Control And Congestion

• Receiver advertises window that specifies how many additional bytes it can accept

• Window size of zero means sender must not send normal data (ACKs and urgent data allowed)

• Sender chooses effective window smaller than receiver’s advertised window if congestion detected– Allowed_window = min(receiver_advertisement,

congestion_window)

– Congestion window is reduced by half for every loss – multiplicative decrease

27

TCP Congestion Control• When CongWin is below Threshold, sender in slow-

start phase, window grows exponentially.

• When CongWin is above Threshold, sender is in congestion-avoidance phase, window grows linearly.

• When timeout occurs, Threshold set to CongWin/2 and CongWin is set to 1 MSS (Maximum Segment Size).

• When a triple duplicate ACK occurs, Threshold set to CongWin/2 and CongWin set to Threshold.

• Additive Increase Multiplicative Decrease (AIMD)

28

TCP Congestion ControlQ: When should the

exponential increase switch to linear?

A: When CongestionWindow gets to 1/2 of its value before timeout.

Implementation:• Variable Threshold

• At loss event, Threshold is set to 1/2 of CongWin just before loss event

From Tanenbaum’s book, fourth edition, pp. 550

top related