Yesterday we briefly talked about HTTP and HTTPS. Why do we say it is simple? Because it is just an explanation of the basic HTTP protocol and the security of HTTPS. Then some readers asked, why don’t we talk about some advanced content? Stop Waiting ProtocolBefore we understand the sliding window protocol, we need to first understand what the stop-and-wait protocol is and how it works. The stop-and-wait protocol is the simplest but most basic data link layer protocol. Many basic concepts of protocols can be learned from this protocol. Stop and wait means that after sending a packet, the packet stops sending and waits for the other party's confirmation. The next packet is sent after receiving the confirmation. In short, after the sender sends a data packet, if there is no confirmation from the other party, it will wait and not send the next data packet. After receiving the confirmation, it will continue to send data packets. picture This also makes the shortcomings of the stop-and-wait protocol particularly obvious.
The low efficiency is hard to imagine. For example, if our bandwidth is 100M and the stop-and-wait protocol only sends one data packet each time, this wastes bandwidth, not to mention that many bandwidths are now over a gigabit. Because of this efficiency issue, the stop-and-wait protocol is not very applicable, so other protocols have emerged, which is the sliding window protocol we will talk about next. Sliding Window ProtocolSo what is a sliding window protocol? The Sliding Window Protocol is an application of the TCP protocol, used for flow control during network data transmission to avoid congestion. The protocol allows the sender to send multiple data packets before stopping and waiting for confirmation. Since the sender does not have to stop and wait for confirmation after each packet is sent, the protocol can speed up data transmission and improve network throughput. In the sliding protocol, the sender needs to maintain a sending window. As the data is transmitted, this window needs to slide forward continuously. This is different from the stop-and-wait protocol. What is the difference? The difference is that it allows the sender to send multiple packets before stopping and waiting for confirmation, instead of just sending one packet each time like the stop-and-wait protocol. In this way, the sender does not need to stop and wait for each packet. This is the most essential difference between them. At this point, some readers may have questions: how many data packets will be sent at this time? The size of this data packet depends on a parameter, which we call the window size. Let's simply simulate the situation where there is no data loss under this sliding window protocol. picture In the figure above, the window size is 4, and our sender has 10 packets to send, which means that we can send four packets at a time. picture When the sender sends the first packet, does the sliding window start running at this time? Indeed, when we send the first packet, the sliding window starts running, which means that we can send packets with a window size of 4 before receiving the confirmation. After data packet No. 3 is sent, the corresponding confirmation messages of No. 0-3 are also fed back to the sender. At the same time, the windows began to slide to the left. picture We can also see from the figure that the parts that have been sent, are being sent, and are waiting to be sent are distinguished. The principle of the sliding window protocol can be seen as follows: The main principle of the sliding window protocol is to identify each data packet by using a sequence number and confirm the received data packet by using an acknowledgment number. The sender maintains a send window, which contains data packets that have been sent but not received an acknowledgment. The receiver maintains a receive window, which contains data packets that have been received but not delivered in sequence. When sending a data packet, the sender adds the sequence number of the data packet to the data packet and sends it to the receiver. After receiving the data packet, the receiver adds the confirmation number to the confirmation packet and sends it to the sender. After receiving the confirmation packet, the sender slides the sending window forward, removes the confirmed data packet from the sending window, and continues to send the next data packet. If the sender does not receive a confirmation packet within a certain period of time, or the receiver does not receive a correct data packet within a certain period of time, the sliding window protocol will trigger a timeout retransmission mechanism to resend the unconfirmed or incorrectly received data packet. The sliding window protocol can improve the efficiency and reliability of data transmission while making full use of network bandwidth. It is widely used in various network communications, such as the TCP protocol, which is implemented based on the sliding window protocol. Points to note about the sliding window protocol(1) The sender does not have to send a full window size of data. (2) A segment from the receiver acknowledges the data and slides the window to the left because the window size is relative to the acknowledgment sequence number. (3) The window size can be reduced, but the left edge of the window cannot be moved to the right. (4) The receiver does not have to wait for the window to be filled before sending an ACK. The right and left depend on the direction of the window movement when you understand the picture. I am used to it from right to left, you can also understand it as from left to right, the understanding is the same. So, do you understand the sliding window protocol? |
>>: IoT connections to grow 400% in four years
The 5G standards will gradually be released next ...
SoftShellWeb recently launched several VPS monthl...
Tomorrow is the end of the holiday. If you stay a...
API Gateway The reason for the emergence of API g...
I have calculated this once in an old article, bu...
The 2017 Huawei Connect Conference officially cam...
[[375985]] [51CTO.com original article] "If ...
Preface The COVID-19 pandemic has had an unpreced...
At the start of every new year, experts and forec...
The GSMA's in-house The Mobile Economy Report...
Fourth quarter results for fiscal year 2022: Sale...
SpartanHost has restocked the DDoS Protected SSD ...
Each device connected to the network needs a uniq...
"I missed Lenovo 10 years ago, but I cannot ...
Where does the “mutual trust” of the sharing econ...