Sunteți pe pagina 1din 12

Transmission Control Protocol

(TCP)
Lecture Date: 8th April 2020, 11:50 A.M. to 12:10 P.M.
Transmission Control Protocol (TCP)

 TCP, like UDP, is a process-to-process (program-to-program) protocol.


 TCP, therefore, like UDP, uses port numbers.
 Unlike UDP, TCP is a connection oriented protocol; it creates a virtual connection
between two TCPs to send data.
 TCP uses flow and error control mechanisms.
Services of TCP
 Process to Process Communication
 TCP provides process to process communication, i.e, the transfer of data takes place
between individual processes executing on end systems. This is done using port
numbers or port addresses. Port numbers are 16 bit long that help identify which
process is sending or receiving data on a host.
 Stream Oriented
 This means that the data is sent and received as a stream of bytes(unlike UDP or IP
that divides the bits into datagrams or packets). However, the network layer, that
provides service for the TCP, sends packets of information not streams of bytes.
Hence, TCP groups a number of bytes together into a segment and adds a header to
each of these segments and then delivers these segments to the network layer. At the
network layer, each of these segments are encapsulated in an IP packet for
transmission. The TCP header has information that is required for control purpose
which will be discussed along with the segment structure.
 Full Duplex Service
 Communication can take place in both directions at the same time.
Services of TCP
 Connection Oriented Service
 TCP provides connection oriented service by using three way handshaking. It defines 3 different
phases:
 Connection establishment
 Data transfer
 Connection termination

 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

 Header Length (HLEN)


 This is a 4 bit field that indicates the length of the TCP header by number of 4-byte words in the header, i.e, if
the header is of 20 bytes(min length of TCP header), then this field will hold 5 (because 5 x 4 = 20) and the
maximum length: 60 bytes, then it’ll hold the value 15 (because 15 x 4 = 60). Hence, the value of this field is
always between 5 and 15.

 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

 Synchronization (SYN) – It is used in first step of connection


establishment phase or 3-way handshake process between the two hosts. Only
the first packet from sender as well as receiver should have this flag set. This is
used for synchronizing sequence number i.e. to tell the other end which sequence
number they should accept.
 Finish (FIN) – It is used to request for connection termination i.e. when there is
no more data from the sender, it requests for connection termination. This is the
last packet sent by sender. It frees the reserved resources and gracefully terminate
the connection.

S-ar putea să vă placă și