Computer Network - Part 1 of Data Link Layer

Table of contents

1. Overview of the data link layer

2. Encapsulation and framing

3. Error detection

(1) Parity check

(2) Cyclic Redundancy Check (CRC)

4. Reliable transmission

(1) Stop-wait protocol SW 

(2) Back N frame protocol GBN

(3) Select retransmission protocol SR

5. Point-to-point protocol PPP

(1) The frame format of the point-to-point protocol PPP

​(2) Transparent transmission - the byte-oriented asynchronous link adopts the byte filling method of inserting escape characters

(3) Transparent transmission - the bit-oriented synchronous link adopts the bit stuffing method of inserting bit 0 

(4) Working status of the point-to-point protocol PPP

6. Media Access Control MAC

(1) Static division of channels

1. Frequency division multiplexing FDM

2. Time division multiplexing TDM

3. Wavelength division multiplexing WDM

4. Code division multiplexing CDM

(2) Dynamic access control

1. Random access-protocol used by bus LAN: CSMA/CD (carrier sense multiple access/collision detection)

2. Random access - protocol used by wireless LAN: CSMA/CA (carrier sense multiple access/collision avoidance)


1. Overview of the data link layer

The position of the data link layer in the network architecture is as follows. When we study the data link layer specifically, it can be considered that data is directly transmitted on the data link layer through the link

A link is a physical line from one node to an adjacent node without any other switching nodes in between.

Data link (Data Link) refers to the addition of hardware and software that implements communication protocols to the link to form a data link.

Three important issues of the data link layer:

① Encapsulation into a frame

After layer-by-layer encapsulation, frame header and frame tail are added when reaching the data link layer to form a frame

The packaged format is as follows:

② Error detection

Bit errors can occur after a frame encounters a disturbance during transmission (bit 0 becomes bit 1 and vice versa)

How does the receiver know that a bit error has occurred at this time? The error detection code can be used. Before sending the data, the sender can calculate the error detection code based on the data to be sent and the error detection algorithm, and encapsulate it at the end of the frame. After receiving the data, the receiver can detect whether there is an error code in the frame through the error detection code and error detection algorithm in the frame tail.

③ Reliable transmission

When the data received by the receiver has a bit error, if it is based on an unreliable transmission protocol, it will be discarded directly without taking any measures. If it is a reliable transmission protocol, the sender needs to resend so that the receiver can receive the data correctly

The above is a point-to-point protocol. If it is a data link layer using a broadcast channel, then in addition to the above, it is necessary to solve the problem of sending purpose and collision

That is, how to know that the data is sent to C, you can add the destination address of the frame to the frame and transmit it together

 

 The collision problem is inevitable in a shared LAN, and the Ethernet media access control protocol CSMA/CD can be used

2. Encapsulation and framing

Encapsulation into a frame means that the data link layer adds a header and a frame trailer to the protocol data unit delivered by the upper layer to make it 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

When the data link layer delivers the frame to the physical layer, and the physical layer converts the bits that make up the frame into electrical signals and sends them to the transmission medium, how does the receiver extract individual frames from the bit stream delivered by the physical layer? This is one of the meanings of the existence of frame header and frame tail, that is, frame delimitation

 Such as the format of the PPP frame, the frame delimitation mark will be added at the frame header and frame end

 But not every data link layer frame contains a frame delimitation mark, such as the MAC frame format of Ethernet version 2, which adds a preamble in front of the frame through the physical layer, and specifies the interval between frames to be sent

 

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.

  • The byte-oriented physical link uses the method of byte filling (or character filling) to realize transparent transmission
  • Bit-oriented physical link uses bit stuffing method to realize transparent transmission

Byte-oriented physical link :

When the data delivered by the upper layer also contains the same data as the frame delimitation, the receiver will receive the frame incorrectly. The solution is to scan the data, and add an escape character after each data or escape character that is the same as the frame delimiter, and the physical layer of the receiving end knows that it is a frame when it encounters the first frame delimiter At the beginning, when you encounter the escape character, you will know that the next 1 byte is the same as the frame delimiter, but its content is data.

