directory

1. Data link layer

2. Encapsulation into frames

Three, error detection

Four, reliable transmission

1. Stop waiting for the agreement

2. Sliding window protocol

3. Select the retransmission protocol

Five, the summary

1. Data link layer

This article describes the data link layer in a five-tier protocol architecture. This layer is the lower layer of the computer network. The figure below shows the role of the data link layer in data transmission.

A link is a physical line from one node to a neighboring node, with no other intersecting nodes in between. It can be understood that the path through which two computers communicate with each other contains many such links.

A data link is a line containing communication protocols, including hardware and software implementations, used to transmit data.

In the data link layer, there are three important problems: encapsulation into frames, error detection and reliable transmission. Let’s take a look at what it is, focusing on how reliable transmission works.

2. Encapsulation into frames

The unit of transmission at the data link layer is frame. The IP datagram at the network layer becomes the data part of the frame, and then the head and tail of the frame constitute a complete data frame. The frame header and the frame tail serve as frame boundaries and contain some necessary control information.

The length of the data portion of the frame is specified, and the maximum Transmission unit (MTU) value is the upper limit (1500 bytes).

** Frame delimiters mark the start and end of a frame. ** Transparent transmission problem occurs if frame delimiters are present in data. Transparent transmission means that there is no restriction on upper-layer data transmission. The data link layer needs to provide transparent transmission services.

Therefore, the method of byte filling is adopted, and the escape character is inserted before the marking character, which solves the problem of transparent transmission.

Three, error detection

In order to detect errors at the data link layer, an error checking field is set at the end of the frame, which uses cyclic redundancy check (CRC) technology ** for error detection.

Here does not make the specific introduction, in the computer composition principle has the detailed principle introduction and mathematical calculation process.

CRC has a disadvantage that it can only detect errors but not correct them. This requires the use of error correction code forward error correction, but the cost is very high, generally not used in computer networks. The real solution is to retransmit or discard the wrong frame. The following method in reliable transmission solves the problem of data error/loss.

Four, reliable transmission

Reliable transmission is the implementation of reliable service over an unreliable channel. It looks very abstract, but here’s a better picture.

The service provided by reliable transmission, shown on the left, is implemented by a two-way unreliable channel, shown on the right.

Unreliable channel transmission can cause errors, loss, duplication, or disorder, so to achieve reliable service, reliable transport protocols need to communicate in both directions over unreliable channels.

The principle of reliable transmission is not only in the data link layer, but also used in TCP protocol to realize reliable service.

The implementation of reliable transmission involves a number of protocols, which are constantly updated to optimize the transmission efficiency.

1. Stop waiting for the agreement

** Stop-and-wait protocol (SW, stop-and-wait) ** has been through a process of improvement. The way to achieve reliable transmission is to retransmit when an error is found.

Initially, the protocol stipulated that received data would be acknowledged (ACK) and denied (NAK). Later, I didn’t think it was necessary to use the denial mechanism. On the one hand, it was more complicated to implement and on the other hand, it was less efficient.

Another good idea, therefore, is to start a timeout timer after the sender finishes sending a piece of data and turn on the timeout retransmission mechanism. It turns out that the protocol is simpler and more responsive than NAK to solve errors at all.

At this point, the problem of data error and loss is solved, but there is another situation, the problem of data duplication. The sending sequence number was added later to solve the problems of sequence and duplicate data.

The acknowledgement and timeout retransmission mechanism implements this protocol, so it also becomes automatic request retransmission (AQR).

For the data link layer, the round trip time of point-to-point communication is determined, and timing problems are not likely to occur. In this layer, the implementation of SW protocol can not number data groups.

The stop-wait protocol is simple to implement, but the disadvantage is that the channel utilization is low, sending a packet at a time and then confirming, wasting many idle resources. Therefore, to further improve the pipeline transmission method to improve the channel utilization, the following sliding window protocol is introduced.

2. Sliding window protocol

The concept of sliding window comes from the fact that the sending window keeps sliding forward during the working process of the protocol, so it is called sliding window protocol.

The send window is used to limit the number of data packets that can be sent continuously when the pipeline transmits data. From this point of view, is a continuous AQR protocol.

The sender needs to maintain a sending window: the range of numbers of packets that the sender has sent but has not received acknowledgement. The window size is the maximum number of unacknowledged packets that the sender has sent.

The sending window then slides forward one unit after the sender receives an acknowledgement.

Working process:

(1) ** The receiving party only receives the groups in sequence. ** When it receives an out-of-order packet, it discards it and recognizes the ordered packet. If also defined as a window, the size of the receiving window is 1.

(2) ** The receiving party shall adopt the method of cumulative confirmation. ** After n packets are received, the last packet arriving in sequence is confirmed.

(3) The sender uses the timeout retransmission mechanism to retransmit the incorrect or lost packets. If an error occurs in a packet, all packets sent after the packet need to be retransmitted. If the packet is returned, the sent N packets need to be retransmitted. Therefore, it is called the Rollback N-frame protocol (GBN).

The whole process can be found that the GBN protocol is based on the SW protocol to modify the sender’s algorithm, the receiver’s algorithm remains unchanged.

3. Select the retransmission protocol

The GBN protocol greatly improves channel utilization, but there is a problem with its name! Rolling back N frames means that a packet error may result in a large number of packets being retransmitted, but these may have all been correctly received by the receiver because they did not arrive in order.

Therefore, the ** choice retransmission Protocol (SR) ** was born to solve this problem.

As mentioned above, the receiver of the GBN protocol can be regarded as maintaining a receiving window of size 1, so to solve the problem of repeatedly sending unnecessary packets, the receiver enables the caching mechanism, and the receiving window size is no longer 1. Of course, we can no longer use the cumulative confirmation method, but to confirm each group one by one. The receiver caches to hold packets that do not arrive in order.

SR protocol is obviously much more complex than GBD protocol.

The figure above shows an example of how the SR protocol works. You can see that with the caching mechanism, the receiver is able to retransmit only the wrong groups, improving efficiency.

Five, the summary

The data link layer data transmission principle as described above, it is fascinating to find that the unreliable channel with a suitable reliable protocol (SW, GBN, or SR) can provide reliable service upward. However, the current performance of wired network has greatly reduced the probability of error in the transmission process, and the confirmation and retransmission protocols can not be used at the data link layer. But for wireless channel transmission, there is still a relatively high bit error rate, so the data link layer still needs to achieve reliable transmission to provide services for the upper layer.

Of course, in this article, I mainly record and learn several important contents of the data link layer, including encapsulation into frames, error detection and reliable transmission. The focus is on the specific contents of several protocols to achieve reliable transmission. The knowledge of the data link layer is more than that. There are also ** point to point protocol (PPP), carrier sense multiple access/collision detection (CSMA/CD) ** and other aspects of the content.

If you feel good, welcome “one key three” oh, click like collection attention, direct comments, communication and learning!

A lot of AC, Offer a lot!

In this paper, starting my CSDN blog: csdn-czh.blog.csdn.net/article/det…