Computer Network Chapter III Review Notes (Data Link Layer)

The channels used by the data link layer mainly include:

1) Point-to-point channel. One-to-one point communication.
2) Broadcast channel. One-to-many broadcast communication method. This is what the local area network uses.

1. Point-to-point communication

Data link and frame

link Data link
A physical line (wired or wireless) from a node to an adjacent node without any other switching nodes in the middle. A communication protocol is added to control the physical link of data transmission. Some terms refer to data links as logical links.
Protocol data unit of the data link layer-frame Network layer protocol data unit-IP datagram (abbreviated as datagram, packet, packet)

Two, three basic questions

  • 1. Encapsulation into a frame : before and after a piece of data (the data has an upper limit, the maximum MTU) is added a header and a tail including a lot of necessary control information (to facilitate frame delimitation), which constitutes a frame.SOH(Start Of Header)和ROT(End Of Transmission) represents the beginning of the frame and the end of the frame respectively. This is the name of the character. Their hexadecimal codes are 01 (binary 00000001) and 04 (binary 00000100).
    The solution is: The sending frame failed and was interrupted. When recovering later, you can judge whether it is a complete frame through the frame delimitation. If it is not (only the start character SOH, no end character EOT), it must be discarded.
  • 2. Transparent transmission : No matter what kind of bit combination data, it can pass this data link layer as it is without error.
    If the binary code of a byte in the transmitted data is exactly the same as the control character such as SOH or EOT, the data link layer will find the "frame boundary" by mistake, causing errors in data transmission. byEscape character paddingWay to solve it. Specifically: the data link layer at the sender adds one before "SOH" and "EOT" in the dataEscape character "ESC"(Hexadecimal 1B, binary 00011011), the data link layer at the receiving end deletes this inserted escape character before sending the data to the network layer. (Byte transmission, character transmission)

Example: Transparent transmission is the basic function of the data link layer. The so-called transparency refers to (C)
A. The content, format and coding of the
transmitted data are limited B. The direction of the transmission data is transparent
C. The content, format and coding of the transmitted data are unlimited
D. Transparent way of data transmission

  • 3. Error detection : Bit error, cyclic redundancy check is widely used to check. Transmission errors (frame loss, frame duplication, frame out of sequence). In a period of time, the ratio of transmitted error bits to the total number of transmitted bits is called bit error rate BER.
    At present, the error detection technology of cyclic redundancy check CRC is widely used in the data link layer.

CRC principle:

1. Cyclic check code (CRC code) : It is the most commonly used error check code in the field of data communication. Its characteristic is that the length of the information field and the check field can be selected arbitrarily.

2. The basic principle of generating CRC code : any code composed of a binary bit string can correspond to a polynomial whose coefficients are only '0' and '1'.

For example, the polynomial corresponding to the code 1010111 is x6+x4+x2+x+1, and the polynomial is the code 101111 corresponding to x5+x3+x2+x+1.

3. The principle of CRC code set selection : if the codeword length is N, the information field is K bits, and the check field is R bits (N=K+R), then for any codeword in the CRC code set, there is and There is only one R degree polynomial g(x), such that V(x)=A(x)g(x)=xRm(x)+r(x); where: m(x) is the K degree information polynomial, r( x) is a check polynomial of degree R-1, g(x) is called a generator polynomial: g(x)=g0+g1x+ g2x2+…+g(R-1)x(R-1)+gRxR g(x) generates a CRC codeword, and the receiver uses the g(x) to verify the received CRC codeword.

4. CRC check code software generation method : with the aid of polynomial division, the remaining numbers are check fields.
For example: the information field code is: 1011001; corresponding to m(x)=x6+x4+x3+1. Assuming the generator polynomial is: g(x)=x4+x3+1; then the code corresponding to g(x) is: 11001x4m( x)=x10+x8+x7+x4 The corresponding code is recorded as: 10110010000; using polynomial division (modulo 2 operation): the divisor is 10110010000, the dividend 1011001 is filled with 6 0----> 1011001000000
and the remainder is: 1010 (ie The check field is: 1010) Sender: The transmitted transmission field is: 1 0 1 1 0 0 1 1 0 10 Information field check field Recipient: Use the same generated code to verify: Received field/generated code (Binary division) If it can be divided, it is correct,

