Four, Data link layer

Source: Internet
Author: User
Tags control characters

The data link layer described in this chapter is divided into:

Data link layer for point-to-point channels

Data link layer for broadcast channel (local area network)

Main content:

1, the characteristics of the point-to-point channel and broadcast channel of the data link layer, and the protocol used by the two channels (PPP protocol and CSMA/CD Protocol)
2, three basic issues in the Data Link layer: Package framing, transparent transmission, and error detection
3, hardware address of the Ethernet MAC layer
4, the function and use of adapter, transponder, hub, bridge, Ethernet switch , the basic concept of Data Link layer 1, overview

Data Link layer: the second layer in the OSI Reference Model, between the physical layer and the network layer, providing services to the network layer on the basis of the services provided by the physical layer. The function of the data link layer is to strengthen the function of the physical layer transmitting the original bit stream.

Channel Type: There are two main types of channels used by the data link layer:

Point-to-point channel : This channel uses a one-to-one point-to-point communication method.

Broadcast channel : This channel uses a one-to-many broadcast communication method, 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 data transmission for these hosts. 2, simple model of data link layer

The Network Layer Protocol data unit is an IP datagram (or simply an array of reports, packets, or packages). The data link layer sends the data from the network layer to the link, and the data in the received frame is taken out and handed over to the network layer.

3 link VS data link

A link is a passive point-to-points physical line segment with no other Exchange nodes in the middle.
A link is just one part of a pathway.

In addition to the physical circuit, the data link must have a communication protocol to control the transmission of the data. Adding the hardware and software that implements these protocols to the link constitutes a data link.

The most common approach now is to use adapters (that is, network cards) to implement the hardware and software for these protocols. The general adapter includes both the data link layer and the physical layer of the two layers of functionality. two, three basic questions

Frame delimitation

The sender of the data link layer should let the receiver's data link layer know where the sent frame begins and where it ends.

Transparent transmission

The combination of bits sent by the data link layer must be unrestricted.

Error detection

The data link layer must have error detection capability. 1, Frame bound (encapsulated into frames)

Encapsulating frames (Framing) is the addition of headers and tails before and after a piece of data, which then forms a frame.

Frame delimitation (framing) is the boundary that determines the frame. Each link layer protocol specifies the upper limit of the length of the data portion of the frame-the Maximum Transmission Unit MTU (Maximum Transfer unit).

The data link layer of the sender joins the pre-agreed mark before and after the frame, allowing the receiver to recognize the beginning and end of the frame and the exact position of the data part loaded in the frame after receiving the frame.

One important function of the first and the tail is the frame delimitation.

Header and tail Effects: frame delimitation, other control information.

When a frame is sent, it is sent starting from the frame header.

Various data link layer protocols are explicitly defined for both the first and the end of a frame.

In order to improve the efficiency of frame transfer, the length of the frame data part should be greater than the length of the header and tail as much as possible, but each link layer protocol specifies the upper limit of frame data part length. This upper limit is called the Maximum Transfer Unit MTU (Maximum Transfer unit).

examples of how to use control characters for frame delimitation:

When data is composed of printable ASCII code, the frame delimitation can use special frame delimiters.

ASCII code has 128 different ASCII codes, which can be printed with 95, non-printable 33.

The ASCII control character Soh represents the beginning of the frame header and EoT represents the end of the frame. Note that the SOH ASCII code is 01, while the ASCII code for EOT is 04. EoT and Soh are not combinations of E, O, T and S, O, H letters.

frame -bound effect:

1) When transferring asynchronously, you can determine the start and end of a frame.

2) When transmitting synchronously, the sender sends the data frame continuously. The receiver uses the frame delimiter to find the starting and ending positions of each frame from a continuous stream of bits.

3) In the case of a transient failure, and resend, the receiver determines whether to receive or discard according to the frame delimiter. 2, transparent transmission 1) Issues

2) solve the problem of transparent transmission

To solve the problem of transparent transmission with the byte Fill method:

A, byte padding (byte stuffing) or character padding (character stuffing)-the data link layer of the sending end inserts an escape character "ESC" (its hexadecimal encoding is 1B) before the control character "SOH" or "EOT" appears in the data.

b, the data link layer of the receiving end removes the inserted escape character before sending the data to the network layer.

C, 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, it deletes the previous one.

3 Error detection

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

Over a period of time, the ratio of transmission errors to the total number of transmitted bits is called BER ber (bit error rate).

In order to guarantee the reliability of data transmission, all kinds of error detection measures must be adopted in the computer network.

used error detection technique for cyclic redundancy test CRC (Cyclic redundancy check)

The basic idea of CRC code:

A, add some check bits to the information message, constitute a specific message to be transmitted, so that it can be a pre-agreed polynomial (generate polynomial) to be exhausted.

b, the receiving party receives the message, and then uses the same generated polynomial to remove the received message polynomial, can be in addition to express the transmission is correct, otherwise incorrect.

The principle of cyclic redundancy test:

In the frames transmitted at the data link layer, the error detection technique of cyclic redundancy test CRC is widely used.

On the sending side, the data is first divided into groups. Assume each group of K-bits.

Suppose a set of data to be transferred M = 101001 (now k = 6). We add the N-bit redundancy code for error detection in the back of M and send it together.

Calculation of redundant codes:

A binary modulo 2 operation is performed on a 2n multiply m, which is equivalent to adding n 0 after M.
The resulting (k + N) bits divided by the pre-selected length of the (n + 1) bits of the divisor p, the quotient is Q and the remainder is R, the remainder R is less than the divisor P 1 bits, that is, R is N-bit.

Cases:
Now k = 6, M = 101001.
Set n = 3, divisor P = 1101,
Dividend is 2nM = 101001000.
The result of the modulo 2 operation is: quotient Q = 110101,
Remainder R = 001.
The remainder R is added as a redundant code after the data M is sent out. The data sent is: 2nM + R
i.e.: 101001001, total (k + N) bits.

The principle of cyclic redundancy test is explained:

The receiving end carries out a CRC check on each frame received:

A, if the remainder of R = 0, then determine that the frame is not wrong, accept the (accept).

b, if the remainder r0, then the frame is determined to be wrong, discarded.

Limitations:

This method of detection does not determine which or which bits are wrong.

As long as the strict selection, and the use of a sufficient number of divisor P, then the probability of detection error is very small and small.

frame Test sequence FCS:

The redundancy code added after the data is called the frame check sequence FCS (frame checked Sequence).

Cyclic redundancy test CRC and frame test sequence FCS are not equivalent.

CRC is a common method of error detection, and FCS is a redundant code that is added behind the data.

FCS can be obtained using CRC, but the CRC is not the only way to get FCS.

to create a polynomial choice:

The resulting polynomial should meet the following requirements:

A, any one error should cause the remainder to be 0

b, different bit errors should make the remainder different

C, the remainder continues to be modulo 2 except that the remainder should be recycled

The standard CRC generates a polynomial g (x):

Crc−4:g (x) =x4+x+1 C R c−4:g (x) = x 4 + X + 1 CRC-4: G (x) =x^4+x+1

Crc−12:g (x) =x12+x11+x3+x2+x+1 C R c−12:g (x) = x + x one + x 3 + x 2 + x + 1 crc-12:g (x) =x^{12}+x^{11}+x^3+x^2+x+ 1

Crc−ansi:g (x) =x16+x15+x2+x C R c−a N S i:g (x) = x + x + x 2 + x crc-ansi:g (x) =x^{16}+x^{15}+x^2+x

Crc−ccittv.41:g (X

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.