1 Kyung Hee University Chapter 12 Transmission Control Protocol.

111
1 Kyung Hee University Chapter 12 Chapter 12 Transmission Transmission Control Control Protocol Protocol

Transcript of 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

Page 1: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

11Kyung Hee University

Chapter 12 Chapter 12 Transmission Transmission

Control ProtocolControl Protocol

Page 2: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

22Kyung Hee University

IntroductionIntroduction Position of TCP

Page 3: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

33Kyung Hee University

Introduction (cont’d)Introduction (cont’d)Responsibilities of Transport Layer

to create a process-to-process communication using port numbers in case of TCP

to provide a flow-and-error control mechanism at the transport level

TCP uses sliding window protocol to achieve error control. TCP uses the acknowledgment packet, time-out, and

retransmission to achieve error control.

to provide a connection mechanism for the application program

sending streams of data to the transport layer by application program

making a connection with the receiver, chopping the stream into transportable units, numbering them and sending them one by one

Page 4: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

44Kyung Hee University

Introduction (cont’d)Introduction (cont’d) At the receiving end, waiting until all the different units

belonging to same application program have received, checking, passing those that are error free and delivering them to the receiving application program as a stream.

After the entire stream has been sent, the transport layer should close the connection.

TCP is called a connection-oriented, reliable transport

protocol

adding connection-oriented and reliability features to the services of IP

Page 5: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

55Kyung Hee University

12.1 Process-to-Process Communication12.1 Process-to-Process Communication

Host-to-host communication and process-to-process

communication

Page 6: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

66Kyung Hee University

Process-to-Process Communication (cont’d)Process-to-Process Communication (cont’d)

Port Addresses (Numbers)

process-to-process communication that achieved through the client/server paradigm

to define the client and server programs, we need second identifiers called port numbers.

integers between 0 and 65,535

The client program running on the local computer defines itself with a port number, chosen randomly by the TCP software running on the local host

using a ephemeral port number

But, the server program on the remote computer must also define itself with a port number

using a well-known port number

Page 7: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

77Kyung Hee University

Process-to-Process Communication (cont’d)Process-to-Process Communication (cont’d)

Explanation of port numbers using TENET application

Page 8: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

88Kyung Hee University

Process-to-Process Communication (cont’d)Process-to-Process Communication (cont’d) Well-known ports used by TCP

Page 9: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

99Kyung Hee University

Process-to-Process Communication (cont’d)Process-to-Process Communication (cont’d)

Socket Addresses

To make a connection,

needs 2 identifier : IP address + Port number Socket address

a pair of socket address– Client socket address– Server socket address

Page 10: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

1010Kyung Hee University

12.2 TCP Services12.2 TCP Services Stream Delivery Service

TCP is a stream-oriented protocol

TCP creates an environment in which the two processes seem to be connected by an imaginary “tube” that carries their data across the Internet.

Page 11: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

1111Kyung Hee University

TCP Services (cont’d)TCP Services (cont’d)

Sending and Receiving Buffers

Because the sending and receiving processes may not produce and consume data at the same speed, TCP needs buffers for storage.

One way to implement is to use a circular array

Not acknowledged

Page 12: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

1212Kyung Hee University

TCP Services (cont’d)TCP Services (cont’d)

TCP Segments

Page 13: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

1313Kyung Hee University

TCP Services (cont’d)TCP Services (cont’d)

Stream Data Service (stream transport layer service)

The sending TCP

1) accepts a stream of characters from sending application program

2) creates packets called segments, of appropriate size extracted from the stream

3) sends segments across the network

The receiving TCP

1) receives segments, extracts data from segments

2) orders segments if they have arrived out of order

3) delivers segments as a stream of characters to the receiving application program

Page 14: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

1414Kyung Hee University

TCP Services (cont’d)TCP Services (cont’d)

For stream delivery,

the sending and receiving TCPs use buffers

the sending TCP uses sending buffer to store the data coming from the sending application program.

– the sending application program writes data to the buffer of the sending TCP

the receiving TCP receives the segments and stores them in a receiving buffer

– the receiving application program uses the read operation to read the data from the receiving buffer.

– Since the rate of reading can be slower than the rate of receiving, the data is kept in the buffer until the receiving application reads it completely.

Page 15: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

1515Kyung Hee University

TCP Services (cont’d)TCP Services (cont’d)