Bit-oriented physical link:

Use zero-bit padding in the same data as the frame delimiter to ensure the uniqueness of the frame delimiter in the entire frame

In order to improve the transmission efficiency of the frame, the length of the data part of the frame should be as large as possible.
Considering various factors such as error control, each data link layer protocol specifies the upper limit of the length of the data part of the frame, that is, the maximum transmission Unit MTU (Maximum Transfer Unit).

3. Error detection

The actual communication link is not ideal, and errors may occur during the transmission of bits: 1 may become 0, and 0 may also become 1. This is called a bit error.
Over a period of time, the ratio of the wrong bits to the total number of bits transmitted is called the bit error rate BER (Bit Error Rate).

Using error detection codes to detect whether bit errors occur during data transmission is one of the important issues to be solved by the data link layer.

The frames shown below all contain the frame check sequence FCS field, which is used to allow the data link layer of the receiver to detect whether the received data has a bit error.

Next, the verification method is introduced

(1) Parity check

Add 1 parity bit after the data to be sent to make the number of "1" in the whole data (including the added parity bit) be odd (odd parity) or even (even parity).

  • If there is a bit error in an odd number of bits, the parity changes and the bit error can be checked.
  • If a bit error occurs in an even number of bits, the parity does not change and the error cannot be detected (missed detection)

 (2) Cyclic Redundancy Check (CRC)

  1. The sending and receiving parties agree on a generating polynomial G(x);
  2. The sender calculates the error detection code based on the data to be sent and the generator polynomial, and adds it to the end of the data to be transmitted and transmits it together
  3. The receiver calculates whether the received data has a bit error by generating a polynomial;

practice questions

1. The error detection code can only detect errors in the transmission process of the frame, but it cannot locate the errors , so it cannot correct the errors.
2. In order to correct errors in transmission, an error correction code with more redundant information can be used for forward error correction . However, the overhead of error-correcting codes is relatively large , and they are rarely used in computer networks .
3. The cyclic element residual check CRC has good error detection ability (very low detection rate) . Although the calculation is relatively complicated, it is very easy to implement with hardware , so it is widely used in the data link layer
4. Usually in computer networks Use the error detection and retransmission method we will discuss in subsequent courses to correct errors in transmission or just discard frames with detected errors, depending on whether the data link layer provides reliable transmission services or unreliable transmission services to its upper layers

4. Reliable transmission

When the receiver detects a bit error in the frame, if the data link layer provides different types of services to the upper layer, the method is also different.

  • Unreliable transmission service, then only discard frames with bit errors, and do nothing else;
  • Reliable transmission service, realize what the sender sends, what the receiver receives.

Generally, the bit error rate of the wired link is relatively low . In order to reduce overhead, the data link layer is not required to provide reliable transmission services upwards. Even in the event of bit errors, the issue of reliable transmission is handled by its upper layers.
The wireless link is susceptible to interference and the bit error rate is relatively high , so the data link layer must provide reliable transmission services to the upper layer.

Three Realization Mechanisms for Reliable Transmission

(1) Stop-wait protocol SW 

 

Channel utilization for the stop-and-wait protocol

When the round-trip delay RTT is much greater than the data frame transmission delay To (for example, using a satellite link), the channel utilization is very low.

If retransmission occurs, the channel utilization rate will be reduced for the transmission of useful data information

In order to overcome the shortcoming of the very low channel utilization rate of the stop-and-wait protocol, two other protocols have been produced, namely the back-N frame protocol GBN and the selective retransmission protocol SR .

(2) Back N frame protocol GBN

The stop-and-wait protocol is underutilized, and even less so when timeout retransmissions occur. The use of pipeline transmission can improve channel utilization

The fallback N frame protocol is based on pipeline transmission. Each time a group in the sending window is received, the sending window moves backward after receiving the ACK from the receiver.

After the receiver sends an ACK confirmation to the sender after receiving, the sending window moves backward

