chapter 12 transmission control protocol (tcp). outline process-to-process communication tcp...

149
Chapter 12 Transmission Control Protocol (TCP)

Upload: oswin-horton

Post on 17-Jan-2016

225 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Chapter 12

Transmission Control Protocol (TCP)

Page 2: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Outline PROCESS-TO-PROCESS COMMUNICATION TCP SERVICES NUMBERING BYTES FLOW CONTROL SILLY WINDOW SYNDROME ERROR CONTROL TCP TIMERS

Page 3: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Outline (Cont.) CONGESTION CONTROL SEGMENT OPTIONS CHECKSUM CONNECTION STATE TRANSITION DIAGRAM TCP OPERATION TCP PACKAGE

Page 4: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-1

Position of TCP in TCP/IP Protocol Suite

The McGraw-Hill Companies, Inc., 2000

Page 5: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Introduction Transport layer functionality

Create a process-to-process communication Port numbers by TCP

Create a flow and error-control mechanism at the transport layer For flow control: TCP uses a sliding window protocol For error control: TCP uses the acknowledge packet,

time-out, and retransmission mechanisms

Page 6: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

PROCESS TO

PROCESSCOMMUNICATION

12.112.1

The McGraw-Hill Companies, Inc., 2000

Page 7: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-2

TCP versus IP

The McGraw-Hill Companies, Inc., 2000

Page 8: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Port Number Client’s port number

Chosen randomly by the TCP software running on the local host

Called ephemeral port number Server’s port number

Define itself with a port number Called well-known port numbers

Page 9: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-3

Port Numbers

The McGraw-Hill Companies, Inc., 2000

Page 10: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Well-Know Ports Used by TCPPort Protocol Description

7 Echo Echoes a received datagram back to the sender

9 Discard Discards any datagram that is received

11 Users Active users

13 Daytimes Return the data and the time

17 Quote Return a quote of the day

19 Chargen Return a string of characters

20 FTP, Data File Transfer Protocol (data connection)

21 FTP, Data File Transfer Protocol (control connection)

Page 11: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Well-Know Ports Used by TCPPort Protocol Description

23 Telnet Terminal Network

25 SMTP Simple Mail Transfer Protocol

53 DNS Simple Mail Transfer Protocol

67 BOOTP Bootstrap

79 Finger Finger

80 HTTP Hypertext Transfer Protocol

111 RPC Remote Protocol Call

Page 12: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Socket Addresses Socket address

The combination of IP address and port number

Page 13: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

TCPSERVICES

12.212.2

The McGraw-Hill Companies, Inc., 2000

Page 14: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

TCP Services TCP provides services to the processes at the

application layer Stream Delivery Service Full-Duplex Service Connection-Oriented Service Reliable Service

Page 15: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Stream Delivery Service UDP treats each chunk independently

No any connection between the chucks

In contrast, TCP allow the data be delivered/received as a stream of bytes

Page 16: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-4

Stream Delivery

The McGraw-Hill Companies, Inc., 2000

Page 17: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Stream Delivery Service (Cont.) However, the sending and receiving speed

may not be the same TCP needs buffers for storage

Two buffers in TCP Sending buffer and receiving buffer Also used in flow- and error-control mechanisms

Page 18: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-5

Sending and Receiving Buffers

The McGraw-Hill Companies, Inc., 2000

Page 19: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Sending Buffers The sending circular buffer has three types of

sections White section: empty location

Can be filled by the sending process Gray section: hold bytes that have been sent but not yet

acknowledged TCP keeps these bytes until it receives acknowledges

Color section: bytes to be sent by the sending TCP TCP may be able to send only part of this colored section

The slowness of the receiving process The congestion in the network

Page 20: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Receiving Buffer The receiving circular buffer is divided into

two areas White area:

Empty locations to be filled

Colored area: Contain received bytes that can be consumed by the

receiving process

Page 21: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Segments TCP groups a number of bytes together into a

packet called a segment TCP adds a header to each segment Then, the segments are encapsulated in an IP

datagram

Page 22: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-6

TCP Segments

The McGraw-Hill Companies, Inc., 2000

Page 23: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Full-Duplex Service TCP offers full-duplex service

Data can flow in both directions at the same time

Each TCP has a sending and receiving buffer and segments are sent in both direction

