TCP Sequence Number and Wrap Around Concept

Learn via video courses
Topics Covered

Overview

TCP is a connection-oriented transport layer protocol. The TCP sequence number is a 32-bit number that helps in providing a sequence number that is suitable with other transmitting bytes of the TCP connection. TCP sequence number uniquely identifies each data byte as it is a stream-oriented protocol. Using a sequence number over and again for maintaining data transmission continuity is called the Wrap Around concept.

What is TCP?

TCP is a protocol of transport layer. Through TCP, we can connect remote computers with the help of conveying and also provide the service of transferring messages by supporting the network and the internet. A network communication protocol through which data packets are transferred across the internet is called a transmission control protocol(TCP).

  • TCP is one of the protocols that is mostly used in digital networks. The transmission control protocol is also a part of the internet protocol suite also known as the TCP/IP suite.
  • TCP provides the facility of end-to-end transferring of messages between various nodes.
  • Before the transmission of data, it is the responsibility of TCP to create a connection between the destination and the source nodes. And also makes sure that this connection remains preserved till the communication is not completed.
  • TCP is responsible for breaking down data into smaller packets and also makes sure that the integrity of data remains the same until the packet reaches its destination.

TCP Sequence Number and Its Purpose

The number allocated to the first byte of data of the packet is defined by the TCP sequence number of 32 bits. We use the TCP protocol for transferring data in the form of streams. To maintain the connectivity, each transferring byte is numbered. In the process of connection establishment, each party needs to generate an initial sequence number (ISN). This TCP sequence number is generated by the random number generator. The size of a TCP sequence number is 32 bits long.

So TCP sequence numbers have a fixed amount of sequence numbers starting from 0 to (2321)=4GB(2^{32}-1) = 4GB, which means that we cannot send more than 4 GB of data along with a unique sequence number. TCP Sequence Number helps in providing a sequence number that is suitable with other transmitting bytes of TCP connection. A Unique ISN is provided for each connection.

Following purposes are served by the TCP sequence number:

  • Helps in the unique identification of each data byte.
  • It helps in the formation of TCP segments and also helps in reassembling them.
  • It also helps in maintaining the record of how much data is transferred and how much is received.
  • If the data is received in the wrong order then it helps in maintaining the correct order of data.
  • When the data is lost in the transmission process then it helps to request that lost data.

Wrap Around Concept

All sequence numbers are used at the time of considerable traffic. There must be a unique sequence number for every packet and as they do not exist indefinitely i.e. 4 Gigabyte at some time all the sequence number gets exhausted. Previously used sequence numbers can be used again when accessible and this sequence number reusing is called the wrap-around idea.

Wrap around the term is defined as given below: When all the sequence numbers have been used up using a sequence number over and again for maintaining data transmission continuity.

This allows data transmission of more data without any worry about how much data we have to send. Because of the reusability feature of the TCP sequence number.

When and How is the Wrap Around Used?

Suppose we want to download the software having the size(4GB+ 2-byte), but only the 4GB sequence number is accessible, any TCP sequence number is not available by the left out 2 bytes. So in this type of situation, the wrapping of the sequence number means we repeatedly use the sequence number. This wrapping is impacted by the random initial sequence numbers. In starting there may be a situation in which we receive a lower sequence number but the sequence number will reset to zero after spending all the sequence numbers.

TCP sequence wrapping Idea includes the method of recycling sequence numbers according to their requirements.

We can start using sequence numbers from anywhere according to our need but we always get sequence number 2322^{32} from everywhere.

Wraparound Time

The time taken to wrap around is known as the wrap-around time. Suppose we begin with a zero TCP sequence number (it can be another number also) then it shows after how much time the same sequence number will be used again. So, the time it takes to reuse the same sequence number or the time it is required to repeat the same sequence number whenever required is known as wrap-around time.

Wrap-around time is generally represented by the available sequence numbers and available bandwidth. Bandwidth is the rate at which bits are used. The sequence number is consumed faster if the rate of consumption is performed fast.

