局域网络可靠传输技术 -- 滑动窗口技术

版权声明:如果喜欢的话,可以撩我哟,此处没有联系方式,想要就自己找哈。 https://blog.csdn.net/qq_39384184/article/details/84558300

Introduction

Reliable Transmission:

  • Acknowledgements
    • An acknowledgement (ACK for short) is a small control frame that a protocol sends back to its peer saying that it has received the earlier frame.
      • A control frame is a frame with header only (no data).
  • Timeouts
    • If the sender does not receive an acknowledgment after a reasonable amount of time, then it retransmits the original frame.
    • The action of waiting a reasonable amount of time is called a timeout.

The general strategy of using acknowledgements and timeouts to implement reliable delivery is sometimes called Automatic Repeat reQuest (ARQ).


Stop-and-Wait protocol

Idea of stop-and-wait protocol is straightforward:

  • After transmitting one frame, the sender waits for an acknowledgement before transmitting the next frame.
  • If the acknowledgement does not arrive after a certain period of time, the sender times out and retransmits the original frame

Four different scenarios(情节) for the stop-and-wait algorithm:

  1. The ACK is received before the timer expires;
  2. The original frame is lost;
  3. The ACK is lost;
  4. The timeout fires too soon (or the ACK is delayed).

If the acknowledgment is lost or delayed in arriving:

  • The sender times out and retransmits the original frame.
  • As a result, duplicate copies of frames will be delivered.
  • To solve this:
    • Use 1 bit sequence number (0 or 1)
    • When the sender retransmits frame 0, the receiver can determine that this is a second copy of frame 0 rather than the first copy of frame 1 and therefore can ignore it.

Sliding Window Protocol

  • Sender assigns a sequence number denoted(为……名称) as SeqNum to each frame.
  • Sender maintains three variables:
    • Sending Window Size (SWS)
      • Upper bound on the number of outstanding (unacknowledged) frames that the sender can transmit.
    • Last Acknowledgement Received (LAR)
      • Sequence number of the last acknowledgement received.
    • Last Frame Sent (LFS)
      • Sequence number of the last frame sent.
  • Sender also maintains the following invariant: LFS–LAR ≤ SWS
  • Receiver maintains three variables:
    • Receiving Window Size (RWS)
      • Upper bound on the number of out-of-order frames that the receiver is willing to accept.
    • Largest Acceptable Frame (LAF)
      • Sequence number of the largest acceptable frame.
    • Last Frame Received (LFR)
      • Sequence number of the last frame received
  • Receiver also maintains the following invariant: LAF–LFR ≤ RWS

Cumulative Acknowledgement

  • Let SeqNumToAck denote the largest sequence number not yet acknowledged, such that all frames with sequence number less than SeqNumToAck have been received
  • The receiver acknowledges the receipt of SeqNumToAck even if high-numbered packets have been received: This acknowledgement is said to be cumulative.

Issues with Sliding Window Protocol

When timeout occurs, the amount of data in transit decreases, When the packet loss occurs, this scheme is no longer keeping the pipe full.

  • Negative Acknowledgement (NAK)
  • Additional Acknowledgement
  • Selective Acknowledgement

Select the window size:

  • SWS: Delay ✘ Bandwidth
  • RWS: = SWS

Finite(有限) Sequence Number:

  • Frame sequence number is specified in the header field, So has hinite size and It is necessary to wrap around.
  • MaxSeqNum: ≥ SWS+1, fault when ack lost.
  • MaxSeqNum: To avoid above case, if RWS = SWS, SWS < (MaxSeqNum+1)/2

Examples:

在这里插入图片描述

在这里插入图片描述

Sliding Window Protocol provides three features:

  • Reliable Transmission
  • Preserve the order
    • Each frame has a sequence number.
    • Out of order frames will be buffered.
  • Flow control
    • Receiver is able to throttle(压制) the sender by setting the value of RWS.
    • Keeps the sender from overrunning the receiver.

想了解更多关于计算机网络架构与网络安全:计算机网络架构与网络安全专栏

猜你喜欢

转载自blog.csdn.net/qq_39384184/article/details/84558300