Page 24: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Connection-Oriented Service TCP is a connection-oriented protocol

However, the connection is virtual, not a physical connection

Each TCP segment may use a different path to reach the destination

Page 25: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Reliable Service TCP uses an acknowledge mechanism to

check the safe and sound arrival of data

Page 26: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

NUMBERINGBYTES

12.312.3

The McGraw-Hill Companies, Inc., 2000

Page 27: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Numbering Bytes TCP uses sequence number and

acknowledgement number to keep track of the segment being transmitted or received Notably, these two fields refer to the byte

number, not the segment number

Page 28: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Byte Numbers TCP numbers all data bytes that are

transmitted in a connection The numbering does not necessarily start

from 0 It starts randomly Between 0 and 2^32 – 1 for the number of the

first byte Byte numbering is used for flow and error control

Page 29: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

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

The numbering starts with The numbering starts with a randomly generated number.a randomly generated number.

The McGraw-Hill Companies, Inc., 2000

Page 30: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Sequence Number TCP assigns a sequence number to each

segment that is being sent

The sequence number for each segment is the number of the first byte carried in that segment

Page 31: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

The value of the sequence number field in a segment defines the number

of the first data byte contained in that segment.

The McGraw-Hill Companies, Inc., 2000

Page 32: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Imagine a TCP connection is transferring a file of 6000 bytes. The first byte is numbered 10010

What are the sequence numbers for each segment if data is sent in five segments with The first four segments carrying 1,000 bytes The last segment carrying 2,000 bytes?

Example 1Example 1

Page 33: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

SolutionSolution

The following shows the sequence number for each segment:

Segment 1 10,010 (10,010 to 11,009)

Segment 2 11,010 (11,010 to 12,009)

Segment 3 12,010 (12,010 to 13,009)

Segment 4 13,010 (13,010 to 14,009)

Segment 5 14,010 (14,010 to 16,009)The McGraw-Hill Companies, Inc., 2000

Page 34: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Acknowledgment Number Communication in TCP is full duplex

Both parties can send and receive data at the same time in a connection

Each party numbers the bytes, usually with a different starting byte number Sequence number: the number of the first byte

carried by the segment Acknowledgment number: the number of the next

byte that the party expects to receive

Page 35: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Acknowledgment Number (Cont.) Acknowledgment number is cumulative For example, if a party uses 5,643 as an

acknowledgment number It has received all bytes from the beginning up to

5,642 Note that, this does not mean that the party has

received 5642 bytes The first byte number does not have to start from 0

Page 36: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

The value of the acknowledgment field in a The value of the acknowledgment field in a segment defines the number of the segment defines the number of the

next byte a party expects to receives. next byte a party expects to receives. The acknowledgment number is cumulative.The acknowledgment number is cumulative.

The McGraw-Hill Companies, Inc., 2000

Page 37: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

FLOWCONTROL

12.412.4

The McGraw-Hill Companies, Inc., 2000

Page 38: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Flow Control The amount of data a source can send before

receiving an acknowledgment Two extreme cases

Send 1 byte of data and wait for an acknowledge Source would idle most of the time

Send all of the data without worrying about acknowledgment May overwhelm the receiver Inefficient if some part of data is lost, duplicated, received our of

order or corrupted

Solution: the sliding window protocol by TCP

Page 39: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Sliding Window Protocol Both hosts use a window for each connection

Containing bytes that a host can send before worrying about an acknowledgment

Called sliding windows The window can slide over the buffer

TCP’s sliding windows are byte orientedTCP’s sliding windows are byte oriented

Page 40: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

A sliding window is used to make A sliding window is used to make transmission more transmission more

efficient as well as to control the flow of efficient as well as to control the flow of data so that the destination data so that the destination

does not become overwhelmed with data. does not become overwhelmed with data. TCP’s sliding windows are byte oriented.TCP’s sliding windows are byte oriented.

The McGraw-Hill Companies, Inc., 2000

Page 41: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Sending Buffer Bytes before 200

The sender can reuse these locations Bytes 200 to 202

Sender must keep these bytes in cases they are lost or damaged

Page 42: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Receiver Window Receiver window

If the total size of the receiving buffer is N M locations are already occupied Then, N-M more bytes can be received Receiver windows = N – M