Data link layer of broadcast communication

local area network

Features:

  • With broadcast function, The entire network can be easily accessed from one site; hosts on the LAN share various hardware and software resources on the LAN

  • Facilitate system expansion and evolution, The position of each device can be flexibly adjusted and changed

  • Improved system reliability, Availability and survivability

Topological structure of the local area network: bus type, ring network, star network

Two sublayers of the data link layer:

逻辑链路控制(LLC):靠近网络层,看不见下面的局域网,为网络层提供统一的接口,已经过时

媒体接入控制(MAC):靠近物理层,存放与接入媒体有关的内容

The role of the adapter:

网络适配器又被称为网卡

包含了数据链路层和物理层两层的功能

Important functions of the adapter:
(1) Serial\parallel conversion
(2) Data caching
(3) Install device drivers in the computer's operating system
(4) Realize the Ethernet protocol

CSMA\CD protocol (Carrier sense multi-point access/collision detection1

The characteristics of the bus: when a host sends data, all hosts on the bus can detect the data, which is the broadcast communication method

Measures taken to make communication easier:

(1) The connectionless working method is adopted, and the data can be sent directly without establishing a connection first; the adapter does not number the data frame and does not require a confirmation to be sent back; therefore, the Ethernet provides best-effort delivery, which is unreliable delivery; errors are received The frame is discarded, and whether to retransmit is determined by the higher layer, and has nothing to do with Ethernet; only one host is allowed to send data at the same time; CSMA/CD protocol is used

(2) The transmitted data uses Manchester encoding

The reason for the collision:

The propagation delay of the electromagnetic wave on the 1km cable is 5μs. During this period of time, the data sent by other hosts cannot be detected, which will cause a transmission conflict at some time later.

Applicable environment: two-way alternate communication (half duplex communication)

Uncertainty of Ethernet transmission: each station may encounter a collision within a period of time after sending data by itself. This period of time is uncertain and depends on the distance from another sending station, so there is no guarantee that it will be able to Your own data frame was successfully sent

Contention period (collision window):

Ethernet end-to-end round-trip time 2τ; no collision is detected after the contention period, to be sure that this transmission will not send a collision

Truncated binary exponential backoff algorithm:

Used to determine the timing of retransmission after a collision, not to send again immediately after the channel is idle, but to postpone a random time

具体流程:
(1)规定了基本退避时间为争用期2τ,具体的争用期时间是51.2μs;对于10Mbit/s以太网,争用期内能发送512bit,即64字节,也可以说争用期是512比特时间。
(2)从离散的整数集合[0,1,...,(2^k-1)]中随机取一个数,记为r,重传应推后r倍的争用期,k=min(重传次数,10)
(3)当重传16次仍不成功时,丢弃该帧,向高层报告凡长度小于64字节的帧都是由于冲突而异常终止的无效帧

强化碰撞:当发现碰撞时,处理立即停止发送数据外,还要继续发送32bit或48bit的人为干扰信号,使所有用户都知道发生了碰撞;帧间最小间隔:9.6μs,即96比特时间,使刚收到数据帧的站的接受缓存来得及清理,做好接收下一帧的准备

Insert picture description here

CSMA/CD sending process:

Listen first, send later, send while listening, conflict stops, delay sending

(1) Ready to send: The adapter obtains a packet from the network, adds the header and tail to form an Ethernet frame, puts it into the Ethernet buffer, and detects the channel before sending

(2) Channel detection: If the channel is detected to be busy, it will continue to detect until the channel becomes idle; if the channel is detected to be idle and remain idle for 96 bits, this frame is sent

(3) The channel is still continuously detected during the sending process, and the channel is monitored while sending. There are two possibilities here:

发送成功:争用期内未检测到碰撞。这个帧一定能发送成功。发送完毕后回到(1)

发送失败:争用期内检测到碰撞。立即停止发送,并按规定发送人为干扰信号(强化碰撞),执行指数退避算法,等待r倍512比特时间后,返回步骤(2);若重传16次仍不成功,停止重传并向上报错

Principle of CSMA/CD control method (from: Wang Gang's blog )
https://www.wonggang.com/8126.html

To avoid receiving erroneous data. Specify a minimum frame length of 64 bytes (Any less than is invalid frame), that is, 512 bits.
If the data sent is very small, some stuffing bytes must be added to make the frame length not less than 64 bytes. For a 10Mbit/s Ethernet, the time to send 512 bits requires 51.2μm

The characteristics of the hub:

(1)使用集线器的以太网在逻辑上仍是一个总线网,各站共享逻辑上的总线,还是使用CSMA/CD协议,在同一时刻只允许一个站发送数据

(2)一个集线器有多个接口,因此一个集线器很像一个多接口转发器

(3)集线器工作在物理层,仅简单的转发比特,不进行碰撞检测

(4)有专用的芯片,能自适应串音回波抵消

Ethernet channel utilization

Ethernet's MAC layer

When the data rate is constant, the length of the Ethernet connection is limited, and the frame length of the Ethernet cannot be too short. The limit channel utilization Smax:

Invalid MAC frame:

(1)帧的长度不是整数个字节


(2)用收到的帧检验序列FCS查出差错


(3)收到的帧的MAC客户数据长度不在46~1500字节之间,或MAC帧长度不在64~1518

Mac frame format

Insert picture description here

The data length is between 46 and 1500, 46 bytes: the maximum length of 64 bytes minus 18 bytes of the header and tail to get the minimum length of the data field The
last field is the 4-byte frame check sequence FCS (CRC check)
Frame length: 64-1518 bytes

Broadcast domain & conflict domain

Hubs can be stacked for use, and the total line length cannot exceed the maximum network segment length of the Ethernet

In a computer network using a hub, when one party sends a message, other machines cannot send it

Hub value contains physical layer protocol

The transmission medium is the physical communication between the originator and the receiver in the communication network

The main function of the physical layer is to realize the transparent transmission of the bit stream

How does STP provide a loop-free network to properly block certain ports

Router has one port and one broadcast domain.
Without router, there is only one.
Hubs cannot isolate conflict domains.

Each port of the switch is a conflict domain
Conflict domain: Every node in the same collision domain can receive all sent frames.
All ports of the HUB hub are in the same collision domain

The network card works at the physical layer

The repeater works at Physical layerUsed to restore the signal in the network and resend it to the network segment of other companies. The
hub works onPhysical layer, Used to connect each physical device. The
bridge works indata link layerThe media access sub-layer (Mac) is
used to transmit data packets in multiple network segments that use the same communication protocol

The switch is alsodata link layerThe main function is similar to the bridge, the
router works inNetwork layer

Switch: The switch is used to separate conflict domains, but cannot separate broadcast domains (except VLAN). Therefore, each port of the switch is in a conflict domain, and all ports are in a broadcast domain.

Self-learning function of the switch:

Formation of the address table : After receiving an unknown address, store the correspondence between the source address and the interface, and broadcast it to ports other than the source port. If the destination address does not match, discard it, otherwise receive and reply, and store the correspondence after receiving the reply; address The table has valid time, and it will be invalid if it exceeds the valid time

Spanning Tree Protocol STP: Solving the problem of infinite loop

Router: The router is used to separate the broadcast domain, and each port of the router is in a broadcast domain. For example, on a one-way street, both A and B pass, but only one can pass at the same time. At this time, there will be a conflict, and it must be repeated, but only one can pass. A hub is a typical example of working in a conflict domain.

Hub, one conflict domain, one broadcast domain
Switch, multiple conflict domains, one broadcast domain
Router, multiple conflict domains, multiple broadcast domains

Reliable transmission mechanism:
Confirm, automatic retransmission

Bridge
Multiple Ethernets form a network segment through a network bridge. The
switch is a multi-port network bridge.

The data link layer performs flow control between adjacent nodes.


  1. Multi-point access: description is a bus network

    Carrier Sense: Check if there are other computers on the bus that are also sending; each host must constantly check the channel. The detection before sending is to obtain the right to send, and the detection during sending is to detect collisions in time

    Collision detection: monitoring while loosing is also called collision detection; when a collision occurs, it will stop happening immediately, and then send again after waiting for a random period of time ↩︎

Guess you like

Origin blog.csdn.net/weixin_44763595/article/details/111823029