It has 3,200 words and takes about 25 minutes to read
3.1 Basic Concepts
3.1.1 Channel Type
There are two types of channels used by the data link layer:
- Point-to-point channel: This channel uses one-to-one point-to-point communication.
- Broadcast channel: This channel uses one-to-many broadcast communication, so the process is more complex. There are many hosts connected on the broadcast channel, so a dedicated shared channel protocol must be used to coordinate the data transmission of these hosts.
3.1.2 Links and Data Links
A link is a physical segment of a point-to-point line with no other points in between.
- A link is only one component of a path.
In addition to physical lines, communication protocols must control the transmission of these data. If the hardware and software to implement these protocols are added to the link, it constitutes a data link.
- The most common approach today is to use adapters, or network cards, to implement the hardware and software of these protocols.
- Generally, adapters include the data link layer and the physical layer.
3.1.3 Frame transmission process
The data link layer acts like a data pipeline, often drawing a digital pipeline between two peer data link layers, and the data transmitted on this digital pipeline is in frames.
3.2 Three basic questions
3.2.1 Encapsulation into frames
- Framing is a frame by adding a header and a tail to a piece of data. Determine frame boundaries.
- One of the most important functions of the header and tail is frame delimiting.
MTU: indicates the maximum transmission unit. The maximum Ethernet transmission unit cannot exceed 1500 bytes
Extension: If the frame is not sent, the sending end has a problem, can only resend the frame. When the receiver receives an “incomplete frame”, does it discard it? Why is that?
A: It will be discarded, because the first or the tail of the frame is not received, the data part of the frame is incomplete, after receiving it, it cannot be used, so it has to be discarded.
3.2.2 Transparent Transmission
1. Transparent transmission
If printable characters (keyboard input) are used as part of the data, non-printable characters are used as the beginning or end of the frame
- If the data transmitted is a set of 95 printable characters in THE ASCII code, there is no problem.
- The problem occurs when the data being transferred contains “non-printable characters” (such as transferring pictures), as shown below:
2. Use byte filling method to solve the problem of transparent transmission
The data link layer at the sending end inserts a filler “ESC” (whose hexadecimal code is 1B) before the occurrence of the control character “SOH” or “EOT” in the data.
Byte padding or character padding – The data link layer at the receiving end removes the inserted escape characters before sending the data to the network layer.
If an escape character is also present in the data, an escape character should be inserted before the escape character. When the receiver receives two consecutive escape characters, it deletes the first one of them.
3.2.3 Error control
Bit errors may occur during transmission: 1 May become 0, and 0 May become 1.
Bit error rate: The ratio of the number of incorrectly transmitted bits to the total number of transmitted bits over a period of time. Bit error rate is closely related to signal-to-noise ratio.
In order to ensure the reliability of data transmission, various error detection measures must be adopted in computer network data transmission. Such as cyclic redundancy check CRC
If only cyclic redundancy detection CRC error detection technology is used in the data link layer, only error-free acceptance of frames can be achieved, that is, “All frames accepted by the data link layer at the receiving end can be considered with a probability very close to 1 that there is no error in the transmission process of these frames.” The frame discarded by the receiver was received at one time, but was eventually discarded because of an error, that is, it was not accepted. The above can be approximately expressed as: “All frames accepted by the data link layer at the receiving end are error-free”.
3.3 Using point-to-point Channels
3.3.1The PPP protocol
The most commonly used data link layer protocol in the world, PPP is used when users use dial-up phone lines to access the Internet.
3.3.2 REQUIREMENTS that PPP protocol should meet
Confirmation, frame encapsulation, transparency, multiple network layer protocols, multiple types of links, error detection, detection of connection status, maximum transfer unit, network layer address negotiation, data compression negotiation.
3.3.3 filling
How to do if the value of the flag field appears in the information field, it may be mistaken as “flag”?
-
Byte filling method:
1. Convert each 0x7E byte present in the information field into a 2-byte sequence (0x7D, 0x5E).
2. If a 0x7D byte is present in the information field, it is converted to a 2-byte sequence (0x7D, 0x5D).
3. If an ASCII control character (that is, a character whose value is less than 0x20) appears in the information field, add a 0x7D byte before the character and change the encoding of the character.
-
Zero-bit filling method: the sender encounters 5 consecutive 1’s and adds a 0 to the end, while the receiver encounters 5 consecutive 1’s and removes the following 0
3.3.4 Do not use serial number and confirmation mechanism
PPP does not use the sequence number and confirmation mechanism for the following reasons:
- When the probability of errors at the data link layer is small, PPP is a relatively simple protocol.
- In the Internet context, the PPP information field puts the data into the IP datagram. Reliable transmission at the data link layer does not guarantee reliable parameters at the network layer.
- The frame check sequence FCS field ensures error-free acceptance.
3.4 Using broadcast Channels
3.4.1 Features and advantages of LAN
The main characteristics of LAN are: the network is owned by a single unit, and the geographical scope and site data are limited.
Lans have the following major advantages:
- With broadcast function, it is easy to access the whole network from one site. Hosts on the LAN can share hardware and software resources connected to the LAN.
- Facilitate the expansion and gradual evolution of the system, the position of the equipment can be flexibly adjusted and changed.
- The reliability, availability and survivability of the system are improved.
3.4.2 CSMA/CD protocol
(1) Carrier Sense multipoint access/collision detection
- Multipoint access means that many computers are connected to a bus in multipoint access mode.
- Carrier listening refers to that each station should check whether there are other computers on the bus transmitting data before sending data. If there are other computers transmitting data, do not send data temporarily in order to avoid sending collision. Carrier sense is the use of electronic technology to check the bus for data signals sent by other computers. (Detect the signal voltage on the channel)
(2) After the collision is detected
At the time of the collision, the signal transmitted on the bus was so distorted that no useful information could be recovered from it.
Each station that is sending data, as soon as it detects a collision on the bus, stops sending immediately to avoid wasting network resources, and waits a random amount of time before sending again.
(2.1) Binary subtree type retreat algorithm
The station in the collision is delayed (retreated) for a random amount of time after it stops sending data.
- Determine the basic retreat time, generally taken as the contention period 2t.
- Define the parameter k, k=Min[retransmission times, 10]
- Pick a random number from the set of integers [0,1…, (2^k-1)] and call it r. The delay required for retransmission is r times the basic backoff time.
- When retransmission fails 16 times, the frame is discarded and reported to higher management.
(3) Competition period
The station that sent the data frame first will know at most 2T (twice the end-to-end round-trip delay) after sending the data frame whether the data frame was hit or not.
You can be sure that this send will not collide if no collision has been detected during the contention period.
(3.1) Contention period of Ethernet
- Ethernet’s end-to-end round-trip delay of 2T is called the contention period, or collision window. Generally, 51.2us is taken as the length of the contention period.
- For 10Mb/s Ethernet, 512bits can be sent during contention, meaning that subsequent data will not conflict.
- If the first 64 bytes of Ethernet data conflict, the subsequent data does not conflict.
(3.2) Minimum effective frame length
- If a conflict occurs, it must be within the first 64 bytes of the message.
- Since sending is terminated as soon as a conflict is detected, less than 64 bytes of data must have been sent.
- Ethernet specifies a minimum valid frame length of 64 bytes (padding 0 if less than 64 bytes), and any frame less than 64 bytes is an invalid frame that conflicts and terminates abnormally.
3.5 Ethernet
- Ethernet provides services that are unreliable delivery, that is, best effort delivery.
- When a receiving station receives an errant data frame, it discards it, and no other instructions are made. The correction of errors is at the top.
- If the upper layer discovers that some data is missing and retransmits it, Ethernet does not know that it is a retransmitted frame, but sends it as a new data frame.
3.5.1 Ethernet Channel utilization
Ethernet channels are occupied:
- The length of contention period is 2T, that is, twice the end-to-end propagation delay. No interference signal is sent after a collision is detected.
- The frame length is L (bit) and the data transmission rate is C (bit/s), so the frame transmission time is L/C = T (s).
This is the average time it takes to send a frame from the time it is initially sent to the time it will be retransmitted several times after a possible collision, until it is successfully sent and the channel becomes idle (i.e., time t passes again so that no signal is propagating on the channel).
(1) Parameter A
To improve Ethernet channel utilization, the ratio of T to T0 must be reduced. Parameter A is defined in Ethernet network, which is the ratio of Ethernet one-way end-to-end delay T to frame transmission time T0:
a = t / T0
- A ->0 means that a collision can be detected immediately, and immediately stop sending, so the channel utilization rate is very high.
- The larger a is, it indicates that the proportion of the contention period increases, and many channel resources are wasted every time a collision occurs, resulting in a significant decrease in channel utilization.
(2) Maximum channel utilization
1. Ethernet parameters
When the data rate is constant, the length of Ethernet cables is limited; otherwise, the value of T will be too large
The Ethernet frame length cannot be too short, otherwise the value of T0 will be too small, making the value of A too large.
2. Maximum channel usage
Ideally, stations on the Ethernet would send data without collisions (this is clearly no longer CSMA/CD, but requires a special scheduling method), with one station sending data as soon as the bus is idle.
The time it takes to send a frame is T0+t, and the time it takes to send the frame itself is T0. Thus, we can calculate the limit channel utilization rate S Max under ideal conditions as follows:
S max = T0 / (T0+t) = 1 / (1+a)
3.5.2 MAC Layer of Ethernet
Hardware address of the MAC layer (MAC address)
On lans, hardware addresses are also called physical addresses or MAC addresses.
The MAC address consists of 48 bits. The first 24 bits are the address field assigned to the manufacturer, and the last 24 bits are assigned by the manufacturer.
(1) The adapter checks the MAC address
The adapter does not receive a MAC frame from the network and first checks the MAC address in the MAC frame with hardware:
- If the frame is sent to this site, accept it and then do other processing.
- Otherwise, the frame is discarded and no further processing is done.
(2) The type of frame sent to this site
- Unicast frames: one-to-one
- Broadcast frame: a pair of plenary
- Multicast frames: one to many