Computer network - data link layer - implementation mechanism of reliable transmission: stop-wait protocol SW (confirmation and denial, timeout retransmission, etc., channel utilization and related exercises)

Table of contents

Stop-Wait Protocol SW

Confirm and Deny

Timeout retransmission

confirmed lost

confirmed late

Summary (notes)

SW channel utilization

Practice questions


The following article will introduce three reliable transmission implementation mechanisms, which are:Stop-wait protocol, fallback N-frame protocol and selective retransmission protocol . It should be noted that the basic principles of these three reliable transmission implementation mechanisms are not limited to the data link layer, but can be applied to
all aspects of the computer network architecture. In the layer protocol
, I hope that when learning, we should not limit our thinking to the data link layer, but should look at the entire network architecture.


Stop-Wait Protocol SW

This article introduces the stop-and-wait protocol, as shown in the figure below:

The sender and receiver communicate based on the Internet, rather than being limited to a point-to-point data link.

Confirm and Deny

The ordinate is time,the sendergivesthe receiverSend the data packet, and the receiver will perform error detection on it after receiving it; if there is no error, it will accept the data packet and send . ACK sends an acknowledgment packet, referred to as The sender

The sender can only send the next data packet after receiving the confirmation packet for the sent data packet; assuming that this data packet has a bit error during the transmission process, a>NAK sends a negative packet, referred to as The party performs error detection on it after receiving it. If a bit error is found, the data packet is discarded and sent to The receiver

After the sender receives the acknowledgment packet for the sent data packet, it knows that there is an error in the data packet it sent before and was The receiverrejects and immediately retransmits the data packet.

Therefore,the sender cannot delete the data packet from the cache immediately after sending it. The data packet can be deleted from the cache only after the confirmation packet is received.

From this process, after each data packet is sent by the sender, it stops sending the next data packet and waits for an acknowledgment packet or denial packet from the receiver.

  • If a confirmation packet is received, the next data packet can be sent;
  • If a negative packet is received, the previously sent data packet is retransmitted;

In this way, whatever the sender sends, the receiver will eventually receive, which is the so-called reliable transmission.

Timeout retransmission

But the actual situation is far more complicated than we imagined. Let’s look at this situation:

The sender sends a data packet to the receiver, but the data packet is lost during transmission.

It should be noted that this situation is not likely to occur for point-to-point channels at the data link layer; but for complex Internet environments where multiple networks are interconnected through multiple routers, this situation will often occur.

In this case,the receiver will not send confirmation or denial packets for no reason since it cannot receive the data packet. ; If no other measures are taken, the sender will always be in a state of waiting for the receiver to confirm or deny the packet.

To solve this problem, you can start a timeout when the sender finishes sending a data packet Timer; if the retransmission time set by the timeout timer is reached and the sender still cannot receive< /span> a>. timeout retransmission's confirmation or denial packet will retransmit the original data packet. This is called Receiver

Generally, the retransmission time can be selected to be slightly longer than the time from sender to receiver a>The average round trip time of , as shown in the figure below:

Sender times out and retransmits the previously sent data packet. The receiver correctly receives the retransmitted data packet and sends it to the sender Send a confirmation packet, The senderAfter receiving the confirmation packet, send the next data packet,Receiver. the senderAfter correctly receiving the data packet, send a confirmation packet to

confirmed lost

So far, it seems that reliable transmission can be achieved based on stopping waiting and using acknowledgment or denial packets, coupled with timeout retransmission. But please think about it more deeply: Will there be other situations where these current methods are not enough to achieve reliable transmission?

Let’s look at this situation:

Since the data packet sent by the sender may be lost, the acknowledgment or denial packet sent by the receiver may also be lost.

For example:
The sender sends a data packet. After the receiver correctly receives the data packet, it sends an acknowledgment packet to the sender, but the acknowledgment packet is lost during transmission. , this will inevitably cause the sender to timeout retransmit the previously sent data packet; assuming that the retransmitted data packet also reaches the receiver correctly, then the question now arises, how does the receiver determine whether the data packet is a duplicate? What about the grouping?

In order to avoid packet duplication such a transmission error, a sequence number must be given to each data packet , for example, the sequence number of the data packet is 0. For the stop-and-wait protocol, since every time a data packet is sent, it will stop and wait, as long as it ensures that every time a new data packet is sent < a i=5> Its sequence number is different from the sequence number of the last data packet sent. Therefore, it is enough to use one bit to number , that is, sequence numbers 0 and 1.

In this way, based on the sequence number of the data packet,the receiver can determine whether the data packet is repeated.

Receiver discards duplicate data packets and sends Sender for the data packet. Acknowledge the packet to avoid thesender from retransmitting the data packet over time again.

The sender can send the next data packet after receiving the confirmation packet for data packet No. 0. Its sequence number is 1, and receives it. After the party correctly receives the data packet No. 1, it sends a confirmation packet to the sender .

confirmed late

By confirming the loss of packets, we have raised the issue of numbering data packets. So do confirmation packets also need to be numbered?

Let’s look at this situation:

The sender sends the data packet No. 0, the receiver receives it correctly and sends Timeout retransmission of data packet No. 0. Sender sends a confirmation packet, which is late for some reason; this will inevitably lead toSender

During the transmission of the retransmitted data packet No. 0, the sender received the late confirmation packet, so it sent data No. 1 After receiving the retransmitted data packet No. 0, the receiver found that it was a duplicate data packet and discarded it.

And send a confirmation packet to thesender for this data packet to avoidthe senderTimeout again and retransmit the data packet.

Now comes the question:

We can clearly see that this is a duplicate confirmation of data packet No. 0; butthe sender how does it know? ?

If no other measures are taken,the sender will mistakenly think that this is the confirmation of data packet No. 1; if the confirmation packet is also Numbering can enable thesender to avoid this misjudgment, as shown in the following figure:

The sequence number of the ACK0 confirmation packet is 0.The sender knows that this is a duplicate confirmation packet through the sequence number of the confirmation packet, so it ignores it. Yes; Receiver correctly accepts data packet No. 1, and sends SenderSend an acknowledgment packet for this data packet, with the sequence number being 1. After the sender receives the acknowledgment packet, it sends the next data packet with the sequence number 0.

Please note that this data packet is not the same data packet as the previous data packet with sequence number 0.

We use the method of numbering confirmation groups to solve the problem of repeated confirmations caused by late confirmations.

It should be noted,

For point-to-point channels at the data link layer, the round-trip time is relatively fixed and there will be no late confirmation. Therefore, if the stop-and-wait protocol is only implemented at the data link layer, there is no need to number the confirmation packets.

Summary (notes)

  • When the receiving end detects an error in the data packet, it discards it and waits for the sender's timeout retransmission. However, for point-to-point links with high bit error rates, in order to make the senderretransmit as early as possible, it can also The sender sends a negative packet (NAK).
  • In order for the receiver to determine whether the received data packets are duplicates, the data packet number needs to be assigned. Due to the stop-and-wait characteristic of the stop-wait protocol, only 1 bit number is enough, that is, sequence numbers 0 and 1.
  • In order for the sender to determine whether the received acknowledgment packet is a duplicate, it is necessary to give theconfirmation packet (ACK) number, using The number of bitsis the same as the number of bits used for the data packet number. The data link layer generally does not have late acknowledgment packets. Therefore, when implementing the stop-and-wait protocol at the data link layer, it is not necessary to number the acknowledgment packets .
  • The timeout timer settingretransmission time should be chosen carefully. Generally, the retransmission time can be selected as slightly larger than the "average round trip time from the sender to the receiver".

The point-to-point round-trip time at the data link layer is relatively certain, and the retransmission time is relatively easy to set;

However, at the transport layer, it is sometimes not easy to set an appropriate retraversal time since the end-to-end round trip time is very uncertain.

SW channel utilization

Next, let’s take a look at the channel utilization of the stop-wait protocol, as shown in the figure below:

The abscissa is time. For the sake of simplicity, assume that there is a direct channel between the sender and the receiver.

The sender stops sending after sending a data packet and waits forthe receiver to respond Confirmation of data packets. After receiving the confirmation packet
, the next data packet can be sent, and so on.

This period of time is spent by the sender sending data packetsSending delay TD:

This period of time is between the sending and receiving partiesRound trip time RTT:

This period of time is spent by the receiver to send the confirmation packetSending delay TA :

The figure ignores the receiver's processing delay of data packets and the sender's processing delay of acknowledgment packets.

This is the total time elapsed by a sender using the stop-and-wait protocol from sending one data packet until the next data packet can be sent
:

Because it is only used to transmit useful data, that is, data packets, within time TD. Therefore, the channel utilization U can be calculated using the following formula:

TA is generally much smaller than TD and can be ignored; when RTT is much larger than TD, the channel utilization will be very low.

 For example:

As can be seen,

  • When the round-trip delay RTT is much larger than the data frame transmission delay TD (for example, using a satellite link), the channel utilization is very low.
  • If retransmission occurs, the channel utilization rate will be reduced for transmitting useful data information.
  • In order to overcome the shortcoming of low channel utilization of the stop-and-wait protocol, two other protocols have been produced, namely the fallback N-frame protocol GBN and the selective retransmission protocol SR.

Practice questions

According to the meaning of the question, you can draw a schematic diagram of the stop-wait protocol:

The channel utilization rate of the stop-and-wait protocol is equal to the transmission delay of the data frame divided by the transmission delay of the data frame plus the end-to-end round-trip delay
, which is twice the one-way propagation time delay.

Assume that the length of the data frame is x bits, and substitute it with the related known quantities given in the question into the above formula to get:

Therefore, the final answer is choice D.

Finally, a reliable transmission protocol implemented through acknowledgment and retransmission mechanisms, such as the stop-and-wait protocol, is often calledautomatic request
Retransmission protocol ARQ (Automatic Repeat reQuest)
, which means that the retransmission request is automatic, because the receiver does not need to explicitly request the sender to retransmit an erroneous packet.


END 


Study from: Lake University of Science and Technology - Computer Network Micro Classroom 

Guess you like

Origin blog.csdn.net/li13437542099/article/details/134866831