Full-Duplex Service

TCP offers full-duplex service

After two application programs are connected to each other, they can both send and receive data.

Piggybacking

When a packet is going from A to B, it can also carry an acknowledgment of the packets received from B

Page 16: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

1616Kyung Hee University

TCP Services (cont’d)TCP Services (cont’d)

Connection-Oriented Services

1. A’s TCP informs B’s TCP and gets approval from B’s TCP

2. A’s TCP and B’s TCP exchange data in both directions

3. After both processes have no data left to send and the buffers are empty, two TCPs destroy their buffers

Reliable Service

TCP uses the acknowledgment mechanism to check the safe and sound arrival of data

Page 17: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

1717Kyung Hee University

12.3 TCP Features12.3 TCP Features

Byte numbers

All data bytes being transferred in each connection are numbered by TCP.

The numbering starts with a randomly generated number.

Number range for first byte : 0 ~ 2 32 -1

If random number is 1,057 and total number 6,000bytes, the bytes are numbered from 1,057 to 7,056

Byte numbering is used for flow and error control.

Page 18: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

1818Kyung Hee University

Numbering Bytes (cont’d)Numbering Bytes (cont’d)

Sequence number

After the bytes have been numbered, TCP assigns a sequence number to each segment that is being sent.

Segment number for each segment is number of the first byte carried in that segment.

Page 19: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

1919Kyung Hee University

Numbering Bytes (cont’d)Numbering Bytes (cont’d)

Example 2

Imagine a TCP connection is transferring a file of 5000 bytes. The first byte is numbered 10001. What are the sequence numbers for each segment if data is sent in five segments with the each segment carrying 1,000 bytes?

Page 20: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

2020Kyung Hee University

Numbering Bytes (cont’d)Numbering Bytes (cont’d)

SolutionSolution

The following shows the sequence number for each segment:

Segment 1 10,001 (10,001 to 11,001)

Segment 2 11,001 (11,001 to 12,001)

Segment 3 12,001 (12,001 to 13,001)

Segment 4 13,001 (13,001 to 14,001)

Segment 5 14,001 (14,001 to 15,001)

Page 21: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

2121Kyung Hee University

Numbering Bytes (cont’d)Numbering Bytes (cont’d)

Acknowledgment Number

The value of the acknowledgment field in a segment defines the number of the next byte a party expects to receives. The acknowledgment number is cumulative.

Page 22: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

2222Kyung Hee University

12.3 Segment12.3 Segment

A packet in TCP is called segment

Page 23: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

2323Kyung Hee University

Segment (cont’d)Segment (cont’d) Source port address

defining the port number of application program in the host that is sending the segment

Destination port address

defining the port number of application program in the host that is receiving the segment

Sequence number

defining the number assigned to the first byte of data contained in this segment

during the connection establishment, each party uses a random number generator to create an initial sequence number (ISN)

Page 24: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

2424Kyung Hee University

Segment (cont’d)Segment (cont’d)

Acknowledgment number

If the source of the segment has successfully received byte number x from the other party, it defines x+1 as the acknowledgment number

Header length

Indicating the number of 4-byte words in the TCP header

the value between 5 and 15 (20 and 60 bytes)

Reserved

For future use

Page 25: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

2525Kyung Hee University

Segment (cont’d)Segment (cont’d)

Control

Enabling flow control, connection establishment and termination, and mode of data transfer in TCP

Page 26: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

2626Kyung Hee University

Segment (cont’d)Segment (cont’d)

Description of flags in the control field

Page 27: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

2727Kyung Hee University

Segment (cont’d)Segment (cont’d)

Window size

defining the size of the window, in bytes, that the other party must maintain.

maximum size of window : 65,535 bytes

Checksum : picture in next page

Urgent pointer

used when the segment contains urgent data

defining the number that must be added to the sequence number to obtain the number of the last urgent byte in the data section of the segment

Options : 40 bytes

Page 28: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

2828Kyung Hee University

Segment (cont’d)Segment (cont’d)

Page 29: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

2929Kyung Hee University

Segment (cont’d)Segment (cont’d)

A TCP segments is encapsulated in an IP datagram

Page 30: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

3030Kyung Hee University

12.4 TCP Connection12.4 TCP Connection

The server program tells its TCP to make a passive

open

The Client program issues a request for an active open.

