[Computer Network - Data Link Layer] Flow Control and Reliable Transmission Mechanism


Automatic Repeat reQuest (ARQ) restores the erroneous frame by requesting the sender to retransmit the erroneous data frame by the receiver.

1 Stop-and-wait protocol

For the convenience of discussion, let the sender be A and the receiver be B.

1.1 No error case

insert image description here

  • A sends the data frame DATA0, pauses sending after sending, starts the timeout timer , and waits for B's confirmation.
  • When B receives the data frame DATA0, it sends an acknowledgment frame ACK0 to A.
  • A receives the acknowledgment of the data frame DATA0 before the timeout timer expires , then sends the data frame DATA1, and then sends the data frame DATA0, and so on.

[Note] For the stop-wait protocol, because each time a data packet is sent, it stops waiting, as long as it is guaranteed that each time a new data packet is sent, its sequence number is different from the sequence number of the data packet sent last time, so use one bit to Numbering is enough, the serial numbers are 0 and 1. The same is true for acknowledgment frames.

1.2 There is an error condition - data frame error or loss

insert image description here

  • A sends the data frame DATA1, pauses sending after sending, starts the timeout timer , and waits for B's confirmation.
  • B receives the data frame DATA1, detects an error , and discards the data frame DATA1; or the data frame DATA1 is lost during transmission. At this point B will not send any information.
  • After A's timeout timer expires, but still does not receive the confirmation frame ACK1 , it is considered that the data frame just now is lost.
  • A retransmits overtime , resends the data frame DATA1, suspends sending after sending, starts the timeout timer , and waits for B's confirmation.

1.3 Error condition - ACK lost

insert image description here

  • A sends the data frame DATA1, pauses sending after sending, starts the timeout timer , and waits for B's confirmation.
  • B receives the data frame DATA1 and sends the confirmation frame ACK1 , but it is lost during transmission.
  • After A's timeout timer expires, but still does not receive the confirmation frame ACK1 , it is considered that the data frame just now is lost.
  • A retransmits overtime , resends the data frame DATA1, suspends sending after sending, starts the timeout timer , and waits for B's confirmation.
  • B receives the data frame DATA1, resends the confirmation frame ACK1 , and discards the repeated data frame DATA1.

1.4 Error condition - ACK is late

insert image description here

  • A sends the data frame DATA0, pauses sending after sending, starts the timeout timer , and waits for B's confirmation.
  • B receives the data frame DATA0 and sends the confirmation frame ACK0 , but encounters congestion during transmission and fails to transmit to A in time.
  • After the time-out timer of A expires, the confirmation frame ACK0 is still not received , and it is considered that the data frame just now is lost.
  • A retransmits overtime , resends the data frame DATA0, suspends sending after sending, starts the timeout timer , and waits for B's confirmation.
  • B receives the data frame DATA0, resends the confirmation frame ACK0 , and discards the repeated data frame DATA0.
  • A receives this round of acknowledgment frame ACK0 before the timeout timer expires , and sends data frame DATA1 again.
  • At this time, A receives the previous confirmation frame ACK0 , and A discards the repeated confirmation frame ACK0 .

1.5 Performance Analysis

insert image description here

Channel Utilization:

U = T D T + R T T + T A \begin{equation} U=\frac{T_D}{T+RTT+T_A} \end{equation} U=T+RTT+TATD

Because the confirmation packet length is much smaller than the data packet length: TA < < TD T_A<<T_DTA<<TD, so it can be simplified to:

U = T D T + R T T \begin{equation} U=\frac{T_D}{T+RTT} \end{equation} U=T+RTTTD

【Note】set time TTSendLL within TL bit data, the data transfer rate isCCC , then:

Channel utilization = LCT Channel utilization = \frac{\frac{L}{C}}{T}channel utilization=TCL

Channel throughput rate = channel utilization rate × sender's sending rate Channel throughput rate = channel utilization rate\times sender's sending ratechannel throughput=channel utilization×sending rate of the sender

1.6 Related Examples

[Example 1] Host A uses the stop-and-wait protocol to send data to host B, the data transmission rate is 3kbps, the one-way propagation delay is 200ms, and the transmission delay of the confirmation frame is ignored. When the channel utilization is equal to 40%, the length of the data frame is (D).

A. 240 bits

B. 400 bits

C. 480 bits

D. 800 bits

[Solution] Let the data frame length be xbxbx b , substitute the data to get:

Channel utilization = transmission delay of data frame transmission delay of data frame + one-way propagation delay × 2 40 % = xb 3 kb / sxb 3 kb / s + 200 ms × 2 \begin{align*} channel utilization &= \frac{Data frame transmission delay}{Data frame transmission delay + one-way propagation delay\times 2} \\ 40\% &= \frac{\frac{xb}{3kb/s}} {\frac{xb}{3kb/s} + 200ms \times 2} \end{align*}channel utilization40%=Data frame transmission delay+one-way propagation delay×2Data frame transmission delay=3kb/sxb+200ms×23kb/sxb

