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
The data link layer is a very important layer for achieving communication between devices;
There are two types of channels used:
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 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:
Add markers to the head and tail of the data (add frame header and frame tail) to determine the range of the frame.
When the data is a text file consisting of printable ASCII codes, the frame delimiter can be used with a special frame delimiter (SOH
,EOT
) respectively control the start and end of the frame~
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
EOT
If the data link layer finds the frame boundary incorrectly, won't it? Don't worry, there is a solution.
Solution: character padding/byte padding.
SOH
orEOT
Insert an escape character before ESC
(The hexadecimal code is1B
)。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.
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:
Unwanted functionality:
There are three components to a PPP agreement:
LCP
: Used to establish, configure and test data link connections;NCP
: Each of these protocols supports different network layer protocols;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
)。
Tail
The first field (2 bytes) in the trailer is the frame check sequence FCS using CRC.
When PPP is used for asynchronous transmission, a specialCharacter filling method
Each occurrence of the information field0x7E
byte into a 2-byte sequence (0x7D,0x5E
)。
If a message appears in the information field0x7D
Bytes, then the escape character0x7D
Converted to a 2-byte sequence (0x7D,0x5D
)。
If the message field appearsASCII
If a control character of the code (i.e. a character with a value less than 0x20) is used, a0x7D
byte, and change the encoding of the character.
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.
Why does the PPP protocol not use sequence numbers and confirmation mechanisms?
FCS
Fields are guaranteed to be accepted without errors.Data link layer of 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:
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
Network interface board is also calledCommunication adapter orNetwork Interface Card (NIC) orNetwork Card
Important functions of the adapter:
Computers communicate with LAN via adapter
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:
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)
existCSMA
In 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.CSMA
The 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/CD
is aCSMA
Improved 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.