Example: N = 13, M = 6, receiver windows = 7

Page 43: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Sender Window Sender window

A size less than or equal to the size of the receiver window For example

Sender window = receiver window But, sender can send only 4 more bytes because it has already sent 3

bytes

Page 44: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Sliding the Sender Window Sender sends 2 more bytes and an ack. is received

(expecting byte 203) Thus, the receiver window’s size is unchanged

Page 45: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Expanding the Sender Window If the receiving process consumes data faster than it

receives The size of the receiver window expands

Because the buffer has more free locations This situation can be relayed to the sender

Sender window size is also increased

Example Receiver has acknowledged the receipt of 2 more bytes Receiver also increases its window size to 10 Thus, the sender window is also updated accordingly

Page 46: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-11

Expanding the Sender Window

The McGraw-Hill Companies, Inc., 2000

Page 47: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Shrinking the Sender Window If the receiving process consumes data slower

than it receives The size of the receiver window decreases The receiver has to inform the sender to shrink its

sender window size For example

The receiver has received the 5 bytes (205~509) The receiver’s window size is decrease to 6

Page 48: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-12

Shrinking the Sender Window

The McGraw-Hill Companies, Inc., 2000

Page 49: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Closing the Sender Window If the receiver buffer is totally full

The receiver window value is zero When this is relayed to the sender

The sender closes its window The sender cannot send any more data

Page 50: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

In TCP, the sender window size is totally In TCP, the sender window size is totally controlled by the receiver window valuecontrolled by the receiver window value

However, the actual window size can be However, the actual window size can be smaller if there is congestion in the networksmaller if there is congestion in the network

Page 51: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Some Points about TCP’s Sliding WindowsSome Points about TCP’s Sliding Windows The source does not have to send a full The source does not have to send a full

window’s worth of datawindow’s worth of data

The size of the window can be increased or The size of the window can be increased or decreased by the destinationdecreased by the destination

The destination can send an acknowledgment at The destination can send an acknowledgment at any timeany time

Page 52: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

SILLYWINDOW

SYNDROME

12.512.5

The McGraw-Hill Companies, Inc., 2000

Page 53: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Silly Window Syndrome Problem in the sliding window operation

The sending process creates data slowly Or the receiving process consume data slowly Or both Result in the sending of data in very small segment

Reduce the network efficiency

For example, send a one byte segment result in overhead of 41/1 Assume TCP header is 20 bytes + IP header is 20 bytes

Page 54: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Syndrome Created by the Sender Sender application create data too slowly

For example, only 1 byte at a time Sending TCP would create segments containing 1

byte of data Solution: prevent the sending TCP from

sending the data byte by byte Sending TCP must be forced to wait as it collects

data to send in a larger block But, how long should the sending TCP wait?

Page 55: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Nagle’s Algorithm Nagle found the solution to above syndrome

The sending TCP sends the first piece of data it receives from the sending application Even if it is only 1 byte

After sending the first segment, the sending TCP accumulates data in the buffer and wait until Either the receiving TCP sends an acknowledge Or until enough data has accumulated to fill a maximum-size

segment Step 2 is repeated. Segment 3 is sent if an

acknowledgment is received for segment 2 or enough data is accumulated to fill a maximum-size segment

Page 56: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Nagle’s Algorithm (Cont.) Elegance

Very simple Take into account the speed of the application

that creates the data and the speed of the network that transports the data If application is faster than the network

The segments are larger

If the application is slower than the network The segment are smaller

Page 57: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Syndrome Created by the Receiver The receiving TCP may also create a silly window

syndrome If it is serving an application that consumes data slowly

For example Sender application create data in 1K byte blocks But the receiving application consumes data 1 byte at a

time Assume the sender buffer is 4K bytes

Buffer will be full soon Sender then only can send 1 byte data to the receiver

Page 58: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Syndrome Created by the Receiver (Cont.) Solution

Clark’s solution

Delayed acknowledgment

Page 59: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Clark’s Solution Send an acknowledgment as soon as the data

arrives but to announce a window size of zero until Either there is enough space to accommodate a

segment of maximum size Or half of the buffer is empty

Page 60: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Delayed Acknowledgment Delay sending the acknowledgment

When a segment arrives, it is not acknowledged immediately