Solve x = 800 bx=800bx=800b

2 Back N frame protocol (GBN)

Sending window : the sender needs to maintain a sending window WT W_TWT, the sender can drop the sequence number into WT W_T without receiving the receiver's confirmation packetWTAll data packets within are sent out consecutively. Use n bits to number the packet, then WT W_TWTThe value range of is 1 < WT ≤ 2 n − 1 1<W_T≤2^n-11<WT2n1

【Note】If WT > 2 n − 1 W_T>2^n-1WT>2n1 , the receiver cannot distinguish between old and new data packets.

Receive window : the receiver needs to maintain a receive window WR W_RWR, only if it reaches the receiver correctly (no bit error) and the sequence number falls into WR W_RWRThe data packets within are received by the receiver. WR W_RWRThe value can only be 1.

For the convenience of discussing the problem, let the sender be A and the receiver be B, assuming that 3 bits are used to number the packet, then WT W_TWTThe value range of is 2~7, here take WT = 5 W_T=5WT=5

2.1 No error case

  • Initially:
data serial number 0 1 2 3 4 5 6 7 0 1 2
Sender A's WT W_TWT
Sender A has sent
Receiver B's WR W_RWR
Receiver B has acknowledged
  • Sender A sends WT W_TWTordinal 0 within:
data serial number 0 1 2 3 4 5 6 7 0 1 2
Sender A's WT W_TWT
Sender A has sent
Receiver B's WR W_RWR
Receiver B has acknowledged
  • Receiver B receives sequence number 0, and checks that sequence number 0 is WR W_RWRwithin, then receive and return ACK0, WR W_RWRMove forward one sequence number. After sender A receives ACK0, WT W_TWTMove forward one sequence number:
data serial number 0 1 2 3 4 5 6 7 0 1 2
Sender A's WT W_TWT
Sender A has sent
Receiver B's WR W_RWR
Receiver B has acknowledged
  • Next, sender A sends sequence number 1, the same process as before. After A sends the first 5 data, the situation is as follows:
data serial number 0 1 2 3 4 5 6 7 0 1 2
Sender A's WT W_TWT
Sender A has sent
Receiver B's WR W_RWR
Receiver B has acknowledged
  • Of course, the receiver does not have to send an acknowledgment packet for each data packet received, but can send an acknowledgment packet to the last data packet that arrives in sequence after receiving several data packets with consecutive sequence numbers . confirm . ACKn indicates that all data packets with sequence number n and before have been received correctly (for example, ACK4 indicates that sequence numbers 0~4 have been received correctly):
data serial number 0 1 2 3 4 5 6 7 0 1 2
Sender A's WT W_TWT
Sender A has sent
Receiver B's WR W_RWR
Receiver B has acknowledged

2.2 Overtime retransmission, rollback N frames

  • Initially:
data serial number 0 1 2 3 4 5 6 7 0 1 2
Sender A's WT W_TWT
Sender A has sent
Receiver B's WR W_RWR
Receiver B has acknowledged
  • Sender A finishes sending WT W_TWT5 data, sequence number 0 and sequence number 1 are no problem, receiver B returns ACK0 and ACK1 in turn, WT W_TWTSum WR W_RWRMove forward to the corresponding position. But the sequence number 2 has a bit error and is discarded by the receiver B, and at the same time repeatedly sends ACK1 ( the receiver must receive the data packets in order ); after that, B receives the correct sequence numbers 3 and 4, but because it does not fall into WR W_RWR, so they are all discarded, and B repeatedly sends ACK1 twice:
data serial number 0 1 2 3 4 5 6 7 0 1 2
Sender A's WT W_TWT
Sender A has sent
Receiver B's WR W_RWR
Receiver B has acknowledged
  • Sender A's retransmission timer for sequence number 2 has expired, but has not yet received ACK2 from B, so A resends WT W_TWT5 data (note that it is different from the initial data). This time receiver B receives the correct data and returns ACKs in sequence:
data serial number 0 1 2 3 4 5 6 7 0 1 2
Sender A's WT W_TWT
Sender A has sent
Receiver B's WR W_RWR
Receiver B has acknowledged

2.3 Related Examples

[Example 1] The data link layer uses the Back N frame (GBN) protocol, and the sender has sent frames numbered 0~7. When the timer expires, if the sender only receives the acknowledgment of frames 0, 2, and 3, the number of frames that the sender needs to resend is (C).

A. 2

B. 3

C. 4

D. 5

[Example 2] Host A and host B use the Back N frame (GBN) protocol to transmit data. A’s sending window size is 1000, the data frame length is 1000 bytes, and the channel bandwidth is 100Mbps. Every time B receives a data frame Just use a short frame immediately (ignoring its transmission delay) to confirm, if the one-way propagation delay between A and B is 50ms, then the maximum average data transmission rate that A can achieve is about (C).

