(TRANSMISSION CONTROL PROTOCOL)
TCP
TCP meaning Transmission Control Protocol, is a communications standard for delivering data and messages through networks. TCP is a basic standard that defines the rules of the internet and is a common protocol used to deliver data in digital network communications.
TCP enables data to be transferred between applications and devices on a network and is used in the TCP IP model. It is designed to break down a message, such as an email, into packets of data to ensure the message reaches its destination successfully and as quickly as possible.�
Following are some of the services offered by the Transmission Control Protocol (TCP) to the processes at the application layer:
Stream Delivery Service:
1.TCP is a stream-oriented protocol. It enables the sending process to deliver data as a stream of bytes and the receiving process to acquire data as a stream of bytes.
2.TCP creates a working environment so that the sending and receiving procedures are connected by an imaginary "tube"
Sending and Receiving Buffers:
The sending and receiving processes cannot produce and receive data at the same speed. Hence, TCP needs a buffer for storage.
There are two methods of buffers:
Sending Buffer
Receiving Buffer
A buffer can be implemented by using a circular array of 1-byte location, as shown in the figure below. The figure shows the movement of data in one direction on the sending side.
The buffer has three types of locations, which are as follows:
1.Locations that contain the bytes which have been sent, but not acknowledged. It is known as Empty Location.
2.These bytes are kept in the buffer till an acknowledgment is received.
3.The location that contains the bytes which are to be sent by the sending TCP.
Bytes and Segments:
Buffering is used to handle the difference between the speed of data transmission and data consumption. But only buffering is not enough.
We need one more step before sending the data on the Internet Protocol (IP) layer as a TCP service provider. It needs to send data in the form of packets and not as a stream of bytes.
The segment is encapsulated in an IP diagram and then transmitted. The entire operation is transparent to the receiving process. The segment may be deceived out of order, lost or corrupted when it receives the receiving end.
The segments are not of the same size. Each segment can carry hundreds of bytes.
Full-Duplex Service:
TCP offers a full-duplex service where the data can flow in both directions simultaneously. Each TCP will then have a sending buffer and receiving buffer. The TCP segments are sent in both directions.
Connection-Oriented Service:
We are already aware that the TCP is a connection-oriented protocol. When a process wants to communicate (send and receive) with another process (process -2), the sequence of operations is as follows:
TCP of process-1 informs TCP of process-2 and gets its approval.
TCP of process-1 tells TCP of process-2 exchange data in both directions.
The type of connection in TCP is not physical, but it is virtual. The TCP segment encapsulated in an IP datagram can be sent out of order. These segments can get lost or corrupted and may have to be resend. Each segment may take a different path to reach the destination.
Reliable Service:
TCP is a reliable transport protocol. It uses an acknowledgment mechanism for checking the safe and sound arrival of data.
Flow Control :
TCP Flow control deals with the amount of data sent to the receiver side without receiving any acknowledgment. It makes sure that the receiver will not be overwhelmed with data. It's a kind of speed synchronization process between the sender and the receiver.
Error control :
TCP is mainly done through the use of three simple techniques : Checksum – Every segment contains a checksum field which is used to find corrupted segments. If the segment is corrupted, then that segment is discarded by the destination TCP and is considered lost.
Congestion Control :
It is a mechanism that controls the entry of data packets into the network, enabling a better use of a shared network infrastructure and avoiding congestive collapse.
A TCP segment :
It consists of data bytes to be sent and a header that is added to the data by TCP as shown: The header of a TCP segment can range from 20-60 bytes. 40 bytes are for options.
Features of TCP
i) Connection-Oriented protocol:
TCP establishes a reliable connection between sender and receiver before transmitting data packets. It uses a three-way handshake to make a secure connection.
Three-way handshake process:
Steps in three-way handshake:
TCP Connection :
TCP establishes a reliable connection between sender and receiver before transmitting data packets. It uses a three-way handshake to make a secure connection.
Three-way handshake process:
Steps in three-way handshake:
SYN - Source sends an SYN (synchronization) segment to the destination. It indicates that the source wants to establish a connection with the destination.
SYN-ACK: Destination sends back SYN/ACK to the sender to convey that it has received SYN and is ready to establish the connection.� ACK: After getting the SYN-ACK, the destination sends ACK, indicating the source received the SYN-ACK. Now the session is fully reliable.�
After, a three-way handshake source or destination can send the data.
The header of a TCP segment can range from 20-60 bytes. 40 bytes are for options. If there are no options, a header is 20 bytes else it can be of upmost 60 bytes. �Header fields: �
Source Port Address – �A 16-bit field that holds the port address of the application that is sending the data segment. �
Destination Port Address – �A 16-bit field that holds the port address of the application in the host that is receiving the data segment. �
Sequence Number – �A 32-bit field that holds the sequence number.
Acknowledgement Number – �A 32-bit field that holds the acknowledgement number, i.e, the byte number that the receiver expects to receive next.
TCP Data Transfer:
Each data byte sent to a remote host is numbered (i.e. the sequence number in the packet specifies the number of the first data byte in the packet). Upon receipt of data, a host acknowledges the data by sending a reply packet with the acknowledge field set to the sequence number of the next data byte expected (i.e. the sequence number of the next data byte which has not been received).