Tcp syn and ACK

Source: Internet
Author: User

TCP protocol :::

Three-way handshake:
The code bit in the first segment of the handshake is set to SYN, and the serial number is X, which indicates that a handshake is started. After receiving this segment, the receiver sends it back to the sender. Set the code bit to SYN and ACK, set the serial number to Y, and confirm that the serial number is set to x + 1. After receiving this segment, the sender knows that TCP data can be sent. Therefore, the sender sends an ACK segment to the receiver, indicating that the connection between the two parties has been established.
Client --> set SYN flag serial number = J, confirmation number = 0 ----> Server
Client <-- sets the SYN flag to set the ACK flag serial number to K, and the confirmation number is J + 1 <-- Server
Clinet --> set ACK flag serial number = J + 1, confirmation number = k + 1 --> Server
Initiator A and receiver B
A sends a SYN packet to B, B returns a [SYN, ack] to B, and a returns an ACK packet to B;

Data exchange:
A ---- "B
A has sent data, (PSH, ACK) aseq = x, ACK = Y, datalen = z
B receives (ACK) bseq = aack, back = aseq + Alen, datalen = blen
B sent data (PSH, ACK) bseq = bseq + blen, back = back, datalen = blen
A confirm acceptance (ACK) aseq = back, aack = bseq + blen
Note: The PSH mark indicates that the receiving end should submit the data to the application layer as soon as possible. According to my protocol analysis experience, in the data transmission phase, almost all data packets are sent with PSH bits, while the ACK flag is always set in the data transmission phase.

In the data transmission phase, data transmission at the application layer is as follows: (we assume that the serial number = 55555 in the final confirmation package of the client in the connection phase, and the confirmation number = 22222)
Client --> set the PSH mark, set the ACK mark serial number to 55555, the confirmation number to 22222, and the packet length to 11 ---> Server
Client <-- sets the ACK flag, serial number = 22222, confirmation number = 55566 (= 55555 + 11), and data packet length = 0 <--- Server
Client <-- set the PSH mark, set the ACK mark serial number to 22223, the confirmation number to 55566, and the packet length to 22 <--- Server
Client --> sets the ACK flag, serial number = 55566, confirmation number = 22244 (= 22222 + 22), and data packet length = 0 ---> Server
//////////////////////////////////////// //////////////////////////////////////// /////////

 

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.