【untie】

insert image description here

最大平均数据传输速率 = 可发送的数据量 数据帧的发送时延 + 单向传播时延 × 2 = 1000 × 8 × 1000 1000 100 × 1 0 6 + 50 × 1 0 − 6 × 2 = 80 M b p s \begin{align*} 最大平均数据传输速率 &= \frac{可发送的数据量}{数据帧的发送时延+单向传播时延 \times 2} \\ &= \frac{1000 \times 8 \times 1000}{\frac{1000}{100 \times 10^{6}} + 50 \times 10^{-6} \times 2} \\ &= 80Mbps \end{align*} 最大平均数据传输速率=数据帧的发送时延+单向传播时延×2可发送的数据量=100×1061000+50×106×21000×8×1000=80Mbps

3 选择重传协议(SR)

为了使发送方仅重传出现差错的数据分组,接收方不再采用累积确认,而需要对每一个正确接收的数据分组进行逐一确认。用 n ( n > 1 ) n(n>1) n(n>1)个比特给分组编号:

{ 1 < W R ≤ W T W T + W R ≤ 2 n \left\{ \begin{aligned} %\nonumber 1<W_R≤W_T\\ W_T+W_R≤2^{n}\\ \end{aligned} \right. { 1<WRWTWT+WR2n

因此有: 1 < W R ≤ 2 n − 1 1<W_R≤2^{n-1} 1<WR2n1

W R W_R WR取最大值 2 n − 1 2^{n-1} 2n1时, W R W_R WR也取最大值 2 n − 1 2^{n-1} 2n1

【注】为何如此取值?

  • 1 < W R ≤ W T 1<W_R≤W_T 1<WRWT W R W_R WR超过 W T W_T WT没有意义。
  • W T + W R ≤ 2 n W_T+W_R≤2^{n} WT+WR2n:确保接收窗口向前滑动后,落入接收窗口内的新序号与之前的旧序号没有重叠,避免无法分辨新旧数据分组。

现假设采用 3 个比特给分组编序号,则序号范围是 [ 0 , 2 3 − 1 ] [0,2^3-1] [0,231],发送窗口取最大值 W T = 2 3 − 1 = 2 2 W_T=2^{3-1}=2^2 WT=231=22,接收窗口取最大值 W R = 2 3 − 1 = 2 2 W_R=2^{3-1}=2^2 WR=231=22

3.1 有差错情况

  • 初始时:
数据序号 0 1 2 3 4 5 6 7 0 1 2
发送方 A 的 W T W_T WT
发送方 A 已发送
接收方 B 的 W R W_R WR
接收方 B 已确认
  • 发送方 A 发送 W T W_T WT内的序号 0~3:
数据序号 0 1 2 3 4 5 6 7 0 1 2
发送方 A 的 W T W_T WT
发送方 A 已发送
接收方 B 的 W R W_R WR
接收方 B 已确认
  • 接收方 B 只收到序号 0 和序号 2,序号 1 丢失,序号 3 误码被 B 丢弃。于是 B 发送 ACK0 和 ACK2:
数据序号 0 1 2 3 4 5 6 7 0 1 2
发送方 A 的 W T W_T WT
发送方 A 已发送
接收方 B 的 W R W_R WR
接收方 B 已确认
  • 发送方 A 针对序号 1 和序号 3 的重传计时器已经超时,所以重新发送序号 1 和序号 3。接收方 B 正确接收后发送 ACK1 和 ACK3:
数据序号 0 1 2 3 4 5 6 7 0 1 2
发送方 A 的 W T W_T WT
发送方 A 已发送
接收方 B 的 W R W_R WR
接收方 B 已确认
  • 发送方 A 收到 ACK 后,双方的滑动窗口向前移动,继续下一轮传输:
数据序号 0 1 2 3 4 5 6 7 0 1 2
发送方 A 的 W T W_T WT
发送方 A 已发送
接收方 B 的 W R W_R WR
接收方 B 已确认

3.2 相关例题

【例 1】数据链路层采用选择重传协议(SR)传输数据,发送方已发送了 0~3 号数据帧,现已收到 1 号帧的确认,而 0、2 号帧依次超时,则此时需要重传的帧数是(B)。

A. 1

B. 2

C. 3

D. 4

4 总结

协议 发送窗口 W T W_T WT 接收窗口 W R W_R WR
停止-等待协议 1 1 1 1 1 1
后退 N 帧协议 1 < W T ≤ 2 n − 1 1<W_T≤2^n-1 1<WT2n1 1 1 1
Select retransmission protocol 1 < W R ≤ W T , W T + W R ≤ 2 n 1<W_R≤W_T, W_T+W_R≤2^{n} 1<WRWT,WT+WR2n 1 < W R ≤ 2 n − 1 1<W_R≤2^{n-1} 1<WR2n1

Guess you like

Origin blog.csdn.net/baidu_39514357/article/details/130126282