Important things say three times: ARQ protocol

I have encountered a problem recently. I bought a server in Ali Cloud and used it to build a “service service for Internet information”. My home is telecom broadband, very smooth, but inexplicably, can’t work well in the company. The company is also the broadband service of Telecom, which is the company’s telecom broadband service for the dedicated office park.

I have been complaining with the company for a long time, they can’t solve it, saying that I have issued a request from the server, I can only go to the operator after leaving the company, I can only complain the operator. This excuse is really good. The reason is nothing. Check, it is certainly unable to solve it, it is good, not to manage these troubles.

Later, my colleague told me a magical tool, as well as the solution, and finally saved the country. I took the service on the Ali Cloud server, bridged my home, and then in the company, I would connect to the server in my own home. In order to keep your home and Alibaba Cloud, I need to build a reliable tunnel. Here is an ARQ protocol. I didn’t know what ARQ. I looked at Wikipedia today. I feel that it is still very interesting. This article introduces what is ARQ.

Remember: important things say three times

The full name of ARQ is Automatic Repeat Request, don’t ask me why I choose these three uppercase letters, I also think that chooses to be very strange, it is estimated that there is a certain rule of capital abbreviation, I don’t know. But from the literal meaning, it is said that the request is sent once again. It’s as if you talk to others, the man didn’t hear it, you will say it again, until he heard it, this is like we joking: important things say three times. Just a metaphor.

From this name, we can understand another thing. Although ARQ is called a protocol, it is more like a strategy, or a solution suggestion, how to implement, there are many The way, there are also many variants, and this problem will be said.

ARQ, can also be an abbreviation of Automatic Repeat Query, is a confirmation in data transfer (Acknoledgements, the ACK we often say, the recipient sends a message, telling the sender, if you have received a package correctly) And timeout (Timeouts, waiting for a certain time period waiting for a confirmation message) mechanism, in an unreliable network, implement reliable data transmission error control method. If the sender does not receive a confirmation before the timeout, the corresponding encapsulation is usually re-transmitted until the confirmation is received or retryed more than a certain number of times.

Wikipedia Automatic REPEAT Request

Sacrifice: ARQ is generally implemented in the data link (TATA LINK) and Transport layer

FAQ’s common strategy

There are many common strategies: ARQ protocol:

Stop and wait for ARQ (stop-and-wait arq): This is the most simple ARQ implementation, used for both ends of remote communication, ensuring that messaging does not have missing and sequential arrival. In a word, this strategy is that every word, you have to confirm that the second sentence is said, otherwise it will repeat the previous sentence. Obviously, this way is serial sending message frame, and waiting for confirmation to continue, one frame of content is to wait for a shortest time, sometimes add timeout, so the efficiency is very low, the speed is also very Slow, it is very simple to achieve. This protocol is very prone to problems. For example, the recipient’s confirmation message is lost, or the confirmation is too slow, resulting in the sender waiting for too long, the sender will be reissued, and the resulting party receives two-same frames. At this time, the recipient cannot confirm that the last frame is repeated, or there is a new frame. The sender may also receive two confirmation, which cannot be identified whether the same frame is still different. So, this protocol will add a bit (bit) serial number. When the value is only 0 or 1, the receiver is received, it is based on 010101 … such a staggered order, otherwise it is repeated frame, simple discarding It is possible, the confirmation received by the sender also has serial numbers and uses the same policy processing. So, this ARQ is also called “ALTERNATING BIT Protocol);

Back n-frame ARQ (Go-Back-N ARQ): This protocol is relatively above, in fact, in fact, with the idea of ??co-ordination, under this strategy, the sender is waiting for the timeout, can continue to send the data frame, The number of frames, the size of the window, the size of the window, obvious window size, the timeout, data transmission speed match, is a selection of comparison optimization. Similarly, all sending frames have serial numbers, the receiver is strictly accommodated in accordance with the serial number, first receive 1, receive 2, if this is lost, one 4, then the reception party will discard. At the same time, each of the recipients must confirm a serial number, which is the effective maximum number of the valid, in this example, the recipient has been confirmed 2. After all the frames are sent, the sender checks the biggest valid confirmation, then from the largest valid confirmation, the sender has started, for example, the sender has sent to 8, but because of the largest valid confirmation Only 2, then you must resend from 3. In fact, the TCP protocol, which is used is this ARQ policy (variant). From this mechanism, it can be seen that this protocol is characterized by a sliding window, but this window only exists on the sender, the recipient is just a frame of frame processing data, so there is still a lot of waste, some information It will send multiple times repeatedly. If you pick up the unwanted frame, you can quickly use it, you can use it in the future, you can increase efficiency, which will lead to another policy; selective retrans / reject ARQ (Selective Repeat / Reject ARQ): It is actually understood that this is easy, that is, the received non-expected frame is caught up, then tell the sender which frame is missing, the server will not be reissued continuously, and only the recipient’s missing frame If the reception is numbered, the number is quickly forwarded, which greatly reduces the repeated transmission of the data and improves efficiency.

Retreat diagram of N-frame ARQ (a) and selective resend ARQ (b)

Summarize

ARQ is a policy that is incorrectly controlled during data transmission, ensuring data integrity and sequentiality. The core is a reliable data transmission on an unreliable network. For example, there is a wide range of applications in the fields of short-wave radio transmission, GSM network, telegraphs. In today’s complex internet environment, some point-to-point transmission services are also not so reliable for various reasons, and can consider introducing an ARQ policy.

In terms of server-side development, ARQ’s idea can also give us a lot of inspiration when the service is implemented. In addition, this kind of strategy learning and understanding is the basis for understanding more complex network protocols.