TRANSMISSION CONTROL
PROTOCOL
• Transmission Control Protocol (TCP) is a
connection-oriented, reliable protocol.
• TCP explicitly defines connection
establishment, data transfer, and connection
teardown phases to provide a connection-
oriented service.
• To achieve this goal, TCP uses checksum (for
error detection), retransmission of lost or
corrupted packets, cumulative and selective
acknowledgments, and timers.
• TCP Services
– Process-to-Process Communication
– Stream Delivery Service
– Sending and Receiving Buffers
– Segments
– Full-Duplex Communication
– Multiplexing and Demultiplexing
– Connection-Oriented Service
– Reliable Service
• Process-to-Process Communication
– As with UDP, TCP provides process-to-process
communication using port numbers.
• Stream Delivery Service
– TCP, allows the sending process to deliver data as
a stream of bytes and allows the receiving process
to obtain data as a stream of bytes.
– TCP creates an environment in which the two
processes seem to be connected by an imaginary
“tube” that carries their bytes across the Internet
The sending process produces (writes to) the stream and the
receiving process consumes (reads from) it.
• Sending and Receiving Buffers
• Because the sending and the receiving
processes may not necessarily write or read
data at the same rate, TCP needs buffers for
storage.
• There are two buffers, the sending buffer and
the receiving buffer, one for each direction.
• One way to implement a buffer is to use a
circular array of 1-byte locations.
• At the sender, the buffer has three types of
chambers.
• The white section contains empty chambers
that can be filled by the sending process
(producer).
• The colored area holds bytes that have been
sent but not yet acknowledged. The TCP
sender keeps these bytes in the buffer until it
• receives an acknowledgment.
• The shaded area contains bytes to be sent by
the sending TCP.
• The operation of the buffer at the receiver is
simpler. The circular buffer is divided into two
areas (shown as white and colored).
• The white area contains empty chambers to
be filled by bytes received from the network.
• The colored sections contain received bytes
that can be read by the receiving process.
• Segments
• At the transport layer, TCP groups a number of
bytes together into a packet called a segment.
• TCP adds a header to each segment and
delivers the segment to the network layer for
transmission.
• The segments are encapsulated in an IP
datagram and transmitted.
Note that segments are not necessarily all the same size. In the figure, for
simplicity, we show one segment carrying 3 bytes and the other carrying 5 bytes.
In reality, segments carry hundreds of bytes.
• Full-Duplex Communication
– TCP offers full-duplex service, where data can flow
in both directions at the same time.
– Each TCP endpoint then has its own sending and
receiving buffer, and segments move in both
directions.
• Multiplexing and Demultiplexing
– Like UDP, TCP performs multiplexing at the sender
and demultiplexing at the receiver.
– However, since TCP is a connection-oriented
protocol, a connection needs to be established for
each pair of processes.
• Connection-Oriented Service
• TCP, unlike UDP, is a connection-oriented
protocol.
• When a process at site A wants to send to and
receive data from another process at site B,
the following three phases occur:
– 1. The two TCP’s establish a logical connection
between them.
– 2. Data are exchanged in both directions.
– 3. The connection is terminated.
• Reliable Service
– TCP is a reliable transport protocol. It uses an
acknowledgment mechanism to check the safe
and sound arrival of data
TCP Features
• Numbering System
• Although the TCP software keeps track of the
segments being transmitted or received,there is
no field for a segment number value in the
segment header.
• Instead, there are two fields, called the sequence
number and the acknowledgment number.
• These two fields refer to a byte number and not a
segment number.
• Byte Number
• TCP numbers all data bytes (octets) that are
transmitted in a connection.
• Numbering is independent in each direction.
When TCP receives bytes of data from a process,
TCP stores them in the sending buffer and
numbers them.
• The numbering does not necessarily start from 0.
Instead, TCP chooses an arbitrary number
between 0 and 2 power(32) − 1 for the number of
the first byte.
• For example, if the number happens to be 1057
and the total data to be sent is 6000 bytes, the
bytes are numbered from 1057 to 7056.
• Sequence Number
• After the bytes have been numbered, TCP assigns
a sequence number to each segment that is being
sent.
1. The sequence number of the first segment is the ISN
(initial sequence number), which is a random number.
2. The sequence number of any other segment is the
sequence number of the previous segment plus the
number of bytes (real or imaginary) carried by the
previous segment.
• Acknowledgment Number