+

Page 31: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

3131Kyung Hee University

TCP Connection – three-way handshakingTCP Connection – three-way handshaking

A SYN segment cannot carry data, but it consumes one

sequence number.

A SYN + ACK segment cannot carry data, but does

consume one sequence number.

An ACK segment, if carrying no data, consumes no

sequence number.

Page 32: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

3232Kyung Hee University

TCP Connection (Cont’d)TCP Connection (Cont’d)

Data transfer

Page 33: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

3333Kyung Hee University

TCP Connection (Cont’d)TCP Connection (Cont’d)

Urgent data

To send urgent data

Use of URG bit set by sending TCP

Receiving TCP extracts the urgent data from the segment using urgent pointer

Page 34: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

3434Kyung Hee University

TCP Connection (Cont’d)TCP Connection (Cont’d) Connection Termination

The FIN segment consumes one sequence number if it does not carry data.

The FIN + ACK segment consumes one sequence number if it does not carry data.

+

Page 35: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

3535Kyung Hee University

TCP Connection (Cont’d)TCP Connection (Cont’d)

Half-close

-+

+

+

Page 36: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

3636Kyung Hee University

12.5 State Transition Diagram12.5 State Transition Diagram

To keep track of all the different events happening To keep track of all the different events happening

during connection establishment, connection during connection establishment, connection

termination, and data transfer, the TCP software is termination, and data transfer, the TCP software is

implemented as a finite state machine. implemented as a finite state machine.

Page 37: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

3737Kyung Hee University

State Transition Diagram (cont’d)State Transition Diagram (cont’d)

Page 38: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

3838Kyung Hee University

State Transition Diagram (Cont’d)State Transition Diagram (Cont’d) A state transition diagram

Server

Client

Special

Input / Output

Now connection is closed in one direction.Now connection is closed in one direction.

Simultaneous Close

Three-way Handshake

or RST/-

(2MSL)

MSL : Maximum Segment Lifetime (30 sec ~ 1 min)

Page 39: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

3939Kyung Hee University

Connection Establishment and TerminationConnection Establishment and Termination

Page 40: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

4040Kyung Hee University

Connection Termination Using Three-way HandshakeConnection Termination Using Three-way Handshake

Page 41: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

4141Kyung Hee University

Simultaneous OpenSimultaneous Open

Page 42: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

4242Kyung Hee University

Simultaneous CloseSimultaneous Close

Page 43: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

4343Kyung Hee University

Denying a ConnectionDenying a Connection

Page 44: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

4444Kyung Hee University

Aborting a ConnectionAborting a Connection

Page 45: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

4545Kyung Hee University

12.6 Flow Control12.6 Flow Control

Defining the amount of data that a source can send before receiving an acknowledgement from the destination.

Sliding window

For flow control, TCP uses a sliding window protocol

The windowwindow covers a portion of the buffer that a host can send before worrying about an acknowledgment from other host

A sliding window is used to make transmission more efficient as well as to control the flow of data so that the destination does not become overwhelmed with data.

TCP sliding windows are byte oriented.

Page 46: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

4646Kyung Hee University

Sliding Window ProtocolSliding Window Protocol

Page 47: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

4747Kyung Hee University

Sliding Window ProtocolSliding Window Protocol

an Example

Page 48: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

4848Kyung Hee University

Flow Control (cont’d)Flow Control (cont’d)

In TCP, the sender window size is totally controlled by the receiver window value. However, the actual window size can be smaller if there is congestion in the network.

Some Points about TCP’s Sliding Windows:Some Points about TCP’s Sliding Windows:

The size of the window is the lesser of rwnd and cwnd

The source does not have to send a full window’s worth of data.

The window can be opened or closed by the receiver, but should not be shrunk.

The destination can send an acknowledgment at any time as long as it does not result in a shrinking window.

The receiver can temporarily shut down the window; the sender, however, can always send a segment of one byte after the window is shut down. To prevent deadlock by proving

Page 49: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

4949Kyung Hee University

12.7 Error Control12.7 Error Control

Including mechanisms for detecting corrupted

segments, lost segments, out-of-order segments, and

duplicated segments.

Also, including a mechanism for correcting errors after

they are detected.

Error Detection and Correction

Checksum

Acknowledgment : TCP does not use negative acknowledgment

Time-out

Page 50: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

