Article directory
Chapter 3 Data Link Layer
3.1 Data Link Layer Overview
The data link layer is a layer in the computer network architecture, located between the physical layer and the network layer. It is responsible for transferring data between adjacent nodes and provides reliable data transmission.
The main functions of the data link layer include:
frame packing: Divide the data passed down from the network layer into smaller data frames (Frame), and add a header and trailer to each frame for transmission on the physical medium.
physical addressing: A device on a network is uniquely identified by a Media Access Control (MAC) address, also known as a physical address or hardware address. The data link layer uses MAC addresses to identify senders and receivers of data frames.
media access control: Coordinate access by different devices on shared media to avoid conflicts and collisions. Common media access control methods include Carrier Sense Multiple Access/Collision Detection (CSMA/CD) and Carrier Sense Multiple Access/Collision Avoidance (CSMA/CA).
Error Detection and Correction: By adding mechanisms such as check digits or cyclic redundancy check (CRC), redundant information is included in the data frame so that the receiver can detect and correct errors introduced during transmission.
flow control: By using technologies such as sliding windows, control the data flow between the sender and receiver to ensure that the receiver can receive and process data correctly.
link management: Establish, maintain, and release link connections, including link establishment, authentication, authorization, and shutdown operations.
Three important issues in the data link layer: encapsulation into frames, error detection, and reliable transmission
3.2 Encapsulation and framing
Encapsulation into a frame means that the data link layer adds a frame header and a frame tail to the protocol data unit delivered by the upper layer to make it called a frame.
- The frame header and frame trailer contain important control information.
- One of the functions of frame header and frame tail is frame delimitation.
Transparent transmission means that the data link layer does not have any restrictions on the transmission data delivered by the upper layer, as if the data link layer does not exist.
- Byte-oriented physical links use byte stuffing (or character stuffing) to realize transparent transmission.
- Bit-oriented physical links use bit stuffing to realize transparent transmission.
3.3 Error detection
3.3.1 Parity
Parity check: Add 1-bit parity check code after the data to be sent, so that the number of "1" in the entire data (including the added check bit) is odd (odd check) or even (even check).
The miss rate of parity check is very high, so it is usually not used.
3.3.2 Cyclic Redundancy Check
The sending and receiving parties agree on a generating polynomial G(x).
The sender calculates the error detection code (redundancy code) based on the data to be sent and the generator polynomial, and adds it to the back of the transmission to be transmitted together.
The error detection code can only detect that an error occurred during the frame transmission, but it cannot locate the error, so it cannot correct the error.
Cyclic redundancy check has good error detection energy (missing rate is very low), although the calculation is more complicated, but it is very easy to implement with hardware, so it is widely used in the data link layer.
In computer networks, the error detection and retransmission method that will be discussed in our follow-up courses is usually used to correct errors in transmission, or just discard frames that detect errors, depending on whether the data link layer provides reliable transmission services or Unreliable transport service.