WrapAroundtime=totalsequencenumberbandwidth{WrapAround-time=\frac{totalsequencenumber}{bandwidth}} =232bandwidth{=\frac{2^{32}}{bandwidth}}

Why is Wrap Around Possible?

There is a concept which is called the Life Time, the packet will require 3 minutes (180sec) to reach the destination and this is known as the lifetime of the packet. In today's world, after 180 seconds the same TCP sequence number is available but before the wrap-around time, we are not using it. Or we can say in other words that there is no issue in utilizing the sequence number until the wrap-around time is greater than the lifetime. There is a condition of timeout whenever the segment lifetime ends after the wrap-around time. Segment lifetime finishes after the wrap-around time and that means there is a timeout. There is no harm in utilizing the sequence number again if we are using it after the use of all sequence numbers and after the finishing of their lifetime.

How to Reduce the Wraparound Time?

There is no need to wrap around the sequence number if the total number of bits that are consumed is found to be equal to the sequence number. But actually, this is not possible. So we have to use the concept of wrap-around.

To decrease the wrap-around time we have to perform the following actions:

  • Reduce the sequence numbers
  • Increase the bandwidth (possible)

Reduce the Sequence Numbers

Wrap-around time will be higher if the available TCP sequence number is more. Higher will be the wrap-around time if the bandwidth is lesser.

Increase the Bandwidth (possible)

Wrap-around time is inversely dependent on the bandwidth(it is the rate at which messages will be transferred) and also directly dependent on the sequence number.

Example 1: Find the wrap-around time if the bandwidth of the network is given 1 MB / sec.

Solution:

Wrap-around time = Time required for using all the 2322^{32} sequence numbers. For each data byte, 1 sequence number is assigned by the TCP.

We are required to find out the time taken in sending 2322^{32} data bytes for finding the wrap-around time

Now,

Given, bandwidth = 1 MB / sec = 10610^{6} bytes / sec. It means in 1 sec 10610^{6} bytes of data can be sent. So, time required for sending 2322^{32} bytes of data=1106232{\frac{1}{10^{6}}}*2^{32} sec. After solving, we get 1.19 hours.

Now,
1.19 hours is required for consuming all the 2322^{32} sequence numbers if bandwidth = 1 MB / sec. Then Wrap Around Time = 1.19 hours.

Alternatively, by directly applying the formula

Wrap Around Time=232106\frac{2^{32}}{106} sec

= 1.19 hours

Example 2: Find how long packets can be in a link without worrying about having the same TCP sequence number if the bandwidth of the network is 1 GBPS.

Solution:

Given, Bandwidth = 1 GBps = 2302^{30} Sequence numbers = 2322^{32}

So, Wrap around time= SequencenumberBandwidth{\frac{Sequence number}{Bandwidth}} =232230=\frac{2^{32}}{2^{30}} =22=2^2 =4=4

Answer: 4 seconds

Practice Problems Based on Wrap-around Time in TCP

Ques. How many sequence numbers are possible if n bits are given?

Answer

  • There is a possibility of 2 numbers for 1 bit, i.e., 0 and 1
  • There is a possibility of 4 numbers for 2 bits, i.e., 00, 01, 10, 11
  • There is a possibility of 8 numbers for 3 bits, i.e., 000, 001, 010, 011, 100, 101, 110, 111 .. and so on
  • There is a possibility of 2n2^n numbers for n bits, i.e., from 0 to 2n12^{n}-1 (in binary).

Conclusion

  • TCP is a connection-oriented transport layer protocol.
  • The TCP sequence number is 32-bits which helps in providing a sequence number that is suitable with other bytes with other transmitting bytes on the TCP connection.
  • Unique identification of each data byte is one of the purposes of the TCP Sequence number.
  • When all the sequence numbers have been used up using a sequence number over and again for maintaining data transmission continuity is called the Wrap Around concept.
  • Reduce the sequence numbers, and Increase the bandwidth are ways of reducing wrap-around time.