3.0 Data link layer

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.

Simple model of the data link layer

3.1 Data link layer using point-to-point channel

3.1.1 Data Links and Frames

A link is a passive point-to-point physical line segment without any other switching nodes.

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.

The data link layer transmits frames

The data link layer is like a digital pipeline

A digital pipeline is often drawn between two peer-to-peer data link layers, and the data transmitted over this digital pipeline is in frames.

3.1.2 Three basic questions

(1) Encapsulate into frames

Framing is a frame by adding a header and a tail to a piece of data.

One of the most important functions of the header and tail is frame delimiting.

(2) Transparent transmission

Solve the transparent transmission problem

The data link layer at the sending end inserts an escape character “ESC” (whose hexadecimal code is 1B) before the occurrence of the control character “SOH” or “EOT” in the data.

Byte stuffing or characterstuffing — 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) Error control

Bit errors may occur during transmission: 1 May become 0 and 0 May become 1.

Over a period of time, the ratio of the number of transmitting errors to the total number of transmitting bits is called the Bit Error Rate (BER).

Bit error rate is closely related to signal-to-noise ratio.

Principle of cyclic redundancy test

Cyclic redundancy check (CRC) is widely used in data link layer frames.

At the sending end, the data is first divided into groups. Let’s say we have k bits per group.

Suppose the set of data to be transmitted is M = 101001 (now k = 6). We add n bit redundancy code for error detection after M and send it together.

Calculation of redundant codes

The operation of 2^n by M using binary modulo 2 is equivalent to adding n zeros after M.

The resulting number of (k + n) bits divided by the pre-selected divisor P of length (n + 1) bits gives the quotient Q and the remainder R, which is 1 bit less than the divisor P, that is, R is n bits.

Frame check sequence FCS

The redundant codes added to the data are called Frame Check Sequence (FCS).

CRC is a common error-detection method, while FCS is a redundant code added to the end of data.

FCS can be obtained using CRC, but CRC is not the only method used to obtain FCS.

The receiver performs a CRC check on each frame it receives

(1) If the remainder R = 0, it will judge that there is no error in this frame and accept it.

(2) If the remainder R ≠ 0, the frame is judged to be wrong and discarded.

The process of calculating redundancy codes is the process of checking whether there are errors in the data. The divisor must be chosen so that the remainder of dividing the correct data by the divisor is equal to 0.

But the detection method does not determine which bits or bits are at fault.

As long as the divisor P is carefully selected and enough digits are used, the probability of undetected errors is very, very small.

Only CRC error detection technique with cyclic redundancy test can only achieve error-free accept.

“Error-free acceptance” means that “all frames accepted (excluding discarded frames) can be considered with a probability very close to 1 that there is no error in their transmission”. In other words, “all frames received by the data link layer of the receiver are not transmitted erratically” (errant frames are discarded instead of being accepted).

To achieve “reliable transmission” (that is, receive what you send), you must add acknowledgement and retransmission mechanisms.

3.2 Point-to-point protocol PPP

3.2.1 FEATURES of PPP

The most widely used data link layer Protocol in the world is point-to-point Protocol (PPP).

PPP is generally used when users use dial-up telephone lines to access the Internet.

The link between the user and the ISP uses PPP

1. Requirements to be met by PPP

Simplicity – this is the number one requirement

Encapsulated into a frame

Transparent transmission

Error detection

2. Functions not required by PPP

Error correction

Flow control

The serial number

Multipoint line

Half duplex or simplex link

3. Composition of PPP protocol

The PPP agreement was established in 1992. Revised in 1993 and 1994, PPP is now the official standard for the Internet [RFC 1661].

PPP has three components

A method for encapsulating IP datagrams into serial links.

Link Control Protocol (LCP).

Network Control Protocol (NCP).

3.2.2 Frame format of PPP

The flag field F = 0x7E (the symbol “0x” indicates that the following characters are represented in hexadecimal. The binary representation of the hexadecimal 7E is 01111110).

Address field A is only set to 0xFF. The address field doesn’t actually work.

Control field C is usually set to 0x03.

PPP is byte-oriented, and all PPP frames are integer bytes in length.

PPP has a 2-byte protocol field

When the protocol field is 0x0021, the information field of the PPP frame is the IP datagram.

If the value is 0xC021, the information field is PPP link control data.

If the value is 0x8021, it indicates network control data.

Transparent transmission problem

When PPP is used on a synchronous transport link, the protocol specifies the hardware to do the bit filling (as HDLC does).

When PPP is used for asynchronous transmission, a special character padding method is used.

Zero bit fill

PPP, when used on SONET/SDH links, uses synchronous transmission (a series of bits sent continuously). Then PPP protocol uses zero-bit filling method to realize transparent transmission.

At the sending end, whenever five consecutive ones are found, a 0 is immediately filled in. The receiver scans the bit stream in the frame. Every time five consecutive ones are found, the 0 following those five consecutive ones is deleted.

Character fill

If a 0x7D byte is present in the information field, it is converted to a 2-byte sequence (0x7D, 0x5D).

If an ASCII control character (that is, a character with a value less than 0x20) is present in the information field, a 0x7D byte is added before the character and the encoding of the character is changed.

