Chapter 3: Data Link Layer (Part 1)

Data Link Layer Functional Overview

The research idea of ​​data link layer

Only for the same level.
insert image description here

Basic Concepts of Data Link Layer

Node: host, router
Link: The physical the transmission medium of the link mainly includes twisted pair, optical fiber and microwave. Divided into wired link, wireless link.
Data link: A logical hardware and software that implements the control data transmission protocol to the link constitutes a data link.
Frame: A protocol data unit at the link layer that encapsulates a network layer datagram.
The data link layer is responsible for transmitting datagrams through a link from a node to an adjacent node directly connected to another physical link .

Data Link Layer Functional Overview

The data link layer provides services to the network layer on the basis of the services provided by the physical layer . Its most basic service is to reliably transmit the data from the network layer to the network layer of the target machine of the adjacent node. Its main function is to strengthen the function of the physical layer to transmit the original bit stream, and transform the physical connection provided by the physical layer into a logically error-free data link, making it appear as an error-free link to the network layer.
insert image description here
Function 1: Provide services for the network layer . Unconfirmed connectionless service, confirmed connectionless service, and confirmed connection-oriented service. There must be confirmation if there is a connection!
Function 2: Link management, that is, connection establishment, maintenance, and release (for connection-oriented services).
Function three: framing.
Function four: flow control.
Function 5: Error control (frame error/bit error).

Encapsulation framing & transparent transmission

encapsulation into framing

insert image description here
Encapsulation into a frame: It is to add a header and a tail before and after a piece of data , which constitutes a frame. After the receiving end receives the bit stream handed over by the physical layer, it can identify the start and end of the frame from the received bit stream according to the markers in the header and the tail .
The header and tail contain a lot of control information, and one of their important functions is frame delimitation (determining the boundaries of the frame).
Frame synchronization: The receiver should be able to distinguish the start and end of a frame from the received binary bit stream.
Four methods of framing: 1. Character counting method, 2. Character (section) filling method, 3. Zero-bit filling method, 4. Violation encoding method.
insert image description here

character counting

The frame header uses a count field (the first byte, eight bits) to indicate the number of characters in the frame.
insert image description here
Pain point: Eggs are packed in one basket.

character padding

insert image description here
insert image description here

zero bit padding

insert image description here

  1. On the sender side, scan the entire information field and fill in a 0 immediately as long as there are 5 consecutive 1s.
  2. When the receiver receives a frame, it first finds the flag field to determine the boundary , and then scans the bit stream with hardware. When 5 consecutive 1s are found, the following 0s are deleted.
    insert image description here

Code violations

insert image description here
The start and end of the frame can be delimited with "High-High", "Low-Low".
Due to the fragility of the Count field in the byte counting method (the wrong value will lead to catastrophic consequences) and the complexity and incompatibility of character padding implementation, the more commonly used frame synchronization methods are bit padding and illegal encoding. Law.

Transparent transmission

Transparent transmission means that regardless of the bit combination of the transmitted data, it should be able to be transmitted on the link. As a result, the link layer "sees" nothing preventing data transmission.
When the bit combination in the transmitted data happens to be exactly the same as a certain control information, appropriate measures must be taken so that the receiver will not mistake such data as some kind of control information. Only in this way can the transmission of the data link layer be transparent.

Error Control (Error Detection Coding)

Where did the error come from?

In general, errors in transmission are caused by noise .
Global: 1. The random noise (thermal noise) generated by the electrical characteristics of the line itself is inherent to the channel and exists randomly. In general, errors in transmission are caused by noise.
Solution: Increase the signal-to-noise ratio to reduce or avoid interference. (Starting with the sensor)
Locality: 2. The impact noise caused by a specific short-term cause from the outside world is the main cause of errors.
Solution: usually use coding technology to solve.
insert image description here

Error control at the data link layer

insert image description here

Error Detection Coding - Parity Check Code

insert image description here
insert image description here

Error Detection Coding - CRC Cyclic Redundancy Code

Example: The data to be sent is 1101 0110 11, using CRC check, the generator polynomial is 10011, then the final data sent should be?
Generating polynomial problems will give.
Final data sent: data to be sent + frame check sequence FCB
calculation redundancy code:

  1. If the number of digits of the generator polynomial is 5 by adding 0, that is to add 4 0s after the original data;
  2. After adding 0 to the data, divide it by a polynomial, and the remainder is a redundant code.
  3. The redundant code is then used in place of the 0000 position.
    insert image description here
  4. The error checking process at the receiving end
    divides each received frame by the same polynomial, and then checks the resulting remainder R.
    1. If the remainder is 0, it is judged that there is no error in this frame, and it is accepted.
    2. If the remainder is not 0, it is determined that there is an error in this frame (it cannot be determined in place), and it is discarded.

Error Control (Error Correction Coding)

Error Correction Coding - Hamming Code

insert image description here

Hamming distance

The number of bits with different values ​​for the corresponding bits of two legal codes (code words) is called the Hamming distance (code distance) of the two code words. In a valid code set, the Hamming distance of any two legal codes (code words) The minimum value of the distance is called the Hamming distance (code distance) of the code set.
insert image description here

  1. Determine the number of Hamming codes r
    insert image description here
  2. Determine the location of the checksum and data
    n = 0 1 2
    insert image description here
  3. Find the value of the check code
    insert image description here
  4. Error detection and correction
    insert image description here

brain map moment

insert image description here

Flow Control and Reliable Transport Mechanisms

The mismatch between the higher sending speed and the lower receiving capacity will cause transmission errors, so flow control is also an important task of the data link layer.
Flow control at the data link layer is point-to-point, while flow control at the transport layer is end-to-end.
Data link layer flow control method: the receiver will not reply to the confirmation if the receiver cannot accept it.
Transport layer flow control means: the receiver sends a window announcement to the sender.

method of flow control

The stop-wait protocol can be regarded as a special sliding window protocol.
insert image description here
Stop-wait protocol: send window size=1, receive window size=1;
back N frame protocol: send window size>1, receive window size=1
; Protocol: send window size > 1, receive window size > 1

Reliable transmission, sliding window, flow control

insert image description here

brain map moment

insert image description here

stop-wait protocol

"Stop-wait" means to stop sending every time a packet is sent, wait for the other party's confirmation, and then send the next packet after receiving the confirmation.

error free

insert image description here

error condition

  1. Data frame lost or frame error detected
    insert image description here
  2. ACK lost
    insert image description here
  3. ACK late
    insert image description here

performance analysis

insert image description here

channel utilization

insert image description here

brain map

insert image description here

Fallback N Frame Protocol

Disadvantages of stop-and-wait agreements

insert image description here

Sliding window in back N frame protocol

insert image description here

Three things a GBN sender must respond to

insert image description here

What to do on the GBN recipient

insert image description here

GBN in action

insert image description here

Summary of GBN Protocol Highlights

insert image description here

brain map

insert image description here

Choose a retransmission protocol

Disadvantages of GBN Protocol

insert image description here

Select the sliding window in the retransmission protocol

insert image description here

Three things the SR sender must respond to

insert image description here

What to do on the SR receiver

insert image description here

SR in action

insert image description here

Sliding window length

insert image description here

Summary of SR Protocol Highlights

insert image description here

brain map

insert image description here

Guess you like

Origin blog.csdn.net/qq_52077949/article/details/123386253