Wireshark talking about tcp three-way handshake

Source: Internet
Author: User

Wireshark talking about tcp three-way handshake
Capture Data Packets:
Open wireshark --> Capture --> interfaces --> select Nic --> start
Open the browser, enter www.xiyou.edu.cn, and close the browser after the web page is opened successfully.
Click stop in wireshark to stop capturing data)
Analyze Data Packets:
Filter out SYN packets sent from the Local Machine

Wireshark sets a stream index for each tcp connection, so the stream index is 7 here for analysis!
The principle of stream index is not complex. It can be calculated using the tuples of TCP. This is calculated by wireshark in advance.

Three-way handshake packet analysis
First handshake

Seq = 0 no validation number ACK = 0 (notset) SYN = 1
Second handshake

Seq = 0 ack = 1 ACK = 1 SYN = 1
Third handshake

Seq = 1 ack = 1 ACK = 1 SYN = 0
After the three handshakes, a tcp connection is established. The process is simplified as follows:

Let's talk about it again.
The server first creates a transmission control block TCB, prepares to accept client connection requests, and then the server is in the listen status waiting for client connection
The first handshake: the client also needs to create a TCB before connecting and then send a connection request to the server. At this time, the synchronization bit SYN in the header is set to 1, and there is an initial serial number (seq = 0); TCP rules, SYN packets cannot carry data, but also consume a serial number when the message is sent, the client enters the SYS-SENT status
The second handshake: After the server receives a request from the client to connect to the Message segment, if you agree to establish a connection, send a confirmation message to the client. In the confirmation message segment, set both SYN and ACK to 1, the confirmation number is ack = 1 (the seq value in the client is + 1, indicating that the server wants the client to send a message number 1 next time ), at the same time, the server will also select a serial number (seq = 0) for the confirmation message sent this time, and cannot carry the data to consume a serial number, and finally the server enters the SYN-RECD status
The third handshake: after the client is confirmed by the server, it must also send a confirmation to the server. The ACK of this packet segment is set to 1, check no. ack = 1 (seq value in SERVER + 1). The serial number is the seq value of the last sent message + 1, that is, seq = 1. TCP specifies that ACK packets can carry data! However, if no data is carried, no serial number is consumed. Therefore, the sequence number of the next data packet is seq = 1. So far, the TCP connection has been ESTABLISHED and the client enters the ESTABLISHED status, the server enters the ESTABLISHED status after receiving the confirmation message from the client.

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.