Why does TCP use three-way handshake? Can't two or four-way handshakes work?

Why does TCP use three-way handshake? Can't two or four-way handshakes work?

The TCP protocol needs three handshakes to establish a connection, while the SCTP protocol needs four handshakes to establish a connection. We can't help but ask, why doesn't TCP use two or four handshakes to establish a connection?

TCP is a reliable transmission control protocol. It must do two things: one is to ensure reliable data transmission, and the other is to improve transmission efficiency as much as possible. The three-way handshake is designed to achieve these two things.

[[397071]]

Achieving reliability

Assume that A and B want to establish a TCP connection.

First, the operating system randomly selects a 32-bit sequence number. Assume that A's initial sequence number is 1000. Then the data to be sent is numbered, 1001, 1002, 1003...

A will tell B the initial sequence number ISN to let B know what kind of numbered data is legal and what kind of numbered data is illegal. For example, if data with a number of 999 is received, it is illegal.

B will also confirm each numbered data of A. If the received number is 2001, 1001-2000 means that 1000 bytes have arrived safely.

Similarly, B will also perform similar operations. If B's ​​initial serial number ISN is 2000, B will also start numbering 2001, 2002, 2003...

B then tells A the initial sequence number ISN, and A can also confirm how many bytes B has sent and whether the data is legal.

Through the above steps, it is not difficult to find that the essence of the TCP protocol handshake is the sequence number of the data origin of the communicating parties, so as to achieve reliability.

Transmission efficiency

Why is a three-way handshake necessary to achieve reliable data transmission? Is a two-way handshake OK?

Two-way handshake:

  • A sends the synchronization signal SYN+A's initial sequence number
  • B sends the synchronization signal SYN + B's initial sequence number + B's ACK sequence number

The two-way handshake will cause a problem. B has no way of knowing whether A has received its own synchronization signal. Once this synchronization signal is lost, A and B will not be able to reach an agreement on B's initial sequence number.

Obviously, a two-way handshake is undesirable.

So what about the four-way handshake?

  • A sends the synchronization signal SYN+A's initial sequence number
  • B confirms receipt of A's synchronization signal, and records A's ISN locally, naming B's ACK sequence number
  • B sends the synchronization signal SYN+B's initial sequence number
  • A confirms receipt of B's ​​synchronization signal, and records B's ISN locally, naming A's ACK sequence number

Obviously, four steps are not necessary, and steps 2 and 3 can be combined to improve the speed and efficiency of the connection.

The TCP protocol needs to take reliability and transmission efficiency into consideration. Knowing this, we also understand why there can only be three handshakes, not two or four.

<<:  IT presents a new normal in the post-epidemic era. 7 "prescriptions" can help you cure the "sequelae"

>>:  Inventory: Excellent NaaS providers in 2021

Recommend

Is IIoT edge computing ready?

Edge computing, a powerful technology that has be...

Outlook for domestic 5G development in 2021 (I): Current status

The development of 5G has now become another hot ...

Gcore (gcorelabs) Ashburn (Virginia) VPS simple test

Previously, I conducted a simple test on some of ...

What kind of network slicing does 5G require?

Everyone should be familiar with network slicing....

...

2021 China Internet Haha List 4: Top Ten Figures

2021 is a year of rapid change in the field of sc...

SDN changes data center architecture

Software-defined networking (SDN) is seen as havi...

The Difference Between a Network Hub and a Network Switch

What is a Network Hub? A hub in a computer networ...

Comprehensive network monitoring tools to watch in 2020

Network monitoring is one of the most important n...

Aruba expands SD-WAN services to Alibaba Cloud

Aruba, a Hewlett Packard Enterprise company, anno...