0% found this document useful (0 votes)
35 views

TCP - Part-1 - Introduction

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

TCP - Part-1 - Introduction

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 33

Transmission Control Protocol

(TCP)

TCP/IP Protocol Suite 1


Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
TCP Services
Outline
TCP Features
Segment
TCP Connection
Windows in TCP
Flow Control
Error Control
Congestion Control
Options

TCP/IP Protocol Suite 2


TCP SERVICES

TCP lies between the application layer and the


network layer,

It serves as the intermediary between the


application programs and the network
operations.

TCP/IP Protocol Suite 3


TCP/IP protocol suite

TCP/IP Protocol Suite 4


Encapsulation

Frame IP TCP
header
header Application-layer data
header

TCP payload
IP payload
Data-link layer payload

TCP/IP Protocol Suite 5


Stream delivery Service

TCP/IP Protocol Suite 6


Sending and receiving buffers

Stream of bytes

TCP/IP Protocol Suite 7


TCP segments

The bytes of data being transferred in each connection are


numbered by TCP.

The numbering starts with an arbitrarily generated number.

Segment N Segment 1
H H

TCP/IP Protocol Suite 8


Example
Suppose a TCP connection is transferring a file of 5,000 bytes. The
first byte is numbered 10,001. What are the sequence numbers for
each segment if data are sent in five segments, each carrying 1,000
bytes?

The following shows the sequence number for each segment:

TCP/IP Protocol Suite 9


sequence number

The value in the sequence number field of a segment


defines the number assigned to the first data byte
contained in that segment.

acknowledgment number

The value of the acknowledgment field in a segment


defines the number of the next byte a party expects to
receive.

The acknowledgment number is cumulative.

TCP/IP Protocol Suite 10


TCP segment format

A packet in TCP is called a segment.

11
Control field

TCP/IP Protocol Suite 12


TCP CONNECTION

TCP is connection-oriented.

It establishes a virtual path between the source and destination.


All of the segments belonging to a message are then sent over this
virtual path.

How TCP, which uses the services of IP, a connectionless


protocol, can be connection-oriented?

A TCP connection is virtual, not physical. TCP operates at a


higher level. TCP uses the services of IP to deliver individual
segments to the receiver, but it controls the connection itself. If a
segment is lost or corrupted, it is retransmitted.

TCP/IP Protocol Suite 13


Pseudoheader added to the TCP segment

The use of the checksum in TCP is mandatory.

TCP/IP Protocol Suite 14


Connection establishment using three-way handshake

Passive
Active open
open seq: 8000

UAPRS F
SYN
seq: 15000
Connection ack: 8001
opened nd: 5000
U A P R S F rw
SYN + ACK
seq: 8000
ack: 15001
UAPRS F
rwnd: 10000
ACK

Means “no data” !


seq: 8001 if piggybacking
TCP/IP Protocol Suite 15
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.
TCP/IP Protocol Suite 16
Data Transfer

seq: 8001
Send
request ack: 15001
UAPRS F
Data Receive
bytes: 8001-9
000

Send seq: 9001


request ack: 15001
UAPRS F
Data Receive
bytes: 9001-1
0000

seq: 15001 Send


ack: 10001 request
UAPRS F
Data
17000
bytes: 15001-
seq: 10000
ack: 17001
UAPRS F
rwnd:10000

Connection Termination

TCP/IP Protocol Suite 17


Connection termination using three-way handshake

TCP/IP Protocol Suite 18


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

FIN + ACK segment


consumes one sequence number if it
does not carry data.

TCP/IP Protocol Suite 19


Half-Close

TCP/IP Protocol Suite 20


WINDOWS IN TCP

TCP uses two windows for each direction of data


transfer
(send window and receive window)
(i.e. four windows for a bidirectional communication)

To make the discussion simple, we make an assumption that


communication is only unidirectional;

the bidirectional communication can be inferred using two


unidirectional communications with piggybacking.

TCP/IP Protocol Suite 21


Send window in TCP

22
Receive window in TCP

rwnd= buffer size – number of bytes waiting to be pulled

TCP/IP Protocol Suite 23


FLOW CONTROL

Flow control balances the rate a producer creates


data with the rate a consumer can use the data.

TCP separates flow control from error control.

We temporarily assume that the logical channel


between the sending and receiving TCP is error-
free.

TCP/IP Protocol Suite 24


TCP/IP protocol suite

Messages 1
are pushed 5 Flow control 3 Messages
are pulled
feedback

2
Segements are pushed
4
Flow control feedback

Figure shows
•unidirectional data transfer between a sender and a receiver;
•bidirectional data transfer can be deduced from unidirectional one

TCP/IP Protocol Suite 25


An example of flow control

TCP/IP Protocol Suite 26


Shrinking of Windows

The new advertisement, however, defines the new value of rwnd as 4, in which
210 + 4 < 206 + 12.

(byte 214 which has been already sent is outside the window)
TCP/IP Protocol Suite 27
When the send window shrinks, it may creates a problem:

Following relations can need to maintained by receiver to prevent


shrinking

New ack number + new rwnd > = Last ack number + Last rwnd

One way to prevent this situation is:


let the receiver postpone its feedback until enough buffer locations are
available in its window. (to meet the above relation)

In other words, the receiver should wait until more bytes are consumed
by its process.
TCP/IP Protocol Suite 28
Silly Window Syndrome
 Sending data in very small segments

1. Syndrome created by the Sender


 Sending application program that creates data slowly
(e.g. 1 byte at a time)

Prevention
 Wait and collect data to send in a larger block

 How long should the sending TCP wait?


 Solution: Nagle’s algorithm

29 TCP/IP Protocol Suite


Nagle’s algorithm

Nagle’s algorithm takes into account


(1)the speed of the application program that creates the data, and
(2) the speed of the network that transports the data

Observation
1. If application program faster than network, segments are larger
2. If application program slower than network, segments are smaller
Silly Window Syndrome

Syndrome created by the Receiver


 Receiving application program consumes data slowly (e.g. 1 byte at a
time)

The receiving TCP announces a window size of 1 byte. The sending


TCP sends only 1 byte…
Two Solution Proposed
 1: Clark’s solution
 II: Delayed Acknowledgement

Clark’s Approach
 Sending an ACK as soon as data arrives but announcing a window
size of zero until there is enough space to accommodate a segment
of max. size or until half of the buffer is empty

31 TCP/IP Protocol Suite


Silly Window Syndrome
Solution 2: Delayed Acknowledgement
 The receiver waits until there is decent amount of space in its incoming
buffer before acknowledging the arrived segments

 Advantage
 The delayed acknowledgement prevents the sending TCP from sliding its
window.
 It also reduces traffic.

 Disadvantage:
 it may force the sender to retransmit the unacknowledged segments

 TCP balances the advantage & disadvantage and defines that the
acknowledgement should not be delayed by more than 500ms

32 TCP/IP Protocol Suite


Lecture videos on the topic can be found at

Transport Layer Services


https://youtu.be/IL-xFm5h_fE

Transmission Control Protocol - TCP Part-1


https://youtu.be/7tQBgArvvMA

TCP-Part2 - TCP Connection


https://youtu.be/5FsrWyzXskw

TCP-Part3 - Windows in TCP and Flow Control


https://youtu.be/Oc5OiScAIzg

TCP Flow Control


https://youtu.be/t7jkz9M1dHk

Silly Window Syndrome


https://youtu.be/-8YJBXPTi4I

33 TCP/IP Protocol Suite

You might also like