5050Kyung Hee University

Normal OperationNormal Operation

Page 51: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

5151Kyung Hee University

Lost SegmentLost Segment

Page 52: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

5252Kyung Hee University

Fast RetransmissionFast Retransmission

Page 53: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

5353Kyung Hee University

Lost AckLost Ack

Page 54: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

5454Kyung Hee University

Lost ACK Corrected by Resending a SegmentLost ACK Corrected by Resending a Segment

Page 55: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

5555Kyung Hee University

12.8 Congestion Control12.8 Congestion Control

Congestion in a network may occur if the load on the

network is greater than the capacity of the network

Congestion control refers to the mechanism and

techniques to control the congestion and keep the load

below the capacity

Congestion in a network or internetwork occurs

because routers and switches have queues.

Page 56: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

5656Kyung Hee University

Congestion Control (cont’d)Congestion Control (cont’d)

Page 57: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

5757Kyung Hee University

Congestion Control (cont’d)Congestion Control (cont’d)

Network performance

Delay versus Load

Page 58: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

5858Kyung Hee University

Congestion Control (cont’d)Congestion Control (cont’d)

Throughput versus Load

– –the reason is the discarding of packets by the routers

Page 59: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

5959Kyung Hee University

Congestion Control (cont’d)Congestion Control (cont’d)

Congestion control mechanisms

refers to techniques and mechanisms that can either prevent congestion, before it happens, or remove congestion, after it has happened.

open-loop congestion control (prevention) and closed loop congestion control (removal)

Page 60: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

6060Kyung Hee University

Congestion Control (cont’d)Congestion Control (cont’d)Open-loop congestion control

Retransmission policy– the retransmission policy and the retransmission timers must

be designed to optimize efficiency and at the same time prevent congestion

Acknowledgment policy – If the receiver does not acknowledge every packet it receives,

it may slow down the sender and help prevent congestion Discard policy

– In audio transmission, if the policy is to discard less sensitive packets when congestion is likely, the quality of sound is still preserved and congestion is prevented

Page 61: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

6161Kyung Hee University

Congestion Control (cont’d)Congestion Control (cont’d)

Closed-loop congestion control Back pressure

– informing the previous upstream router to reduce the rate of outgoing packets

Choke point – is a packet sent by a router to the source to inform it of

congestion– is similar to ICMP’s source quench packet

Implicit signaling – Detecting an implicit signal warning of congestion and

slow down its sending rate. Ex) receiving delayed ACK

Explicit signaling– Router experiencing congestion can send an explicit si

gnal by setting a bit in a packet to the sender or the receiver.

Page 62: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

6262Kyung Hee University

Congestion Control in TCPCongestion Control in TCP

Congestion window

Today, TCP protocols include that the sender’s window size is not only determined by the receiver but also by congestion in the network

Actual window size = minimum (rwnd, cwnd)

Page 63: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

6363Kyung Hee University

Congestion Control in TCP (cont’d)Congestion Control in TCP (cont’d)

Slow start: exponential increase

MSS(max. segment size)

Page 64: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

6464Kyung Hee University

Congestion Control in TCP (cont’d)Congestion Control in TCP (cont’d)

In the slow start algorithm, the size of the congestion

window increases exponentially until it reaches a thres

hold.

Start cwnd = 1

After 1 RTT cwnd = 1 x 2 = 2 21

After 2 RTT cwnd = 2 x 2 = 4 22

After 3 RTT cwnd = 4 x 2 = 8 23

Page 65: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

6565Kyung Hee University

Congestion Control in TCP (cont’d)Congestion Control in TCP (cont’d)

Congestion avoidance: additive increase

When the size of the congestion window reaches the slow start threshold, in the congestion avoidance algorithm, the size of the congestion window increases additively until congestion is detected

Page 66: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

6666Kyung Hee University

Congestion Control in TCP (cont’d)Congestion Control in TCP (cont’d)

Congestion detection: Multiplicative Decrease

Most implementations react differently to congestion detection:

If detection is by time-out, a new slow start phase starts.

If detection is by three ACKs, a new congestion avoidance phase starts.

Page 67: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

6767Kyung Hee University

Congestion Control in TCP (cont’d)Congestion Control in TCP (cont’d)

TCP congestion policy summary

Page 68: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

6868Kyung Hee University

