TCP connection and Termination

Source: Internet
Author: User

TCP connection and Termination

1. TCP Header


T c p packs user data into a packet segment; it sends data and starts a timer; the other end confirms the received data, sorts the out-of-order data again, and discards repeated data; t c p provides end-to-end traffic control and calculates and verifies a mandatory end-to-end test.
2. TCP connection establishment and Termination



3. TCP status change



As a result, two changes in the ESTABLISHED status start a connection, while the two changes that lead to the exit from the ESTABLISHED status close a connection.



4. 2MSL waiting status

The ti m e wa I T status is also known as the 2 M S L wait status. For each specific t c p implementation, You must select a Maximum message Segment survival time (Ms' L (Maximum Segment Lifetime ). It is the longest time before any packet segment is discarded in the network.
For the m s l value given by A specific implementation, the processing principle is: when t c p executes an active shutdown, concurrent return to the last a c k, the connection must be in the t I m e wa I T state for 2 times M S L. This allows t c p to send the final a c k again to prevent the c k from being lost (the other end times out and resends the final f I N ).

Another result of this 2 m s l wait is that the t c p connection defines the connection plug-in (the customer's I P address and port number, server I P address and port number) cannot be used again. This connection can only be used after 2 Mbit/s l.
Unfortunately, most t c p implementations (such as the Berkeley version) impose more stringent restrictions. During the 2 m s l wait period, the local port used in the plug-in cannot be used by default. Therefore, it is generally caused by active shutdown by the client.

We can say that in Figure 1 8-1 3, it is normal for the customer to take the initiative to close and enter the t I m e wa I T. The server is usually passively shut down and does not enter the t I m e wa I T status. This implies that if we terminate a customer program and immediately restart the customer program, the new customer program will not be able to reuse the same local port. This will not cause any problems because the customer uses the local port and does not care about the port number.
However, for the server, the situation is different, because the server uses a well-known port. If we terminate an existing
After establishing a connection to the server program and trying to restart the server program immediately, the server program will not be able
This well-known port is assigned to its endpoint because it is part of a 2 Mbit/s l connection. Before restarting the server program ~ 4 minutes.
Is an example of the impact of active server shutdown.



5. Maximum packet segment length

Max Segment Size indicates the maximum length of data that t c p transmits to the other end. When a connection is established, both parties must notify their respective MSS. When a connection is established, each party has the MSS option to be advertised to it (the MSS option can only appear in the SYN packet segment ). If one party does not receive the MSS value from the other, MSS is set to the default value of 5 3 6 bytes (this default value allows 2 0 bytes of I p header and 2 0 bytes of t c p header for 5 7 6 bytes of I P datagram ).
Example
Consider our host s l I p and connect to the router B S d I through the s L I P link with M T U 2 9 6. Figure 1 8-8 shows these systems and host s u n.



Initiate a t c p connection from s u n to s l I P, and use t c p d u m p to observe the packet segment. Figure 1 8-9 shows the creation of the connection (omitted the size of the announcement window ).



In this example, the message segment sent by s u n cannot exceed 2 5 6 bytes, because the m s option value it receives is 2 5 6 (2nd rows ). In addition, because s l I p knows that the M T U length of its outbound interface is 2 9 6, even if s u n has advertised that its M S is 1 4 6 0, to avoid data segmentation, however, it does not send packets with more than 2, 5, or 6 bytes of data. The data length allowed by the system is smaller than the MS value of the other end. Only when a host at one end is directly connected to a network with a size smaller than 5, 7, or 6 bytes can this segment be avoided. If both ends of the host are connected to the Ethernet, all use 5 3 6 m s, but the middle network uses 2 9 6 m t u, segmentation will also appear. Using the m t u discovery mechanism on the path is the only way to solve this problem. The MTU discovery mechanism on the path is an error message that uses ICMP to fragment but is set to not fragment bit (DF). This error message returns the next MTU. If the ICMP version used does not return the next MTU, you can only perform one test (set a series of test values) from large to small.

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.