Transmission Control Protocol(TCP) – Transport Layer

transport layer networking protocol

Coming to the 2nd Transport Layer Protocol i.e. Transmission Control Protocol(TCP). The Transmission Control Protocol(TCP) is such an important protocol in the Internet protocol model, that the whole Internet stack is called as the TCP/IP stack.  TCP was 1st introduced in 1974.

A number of applications use TCP for their execution such as HTTP, FTP, SMTP. Web Browser uses TCP to connect to the World Wide Web (www). TCP is used to deliver emails and transfer files from one host to another.

 

TCP is called as Connection-Oriented Protocol. Because in TCP, there is a 3-way handshake between the communicating hosts before exchanging the data or the message. There are lots of services provided by TCP that were not available by UDP. TCP provides Reliable Delivery of data, checks for error in the data and tries for its correction and delivers the packet in their respective order as they were sent by the sender. It also provides congestion control and flow control.

TCP provides a full-duplex mode of transmission i.e. if there is a connection between a Process Y on one host and a Process Z on another host. Then the Application message can be sent from Process Y to Process Z and from Process Z to Process Y within the same TCP connection.

A TCP connection is between a single sender and a single receiver. It means TCP is a point-to-point connection control protocol. Multi-casting is not possible with TCP. Multi-casting is a procedure of sending of data from a single sender to different receiver in a single send operation. 

Problems with Transmission Control Protocol(TCP):

Due to large traffic and congestion in the network, packets might get lost or they can get corrupt. TCP being the reliable data delivery protocol, detects all these problems, try to resolve them, asks for the re-transmission of the lost or corrupt packets, arranges the packet in order and send them to the receiver. The TCP receiver arranges all these packets in order and send them to the Application.

Thus in all this, re-transmissions , in order packet delivery, sometimes TCP results in long delays.

How TCP provides Reliable delivery of data :

TCP does it by a process of positive Acknowledgement. The receiver has to acknowledge the sender by sending a message to the sender, if it has receive the data correctly. The sender keeps the record of every packet it sends and maintains a clock with every packet. If the acknowledgement doesn’t comes before the clock expires, the sender will re-transmit that packet, assuming that the packet is either lost or corrupted.

TCP Packet Structure:

Transmission Control protocol message packet



1. Source Port Number: It is used to identify the sending port number.

2. Destination Port Number: It is used to identify the receiving port Number.

3. Sequence Number and Acknowledgement Number : These are used for the reliable Delivery of data. Each Sequence and Acknowledgement Number is of 32 bits.

4. Header Length : This field is of 4 bytes. It tells the length of the TCP Header. The TCP header can be of variable lengths due to the presence of Option Fields. (In most cases, option field is empty, then the TCP header length is 20 bytes).

5. Unused or Reserved : This is reserved for future use. It is of 3 bit.

6. Pointers: 

  • ACK: This bit is used to indicate that whether the value in Acknowledgement field is valid or not. That means, whether it contains an acknowledgment number for a packet that has been successfully received.
  • RST, SYN and FIN : These 3 bits are used for establishing a connection between and to stop a connection.
  • PSH : This bit indicates whether the data should be pass to the upper layer or not. If  PSH=1, it indicates the receiver should pass the data immediately to the upper layer.
  • URG: This bit is used to indicate , if there is any data , that the host has marked as urgent. If URG=1, then it shows that some data has been marked as urgent. To know the address of that Urgent data, the 16-bit Urgent Data Pointer field is used which gives that information.


7. Checksum: It is of 16 bits. It is used to check that whether the data has arrived correctly or not. It is also used to detect any error in the data.

8. Application Message: It is of 32 bits. It contains the actual Application that the user wants to transmit.

9. Options : This field is of 32 bits. If the user need to send a data that is larger that the Application Message field size, then option field is used by the TCP header.

  • It is recommended that you must send small packets, because if the packet size is larger, than the packet fragmentation will take place at the network layer, resulting in more number of lost packets.
 

TCP Implementation:

 Transmission Control Protocol(TCP) is implemented in different ways. These are:
 

i) TCP TAHOE

 ii) TCP RENO
 

iii) TCP VEGAS

 iv) TCP SACK
 

Concept of Sequence Number and Acknowledgement Number