Congestion Control in TCP (cont’d)Congestion Control in TCP (cont’d)

Congestion example

Page 69: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

6969Kyung Hee University

12.9 TCP Timers12.9 TCP Timers

To perform its operation smoothly, most TCP To perform its operation smoothly, most TCP

implementations use at least four timers.implementations use at least four timers.

Page 70: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

7070Kyung Hee University

TCP TimersTCP Timers

Round Trip Time(RTT)

To calculate the retransmission(RTO), we first need to calculate the round-trip time(RTT)

In TCP, there can be only one RTT measurement in progress at any time

Measured RTT (RTTM) : how long it takes to send a segment and receive an acknowledgment of it.

Page 71: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

7171Kyung Hee University

TCP TimersTCP Timers

Smothed RTT (RTTS) : Weighed average of RTTM and p

revious RTTS

Original No Value

After first measurement RTTS = RTTM

After any other measurement RTTS = (1- ) RTTS + ·

RTTM

The value of is implementation-dependent, but it is normally set to 1/8

Page 72: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

7272Kyung Hee University

TCP TimersTCP Timers

RTT Deviation (RTTD)

Original No Value

After first measurement RTTD = RTTM/2

After any other measurement

RTTD = (1- ) RTTD + · l RTTS – RTTM I

* The value of is also implementation dependent, but is it is usually is sent to ¼.

Page 73: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

7373Kyung Hee University

TCP TimersTCP Timers

Retransmission Timeout (RTO)

Original Initial Value

After any measurement RTO = RTTS + 4 RTTD

Page 74: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

7474Kyung Hee University

Example 10Example 10

Let us give a hypothetical example. Figure 12.38 shows part of a connection. The figure shows the connection establishment and part of the data transfer phases.

1. When the SYN segment is sent, there is no value for RTTM , RTTS , or RTTD . The value of RTO is set to 6.00 seconds. The following shows the value of these variables at this moment:

2. When the SYN+ACK segment arrives, RTTM is measured and is equal to 1.5 seconds. The next slide shows the values of these variables:

RTTM = 1.5 RTTS = 1.5

RTTD = 1.5 / 2 = 0.75 RTO = 1.5 + 4 . 0.75 = 4.5

RTO = 6

Page 75: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

7575Kyung Hee University

Example 10Example 10

3.When the first data segment is sent, a new RTT measurement starts. Note that the sender does not start an RTT measurement when it sends the ACK segment, because it does not consume a sequence number and there is no time-out. No RTT measurement starts for the second data segment because a measurement is already in progress.

RTTM = 2.5RTTS = 7/8 (1.5) + 1/8 (2.5) = 1.625RTTD = 3/4 (7.5) + 1/4 |1.625 − 2.5| = 0.78RTO = 1.625 + 4 (0.78) = 4.74

Page 76: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

7676Kyung Hee University

Example 10Example 10

Page 77: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

7777Kyung Hee University

TCP TimersTCP Timers

Persistence Timer

When acknowledgment with non-zero window size after zero window size is lost, to correct deadlock, TCP uses a persistence timer for each connection

When the sending TCP receives an acknowledgment with a window size of zero, the persistence timer is started

When persistence timer goes off, the sending TCP sends a special segment called a probe

The probe alerts the receiving TCP that the acknowledgment was lost and should be resent.

If a response is not received, the sender continues sending the probe segments and doubling, and resetting the value of the persistence timer until the value reaches a threshold (usually 60 seconds).

After that sender sends one probe segment every 60s until the window is reopened.

Page 78: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

7878Kyung Hee University

TCP TimersTCP Timers

KeepaliveTimer

Used to prevent a long idle connection between two TCPs.

Each time the server hears from a client, it resets this timer.

Time-out is usually 2 hours.

After 2 hours, sending 10 probes to client (each 75 secs), then terminates connection.

TIME-WAIT Timer

The time-wait timer is used during connection termination.

Page 79: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

7979Kyung Hee University

12.10 Options12.10 Options

The TCP header can have up to 40 bytes of optional The TCP header can have up to 40 bytes of optional

information. information.

Options convey additional information to the Options convey additional information to the

destination or align other options.destination or align other options.

Two categories of options

one-byte options

multiple-byte options

Page 80: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

8080Kyung Hee University

OptionsOptions

Page 81: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

8181Kyung Hee University

