Documente Academic
Documente Profesional
Documente Cultură
(TCP)
Lecture Date: 8th April 2020, 11:50 A.M. to 12:10 P.M.
Transmission Control Protocol (TCP)
Reliable
TCP is reliable as it uses checksum for error detection, attempts to recover lost or corrupted
packets by re-transmission, acknowledgement policy and timers. It uses features like byte
number and sequence number and acknowledgement number so as to ensure reliability. Also, it
uses congestion control mechanisms.
Multiplexing and De-Multiplexing
TCP does multiplexing and de-multiplexing at the sender and receiver ends respectively as a
number of logical connections can be established between port numbers over a physical
connection.
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 the byte number and not the
segment number.
Byte Number TCP numbers all data bytes that are transmitted in a connection. Numbering is
independent in each direction. When TCP receives bytes of data from a process, it stores them in the
sending buffer and numbers them. The numbering does not necessarily start from 0. Instead, TCP
generates a random number between 0 and 232 − 1 for the number of the first byte. For example, if
the random number happens to be 1057 and the total data to be sent are 6000 bytes, the bytes are
numbered from 1057 to 7056. We will see that byte numbering is used for flow and error control.
Sequence Number After the bytes have been numbered, 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.
TCP Features
Acknowledgment Number: the acknowledgment number defines the number of the next byte
that the party expects to receive. In addition, the acknowledgment number is cumulative, which
means that the party takes the number of the last byte that it has received, safe and sound, adds
1 to it, and announces this sum as the acknowledgment number.
Flow Control: TCP, unlike UDP, provides flow control. The receiver of the data controls the
amount of data that are to be sent by the sender. This is done to prevent the receiver from being
overwhelmed with data. The numbering system allows TCP to use a byte-oriented flow control.
Error Control: To provide reliable service, TCP implements an error control mechanism.
Although error control considers a segment as the unit of data for error detection (loss or
corrupted segments), error control is byte-oriented.
Congestion Control : TCP, unlike UDP, takes into account congestion in the network. The
amount of data sent by a sender is not only controlled by the receiver (flow control), but is also
determined by the level of congestion in the network.
TCP segment format
The segment consists of a 20- to 60-byte header, followed by data from the application program. The header
is 20 bytes if there are no options and up to 60 bytes if it contains options
TCP segment format
Source Port Address –
16 bit field that holds the port address of the application that is sending the data segment.
Destination Port Address –
16 bit field that holds the port address of the application in the host that is receiving the data
segment.
Sequence Number –
32 bit field that holds the sequence number, i.e, the byte number of the first byte that is sent in
that particular segment. It is used to reassemble the message at the receiving end if the segments
are received out of order.
Acknowledgement Number –
32 bit field that holds the acknowledgement number, i.e, the byte number that the receiver
expects to receive next. It is an acknowledgment for the previous bytes being received
successfully.
TCP segment format
Control flags –
These are 6 1-bit control bits that control connection establishment, connection termination, connection
abortion, flow control, mode of transfer etc. Their function is:
URG: Urgent pointer is valid
ACK: Acknowledgement number is valid( used in case of cumulative acknowledgement)
PSH: Request for push
RST: Reset the connection
SYN: Synchronize sequence numbers
FIN: Terminate the connection
TCP segment format
Window size –
This field tells the window size of the sending TCP in bytes. This value is normally referred to as
the receiving window (rwnd) and is determined by the receiver. The sender must obey the
dictation of the receiver in this case
Checksum –
This field holds the checksum for error control. It is mandatory in TCP as opposed to UDP.
Urgent pointer –
This field (valid only if the URG control flag is set) is used to point to data that is urgently
required that needs to reach the receiving process at the earliest. The sending TCP creates a
segment and inserts the urgent data at the beginning of the segment. The value of this field is
added to the sequence number to get the byte number of the last urgent byte.
TCP segment format: Control Flags
Urgent (URG) –Data inside a segment with URG = 1 flag is forwarded to application layer
immediately even if there are more data to be given to application layer. It is used to notify the
receiver to process the urgent packets before processing all other packets. The receiver will be
notified when all known urgent data has been received.
Acknowledgement (ACK) – It is used to acknowledge packets which are successful received by
the host. The flag is set if the acknowledgement number field contains a valid acknowledgement
number. In given below diagram, the receiver sends an ACK = 1 as well as SYN = 1 in the
second step of connection establishment to tell sender that it received its initial packet.
Push (PSH) – Push flag is used for interactive applications e.g. chatting. If PSH=1 then it will
not buffer the data equal go Maximum Segment Size (MSS). At the sender end, it immediately
sends the segment to network layer after receiving the signal from application layer. At the
receiver end data is immediately transmitted to application layer.
Reset (RST) – It is used to terminate the connection if the RST sender feels something is wrong
with the TCP connection or that the conversation should not exist. It can get send from receiver
side when packet is send to particular host that was not expecting it.
TCP segment format: Control Flags