There is some introduction to THE TCP protocol, just to show that this is a reliable protocol, transport has reliability. Now want to specialized analysis of some, TCP in order to ensure the reliability of transmission, to provide what function? Or how? (All initial packet operations are network card operations) Establish reliable links (three-way handshake)
First, a connection channel is established before TCP communication. Before establishing this channel, a judgment is required. This is the essence of the three-way handshake:
Three handshake protocol
Step 1: Host A sends A SYN/Seq signal to host B. SYN is A flag bit, which is A synchronization sequence number. When TCP is established, it is set to 1, and Seq is the packet sequence number. In this case, host A is in the SYN/SEND state and waits for A reply from host B. If host A does not receive A reply from host B within A certain period of time, host A resends the packet. Assume that SYN/ SEQ is SYN=1 and SEq =200
(The seQ, or sequence number, represents the number of each byte in the data to be sent. Here we need to know that the data to be sent is sometimes too large to be sent all at once, so in TCP it is sent several times.)
Step 2: if host B in network transmission, host A send data is not lost, the host B received, at that time the host B and parses the sending host A Seq data, through in the host A serial number, which is judged Seq, behind needs to send data from which one begins to send, here are A few main functions: 1. To prevent SYN attacks, host B, as the receiving end, sends an ACK to host A. However, if host A fails to receive the ACK, host A resends the ACK to ensure channel connectivity. In this case, host B is in ayN-send state after sending an ACK. At this time may be malicious to receive a lot of unnecessary data, waste resources. 2. It also receives A repetitive SYN from host A (if not received by ACK). 3. You can use the serial number to determine where to read the next data and recombine the data. Ensure sequential and data reliability.
Host B will send A SYN/ACK/ SEQ /ACK signal to host A after receiving the SYN/ SEQ data from host A. The state becomes SYN_REVD and can receive data, during which SYN attacks are vulnerable. The signals that are then returned are SYN=1, ACK=1(confirming the connection), SEq =200, ACK= 201(starting from 201 sequence number next time)
Step 3: If the response from host B is not lost, host A receives the SYN/ACK/ SEq /ACK signal. At this time, host A changes to Established and connects again to send data to host B based on this signal.
That’s the three handshakes.
In addition we have involved speak some of the content above, and retransmission control (control), confirmation reply processing (host B sent to host A confirmation reply), repetitive control (host B after repeating took over, how to control whether receive), by the SYN flag bit and seq response number serial number and confirmation of control, you can think about, The answers are all up there.
Four wave protocol
So that’s about three handshakes, and then what happens when you need to disconnect. As shown in the figure:
That’s the four-wave protocol.
Sliding Windows control the flow of traffic
In A TCP connection, if the connection is established, this time it will send packets, in the process of sending data packets, if the receiver can not receive timely (sent to B, B, when they are sent to A network congestion, here basically need to know in the process of TCP connection, the sender and the receiver is full duplex, Both can work at the same time (sending and receiving), so the sender will need to control to avoid data loss. Sliding window control can realize flow control to the sender.
If packet confirmation is required for each data transfer, the longer the round trip, the greater the throughput of the network. The concept of Windows was introduced to solve this problem.
In general, TCP transmissions are segmented and sharded, while Windows can transmit in larger units without waiting for each acknowledgement. But after the final transmission is complete, a confirmation reply is made throughout the window. If something is lost, it will be retransmitted.
Here we’re going to think of the size of the sliding window as the size of the buffer. The size of this buffer is configurable.
Send window
Is the sequence number of frames that the sender is allowed to send consecutively. The maximum number of frames a sender can continuously send without waiting for a reply is called the size of the sending window.
Receiving window
The serial number list of frames allowed to be received by the receiver. The receiver must process the frames that fall inside the receiving window, and the frames that fall outside the receiving window are discarded. The number of frames a receiver is allowed to receive at a time is called the size of the receive window. Online sliding window function media.pearsoncmg.com/aw/ecs_kuro demonstration… Ork_7 / the cw/content/interactiveanimations/selective – repeatprotocol/index. The HTML TCP window is the unit of byte, not a message, the sender sends the window cannot be more than the receiver to receive the value of the window.
The concept of the size of the sent data.
When establishing a connection, the maximum message length (MSS) that can be received by the receiver is determined by the three-way handshake.
About Flow Control
Is to control the sending end according to the receiving end can receive the actual capacity to control the size of the data sent. Stored in the TCP header. There are receivers to set up. However, if the buffer on the receiving end overflows, the window size also becomes smaller and is sent to the receiving end.
Conclusion: Some of the protocols mentioned above, including three-way handshake, four-way wave, flow control and sliding window, are the guarantees of TCP to ensure reliable connections.
Thank you for reading my article, it is not easy to organize, like to help me point a like, thank you ha.