OptionsOptionsEnd of option (EOP)

After this option, the receiver looks for the payload data

EOP option imparts 2 pieces of information to the destination

1) No more options in the header

2) Data from the application program starts at the beginning of the next 32-bit word

*EOP can be used only once.

Page 82: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

8282Kyung Hee University

OptionsOptions

No Operation

Is One-byte option used as a filler.

*NOP can be used more than once.

Page 83: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

8383Kyung Hee University

OptionsOptions

Maximum segment size (MSS)

defining the size of the biggest unit of data that can be received by the destination of the TCP segment

in spite of its name, defining the maximum size of the data, not the maximum size of the segment

value of 0 to 65,535 bytes : default is 536 to be determined during the connection establishment

phase by the destination of the segment used only in the segments that make the connections. Not

used in the segments during data transfer

Page 84: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

8484Kyung Hee University

OptionsOptions

Window Scale Factor

defining the size of the sliding window

new window size =

window size defined in the header x 2 window scale factor

Determined in phase of the connection setup The largest value of scale factor allowed by TCP/IP is 14.

The value of the window scale factor can be determined only during connection establishment; it does not change during the connection

Page 85: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

8585Kyung Hee University

OptionsOptions

Timestamp

10-byte option

The end with the active open announces a timestamps in the connection request segment (SYN Segment)

If it receives a timestamp in the next segment (SYN + SCK) from the other end, it is allowed to use the timestamp.

Page 86: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

8686Kyung Hee University

Example 12Example 12

Page 87: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

8787Kyung Hee University

OptionsOptions

SACK-permitted and SACK Options

SACK-permitted option is used only during connection established with SYN segment and SYN + ACK segment.

SACK-permitted option is not allowed during the data transfer phase.

SACK Option is used during data transfer only if both ends agree

The option includes a list for blocks arriving out-of-order.

Page 88: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

8888Kyung Hee University

OptionsOptions

SACK

Page 89: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

8989Kyung Hee University

Example 13Example 13

Page 90: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

9090Kyung Hee University

Example 14Example 14

For duplicate segment

Page 91: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

9191Kyung Hee University

Example 15Example 15

Duplicate and out-of-order block

Page 92: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

9292Kyung Hee University

12.11 TCP Package12.11 TCP Package

A TCP package involving a table called Transmission

Control Blocks, a set of timers, and three software

modules: main module, input processing module,

output processing module.

Page 93: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

9393Kyung Hee University

TCP Package (Cont’d)TCP Package (Cont’d)

Transmission Control Block (TCBs)

To control the connection, TCP uses a structure to hold information about each connection.

TCP keeps an array of TCBs in the form of a table

Page 94: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

9494Kyung Hee University

TCP Package (Cont’d)TCP Package (Cont’d)

State : defining the state of the connection according to the state transition diagram

Process : defining the process using this connection at this machine as a client or a server

Local IP address : defining the IP address of the local machine used by this connection

Local port number : defining the local port number used by this connection

Remote IP address

Remote port address

Interface : defining the local interface

Local window : holding information about the window at the local TCP

Remote window

Page 95: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

9595Kyung Hee University

TCP Package (Cont’d)TCP Package (Cont’d)

Sending sequence number

Receiving sequence number

Sending ACK number

Time-out values : retransmission time-out, persistence time-out, keepalive time-out, and so on

Round-trip time

Buffer size : defining the size of the buffer at the local TCP

Buffer pointer : pointer to buffer where the receiving data is kept until is read by the application

Page 96: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

9696Kyung Hee University

TCP Package (Cont’d)TCP Package (Cont’d) Main Module : The main module is invoked by an arrived TCP

segment, a time-out, or a message from an application program

Page 97: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

9797Kyung Hee University

TCP Package (Cont’d)TCP Package (Cont’d)

Main Module (cont’d)

Page 98: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

9898Kyung Hee University

TCP Package (Cont’d)TCP Package (Cont’d)

Main Module (cont’d)

Page 99: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

9999Kyung Hee University

TCP Package (Cont’d)TCP Package (Cont’d)

Main Module (cont’d)

Page 100: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

100100Kyung Hee University

TCP D Package (Cont’d)TCP D Package (Cont’d)

Main Module (cont’d)

Page 101: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

101101Kyung Hee University

TCP Package (Cont’d)TCP Package (Cont’d)

