TCP——三次握手(SYN,SKC)

1.三次握手的維基百科解釋:

To establish a connection, TCP uses a three-way handshake. Before a client attempts to connect with a server, the server must first bind to and listen at a port to open it up for connections: this is called a passive open. Once the passive open is established, a client may initiate an active open. To establish a connection, the three-way (or 3-step) handshake occurs:

  1. SYN: The active open is performed by the client sending a SYN to the server. The client sets the segment's sequence number to a random value A.
  2. SYN-ACK: In response, the server replies with a SYN-ACK. The acknowledgment number is set to one more than the received sequence number i.e. A+1, and the sequence number that the server chooses for the packet is another random number, B.
  3. ACK: Finally, the client sends an ACK back to the server. The sequence number is set to the received acknowledgement value i.e. A+1, and the acknowledgement number is set to one more than the received sequence number i.e. B+1.

At this point, both the client and server have received an acknowledgment of the connection. The steps 1, 2 establish the connection parameter (sequence number) for one direction and it is acknowledged. The steps 2, 3 establish the connection parameter (sequence number) for the other direction and it is acknowledged. With these, a full-duplex communication is established.

 三次握手的目的就是建立連接。那什麼SYN,ACK.

  • SYN(Synchronize Sequence Number)
    客戶端懸着一個隨機序列號X,併發送一個SYN分組,其中可能換包括其他TCP標誌和選項。
  • SYN ACK
    服務器給X加1,並選擇自己的一個隨機序列號Y,追加自己的標註和選項,然後返回響應。
  • ACK(Acknowledgement)
    客戶端給X和Y加1併發送握手期間的最後一個ACK分組。

 

 

 三次握手彎沉夠,客戶端與服務器就可以通信了。客戶端可以在發送ACK分組之後立即發送數據,二服務器必須等收到ACK分組之後才能發送數據。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章