computer networks and the related aspects
These two numbers are of great importance in TCP. As they enable TCP for reliable Data Delivery and in order Delivery of Packets. Let’s take a look and try to understand, what are these two fields.

First of all, I would like to tell you that, TCP Sequence and Acknowledgement Number doesn’t hold the size or number of the transmitted packet, instead they contain the byte stream of those packets. That means Sequence and Acknowledgement number contains the 1st byte of the transmitted packet.

The sender and the receiver decides on , what should be the starting sequence number of the 1st packet.

Sequence Numbers:

For Example : If you have a 50,000 bytes of data to send and the Maximum Segment Size (MSS) is 1000 bytes, you have to send 50 packets. Suppose you and the receiver decide the starting sequence number of 1st packet as 0. The second packet will have sequence number as 1000, 3rd will have 2000 and so on till 50000.
  • MSS refers to the maximum size of a TCP packet that can be sent.

Acknowledgement Number:

 As we have already discussed that TCP is full Duplex, so at the same time both sender and receiver can send packets to each other simultaneously. Let us Suppose that James is the sender and Steve is the receiver.
 

All the packets arriving from James has a sequence number for the data flowing from James to Steve.  Now the Acknowledgement number that Steve puts in its packet is the sequence number of the next packet, that Steve is expecting from James.

 For Example: If Steve has received all bytes numbered from 0 to 499 from James. Then Steve will put the acknowledgement number as 500 in the packet, it will send to James.
  

Cumulative Acknowledgement:

 For Example: If Steve has received bytes numbered from 0 to 499 and bytes from 1000 to 1099. Due to some failure or packet loss, Steve has not received packet from 500 to 999 and Still, he is waiting for 500 segment, to build the whole message from James in a proper order. Thus Steve’s next packet will contain acknowledgement number as 500. Since TCP only acknowledges the 1st byte missing, this is known as Cumulative Acknowledgement.
 This also brings one more concern, that when Steve receives packet from 0 to 499 and then from 1000 to 1099, but packet from 500 to 999 is still missing. Thus the 3rd packet arrives out of order. Now a question arises: What should the receiver do when it receives a packet out of order?
 

Thus , I would like to bring the fact to you that, Computer networking doesn’t impose any restriction on this. It totally depends on the people programming the TCP implementation. They can choose either of these:

 

1. The receiver can discard the out-of-order packet as soon as he receives it.

 or
 

2. The receiver can save the out of order packet in its buffer and waits for the missing packet to arrive.

 
  • Hopefully maximum people will choose the 2nd option , in order to use the network bandwidth to the maximum, and to shorten the delay process.   In Internet, the 2nd choice is used .
  

*****There are various interesting cases, where you sometimes have to re-transmit and sometimes you need not re-transmit a packet due to acknowledgement. Lets have a look at these scenarios.*****

  

Scenario 1: Re-transmission due to lost Acknowledgement :

 
 

Transmission Control Protocol(TCP) acknowledgement number

 
  
 

Scene 2: Cumulative Acknowledgment avoids re-transmission of the 1st packet.

 

cumulative acknowledgement in tcp, tcp acknowledgement number, sender sending a letter, receiver responding to the letter, sequence number, acknowledgment number, time taken by a packet to deliver

 

 Suppose, sender sends a packet of 15 bytes and a packet of 20 bytes back to back and they are received at the receivers side and the receiver sends an acknowledgement for the same. But the acknowledgement for the 1st packet is lost in the network. But before the timeout occurs, the sender receives an acknowledgement for the 2nd packet. Thus, the sender will understand, that the sender has received all the packets till Sequence number 54. Hence it will not resend the 1st packet.

Thank You for reading the article. We hope you enjoyed it.

This is all from us on Transmission Control Protocol(TCP). Do you have something to share with our readers ?

Mandeep Kaur Bajaj

Mandeep Kaur Bajaj

Mandeep passion for blogging encouraged her to write at FitnyTech. She is a tech blogger and writes about Technology , Gadgets , various programming languages. In Blogging world , she is known as "Mandy". Mandeep is very good at cooking also , you can ask her for any cooking advice also.

More Posts

Leave a Reply

Your email address will not be published. Required fields are marked *