Technology Sharing

Computer Networks - Data Link Layer

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

In the previous blog, we learned about the physical layer in computer networks. If you haven't read it yet, you can go and learn about it first, which will help us get started with this study. Computer Networks - Physical Layer
Next, we will start to explain -data link layer

basic concept

The data link layer is a very important layer for achieving communication between devices;
There are two types of channels used:

  • Point-to-point channel
  • Broadcast Channel

insert image description here

link:It is a section from one node to the adjacent nodePhysical Line, without any other switching nodes in between. A link is just a component of a path.
Data Link: It means that adding the hardware and software that implement the communication protocol to the link constitutes a data link. Data links can also be divided into physical links and logical links.

  • The physical link is the link mentioned above.
  • The logical link is the data link mentioned above, which is the physical link plus the necessary communication protocol.

The most common method now is to use an adapter (network card) to implement the hardware and software of these protocols. General adapters on the market include the data link layer and the physical layer.

The data link layer transmits and processes data in frames.

There are many data link layer protocols, and there are three basic problems in common:

  • Encapsulation into frame
  • Transparent transmission
  • Error Control

Encapsulation into frame

Add markers to the head and tail of the data (add frame header and frame tail) to determine the range of the frame.

insert image description here
When the data is a text file consisting of printable ASCII codes, the frame delimiter can be used with a special frame delimiter (SOHEOT) respectively control the start and end of the frame~

Transparent transmission

It means that the data link layer has no restrictions on the transmission data delivered by the upper layer, as if the data link layer does not exist. No matter what bit combination of data is sent, these data will pass through the entire data link layer without error.

Through the above encapsulation and framing operations, someone thought of a problem. If a node part in the data happens to coincide withSOH EOTIf the data link layer finds the frame boundary incorrectly, won't it? Don't worry, there is a solution.

insert image description here

Solution: character padding/byte padding.

  1. The data link layer at the sender receives control characters in the data.SOHorEOTInsert an escape character before ESC(The hexadecimal code is1B)。
  2. The receiving data link layer removes the inserted escape characters before sending the data to the network layer.
  3. If the escape character also appears in the data, then an escape character should be inserted before the escape character. When the receiving end receives two consecutive escape characters, the first one is deleted.

insert image description here

Error Control

During the transmission process,Bit Error, 1 becomes 0, 0 becomes 1

The ratio of transmitted error bits to the total number of transmitted bits over a period of time is calledBit Error RateThe bit error rate is closely related to the signal-to-noise ratio. In order to ensure the reliability of data transmission, error detection measures must be adopted. The data link layer widely uses Cyclic Redundancy Check CRC / Frame Check Sequence FCS Error detection technology.

  1. The sender and receiver agree on a generating polynomial G(x).
  2. The sender calculates an error detection code (redundancy code) based on the data generator polynomial to be sent, and adds it to the end of the transmission data for transmission.
  3. The receiver calculates whether the received data has any bit errors by generating a polynomial.

Point-to-point PPP protocol

Point-to-Point Protocol PPP is the most widely used point-to-point data link layer protocol.

The PPP agreement should meet the following requirements:

  • Simple
  • Encapsulation into frame
  • Transparency
  • Multiple network layer protocols
  • Various types of links
  • Error Detection

Unwanted functionality:

  • Error Correction
  • flow control
  • Serial number
  • Multipoint Line
  • Half-duplex or simplex link

There are three components to a PPP agreement:

  • Encapsulation methods for various protocol datagrams (encapsulation into frames);
  • Link Control ProtocolLCP: Used to establish, configure and test data link connections;
  • Network Control ProtocolNCP: Each of these protocols supports different network layer protocols;

Frame format

The PPP frame header and trailer are 4 fields and 2 fields respectively. PPP is byte-oriented, and all frame lengths are integer bytes.

capital

Flags field F = 0x7E (The symbol 0x indicates that the character following it is expressed in hexadecimal. The binary representation of hexadecimal 7E is01111110), the flag field indicates the start of a frame.

The address field A in the header is defined as0xFF(Right now11111111)。

The control field C in the header is defined as0x03(Right now00000011)。

Satan
Tail

The first field (2 bytes) in the trailer is the frame check sequence FCS using CRC.

Transparency