Receiver waits until there is a decent amount of space in its incoming buffer

Delayed acknowledgment prevents the sending TCP from sliding it window

Page 61: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Delayed Acknowledgment (Cont.) Another advantage

Reduce traffic The receiver does not have to acknowledge each segment

Disadvantage The sender may retransmit the unacknowledged segment

Solution Defines the acknowledgment should not be delayed by

more than 500 ms

Page 62: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

ERRORCONTROL

12.612.6

The McGraw-Hill Companies, Inc., 2000

Page 63: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Error Control TCP provides reliability using error control

Detect corrupted segment, lost segment, out-of-order segment, and duplicated segment

Error control in TCP also correct error after they are detected

Page 64: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Error Detection and Correction Error detection in TCP is achieved by

Checksum Acknowledgment Time-out

Error correction TCP start a one-time counter for each segment sent Once a timer matures, the corresponding segment is

considered to be error Retransmit the segment

Page 65: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-13

Corrupted Segment

The McGraw-Hill Companies, Inc., 2000

Page 66: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-14

Lost Segment

The McGraw-Hill Companies, Inc., 2000

Page 67: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Duplicate Segment Created by a source TCP when the

acknowledgment does not arrive before the time-out

Destination detects duplicate segment since they have the same sequence number Discard the later segment

Page 68: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Out-of-Order Segment Each TCP segment is encapsulated in an IP

datagram IP datagram is routed independently TCP segment may arrive out-of-order

Solution TCP does not acknowledge an out-of-order

segment until it receives all of the segments that precede it

Page 69: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Lost Acknowledgment A lost acknowledgment may not even noticed

by the source TCP Since TCP uses an accumulative

acknowledgment system

Page 70: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-15

Lost Acknowledgment

The McGraw-Hill Companies, Inc., 2000

Page 71: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

TCPTIMERS

12.712.7

The McGraw-Hill Companies, Inc., 2000

Page 72: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-16

TCP Timers

The McGraw-Hill Companies, Inc., 2000

Page 73: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Retransmission Timer When TCP sends a segment, it creates a

retransmission timer to that segment If an acknowledgment is received before the

timer goes off The timer is destroyed

If timer goes off before an acknowledgment arrives The segment is retransmitted and the timer is reset

Page 74: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Calculation of Retransmission Time TCP cannot use the same retransmission time for all

connections Each connection has different length and network

characteristics Furthermore, TCP cannot use the same

retransmission time for one single connection The network behavior is dynamic

Thus, TCP uses the dynamic retransmission time Different for each connection and may be changed during

the same connection

Page 75: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Calculation of Retransmission Time (Cont.) Retransmission time is calculated as twice the

RTT Retransmission time = 2 x RTT

But, how to calculate RTT?

Page 76: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Calculation of RTT Two methods

Use the timestamp option described before TCP start a timer when sends a segment. After

receiving the acknowledgment, calculate the difference

RTT = a x previous RTT + (1-a) current RTT a is usually 90 percent

Page 77: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Calculation of RTT (Cont.) Problem

If a segment is not acknowledged during the retransmission period and it is retransmitted

When the sending TCP receives an acknowledgment, it does not know this acknowledgment is for the first one or for the retransmitted one?

Solution Karn’s algorithm

Page 78: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Karn’s Algorithm Do not consider the RTT of a retransmitted

segment is the calculation of the new RTT

Page 79: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Persistence Timer TCP needs another timer to deal with the zero

window-size advertisement Example

Receiving TCP announces a window size of zero The sending TCP stops transmitting segments After a while, receiving TCP sends an acknowledgment

announcing a non-zero window size However, this acknowledgment was lost

As a result, both sender and receiver continue to wait for each other forever

Page 80: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Persistence Timer (Cont.) Solution: TCP uses a persistence timer for each

connection When the sending TCP receives an acknowledgment

with a window size of zero It starts a persistence timer

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

Contain only 1 byte of data and is never acknowledged Alert the receiving TCP that the acknowledgment may by lost

and should be resent

Page 81: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Persistence Timer (Cont.) Value of persistence timer is set to the value of the

retransmission time However, if a response is not received from the

receiver Another probe segment is sent The value of the persistence timer is double

Above process is repeated until the persistence timer reaches a threshold Usually 60 seconds