The receiver does not necessarily have to send acknowledgments to the received data packets one by one, but can send acknowledgments to the last data packet that arrives in sequence after receiving several data packets (determined by the specific implementation) . ACKn indicates that all data packets with sequence number n and before have been received correctly, that is, cumulative confirmation. As shown in the figure below, the receiver sent ACK1 and ACK4 to the sender after receiving the data, and ACK1 was lost during the sending process, but there is no need to retransmit at this time, because ACK4 is received, which means that the receiver confirmed the previous ACK4 group

When an error occurs, as shown in the figure below, packet 5 has an error and is discarded by the receiver. At this time, because the window number of the receiver is 5, the following 1076 packets do not match and are all discarded. At this time, the receiver discards every packet. An ACK will be sent to the sender, which is the sequence number of the last correctly received packet, ie ACK4. After receiving ACK4, the sender knows that the several packets sent just now have been discarded. At this time, according to the number of repeated ACKs set by the sender, decide whether to retransmit immediately, or wait for the timeout timer to expire before retransmitting.

It can be seen that 1076 is also discarded in this process, which is the so-called fallback N frame. It can be seen that when the communication line is not good, the utilization rate of the fallback N frame protocol is not higher than that of the stop-wait protocol.

Summarize

 (3) Select retransmission protocol SR

The receive window size Wr of the fallback N frame protocol can only be equal to 1 , so the receiver can only receive correctly arrived data packets in sequence .
The bit error of a data packet will cause its subsequent multiple data packets to be discarded by the receiver because they cannot be received in order (although they have no out-of-sequence or bit error). This will inevitably cause the sender to retransmit these data packets over time, which is obviously a great waste of communication resources.
It is possible to try to retransmit only the data packets in error. Therefore, the size Wr of the receiving window should no longer be equal to 1 (but should be greater than 1). In order to further improve performance, the receiving party can first receive out-of-sequence arrivals without error codes and the sequence number (using one-by-one confirmation instead of cumulative confirmation) falls on the receiving side. Those data packets in the window are sent to the upper layer together after all the missing packets are collected. This is the selective retransmission protocol .

 

When an error occurs in the No. 2 packet and the receiver discards it, since the sender only receives the ACK of the No. 3 packet, the window cannot slide forward at this time, and wait for the retransmission timer of the No. 2 packet to expire, and resend the No. 2 packet

Summarize

5. Point-to-point protocol PPP

Point-to-point protocol PPP (Point-to-Point Protocol) is currently the most widely used point-to-point data link layer protocol

The PPP protocol was formulated in 1992 by the Internet Engineering Task Force IETF. After revisions in 1993 and 1994, the current PPP protocol has become the official standard of the Internet [RFC1661, RFC1662].

The PPP protocol provides a standard method for transmitting various protocol datagrams on point-to-point links, which mainly consists of the following three parts :

  • Encapsulation methods for various protocol datagrams (encapsulation into frames)
  • Link Control Protocol LCP         is used to establish, configure and test data link connections
  • A set of Network Control Protocols (NCPs),         each of which supports a different network layer protocol

 

(1) The frame format of the point-to-point protocol PPP

When the same data as the frame delimitation appears in the data

(2) Transparent transmission - the byte-oriented asynchronous link adopts the byte filling method of inserting escape characters

 

(3) Transparent transmission - the bit-oriented synchronous link adopts the bit stuffing method of inserting bit 0 

(4) Working status of the point-to-point protocol PPP

6. Media Access Control MAC

One of the key issues to be considered in the shared channel is how to coordinate the occupation of a shared transmission medium by multiple sending and receiving stations , that is, Medium Access Control (MAC ).

With the development of technology, the maturity of switching technology and the reduction of cost, the switched LAN with higher performance using point-to-point links and link layer switches has completely replaced the shared LAN in the wired field, but due to the broadcast of wireless channels By nature, WLAN still uses shared media technology 

(1) Static division of channels

Multiplexing is an important concept in communication technology. Multiplexing is to simultaneously transmit signals of multiple users through one physical line.
When the transmission capacity of the transmission medium in the network is greater than the total traffic transmitted by multiple single channels, multiplexing technology can be used to establish multiple communication channels on one physical line to fully utilize the bandwidth of the transmission medium .

