Data Communication Computer Network 简明教程
Data-link Control & Protocols
数据链路层负责实现点对点流程和错误控制机制。
Data-link layer is responsible for implementation of point-to-point flow and error control mechanism.
Flow Control
当一个数据帧(第 2 层数据)通过一个介质从一个主机发送到另一个主机时,要求发送方和接收方以相同速度工作。也就是说,发送方以接收方能够处理和接收数据的速度发送数据。如果发送方或接收方的速度(硬件/软件)不同怎么办?如果发送方发送得太快,接收方可能会超载(淹没),数据可能会丢失。
When a data frame (Layer-2 data) is sent from one host to another over a single medium, it is required that the sender and receiver should work at the same speed. That is, sender sends at a speed on which the receiver can process and accept the data. What if the speed (hardware/software) of the sender or receiver differs? If sender is sending too fast the receiver may be overloaded, (swamped) and data may be lost.
可以部署两种类型的机制来控制流:
Two types of mechanisms can be deployed to control the flow:
-
Stop and Wait
这种流控制机制强制发送方在传输数据帧后停止并等待收到已发送数据帧的确认。
This flow control mechanism forces the sender after transmitting a data frame to stop and wait until the acknowledgement of the data-frame sent is received.
-
Sliding Window In this flow control mechanism, both sender and receiver agree on the number of data-frames after which the acknowledgement should be sent. As we learnt, stop and wait flow control mechanism wastes resources, this protocol tries to make use of underlying resources as much as possible.
Error Control
当传输数据帧时,数据帧在传输过程中可能会丢失,或者接收到时损坏。在这两种情况下,接收方都不会收到正确的数据帧,并且发送方对任何丢失的情况一无所知。在这种情况下,发送方和接收方都配备了一些协议,帮助他们检测传输错误,例如数据帧丢失。因此,发送方会重新传输数据帧,或者接收方可能会请求重新发送上一个数据帧。
When data-frame is transmitted, there is a probability that data-frame may be lost in the transit or it is received corrupted. In both cases, the receiver does not receive the correct data-frame and sender does not know anything about any loss.In such case, both sender and receiver are equipped with some protocols which helps them to detect transit errors such as loss of data-frame. Hence, either the sender retransmits the data-frame or the receiver may request to resend the previous data-frame.
错误控制机制的要求:
Requirements for error control mechanism:
-
Error detection - The sender and receiver, either both or any, must ascertain that there is some error in the transit.
-
Positive ACK - When the receiver receives a correct frame, it should acknowledge it.
-
Negative ACK - When the receiver receives a damaged frame or a duplicate frame, it sends a NACK back to the sender and the sender must retransmit the correct frame.
-
Retransmission: The sender maintains a clock and sets a timeout period. If an acknowledgement of a data-frame previously transmitted does not arrive before the timeout the sender retransmits the frame, thinking that the frame or it’s acknowledgement is lost in transit.
数据链路层可以使用以下三种类型的技术,通过自动重复请求 (ARQ) 来控制错误:
There are three types of techniques available which Data-link layer may deploy to control the errors by Automatic Repeat Requests (ARQ):
-
停止等待 ARQ 在停止等待 ARQ 中可能会发生以下转换:发送方维护一个超时计数器。在发送帧时,发送方将启动超时计数器。如果及时收到帧的确认,发送方将传输队列中的下一个帧。如果没有及时收到确认,发送方将假定帧或其确认在传输过程中丢失。发送方将重新传输帧并启动超时计数器。如果收到否定确认,发送方将重新传输帧。
. Stop-and-wait ARQ The following transition may occur in Stop-and-Wait ARQ: The sender maintains a timeout counter.When a frame is sent, the sender starts the timeout counter.If acknowledgement of frame comes in time, the sender transmits the next frame in queue.If acknowledgement does not come in time, the sender assumes that either the frame or its acknowledgement is lost in transit. Sender retransmits the frame and starts the timeout counter.If a negative acknowledgement is received, the sender retransmits the frame.
-
回退 N ARQ 停止等待 ARQ 机制无法充分利用资源。收到确认后,发送方将处于空闲状态,无所事事。在回退 N ARQ 方法中,发送方和接收方都将维护一个窗口。发送窗口大小使发送方能够在不接收前一个帧的确认下发送多个帧。接收窗口使接收方能够接收多个帧并确认这些帧。接收方将跟踪传入帧的序列号。当发送方在窗口中发送所有帧后,会检查已收到积极确认的序列号。如果所有帧都已得到积极确认,发送方将发送下一组帧。如果发送方发现已收到 NACK 或没有收到特定帧的任何 ACK,则会重新传输在此之后未收到任何积极 ACK 的所有帧。
. Go-Back-N ARQ Stop and wait ARQ mechanism does not utilize the resources at their best.When the acknowledgement is received, the sender sits idle and does nothing. In Go-Back-N ARQ method, both sender and receiver maintain a window. The sending-window size enables the sender to send multiple frames without receiving the acknowledgement of the previous ones. The receiving-window enables the receiver to receive multiple frames and acknowledge them. The receiver keeps track of incoming frame’s sequence number. When the sender sends all the frames in window, it checks up to what sequence number it has received positive acknowledgement. If all frames are positively acknowledged, the sender sends next set of frames. If sender finds that it has received NACK or has not receive any ACK for a particular frame, it retransmits all the frames after which it does not receive any positive ACK.
-
选择性重复 ARQ 在回退 N ARQ 中,假定接收方没有用于其窗口大小的任何缓冲器空间,并且必须在帧到达时处理每个帧。这会强制发送方重新传输未确认的所有帧。在选择性重复 ARQ 中,接收方在跟踪序列号的同时,将帧缓冲在存储器中并仅向丢失或损坏的帧发送 NACK。在这种情况下,发送方仅发送收到 NACK 的数据包。
. Selective Repeat ARQ In Go-back-N ARQ, it is assumed that the receiver does not have any buffer space for its window size and has to process each frame as it comes. This enforces the sender to retransmit all the frames which are not acknowledged. In Selective-Repeat ARQ, the receiver while keeping track of sequence numbers, buffers the frames in memory and sends NACK for only frame which is missing or damaged. The sender in this case, sends only packet for which NACK is received.