Page 82: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Keepalive Timer If a client has crashed

A TCP connection will be remain open forever Solution: Keepalive timer

The time-out is usually 2 hours If a server does not hear from the client after two hours

Send a probe segment

If there is no response after 10 probes, each of which is 75 seconds apart It assumes that client is down and terminates the connection

Page 83: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Time-Waited Timer Used during connection termination When TCP closes a connection

It does not consider the connection really closed The connection is held in limbo for a time-waited

period Allow duplicate FIN segment, if any, to arrive at the

destination to be discarded Time-waited time is usually two times the expected

lifetime of a segment Mentioned later

Page 84: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

CONGESTIONCONTROL

12.812.8

The McGraw-Hill Companies, Inc., 2000

Page 85: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Congestion Control An internet is a combination of networks and

connecting devices, e.g., routers A router has a buffer that stores the incoming

packets, processes them, and forward them. When the buffer is full, packets will be

dropped in the router No acknowledgement is received by the sender The sender will retransmit the lost packet

Create more congestion and more dropping of packets

Page 86: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

TCP assumes that the cause of TCP assumes that the cause of a lost segment is due to a lost segment is due to

congestion in the network.congestion in the network.

The McGraw-Hill Companies, Inc., 2000

Page 87: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Congestion Control (Cont.) Flow control

Sender window size is determined by the available buffer space in the receiver

However, in addition to the receiver, the network should be a second entity that determines the size of the sender’s window

Congestion control Determine the sender window size by the

congestion condition in the network

Page 88: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

If the cause of the lost segment If the cause of the lost segment is congestion, is congestion,

retransmission of the segment retransmission of the segment not only does not remove the cause, not only does not remove the cause,

it aggravates it.it aggravates it.

The McGraw-Hill Companies, Inc., 2000

Page 89: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Congestion Control (Cont.) Thus, the sender’s window size is determined

by both Receiver Congestion in the network

Page 90: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Congestion Window The sender has two pieces of information

The receiver-advertised window size The congestion widow size

The actual size of the window is the minimum of these two Actual window size = minimum (receiver window

size, congestion window size)

Page 91: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Congestion Avoidance Two strategies

Slow start

Additive increase and Multiplicative decrease

Page 92: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Slow Start Slow start

At the beginning, the congestion window size = maximum segment size

For each segment that is acknowledged Increase the congestion window size by one

maximum segment unit Until it reaches a threshold of half the allowable

window size

Page 93: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Slow Start However, it is not actually “slow start”

The congestion window size increases exponentially

Send one segment, receives one acknowledge Increase the size to two segments, send two

segments, receives two acknowledges Increase the size to four segments…

Page 94: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Additive Increase and Multiplicative Decrease Additive Increase

After the congestion window size reaches the threshold, the size is increased one segment for each ack. even an ack. is for several segments

The additive increase continues as long as The acknowledgments arrive before their

corresponding time-outs The congestion window size reaches the receiver

window value

Page 95: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Additive Increase and Multiplicative Decrease (Cont.) Multiplicative Decrease

If congestion occurs, the congestion window size must be decreased

How to detect a congestion? Solution: through a lost segment

Networks today are noise free, it is more probable that a segment is lost than that it is corrupted

Page 96: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Additive Increase and Multiplicative Decrease (Cont.) Multiplicative Decrease

Thus, if a time-out occurs, i.e., a lost segment occurs The threshold should be set to half of the last

congestion window size Multiplicative decrease

The congestion window size should start from one again The sender return to the slow start phase

Page 97: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Example Initially, the maximum window size is 32 segments

Threshold is set to 16 segments, half of the maximum window size

1~4 in x-axis: slow start 5-8 in x-axis: additive increase 8 in x-axis: multiplicative decrease

The previous window size = 20 Thus, the new threshold is 10

Page 98: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-17

Multiplicative Decrease

The McGraw-Hill Companies, Inc., 2000

Page 99: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-18

Congestion Avoidance Strategies

The McGraw-Hill Companies, Inc., 2000

Page 100: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

SEGMENT

12.912.9

The McGraw-Hill Companies, Inc., 2000

Page 101: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-19

TCP Segment Format

The McGraw-Hill Companies, Inc., 2000