Reliable transmission using serial numbers and acknowledgements is not provided

PPP protocol does not use serial number and confirmation mechanism for the following reasons:

(1) When the probability of errors at the data link layer is small, it is reasonable to use a relatively simple PPP protocol.

(2) In the Internet environment, PPP information field into the data is IP datagrams. Reliable transmission at the data link layer does not guarantee reliable transmission at the network layer.

(3) Frame inspection sequence FCS field can ensure error-free acceptance.

3.3 Using the data link layer of the Broadcast Channel

3.3.1 Data link layer of LAN

The most important characteristic of LAN is that the network is owned by one organization, and the geographical scope and the number of sites are limited.

Lans have the following major advantages:

(1) with broadcast function, from a site can be very convenient access to the whole network. Hosts on the LAN can share hardware and software resources connected to the LAN.

(2) Facilitate the expansion and gradual evolution of the system, the position of the equipment can be flexibly adjusted and changed.

(3) Improve the reliability, availability and survivability of the system.

LAN Topology

Two sub-layers of the data link layer

In order to better adapt the data link layer to various LAN standards, the 802 Committee split the data link layer into two sub-layers:

(1) Logical Link Control (LLC) sublayer

(2) Medium Access Control (MAC) sub-layer.

The CONTENT related to access to the transport media resides in the MAC sublayer, while the LLC sublayer is independent of the transport media. Lans of any protocol are transparent to the LLC sublayer.

The LLC sublayer is generally not considered in the future

The role of adapters

The Network Interface board is also called a communication adapter or Network Interface Card (NIC).

Key features of the adapter:

(1) Serial/parallel conversion.

(2) Cache the data.

(3) Install device drivers in the operating system of the computer.

(4) Realize Ethernet protocol.

Computers communicate with local area networks through adapters

3.3.2 rainfall distribution on 10-12 CSMA/CD protocol

The original Ethernet connected many computers to a single bus. The connection was thought to be simple and reliable because there were no active devices on the bus.

Ethernet broadcast mode

Every working computer on the bus can detect the data signal sent by B.

Since only computer D’s address matches the address written at the beginning of the data frame, only D receives the data frame.

All the other computers (A, C, and E) have detected A data frame that was not sent to them, so they discard it without being able to collect it.

One-to-one communication is realized on the bus with broadcast characteristics.

Services provided by Ethernet

Ethernet provides services that are unreliable delivery, that is, best effort delivery.

When the destination station receives an errant data frame it discards it and does nothing else. The correction of errors is at the top.

If the upper layer finds 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.

All data sent by Ethernet is encoded in Manchester

The image of 0 and 1 in the Manchester code is opposite. However, the image of 0 and 1 in differential Manchester coding is not fixed, but the image is transformed once when it encounters 1, and remains unchanged when it encounters 0.

Carrier Sense Multipoint Access/Collision Detection (CSMA/CD)

“Multipoint access” means that many computers are connected to a bus in the mode of multipoint access.

“Carrier Sense” means that before sending data, each station should check whether there are other computers on the bus transmitting data. If there are other computers transmitting data, do not send data temporarily in case of collision.

Collision detection (collision detection)

“Collision detection” means that the computer detects the signal voltage on the channel while sending data.

When several stations simultaneously send data on the bus, the signal voltage swing value on the bus will increase (superimposed on each other). When the signal voltage swing value detected by one station exceeds a certain threshold value, it is considered that at least two stations on the bus are simultaneously sending data, indicating a collision.

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.

Influence of propagation delay on carrier listening

Important features

Ethernet using THE CSMA/CD protocol cannot carry out full duplex communication but only two-way alternating communication (half duplex communication).

For a short period of time after each station sends data, there is the possibility of a collision.

This uncertainty of transmission causes the average traffic across Ethernet to be much less than the highest data rate of Ethernet.

Contention issue

The station that sends the first data frame knows at most 2τ (twice the end-to-end round-trip delay) after sending the data frame whether the sent data frame was hit or not.

The end-to-end round-trip delay 2τ of Ethernet is called the contention period, or collision window.

You can be sure that this send will not collide if no collision has been detected during the contention period.

Truncated Binary Exponential Type Backout algorithm

The station in the collision is delayed (retreated) for a random amount of time after it stops sending data.

The basic retreat time is the contention period 2τ. 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.

The parameter k is calculated by this formula: k = Min[retransmission times, 10]. When k < 10, the parameter k equals the number of retransmissions.

When retransmission fails 16 times, the frame is discarded and reported to higher management.

The length of the contention period and the shortest valid frame length

For Ethernet, the length of the contention period is 51.2 μs.

For 10 Mb/s Ethernet, 512 bits, or 64 bytes, can be sent during the contention period.

If the first 64 bytes of Ethernet data do not conflict, the subsequent data does not conflict. So if a conflict occurs, it must be within the first 64 bytes of the message.

Since sending is aborted 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. Any frame shorter than 64 bytes is an invalid frame aborted due to a conflict.

To strengthen the collision

When the sending station discovers a collision:

(1) Stop sending data immediately;

“And 2) send a few more bits of the human jamming signal so that all users know that a collision has now occurred.