Data link layer interpretation

basic introduction

Overview

 There are two main types of channels used by the data link layer

  • Point-to-point channel . A channel that uses one-to-one point-to-point communication .
  • broadcast channel . A channel that uses one-to-many broadcast communication . Since there are many hosts connected on the broadcast channel, a dedicated shared channel protocol must be used to coordinate the data transmission of these hosts, so the communication process is complicated.

 Different link layers may use different data link layer protocols

A frame is a protocol data unit of the data link layer. Frame consists of header, data part and trailer. The header contains the control information of the frame ( such as address, control, etc. ) , the tail contains the frame check sequence, and the data part serves as the data field for storing IP datagrams.

Physical links and data links

 A physical link ( link )   refers to a passive physical line segment between two adjacent nodes without any other switching nodes in between.

When two computers communicate, the path is composed of multiple links connected in series, which means that a link is only a component of a path.

A data link ( datalink , logical link )    consists of physical lines as well as hardware and software that implement communication protocols. Data link layer protocols ( i.e., link control procedures ) are essential for reliable data transmission over unreliable physical links.

A network adapter ( i.e. network card ) is the hardware and software that implements these protocols. It usually has the functions of the data link layer and the physical layer.

 Function

A digital pipe is usually drawn between two peer data link layers, and the unit of data transmitted on this digital pipe is a frame .

Early data communication protocols were called communication procedures . Therefore at the data link layer, procedures and protocols are synonymous. 

The data link layer provides services to the network layer on the basis of the services provided by the physical layer. Its basic task is to encapsulate the IP datagrams transmitted from the network layer into frames and pass them down to the physical layer, extract the IP datagrams from the error-free frames received by the physical layer and hand them over to the network layer, and send them to the error frames. throw away.    

Main functions of the data link layer

  • Link management:  The establishment, maintenance and release of data links.
  • The frame delimitation    receiver should accurately distinguish the beginning and end of a frame from the received bit stream, that is, determine the frame boundary position.
  • Transparent transmission   of any bit combination data can be transmitted correctly.
  • The essence of flow control   is to control the data rate sent by the sender, which should not exceed the capacity of the receiver.
  • Error detection   usually uses the sending end to append an error detection code to the transmitted bit stream, and the receiving end to recalculate the detection code, and compare the two to determine whether an error exists.     

Three basic questions

The data link layer protocol of point-to-point channels needs to solve three basic problems:

  • frame delimited
  • Transparent transmission
  • error detection 

frame delimited 

Frame delimitation is to correctly distinguish the boundaries of frames from the transmitted bit stream.

Several methods used for frame delimitation:

Byte stuffing    uses some specific control characters to delimit the beginning and end of a frame.

When PPP uses asynchronous transmission, we use 0x7D (01111101) as the escape character. The escape rules are as follows:

  • Convert each 0x7E byte appearing in the information field into a 2-byte sequence (0x7D, 0x5E).

  • If a 0x7D byte appears in the information field (that is, the same bit combination as the escape character appears), the escape character 0x7D is converted into a 2-byte sequence (0x7D, 0x5D).

  • If an ASCII code control character appears in the information field (that is, a character with a value less than 0x20), a 0x7D byte must be added in front of the character, and the encoding of the character must be changed. For example, if 0x03 appears (which is "end of transmission" ETX in the control character), it must be converted into a 2-byte sequence (0x7D, 0x31).

In the byte stuffing method, byte stuffing technology is used. The byte being filled in is the escape byte (ESC). 

The bit stuffing method    uses a specific bit combination 01111110 to delimit the beginning and end of a frame, which is currently the most commonly used method.

"Zero bit insertion and deletion" technology is used to solve the problem of specific bit combinations in the transmitted data information. 

Zero-bit padding is much simpler than byte padding. The binary representation of 0x7E is 01111110, so as long as a 0 is inserted every 5 1s, 0x7E can be avoided in the data.

The byte count method    uses a specific character to indicate the beginning of a frame, and then uses a byte count field to indicate the number of bytes required to be transmitted in the frame.