Page 102: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

TCP Segment Format Source port address: 16-bit Destination port address: 16-bit Sequence number: 32-bit

The first byte number in this segment Acknowledgment number: 32-bit

The byte number that the receiver expects Acknowledgment and data can be piggybacked

together

Page 103: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

TCP Segment Format (Cont.) Header length: 4-bit

The number of 4-byte words in the TCP header Value of this field is between 5 and 15

TCP header is between 20-60 bytes

Reserved: 6-bit Reserved for future use

Control: 6-bits

Page 104: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-20

Control Field

The McGraw-Hill Companies, Inc., 2000

Page 105: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

TCP Segment Format (Cont.) Control

URG: urgent pointer is valid ACK: acknowledgment field is valid PSH: push the data RST: the connection must be reset SYN: Synchronization sequence numbers during

connection FIN: terminate the connection

Page 106: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

TCP Segment Format (Cont.) Window size: 16-bit

Define the size of the window, in bytes The maximum window size is 2^16 = 65535

Checksum: 16-bit Urgent pointer: 16-bit

Used when the segment contains urgent data Options: 0~40 bytes

Page 107: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

OPTIONS

12.1012.10

The McGraw-Hill Companies, Inc., 2000

Page 108: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-21

Options

The McGraw-Hill Companies, Inc., 2000

Page 109: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

End of Option Used for padding at the end of the option field

Can only be used as the last option Only one end of option can be used

If more than 1 byte is needed to align the option field, use some no-operation option followed by an end of option

Three pieces of information to the destination No more options in the header The remainder of the 32-bit word is garbage Data from the application program starts at the beginning

of the next 32-bit word

Page 110: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-22

End of option Option

The McGraw-Hill Companies, Inc., 2000

Page 111: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

No Operation Used to align the next option on a 32-bit

boundary

Page 112: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-23

No operation Option

The McGraw-Hill Companies, Inc., 2000

Page 113: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Maximum Segment Size (MSS) Define the size of the biggest chunk of data that can

be received by the destination Notably, it actually defines the maximum size of

data, not the maximum size of segment Default value is 536 Determined during the connection establishment

phase If neither party defines the size, the default is chosen

Page 114: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-24

Maximum segment size Option

The McGraw-Hill Companies, Inc., 2000

Page 115: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Window Scale Factor The window size field in the header defines the size

of the sliding window The size of the windows: 0 ~ 65535 However, it may not be sufficient in some networks

To increase the window size, the window scale factor is used New window size = window size defined in the header x

2window scale factor

However, the window size cannot be greater than the maximum value for the sequence number

Page 116: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Window Scale Factor (Cont.) Notably, window scale factor can be

determined only during the connection setup phase

During data transfer, the size of the window may be changed But it must be multiplied by the same scale factor

The scale factor is also called shift count Multiplying a number by power of 2 = left shift

Page 117: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-25

Window scale factor Option

The McGraw-Hill Companies, Inc., 2000

Page 118: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Timestamp Timestamp field

Filled by the source when a segment leaves When destination sends an acknowledgement

Enter the previous stored timestamp into the timestamp echo reply field

The source, when it receives acknowledgment Calculate the round-trip time

Round-trip time Used by TCP to dynamically define the retransmission

time

Page 119: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-26

Timestamp Option

The McGraw-Hill Companies, Inc., 2000

Page 120: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

CHECKSUM

12.1112.11

The McGraw-Hill Companies, Inc., 2000

Page 121: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Checksum Follow the same procedure as in UDP

However, The inclusion of the checksum in the UDP

datagram is optional The inclusion of checksum for TCP is mandatory

Page 122: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-12

Pseudoheader Added to the TCP Datagram

The McGraw-Hill Companies, Inc., 2000

Page 123: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

CONNECTION

12.1212.12

The McGraw-Hill Companies, Inc., 2000

Page 124: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Connection TCP’s connection-oriented transmission

requires two procedures Connection establishment

Three-way handshaking

Connection termination Four-way handshaking

Page 125: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Connection Establishment Four actions are taken between host A and B

Host A sends a segment to announce its wish for connection and includes its initialization information

Host B sends a segment to acknowledge the request of A Host B sends a segment that includes its initialization

information Host A sends a segment to acknowledge the request of B

