In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
TCP (Transmission Control Protocol, Transport mastery Protocol) is a convergence-oriented, reliable, word-saving-based communication protocol. Data should establish convergence before transmission and disconnect after transmission.
The client should use the connect () function to set up the connection with the server before sending and receiving data. The goal of establishing convergence is to ensure the accuracy of IP addresses, ports, physical links, and so on, so as to open up channels for data transmission.
When TCP sets up the connection, it transmits three data packets, commonly known as the three-way handshake (Three-way Handshaking). An abstract example can be the following dialogue:
[Shake 1] socket A: "Hello, socket B, I have no data to send to you, set up the connection."
[Shake 2] socket B: "OK, my side is ready."
[Shake 3] socket A: "Thank you for accepting my plea."
TCP Datagram construction
Let's first look at the construction of the TCP Datagram:
Several fields with shadows need to be highlighted:
1) sequence number: the Seq (Sequence Number) sequence number occupies 32 bits, which is used to identify the sequence number of the data packet sent from computer A to computer B. when the computer sends data, it is marked to stop.
2) confirmation number: Ack (Acknowledge Number) confirmation number occupies 32 bits, which can be sent by both client and server, Ack = Seq + 1.
3) Mark bits: each mark bit occupies 6 1Bit, which can be identified as URG, ACK, PSH, RST, SYN, FIN. The details are as follows:
URG: the pressing pointer (urgent pointer) is invalid.
ACK: confirm that the serial number is invalid.
PSH: the receiver should deliver this message to the user layer as soon as possible.
RST: reset the connection.
SYN: set up a new connection.
FIN: disconnect a connection.
Summary of English acronyms: Seq is the abbreviation of Sequence, performance sequence; Ack (ACK) is the abbreviation of Acknowledge, performance confirmation; SYN is the abbreviation of Synchronous, preferring to be "synchronous", here shows the establishment of synchronous cohesion; FIN is the abbreviation of Finish, the performance is complete. The establishment of cohesion (three-way handshake)
When using connect () to set up the connection, the client and the server will send three packets to each other, please see the following figure:
After the client misappropriates the socket () function to create the socket, the socket is in the CLOSED form because there is no connection; after the server misappropriates the listen () function, the socket enters the LISTEN form and begins to listen for client requests.
At this point, the client begins to propose and plead:
1) when the client misappropriates the connect () function, the TCP protocol will form a packet and set the SYN flag bit to show that the packet is used to establish synchronous connection. At the same time, a random number 1000 is generated, and the "Seq" field is filled in to represent the serial number of the packet. Complete these tasks, start sending packets to the server, and the client enters the SYN-SEND form.
2) when the server receives the data packet and detects that the SYN flag bit has been set, it knows that this is a "plea packet" sent by the client to establish convergence. The server also sets up a packet and sets the SYN and ACK flag bits. SYN shows that the packet is used to establish connectivity, and ACK is used to confirm the receipt of the packet just sent by the client.
The server generates a random number 2000 and populates the "Seq" field. 2000 has nothing to do with client packets.
The server increments the client packet serial number (1000) by 1, loses 1001, and populates the "Ack" field with this number.
The server takes back the packet and enters the SYN-RECV form.
3) when the client receives the data packet and detects that the SYN and ACK flag bits have been set, it knows that this is a "confirmation packet" sent by the server. The client detects the confirmation number (Ack) field to see if it has a value of 1000 to 1, and if so, clarifies the connection and establishes victory.
Next, the client will continue to build the packet and set the ACK flag bit to show that the customer has accepted the "acknowledgement packet" sent by the server. At the same time, add the packet serial number (2000) sent by the server to 1, lose 2001, and use this number to fill in the "Ack" field.
The client takes back the data packet and enters the ESTABLISED form, showing that the convergence has been successfully established.
4) when the server receives the data packet and detects that the ACK flag bit has been set, it knows that this is an "acknowledgement packet" sent by the client. The server detects the "confirmation number (Ack)" field to see if it has a value of 2000. If so, it clarifies the convergence to establish victory, and the server enters the ESTABLISED form.
At this point, the client and server have entered the ESTABLISED form, convergence to establish victory, and then you can send and receive data.
The initial clarification
The crux of the three-way handshake is to confirm that the other person has received his or her packet, which is accomplished through the "confirmation number (Ack)" field. Calculate the opportunity to record the serial number of the data packet I sent Seq. After receiving the other party's data packet, check the "confirmation number (Ack)" field to see whether Ack = Seq + 1 can be established. If it is true, you have received your own data packet.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 258
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.