Some views on TCP/IP protocol (2): TCP protocol

Source: Internet
Author: User
Tags ack

The above describes the overall architecture of the TCP protocol, today introduces the TCP protocol's famous three-time handshake and four-time handshake.

The server and client must establish a connection before communicating, which is done through three handshakes, thus ensuring the reliability of the communication.

The steps for the three-time handshake are as follows:

Suppose A is the client, B is the server, and a actively communicates with B, the steps are as follows:

1.A send SYN message and Mark Seq=x,ack=0

2.B after receiving the SYN message, if it can communicate, send a confirmation message, and Mark Seq=y,ack=x+1

3.A after receiving confirmation message, send confirmation message, Mark Seq=x+1,ack=y+1

This establishes the connection, where the presence of the state includes

Endpoint State Describe
A, b CLOSED Connection closed, no in-progress communication
B LISTEN Listening status
B SYN RCVD B received the connection request but not confirmed
A SYN SENT A Send a connection request and wait for confirmation
A, b Established Both establish a connection

The four-time handshake close link is as follows:

The specific steps are as follows:

1.A send fin message, Mark Seq=m

2.B after receiving fin message, send confirmation message, Mark Seq=m+1

Fin messages are also sent after 3.B, labeled Seq=n

4.A after receiving fin message, send confirmation message, Mark Seq=n+1

At this point the two sides are disconnected, and the states involved are

Endpoint State Describe
A FIN WAIT 1 Send a close request, wait for confirmation
A FIN WAIT 2 Receipt of B's confirmation request, waiting for the fin message of B
A, b CLOSING Both sides try to close simultaneously, waiting for the other party to confirm
B CLOSE WAIT Received a close request, has been confirmed
A Time waited Complete two-way shutdown, waiting for all packets to die
B Last ACK Wait for the last confirmation

The reason for the 4 handshake is that TCP communication is full-duplex and requires both confirmation.

Some views on TCP/IP protocol (2): TCP protocol

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.