When PPP is used for asynchronous transmission, a specialCharacter filling method

  • Each occurrence of the information field0x7Ebyte into a 2-byte sequence (0x7D,0x5E)。

  • If a message appears in the information field0x7DBytes, then the escape character0x7DConverted to a 2-byte sequence (0x7D,0x5D)。

  • If the message field appearsASCIIIf a control character of the code (i.e. a character with a value less than 0x20) is used, a0x7Dbyte, and change the encoding of the character.

ad

When PPP is used over synchronous transmission links (SONET/SDH), the protocol specifies that hardware is used to completeZero bit padding

  • The entire information field is scanned first at the sending end (usually implemented in hardware, but can also be implemented in software, but it will be slower).

  • Whenever 5 consecutive 1s are found, a 0 is immediately filled in.

  • When the receiver receives a frame, it first finds the flag field F to determine the boundary of the frame, and then uses hardware to scan the bit stream. Whenever five consecutive 1s are found, the 0 after the five consecutive 1s is deleted to restore the original information bit stream.

Essonne

Why does the PPP protocol not use sequence numbers and confirmation mechanisms?

  1. The probability of errors occurring at the data link layer is low
  2. In the Internet environment, the data placed in the information field of PPP is an IP datagram, and the reliable transmission of the data link layer does not guarantee the reliable transmission of the network layer.
  3. Frame Check SequenceFCSFields are guaranteed to be accepted without errors.

Media Access Control

Data link layer of LAN

  • The network is owned by one organization;
  • limited geographic range and number of sites;
  • With broadcast function, one site can widely access the whole network, and the hosts on the LAN can share various hardware and software resources connected to the LAN;

One of the key issues to consider when sharing channels is how to coordinate the occupation of a shared transmission medium by multiple sending and receiving stations. If multiple devices send data at the same time, they will interfere with each other, resulting in transmission failure.
Media access control is divided into static channel division and dynamic access control. The details are as follows:
exist

Ethernet

DIX Ethernet V2 It is the protocol for the world's first LAN product (Ethernet);
IEEE 802.3 Is the firstIEEEEthernet standard;

There are only subtle differences between the two, so 802.3 LAN can be calledEthernet

adapter

Network interface board is also calledCommunication adapter orNetwork Interface Card (NIC) orNetwork Card

Important functions of the adapter:

  • Perform serial/parallel conversion;
  • Cache the data;
  • Implementing Ethernet protocol

Computers communicate with LAN via adapter
describe

CSMA/CD Protocol

The original Ethernet connected many computers to a single bus.Easy to implement broadcast communicationIn order to achieve one-to-one communication, the hardware address of the receiving station is written into the destination address field in the frame header. The data frame can be received only when the destination address in the data frame is consistent with the adapter address. If multiple computers or multiple stations send at the same time, a collision will occur, resulting in a sending failure.


For communication convenience:

  • Use a connectionless approach;
    1) Data can be sent directly without establishing a connection;
    2) The sent data frames do not need to be numbered, nor do they require the other party to send back an acknowledgment;
    3) Correction of errors is determined by higher levels;
  • The data sent is sent usingManchestercoding;

insert image description here
Disadvantages: The bandwidth it occupies is doubled compared to the original baseband signal;

Carrier Sense:

Before sending data, each workstation on the network must confirm whether there is data transmission on the bus.

If there is data transmission (the bus is said to be busy), no data is sent;

If there is no data transmission (the bus is said to be empty), the prepared data is sent immediately.

Multiple Access:

All workstations on the network send and receive data, using the same bus, and the data is sent in a broadcast manner.

Collision Detection:

It means that when the sending node sends an information frame, it must also monitor the media to determine whether a conflict occurs (whether other nodes are also sending information frames at the same time)

existCSMAIn the case of a bus, due to the existence of channel propagation delay, conflicts may still occur even if two stations on the bus do not hear the carrier signal and send frames.CSMAThe algorithm has no conflict detection function. Even if a conflict occurs, the damaged frames will still be sent, reducing the effective data transmission rate.

CSMA/CDis aCSMAImproved solution. The sending station continues to monitor the media during transmission to detect whether there is a conflict. If a conflict occurs, the channel can detect an amplitude that exceeds the carrier signal sent by the sending station itself, thereby determining the existence of a conflict. Once a conflict is detected, the transmission is immediately stopped and a series of blocking signals are sent to the bus to notify other relevant stations on the bus.

ARP Protocol

Hubs and Switches

Switch self-learning and forwarding frames

Spanning Tree Protocol

Virtual Local Area Network (VLAN)