I. TCP three-way handshake and four-way handshake
Flag space:
Syn (synchronous online)
Ack (acknowledgement confirmation)
Psh (push transfer)
FIN (finish)
RST (reset)
URG (Urgent urgent)
Sequence Number:
Sequence Number (sequential number) -- seq
Acknowledge number (confirmation number) -- ack
Format of the first handshake pack
There are a lot of articles on the internet about why TCP needs three handshakes when connecting, and four handshake when closing the connection. A lot of principles are spoken. So many people are hard to understand.In fact, there is only one sentence: The TCP connection is between two endpoints. Because the TCP connection is a reliable connection, it requires two endpoints to send the request and receive confirmation whether the connection is establi
1. Establish a connection protocol (three-way handshake)
(1) the client sends a TCP packet with SYN flag to the server. This is packet 1 during the three-way handshake.
(2) The server responds to the client. This is the first packet in the three-way handshake. This packet carries both the ACK mark and SYN sign. Therefore, it indicates the response to the client S
In the TCP three-way handshake process, which stage does accept occur in the three-way handshake?
The first handshake: the client sends the SYN Packet (SYN = J) to the server.The second handshake: when the server receives the SYN packet, it must confirm the customer's Syn (ACK = J + 1) and send a ask packet (ask = K )
TCP three-way handshake and TCP three-way handshakeFirst handshake
The client calls connect to send a connection request message to the server. The packet is a special packet. The first synchronization bit SYN = 1, and the confirmation bit ACK = 0, seq = x indicates that the value of the validation field is x. The value of this field is selected by the client, the first byte Number of the data sent from th
I. Details about TCP three-way handshake
In TCP/IP, TCP provides reliable connection services and uses three-way handshakes to establish a connection.
1. When a connection is established, the client sends a SYN packet to the server and enters the syn_send status. In this status, the client waits for the confirmation packet from the server.
2. After the server receives the SYN packet from the client, it first confirms to the client that it has received
, PSH = 1;
Reset RST. When rst = 1, it indicates a serious error occurred in the TCP connection. You must release the connection and then re-establish the connection;
Synchronize SYN, which is used to synchronize sequence numbers when a connection is established. When SYN = 1, ACK = 0, it indicates a connection request message. If you agree to the connection, the response message should make SYN = 1, ACK = 1;
Terminate fin to release the connection. When fin = 1, it indicates that the data of
This week, cloudflare announced that it began to provide the keyless service, that is, you put the website on their CDN, without providing your own private key, you can also use SSL encrypted links.
After reading cloudflare's instructions (here and here), I suddenly realized that this is an excellent example to illustrate the running mechanism of the SSL/TLS protocol. It is illustrated and easy to understand.
Next, I will use these images as an examp
This week, cloudflare announced that it began to provide the keyless service, that is, you put the website on their CDN, without providing your own private key, you can also use SSL encrypted links.
After reading cloudflare's instructions (here and here), I suddenly realized that this is an excellent example to illustrate the running mechanism of the SSL/TLS protocol. It is illustrated and easy to understand.
Next, I will use these images as an examp
It takes three handshake to establish TCP and four handshake to disconnect. The entire process is shown in the following illustration:
Let's take a look at how to establish a connection.
First, the client side sends the connection request message, the server segment accepts the connection and replies the ACK message, and allocates resources for this connection. The client side receives the ACK message and
Tags: network socket three-way handshake Three-way handshake:TCP creation requires three handshakes,First, the client sends a connection request packet. The server segment receives the connection and replies to the ACK packet, and allocates resources for the connection. After the client receives the ACK packet, it also generates an ACK packet to the server segment and allocates resources so that the TCP connection is established. four waves:
connection) status.
The above connection creation process is called three-way handshake.
Why does a send a confirmation?
The main purpose is to prevent the failure of the connection request packet segment from being suddenly transmitted to B, thus generating errors.
Ii. TCP connection release
650) This. width = 650; "src =" http://s5.51cto.com/wyfs02/M01/80/1B/wKioL1c4PjmjaG2qAACQqFm6byI323.jpg "Title =" l2.jpg "alt =" wkiol1c4pjmjar2qaacqqfm6byi323
Establish a connection
In TCP/IP, TCP provides reliable connection services and uses three handshakes to establish a connection.First handshake: when a connection is established, the client sends
SYN Packet (SYN = J)
Go to the server and enter the syn_send status. wait for confirmation from the server;
The second handshake: the server receives the SYN Packet and must confirm the customer's Syn (ACK =
The three-time handshake process is as follows:
To build a network environment:
Use Commview to grab the package (because it can catch the loop back to the package), open it, and capture 8888-port packets.
The server-side program is:
#include
Start the server, there is no package at this time.
The client program is:
#include Open the client, at this point observation commview, there are three packets, this is the TCP established three times
Turn from: http://apps.hi.baidu.com/share/detail/42639337
TCP Message Segment Header format:
Ordinal number: The ordinal number of the first byte of the data sent by this paragraph.
Acknowledgment number ack: expecting to receive the number of the first data byte of the next message segment
Confirm ack: 1 digits, the confirmation Number field is valid only when ack=1. Ack=0, the confirmation number is invalid
Synchronous syn: Used to synchronize serial numbers when the connection is established
The answer is: The Accept process occurs after three handshakes, and after three handshakes are completed, the client and server establish a TCP connection and can interact with the data. You can then call the Accept function to get this connection.TCP Accept SummaryAfter the TCP accept is a three-time handshake, accept correctly returns after the TCP Server can connect with the client is established and can communicateNote distinguish between the lis
server perspective, it only needs to send a request SYN, and then receives ack to know that the connection can be established.
Therefore, when establishing a connection, you only need to shake hands three times at least, that is, the server receives the client SYN, and then sends the ACK to the client and carries its own syn, in this way, only three handshakes are required to enable both sides to receive SYN and ack.
Of course, you can also use 4 or more handshakes when designing your own, but
There are many articles on the Internet that TCP why the connection requires three times to shake hands, close the connection requires four times handshake, said a lot of principles, but let a lot of people difficult to understand.
In fact, there is only one sentence: TCP connection is between two endpoints, because the TCP connection is a reliable connection, so whether to establish a connection or close the connection, requires two endpoints to sen
Turn from: HTTPS Unidirectional authentication Instructions _ digital certificate, digital signature, SSL (TLS), SASLBecause TLS + SASL is used in the project to do the security authentication layer. So read some online information, here to do a summary.1. First recommend several articles:Digital certificate: http://www.cnblogs.com/hyddd/archive/2009/01/07/1371292.htmlDigital certificates and ssl:http://www
": 1) Fortezza Key exchange2) encryption Algorithm3) Customer certificate. 6. Certificate_verify and finished messages: SSLv3.0 and TLS compute finished and SHA with certificate_verify and MD5 messages1 hash code, the calculated input is slightly different, but the security is equal. 7. Cryptographic calculation: TLS differs from SSLv3.0 in the way that the master secret is computed. However, both the cl
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.