Reading notes--TCP: Transmission Control Protocol (II)

Source: Internet
Author: User

TCP establishes a connection
    1. The request side (client) sends a SYN indicating the server port number that the client intends to connect to, as well as the initial sequence number.
    2. The service side sends back the SYN message segment that contains the initial sequence number of the server as a reply. At the same time, the confirmation number is set to customer's ISN plus 1 to confirm the customer's SYN message segment. A SYN occupies an ordinal number.
    3. The client must set the confirmation sequence to the service side's isn plus 1 to confirm the SYN message segment of the server.

TCP connection termination

It takes three handshake to establish a connection, and 4 handshake to terminate a connection. This is caused by a semi-shutdown of TCP. Since a TCP connection is full-duplex (that is, the data can be delivered simultaneously in two directions), each direction must be closed separately.

    1. The client sends a fin to close the data transfer from the client to the server.
    2. The service side receives this fin, sends back an ACK, confirms the serial number to receive the serial number plus one. As with Syn, a fin will occupy a sequence number.

    3. The server completes the data transfer and sends to the client a fin.

    4. After the client receives fin, it sends an ACK to the server.

Semi-shutdown of TCP

TCP provides the ability for one end of a connection to accept data from the other end after it has been sent. This is called semi-closing.

In order to use this feature, the programming interface must provide a way for the application to explain "I have finished the data transfer, so send a file end (Fin) to the other end, but I also want to receive data from the other end until it sends me the end of the file (Fin)."

MSL (Maximum Segment LIfetime)

Each specific TCP implementation must select a message segment Maximum lifetime MSL. He is the longest time in the network before any message segments are discarded. We know that this time is limited because the TCP segment is transmitted over the network as an IP datagram, while the IP datagram has a TTL field that restricts its lifetime. The limit for the IP datagram TTL is based on the hop count, not the timer. For a specific implementation of the MSL value given, the principle of processing is: When TCP performs an active shutdown, and then returns the last ACK, the connection must remain in the TIME_WAIT state for a time of twice times the MSL. This allows TCP to send the final ACK again to prevent the ACK from being lost (the other end times out and the last fin is sent again)

Reading notes--TCP: Transmission Control Protocol (II)

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.