Main Module (cont’d)

Page 102: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

102102Kyung Hee University

TCP Package (Cont’d)TCP Package (Cont’d)

Main Module (cont’d)

Page 103: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

103103Kyung Hee University

TCP Package (Cont’d)TCP Package (Cont’d)

Main Module (cont’d)

Page 104: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

104104Kyung Hee University

TCP Package (Cont’d)TCP Package (Cont’d)

Main Module (cont’d)

Page 105: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

105105Kyung Hee University

TCP Package (Cont’d)TCP Package (Cont’d)

Input processing module

handles all the details needed to process data or acknowledgment received when TCP is in the ESTABLISHED state

sends an ACK if needed, takes care of the window size, does error checking, and so on

Output processing module

handles all the details needed to send out data received from application program when TCP is in the ESTABLISHED state

handles retransmission time-outs, persistent time-outs, and so on

Page 106: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

106106Kyung Hee University

Summary(1)Summary(1)

Transmission Control Protocol (TCP) is one of the transport layer protocols in the TCP/IP protocol suite.

TCP provides process-to-process, full-duplex, and connection-oriented service.

The unit of data transfer between two devices using TCP software is called a segment; it has 20 to 60 bytes of header, followed by data from the application program.

A TCP connection normally consists of three phases: connection establishment, data transfer, and connection termination.

Connection establishment requires three-way handshaking; connection termination requires three- or four-way handshaking.

TCP software is implemented as a finite state machine.

TCP uses flow control, implement as a sliding window mechanism, to avoid overwhelming a receiver with data.

Page 107: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

107107Kyung Hee University

Summary(2)Summary(2)

The TCP window size is determined by the receiver-advertised window size(rwnd) or the congestion window size(cwnd), whichever is smaller. The window can be opened or closed by the receiver, but should not be shrunk.

The bytes of data being transferred in each connection are numbered by TCP. The numbering starts with a randomly generated number.

TCP uses error control to provide a reliable service. Error control is handled by the checksum, acknowledgement, and time-out. Corrupted and lost segments are retransmitted and duplicate segments are discarded. Data may arrive out of order and temporarily stored by the receiving TCP, but TCP guarantees that no out-of-order segment is delivered to the process.

In modern implementations, a retransmission occurs if the retransmission timer expires or three duplicate ACK segments have arrived.

TCP uses congestion control to avoid and detect congestion in the network.

Page 108: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

108108Kyung Hee University

Summary(3)Summary(3)

The slow start (exponential increase), congestion avoidance (additive increase), and congestion detection (multiplicative decrease) strategies are used for congestion control.

In the slow start algorithm the size of the congestion window increases exponentially until it reaches a threshold.

In the congestion avoidance algorithm the size of the congestion window increases additively until congestion is detected.

Most implementations react differently to congestion detection: If detection is by time-out, a new slow start phase starts. If detection is by three ACKs, a new congestion avoidance phase starts.

TCP uses four timers (retransmission, persistence, keepalive, and time-waited) in its operation.

In TCP, there can be only be one RTT measurement in progress at any time.

Page 109: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

109109Kyung Hee University

Summary(4)Summary(4)

TCP does not consider the RTT of a retransmitted segment in its calculation of a new RTO.

TCP uses several options to provide more services.

The end-of-option (EOP) option is used for alignment and indicates there are no more options in the header. EOP can be used only once.

The no-operation (NOP) option is used for filler and alignment purposes. NOP can be used more than once.

The maximum segment size option is used in connection setup to define the largest allowable data segment. The value of MSS is determined during connection establishment and does not change during the connection.

The window scale factor is a multiplier that increases the window size.

Page 110: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

110110Kyung Hee University

Summary(5)Summary(5)

The timestamp option shows how much time it takes for data to tra

vel from sender to receiver. One application of timestamp option is

in the calculation of round trip time (RTT). Another application is fo

r PAWS.

Recent implementations of TCP use two more options, SACK-perm

itted option and SACK option. These two options allow the selectiv

e acknowledgment of the received segments by the receiver.

Transmission control blocks (TCBs) hold information about each T

CP connection.

A TCP package can contain TCBs, timers, a main module, an input

processing module, and an output processing module.

Page 111: 1 Kyung Hee University Chapter 12 Transmission Control Protocol.

111111Kyung Hee University

Q and AQ and A