TCP connection Establishment
In order to establish a TCP connection, the computer needs to do the following for us: 1. the requester (usually called the customer) sends a SYN segment to indicate the server port to which the customer intends to connect and the initial serial number (ISN ). This SYN segment is Section 1 in the following UML. 2. the server sends back the SYN packet segment containing the server's initial serial number (Segment 2 in the UML diagram below) as the response. At the same time, set the serial number to the customer's ISN plus 1 to confirm the customer's SYN packet segment. 3. the customer must set the validation serial number to ISN plus 1 of the server to confirm the SYN packet segment of the server (segment 3 in the UML diagram below ). the three packets are connected. This process is called the three-way handshake ). The end that sends the first SYN will execute active open ). Receive the SYN and send it back to the other end of the next SYN for passive open ). The following uses the PlantUML language to draw flowcharts to help you better understand the establishment of TCP connections. Here we provide the tools and source code used in the author's drawing process, so that there is a truth in the diagram, you can make any modification. :-)
Autonumberparticipant ipant clientparticipant ipant servernote over client. Both the initial status of serverclient and server are in CLOSEDend noteclient-> server: SYN (SEQ = x) activate clientnote left: Step 1 of three handshakes, \ n then the client is in the SYN_SENT state clientactivate servernote right: step 1 of the three handshakes, \ n then the server is in the SYN_RCVD State client-> server: (SEQ = x + 1, ACK = y + 1) deactivate clientdeactivate servernote left of client: step 1 of the three handshakes. \ nclient confirms that the server SYN, \ n is in the ESTABLISHED status note right of server: after the SYN of the server is confirmed by the client, \ nserver also enters the ESTABLISHED status note over client, and the three handshakes of serverend, both the client and server enter the ESTABLISHED status. From now on, both parties can transmit data. end note # + END_SRC