However Step 2 and 3 can not combined into one step

Page 126: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Connection Establishment (Cont.) Three-way handshaking

The client sends the first segment, a SYN segment Source and destination port number Initialization sequence number (ISN) If client wants to define MSS, add MSS option If client needs a larger window, define the window scale factor

option Does not contain any acknowledgment number Does not define the window size either

A window size makes sense only when a segment includes an acknowledgment

Page 127: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Connection Establishment (Cont.) Three-way handshaking

The server sends a second segment, a SYN and ACK segment Acknowledge the receipt of the first segment using the ACK flag

and acknowledgment number field The acknowledgment number is the client initialization sequence

number + 1 The server must also defines the client window size

Initialization information for the server Initialization sequence number Window scale factor if used MSS is defined

Page 128: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-28

Three-way Handshaking

The McGraw-Hill Companies, Inc., 2000

Page 129: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Connection Establishment (Cont.) Three-way handshaking

The client sends the third segment, ACK segment Acknowledge the receipt of second segment

ACK flag is set Acknowledgement number = server initialization sequence

number + 1 Must also define the server window size

Set the window size field

Data can be sent with the third packet

Page 130: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Connection Establishment (Cont.) Active open

The side that sends the first SYN

Passive open The side that receives this SYN and sends the

next SYN

Page 131: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Connection Termination The connection may be closed in one

connection, but left open in the other connection When connection in one direction is terminated

The other party can continue sending data in the other direction

Therefore, four actions are needed to close the connection in both direction Step 2 and 3 cannot be combined

Page 132: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Connection Termination Four steps

Host A sends a segment announcing its wish for connection termination

Host B sends a segment acknowledging the request of A The connection is closed in one connection But host A can continue sending data to A

Host B sends a segment to close the connection Host A acknowledges the request of B

Page 133: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Connection Termination (Cont.) Four-way handshaking

The client TCP sends the first segment, FIN segment The server TCP sends the second segment, an ACK

segment Acknowledgment number = sequence number in FIN + 1

The server TCP may continue to send data until it sends a FIN segment

The client TCP sends the fourth segment, an ACK segment Acknowledgment number = sequence number in FIN + 1

Page 134: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Connection Resetting Reset: the current connection is destroyed Three cases needs to be reset

The TCP on one side has requested a connection to a nonexistent port TCP on the other side may send a segment with its RST bit set to

cancel the request One TCP may want to abort the connection due to an

abnormal situation It can send an RST segment to close the connection

The TCP on one side may discover that the TCP on the other side is idle for a long time It may send an RST segment to destroy the connection

Page 135: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-29

Four-way Handshaking

The McGraw-Hill Companies, Inc., 2000

Page 136: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

STATETRANSITION

DIAGRAM

12.1312.13

The McGraw-Hill Companies, Inc., 2000

Page 137: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-30

State Transition Diagram

The McGraw-Hill Companies, Inc., 2000

Page 138: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-31

Client States

The McGraw-Hill Companies, Inc., 2000

Page 139: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Figure 12-32

Server States

The McGraw-Hill Companies, Inc., 2000

Page 140: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

TCPOPERATION

12.1412.14

The McGraw-Hill Companies, Inc., 2000

Page 141: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

TCP Operations Encapsulation and Decapsulation

Buffering

Multiplexing and Demultiplexing

Pushing Data

Urgent Data

Page 142: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Encapsulation and Decapsulation

Page 143: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Buffering TCP creates sending and receiving buffers for

each connection Discussed before

Page 144: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Multiplexing and Demultiplexing

Page 145: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Pushing Data In some applications, delayed transmission

and delayed delivery of data may not be acceptable

TCP provides the push operation Sending TCP should not wait for the window to

be filled It must create a segment, set the push bit (PSH), and

send it immediately

Page 146: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

Urgent Data In some cases, the sending application wants

a piece of data to be read out of order TCP provides the urgent data

Sender creates a segment, insert the urgent data at the beginning of the segment and sends the segment with the URG bit set

The urgent pointer field defines the end of the urgent data and the start of normal data

Page 147: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

TCP PACKAGE

12.1512.15

The McGraw-Hill Companies, Inc., 2000

Page 148: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

TCP Package

Page 149: Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW

TCBs: Transmission Control Block