This method is only used in the DDCMP protocol. The problem is that if the byte count value is wrong during the transmission process, the end boundary of the frame cannot be determined. 

The illegal bit coding method    uses illegal coding as frame boundaries. 

This method only applies when a specific bit encoding is used on the physical media. For example, when biphase code transmission is used in a local area network, there is a level jump at the midpoint of each symbol. Obviously, the bit coding that does not cause level hopping at the midpoint of the symbol is illegal bit coding, and this illegal bit coding can be used as a frame delimiter. 

Transparent transmission 

 Transparent transmission means that no matter what form of bit combination is transmitted on the link, it will not affect the normal progress of data transmission.

  • In the byte stuffing method, byte stuffing technology is used. The byte being filled in is the escape byte (ESC) .
  • In the bit stuffing method, "zero bit insertion and deletion" technology is used. For example, insert a specific bit combination "01111110" .
  • In the byte count method, the byte count field is used to indicate the number of bytes to be transmitted.

 Example of transparent transmission using byte stuffing technology

If control characters appear in the transmitted data, insert an escape character " ESC " ( 1BH ) to solve the problem . If an escape character also appears in the data, another escape character should be inserted before the escape character. Inserted escape characters should be removed on the receiving end

 

error control 

Data signals may have errors during transmission: a 1 may become a 0 , and a 0 may become a 1 .

BER ( Bit Error Rate ) is a metric that measures transmission errors. This metric represents the ratio of erroneously transmitted bits to the total number of transmitted bits over a period of time.

The bit error rate has a great relationship with the signal-to-noise ratio. In order to ensure the reliability of data transmission, various error detection measures must be used when transmitting data over a computer network. Cyclic redundancy check CRC is an error detection technology widely used in the data link layer.

Notice

  • Frame check sequence FCS and CRC have different meanings. CRC refers to an error detection method, while FCS is a redundant code added after the data field for error detection.
  • Cyclic Redundancy Check CRC error detection technology can only achieve error-free acceptance . " Error-free acceptance" means: " For all received frames ( that is, excluding discarded frames ) , we can believe that no errors occurred during the transmission of these frames with a probability very close to 1. " In other words, all frames accepted by the data link layer at the receiving end have no transmission errors (frames with errors are discarded and not accepted).
  • To achieve " reliable transmission " ( that is, receive what you send ) , acknowledgment and retransmission mechanisms must be added .

Exercise explanation 

The data link layer protocol uses the following character encodings: A:01000111 B:11100011 FLAG:01111110 ESC:11100000. In order to transmit a frame containing 4 characters: AB ESC FLAG, what is the bit sequence (binary representation) sent when using which of the following framing methods is used? (1) Byte count (2) Byte-stuffed flag byte (3) Bit-stuffed flag byte

  • (1) The byte counting method requires frame length information, so a total of 5 bytes need to be sent. The sending sequence is: 00000100 (representing 4) 01000111 (A) 11100011 (B) 11100000 (ESC) 01111110 (FLAG);

The byte counting method requires frame length information, that is, the same length and binary need to be used to express the corresponding total number of bytes, so it is 4, so a total of 5 bytes need to be sent.

  • (2) FLAG is the start and end flag. So the sending sequence is: 01111110 (FLAG) 01000111 (A) 11100011 (B) 11100000 (ESC) 11100000 (ESC) 11100000 (ESC) 01111110 (FLAG) 01111110 (FLAG)

FLAG is the start and end flag. That is to say, corresponding escape symbols must be added at the beginning and end, and then for things that are already escape symbols, additional escape symbols must be added in front, so a total of 2 esc and two flags

  • (3) If five consecutive 1s are encountered in the data, 0 will be added after them. So the sending sequence is: 01111110 (FLAG) 01000111 (A) 110100011 (B) 111000000 (ESC) 011111010 (FLAG) 01111110 (FLAG)

 The bit filling method is to add 0 after five consecutive 1's in the data, and then the end and beginning of the flag itself must be included.

Guess you like

Origin blog.csdn.net/m0_62436868/article/details/135192054