[Computer Network Notes] Data link layer (encapsulation into framing, error detection, reliable transmission)

Link: A physical line from one node to an adjacent node without any other switching nodes in between.

Data link: Add hardware and software that implements a communication protocol to the link

The data link layer transmits and processes data in units of frames.

Three processes: encapsulation and framing, error detection, reliable transmission

Encapsulation into framing:

After the data link layer of the sender encapsulates the data unit delivered by the upper layer into a frame, it also converts the bits constituting the frame into electrical signals through the physical layer and sends it to the transmission medium.

 Supplement: Not every data link layer protocol frame contains a frame delimiter flag.

MAC frames do not have frame delimitation flags.

MAC frame transmission process: 

Transparent transmission problem:

Byte-oriented physical links use byte stuffing (character stuffing) for transparent transmission

 Bit-Oriented Physical Links Using Bit Stuffing to Realize Transparent Transmission

Error detection:

Bit errors: Bits may have errors during transmission: 1 may become 0, 0 may become 1.

Bit Error Rate: The ratio of transmitted bits in error to the total number of bits transmitted over a period of time 

Error detection codes can be used to detect errors in frames during transmission.

The error detection code is in the FCS field at the end of the frame: 

 process:

Before the frame is sent, the error detection code is calculated based on the data to be sent and the error detection algorithm, and is encapsulated at the end of the frame. After the receiver receives the frame, through the error detection code and the error detection algorithm, it can judge whether there is a code error in the transmission process of the read frame.

Common error detection methods:

 Parity:

Add 1 parity bit after the data to be sent, so that the number of 1s in the entire data (including the added parity bit) is odd (odd check) or even (even check)

 Therefore, if there is an odd number of errors, the parity changes, and errors can be detected;

If there is an even number of errors, the parity does not change, and errors cannot be detected, which is also called missed detection.

Because the missed detection rate of parity is relatively high, the data link layer of computer network does not adopt this error detection method.

Cyclic Redundancy Check CRC:

Using CRC error detection, the missed detection rate is relatively low, and it is easy to implement in hardware, so it is widely used in the data link layer.

● Both parties agree on a generator polynomial G(x)

The sender calculates an error detection code (redundancy code) based on the data to be sent and the generator polynomial, and adds it to the back of the data to be transmitted

●The receiver calculates whether the received data has an error by generating a polynomial

 Error detection codes can only detect errors in the transmission process, but cannot locate errors, so they cannot correct errors.

To correct errors in transmission, error correction codes with more redundant information can be used for forward error correction, but the overhead of error correction codes is relatively large and is rarely used in computer networks.

For error handling in transmission: error detection and retransmission or direct discard. Depends on the services provided by the data link layer to the upper layers.

Reliable transmission:

After the receiver receives the frame with bit error, it will not receive the frame and discard it.

If the data link layer provides an unreliable service to the upper layer, it is discarded;

If the data link layer provides reliable service to the upper layers, other measures are required to ensure that the receiver can also receive a correct copy of the discarded frame.

In general, the bit error rate of the wired link is relatively low, and the data link layer is not required to provide reliable transmission services upward in order to reduce overhead. Even if errors occur, the problem of reliable transmission is handled by its upper layers.

The wireless link is susceptible to interference and has a high bit error rate, so the data link layer is required to provide reliable transmission services to the upper layer.

Classification of errors in computer networks:

Bit error: 0 becomes 1 or 1 becomes 0, error detection has parity and CRC.

Packet loss, packet out of sequence, packet duplication

 

 Transmission errors such as packet loss, packet out-of-sequence, and packet duplication generally do not appear at the data link layer, but at the upper layer.

Bit errors occur at the data link layer

The reliable transmission service is not limited to the data link layer, and other layers can choose to achieve reliable transmission.

The implementation of reliable transmission is complicated and the overhead is relatively high. Whether or not to use reliable transmission depends on the application requirements.

Three mechanisms to achieve reliable transmission: stop-wait protocol SW, fallback N frame protocol GBN, select retransmission protocol

The basic principles of these three reliable transmission mechanisms are not limited to the data link layer, but can be applied to various layer protocols of computer network architecture.

Stop waiting for protocol:

Array packet loss: timeout retransmission 

 

Acknowledgment Packet Lost, Data Packet Duplicate: Data Packet Number 

Acknowledgment packets are late and cause the problem of duplicate acknowledgments: number the acknowledgment packets

The stop-wait protocol stops sending and waits for an acknowledgment packet from the receiver every time a packet is sent, and the next packet can be sent only after the acknowledgment packet is received. Therefore, each time a packet is sent, it is necessary to wait at least the round-trip time between the sender and receiver.

When the round-trip time is large, the channel utilization is very low.

In order to improve channel utilization, drain line transmission can be used

Fallback N frame protocol: 

Send packets without errors 

 The receiver using the rollback N frame protocol can adopt the method of accumulative acknowledgment, that is, the receiver does not necessarily need to send acknowledgments for the received data packets one by one.

 Error cases:

 It can be seen that when the communication line is not good, the channel utilization rate of the back-N frame protocol is not higher than that of the stop-wait protocol.

When the sending window is > 2^n-1, there will be a problem that the receiver cannot distinguish the old and new packets

Choose a retransmission protocol:

 

process:

Guess you like

Origin blog.csdn.net/m0_52043808/article/details/124250940