1. Frequency division multiplexing FDM

The frequency band resource of the transmission line is divided into multiple sub-frequency bands to form multiple sub-channels, and each sub-channel needs to be divided into isolated frequency bands to avoid interference between sub-channels. When multiple signals are input into a multiplexer, the multiplexer modulates each signal to a different carrier, and the receiving end separates the signals by the corresponding demultiplexer through filtering, and synthesizes the multiplexed signal Revert to the original multiplex signal.

Obviously, all users of frequency division multiplexing occupy different frequency band resources for communication at the same time

2. Time division multiplexing TDM

Time-division multiplexing technology allocates the bandwidth resources of the transmission line to different users in turn according to time slots, and each pair of users only uses the line to transmit data in the allocated gaps, and time-division multiplexing technology divides time into equal-length time-division multiplexing frame. Each TDM user occupies a time slot with a fixed serial number in each TDM frame, as shown in the figure below, the time slot occupied by each user occurs periodically, and the period is the length of the TDM frame . Obviously, all users of time-division multiplexing occupy the same frequency bandwidth at different times.

3. Wavelength division multiplexing WDM

Wavelength division multiplexing is the frequency division multiplexing of light. The figure below shows 8 optical carriers with a transmission rate of 2.5Gbit/s, and their wavelengths are all 1310nm. After optical modulation, the wavelengths are respectively converted to 1550~1561.2nm. Each optical carrier is separated by 1.6nm. These 8 very close optical carriers are transmitted on one optical fiber through an optical multiplexer (or multiplexer), so the transmission rate on one optical fiber reaches 8*2.5Gbit/s=20Gbit/s . The optical signal will attenuate after being transmitted for a period of time, and the attenuated signal needs to be amplified to continue the transmission. This is the function of the erbium-doped fiber amplifier.

4. Code division multiplexing CDM

(2) Dynamic access control

1. Random access-protocol used by bus LAN: CSMA/CD (carrier sense multiple access/collision detection)

CSMA/CD Agreement - Contention Period

 CSMA/CD protocol - minimum frame length

  CSMA/CD protocol - maximum frame length

 

CSMA/CD protocol - frame transmission process

CSMA/CD protocol - frame receiving process

 2. Random access - protocol used by wireless LAN: CSMA/CA (carrier sense multiple access/collision avoidance)

hidden station problem

 

Interframe Space IFS

How CSMA/CA works

Question 1: Why does the source station wait for a period of time for DIFS after detecting that the channel is idle?

It is to take into account that there may be other stations with high priority frames to send. If there is, it is necessary to let the high priority frame be sent first

Question 2: Why does the destination station wait for a period of time for SIFS after receiving the data frame correctly before sending the ACK frame?

SIFS is the shortest interframe space used to separate frames belonging to a conversation. During this time, a station should be able to switch from sending mode to receiving mode.

Question 3: After the channel changes from busy to idle and the DIFS time has elapsed, it is necessary to back off for a random period of time before using the i channel?

Prevent collisions caused by multiple sites sending data at the same time

Backoff Algorithm of CSMA/CA

Channel Reservation and Virtual Carrier Sense of CSMA/CA

In order to reduce the probability of collision and the impact of collision as much as possible, the 802.11 standard allows the station to send data to reserve the channel

  1. Before sending data, the source station sends a short control frame called RTS (Request to Send), which includes the address, destination address and the duration required for this communication (including the corresponding confirmation frame).
  2. If the destination station correctly receives the RTS frame sent by the source station and the medium is idle, it will send a response control frame called CTS (Clear To Send), which also includes the duration required for this communication (from RTS frame to copy this duration into a CTS frame).
  3. After receiving the CTS dump, the source station can send its data frame after waiting for a period of SIFS
  4. If the destination station correctly receives the data frame sent by the source station, it will send an acknowledgment frame ACK to the source station after the waiting time SIFS.

Guess you like

Origin blog.csdn.net/m0_62946761/article/details/131354425