2024 Postgraduate Entrance Examination 408-Computer Network Chapter 3-Data Link Layer Study Notes

Article directory

Preface

Currently preparing for the 24 Postgraduate Entrance Examination, I will now summarize and organize the knowledge points learned in 408 of 24 Computer Kings.

Blogger blog article directory index: Blog directory index (continuously updated)

Map of this chapter:
image-20230730111216971


1. Functions of the data link layer

1.1. Research ideas of data link layer

Process : Host A sends data to Host B. The sender will encapsulate the corresponding data by adding corresponding control information at each layer, and then transmit it out. It will also go through the decapsulation and encapsulation process when passing through the intermediate system, and finally transmit it. Go to host B to obtain the data by unblocking it.

image-20230730111833361

上图的话可以看到数据是自上而下先封装之后自下而上再解封,当专门只研究数据链路层问题时,我们只关心协议栈的水平方向的各个数据链路层,如下图的箭头所示,这就是这一张研究链路层的一个研究思想。

image-20230730112133846


1.2、数据链路层基本概念

结点:主机、路由器。

  • 相邻结点:使用一条线连接起来的两个节点。

链路:网络中两个结点之间的物理通道,链路啊的传输介质主要有双绞线、光纤和微波,分为有线链路、无线链路。

数据链路:网络中两个结点之间的逻辑通道,把实现控制数据传输协议的硬件和软件加到链路上就构成了数据链路。

  • 简述:控制数据传输协议的硬件和软件 + 链路 = 数据链路

:链路层的协议数据单元,封装网络层数据报。

image-20230730112738663

数据链层负责内容:通过一条链路从一个结点向另一个物理链路直接相连的相邻节点传送数据报。

主要职责:将上层网络层交付给他的数据报安全的、无差错的,传给它的相邻节点。


1.3、数据链路层功能概述(5个功能)

功能概述:数据链路层在物理层提高服务的基础上向网络层提供服务,其最基本的服务是将源自网络层来的数据可靠地传输到相邻节点的目标机的网络层。

主要作用:加强物理层传输原始比特流的功能,将物理层提供的可能出错的物理连接改造成逻辑上无差错的数据链路,使之对网络层表现为一条无差错的链路。

Describe the process : The boss of company A gave five documents to the secretary and asked her to send them to company B. The secretary would definitely not take them there by herself. At this time, he asked a fool to transport them. Because he was worried, he sent the five documents. The fool took the number to him; then the fool took it to company B and gave it to the secretary of company B. At this time, he found that there were a few documents missing, so he asked the fool to resend them. After the documents were resent and all were received, company B The little secretary is handed over to the big boss.

  • The big boss: the network layer; the little secretary: the data link layer; the fool: the physical layer.

image-20230730112934758

  • The physical layer is relatively stupid and is only responsible for transmitting data. Sometimes it is easy to lose data. Therefore, the data link layer needs to be prepared in advance to predict possible errors in advance and then carry out corresponding error control , which is equivalent to giving the network layer Provided error-free service . (That is to say, when it reaches the network layer, the data must be intact and error-free)

In order to achieve an error-free data link, certain functions will be available at this time:

Function 1: Provide services for the network layer

Includes: unconfirmed no-connection service, confirmed no-connection service, and confirmed connection-oriented service.

①无确认无连接服务: Usually used to implement communication or a communication channel with a relatively low bit error rate. That is to say, the original host does not need to establish a link connection with the destination host in advance during the process of sending data. After the destination host receives the data link layer No confirmation is required either.

  • Disadvantage: If the data is really lost, the data link layer will not retransmit it, but will directly hand it over to the upper layer for processing, which is not very responsible.
  • Purpose: For real-time communication, faster speed requires this service.

②有确认无连接服务: There is no need to establish a connection in advance. The destination host must send back a confirmation when receiving the data. If the source host does not receive the confirmation signal, it will retransmit the frame that has just not received the confirmation. At this time, it is OK Improve the reliability of the data link layer.

  • Suitable scenarios: Suitable for communication channels with relatively high bit error rates.

③有确认面向连接服务: A connection needs to be established first, and then after the receiving end receives the frame, it needs to return a confirmation frame before it can continue to send the next one.

  • Advantages: The safest and most reliable.

Note : There must be confirmation if there is a connection! If there is a connection, it must be confirmed, so there is no connection-oriented service without confirmation.

功能二:链路管理,即连接的建立、维持、释放(用于面向连接的服务)。

功能三:组帧。

功能四:流量控制,接收方用来限制发送方的速度。

功能五:差错控制。

  • 差错包含帧错/位错,对于各个错误都有相应的手段来进行控制

二 、组帧

2.1、封装成帧以及发送帧的过程(包含名词解释)

将网络层交付给的IP数据报进行加工处理,也就是在数据报上加头、加尾形成链路层传送的数据传送单元,也就是形成帧。

image-20230730133152555

封装成帧组帧,发送端的过程):发送方在一段数据的前后部分添加首部和尾部,这样就构成了一个帧。接收端在收到物理层上交的比特流后,就能够根据首部和尾部的标记,从收到的比特流中识别帧的开始和节数。

  • 首部、尾部添加一个字段或者说是字节,这个字节就叫做帧定界符

image-20230730133409019

  • 帧定界:首部和尾部包含许多控制信息,这个是其中的一个。其作用就是确定帧的界限。其他的控制信息还包含有差错控制、流量控制、一些物理地址相关的信息。

发送帧的过程:从帧的开始,也就是帧的首部开始逐个比特发送,直到发送到这个帧尾部为止,接收端接收的时候可以根据帧首部判断此时接收帧了,直到接收到帧尾部的定界符。

  • image-20230730134154357

帧同步接收端的过程):接收方应当能从接收到的二进制比特流中区分出帧的起始和终止。

  • 数据链路层的帧长:帧的数据部分+帧首部+帧尾部。
    • 注意:为了提高帧的传输效率,都应该使帧的数据部分尽可能的大于首部和尾部,也就是说帧大部分应该是数据部分。此时会给数据部分设置一个极限值,叫做最大传输单元MTU
  • 最大传输单元MTU: Used to describe the length of the data part of the frame. The length of MTU is different according to different protocols. When transmitting the frame, the data part must be <= MTU maximum transmission unit.

image-20230730134649120


2.2. Implement transparent transmission and four framing methods

2.2.1. What is transparent transmission?

It means it's real but you can't see it.

透明传输: means that no matter what bit combination the transmitted data is, it should be able to be transmitted on the link. Therefore, the link layer refers to the "invisible" things that hinder the transmission of data.

  • There is no need to know the amount of data transferred, just send these things directly to the other side.

When the bit combination in the transmitted data happens to be exactly the same as a certain control information, appropriate measures must be taken so that the receiver will not mistake such data as some kind of control information. Only in this way can the transmission of the data link layer be guaranteed. Be transparent.

Four methods of framing : 1. Character counting method. 2. Character (section) filling method. 3. Zero bit filling method. 4. Illegal coding laws.


2.2.2. Method 1: Character counting method

Rules : The frame header uses a count field (first byte, eight bits) to indicate the number of characters in the frame.

Example : By reading the first byte, we can know the total length of a frame sent. For example, the first one below is 5, which means that this frame is 5 bytes, until 4; the third frame The first byte in is 8, which means this frame contains 8 bytes until the end of 6.

image-20230730151056914

Defect : Imagine if there is interference during the transmission process in the above picture, and the first byte number 5 of each frame changes to other numbers, then will there be a devastating problem, and all subsequent frames will not be parsed normally? received, so this method is not very commonly used in practical applications.


2.2.3. Method 2: Character filling method

Rules : Add header and tail codes to the beginning and end of the transmitted data to indicate the start and end of the frame.

image-20230730151826141

Just setting the first encoding is not enough. We may encounter the following two scenarios :

Scenario 1 : The transmitted frame is composed of a text file (because the characters in the text file are all ASCII codes input from the keyboard). Then no matter what characters are input from the keyboard, they can be put into the frame and transmitted (because there is no overlap with SOH and EOT encoding), that is, transparent transmission.

Scenario 2 : If the transmitted frame is composed of non-text files (binary programs or images, etc.), then the same binary encoding as SOH and EOT may appear in very large cases . If no additional rules are added at this time, it may be received The end may end early when reading. In this case, we need to use character filling method to achieve transparent transmission .

The repetition mentioned above is shown in the figure below:

image-20230730152156633

Solution : Add a character padding before the repeated SOH and EOF codes in the actual data part, which means it is not just an escape character at the beginning or end.

Solution example : In the following original data, you can see that there are many EOT, SOH, and ESC identical codes in the header and tail. At this time, we add a character padding in front of each repeated one, and then when the receiving end actually reads it, When you encounter byte padding, you will know that the following character is not the beginning or end of the header, and it will be read as a data content character.

image-20230730152619223


2.2.4. Method 3: Zero bit filling method

Rule : Add the unified code 0111110 to the beginning and end of the data part, that is, 1 0 followed by 6 1s and then 1 0.

image-20230730153318845

Question : What if the data in the intermediate frame also appears with the encoding 01111110? How to solve it?

Solution : If the sender encounters five consecutive 1's in the data part before sending the data, it will directly add a 0 at the end to complete the filling; if the receiving end encounters five consecutive 1's when reading the data in the frame When 0, first delete the following 1, and then the same cycle repeats.

image-20230730153531693

Features : Transparent transmission is guaranteed, and any combination of bits can be transmitted in the transmitted bit stream without causing errors in the judgment of frame boundaries.


2.2.5. Method 4: Illegal coding method

A method to achieve transparent transmission during physical layer bit encoding .

Rules : There are only two rules to represent 0 and 1 in Manchester encoding, which are high-low or low-high (according to the question requirements). There will be no high-high or low-low situations, so we can use High-high and low-low serve as the start and end of boundary frames.

Application : ieee802.1 uses this encoding method.


2.2.6. Summary of the four methods

Summary :

1. Regarding the vulnerability of the Count field in the byte counting method (once there is an error in the first value, it will affect all subsequent reads).

2. The implementation of character filling is relatively complex and incompatible.

3. Currently, the more commonly used frame synchronization methods are: bit stuffing and illegal encoding methods.


3. Error control

3.1. Where do the errors come from?

In summary , errors in transmission are caused by noise.

全局性: The random noise (thermal noise) generated by the electrical characteristics of the line itself is inherent to the channel and exists randomly.

  • Solution: Improve the signal-to-noise ratio to reduce or avoid interference (attack the sensor).
    • After improving the signal-to-noise ratio, the bit error rate will decrease and the errors will be reduced. The bit error rate refers to the number of error bits/total bits.

局部性: Impact noise caused by specific temporary external reasons is the main cause of errors.

  • Solution: Resolved by utilizing encoding count.
  • Impact means that data is suddenly punched during transmission, which is affected by impact noise.

There are two types of errors : bit errors and frame errors.

  • 位错: Refers to bit errors, 1 becomes 0, and 0 becomes 1.
  • 帧错: Refers to a combination of several bits, that is, an error occurs in frame units. Mechanisms such as frame number confirmation and retransmission can be used to solve the problem of frame errors.

It mainly includes three situations: loss, duplication, and disorder.

image-20230730162246818

The link layer provides services to the network layer :

  • For good communication quality, the choice of wired transmission link: no confirmation, no connection service.
  • For poor communication quality, the choice of wireless transmission link: confirmed connection-less service, confirmed connection-oriented service.

We can use different reliable transmission mechanisms for different links.


3.2. Error control at the data link layer (introduction to detection coding and error correction coding)

image-20230730162631239

Since the data link layer is point-to-point, each node and its next adjacent node actually form a relationship between the sender and the receiver. Once the relationship is established, the receiver should respond to the sender's The data is subject to error detection and even correction.

If you want to detect errors: use error detection coding ; if you want to correct errors, use error correction coding .

The error detection coding adopts coding : 奇偶校验码, 循环冗余码(this detection method is often used at present).

The codes used for error correction coding are : 海明码.


3.3. Coding VS coding (comparison of coding between physical layer and data link layer)

Encoding VS encoding (comparison of encoding between the physical layer and the data link layer) : The data encoding and modulation of the data link layer and the physical layer are different.

  • Physical layer coding is aimed at a single bit and solves problems such as bit synchronization during transmission, such as Manchester coding.
  • The encoding of the data link layer is for a group of bits , and the counting of redundant codes is used to determine whether an error occurs in a group of binary bits during the transmission process.

What is redundant coding?

  • Before the data is sent, certain redundant bits are attached according to a certain relationship to form a code word that conforms to a certain rule before sending.
  • When the valid data to be sent changes, the corresponding redundant bits also change, so that the code words follow the same rules. The receiving end determines whether there is an error based on whether the received codeword still conforms to the original rules .

3.4. Error detection coding (two methods)

Method 1: Parity check code

Combination : It is composed of n-1 information elements and 1 check element, of which n-1 information elements are the actual data to be sent. We can do it ourselves by adding 1 check element before n-1 bits. Add, specify whether it is an odd or even number by the number of 1's.

image-20230730170422920

Limitations of the parity check code : If one bit changes, then we can detect it, but if two bits change, such as 1 to 0, 0 to 1, then it still cannot be detected.

Example : If there is a character S, the ASCII code from low to high is 1100101, and odd parity is used, which error cannot be detected in the following received transmission characters?

image-20230730170617390

Analysis : The given value is 1100101, so the question says to use odd parity, so since the given characters only have an even number of 1, then we add the previous check element 1, which is 6 digits at this time, and then look at the options. It can be seen that the numbers in A, B, and C are all even, and only the number of 1 in D is an odd number. At this time, it is obvious that there is a problem with AC, but it cannot be detected with D , because It may be that two of the bits have changed, or it may be that there is no error.

Characteristics of parity check code : It can only detect odd number of bit errors, and the error detection capability is 50%.


Method 2: CRC cyclic redundancy code

Simple version of CRC cyclic redundancy code example (decimal)

The following example is not much different from the actual CRC cyclic redundancy code. One uses decimal numbers, while CRC divides binary numbers.

Sender : First, we give the data 5 we want to transmit and the polynomial 2. Then we perform the division operation and the remainder is the redundant code 1. Then we add the sent data and the redundant code to get the final data 5 sent. + 1 = 6.

Receiving end : To detect whether there is a transmission error, you can use the obtained data 6 to be in the polynomial. If the remainder is 0, it means there is no error.

image-20230730182356778


Practical CRC cyclic redundancy code application (binary)

Standardize the process

Step 1. Prepare valid data to be transmitted.

First, cut the data to be sent into bit combinations one after another:

image-20230730182750168

Step 2. Add the obtained redundancy code to each group to form a frame and then send it

image-20230730182858231

  • The actual question will give a generating polynomial with r+1 digits.

Sometimes the generator polynomial similar to 11011 is not directly given, but it may be 1x2 4 + 1x2 3 + 0x2 2 + 1x2 1 + 1x2 0 , which forms 11011.

  • For the order of a number, it depends on the highest bit corresponding to 2. For example, 11011, the largest polynomial is 2 4 , then the corresponding order is 4.

We first add the r-bit 0 after the data to be transmitted, as follows:

image-20230730183048430

The final calculation method of the FCS frame check sequence is as follows, and finally an FCS with a remainder of r bits is obtained, which is the frame detection code:

image-20230730183546525

Step 3: Receiver Inspection

We take the final received data and divide it by the generator polynomial, and finally decide whether to discard it based on whether the remainder is 0:

image-20230730183811776

Features : The generation of FCS and the CRC check at the receiving end are all implemented by hardware, and the processing is very fast, so there will be no delay in data transmission.


Practical examples

Topic :

image-20230730183957641

Analysis : Given the sent data and the generating polynomial, we can calculate the remainder frame detection sequence.

Step 1: Prepare valid data to be transmitted.

The data to be sent is 1101011011, and the generator polynomial is 10011. Then we find the order of the generator polynomial.

10011 is expressed as a polynomial: x 4 + x 1 + x 0. At this time, the order can be determined to be 4.

Step 2: Add the obtained redundancy code to each group to form a frame and then send it

Calculate redundant codes :

  1. Adding 0s: Assuming that the order of the generator polynomial G(x) is r, add r 0s.
  2. Modulo 2 division: The data is divided by the polynomial after adding 0, and the remainder is the bit sequence of the redundant code/FCS/CRC check code. (The original subtraction of the process, here is XOR, same as 0 and different as 1)

We first add 4 digits of 0 after the data to be sent, which is: 11010110110000.

Next we perform the division operation. Note that the process should be the same as 0 and different from 1:

image-20230730184759504

Finally, the remainder FCS (redundant code or FCS frame check sequence) is obtained:

image-20230730184838515

After getting the remainder, we replace all the previously added 0s with the remainder and transmit it. The value transmitted at this time is: 11010110111110.

The final data to be sent is:实际的数据+帧检测序列

Step 3: Receiver Inspection

Divide each received bit frame by the same divisor, and then check whether the resulting remainder R is 0.

  • If the remainder is 0, it is determined that there is no error in this frame and is received.
  • If the remainder is not 0, it is determined that the frame is in error (cannot be determined to be in place) and discarded.

image-20230730185251970


Points to note about CRC (question point: whether error-free reception means reliable transmission)

1. Be sure to distinguish the difference between CRC and FCS: CRC refers to a method of detecting encoding, while FCS refers to the frame detection sequence.

2. By default, as long as the receiving end receives it, it means there is no problem with the frame. Here is a probability close to 1 that there is no error.

  • In extreme cases, even if the final remainder may be 0, an error may still occur.
  • In the data link layer, only using cyclic redundancy check CRC error detection to detect odd numbers can only achieve error-free reception of frames, that is, "for all frames accepted by the data link layer at the receiving end, we can detect them as very close to 1 There is a probability that no errors occurred during transmission of these frames." Although the frames discarded by the receiving end were mentioned, they were eventually discarded due to errors.
  • "All frames accepted by the data link layer at the receiving end are error-free" (this is the default belief).

3. Question: Does error-free reception mean reliable transmission?

  • "可靠传输"指的是数据链路层发送端发送什么,接收端就收到什么。
  • 对于CRC检验,只能够实现无比特差错的传输,但这还不是可靠传输。
    • 原因描述:只要接收了这个帧,就没有比特差错,但是这并不能叫做可靠传输,因为我们有一些帧丢弃了它(让其重传),没有这些帧进行处理,那发送端发送的全部数据接收端并没有全部接收,所以这还达不到可靠传输。

3.5、纠错编码

3.5.1、海明码

对于之前的奇偶校验码仅仅只能够检测出错误,对于海明码则可以发现错误、找到位置、纠正错误

工作流程如下

image-20230730200907745

  • 第二步中是要将这个校验码插入到数据位数当中,这一点与前面两种检测编码不一样,对于奇偶校验码和CRC循环冗余码都是在最低为附加上一位或者是几位的效验码,但是在海明码这里需要根据一定的规则,在数据位当中安插上这个校验码。

3.5.2、认识海明距离

海明距离:两个合法编码(码字)的对应比特取值不同的比特数称这两个码字的海明距离。

  • 或者说:一个有效编码中,任意两个合法编码(码字)的海明距离的最小值称为该编码集的海明距离(码距)。

举例:例如1000、1111的海明距离就是三位,若是01、00那么就是1位。

**若是求一个编码系统当中的码距呢?**也就是取任意两个编码之间的最小距离(不同的位数)。

场景1:当我们编码系统中码距为1时,是无法检测出1位错的。

image-20230730213447888

试想,传输过程中000出现了错误变为了001,那么我们是无法判断它是否错误的,因为在正确的编码传输中包含有001。

场景2:若是编码系统中的码距为2,那么可以检测出1位错误,但是不能够被纠正。

image-20230730213618933

试想:若是0000错了一位变为了0001,此时我们就能够发现它有错误,原因是正确的编码中并没有码距为1的与其相同的编码,所以能够检测出来。

那是否能够纠正呢?依旧是不行的,我们举个例子,就以0000来传输错误一位来看,可能出现的错误情况有:

1000
0100
0010
0001

When we transmit 0010, we can find that it is wrong because it does not exist in the correct encoding. At this time, we correct it and modify any bit as follows:

1010 命中
0110 命中
0000 命中
0011 命中

It can be found that correcting any one bit can match all the correct ones, then it directly proves that it cannot be corrected!

Scenario 3: What if the code distance is 3?

0000
0111

If a number is modified during the transmission of 0000, it may be 0010, then we correct it and try to modify the wrong bit:

1010 
0110
0000 命中
0011

It can be seen that only 1 is hit, so it can be concluded that if the distance is 3, then 1 error can be corrected and 1 or 2 errors can be detected.

Final conclusion: If the Hamming code needs to detect d dislocations, then the code distance is d+1. If you want to correct the d dislocations, it needs to be 2d+1.


3.5.3. Work flow of Haiming code (including detailed process, combined with examples)

You can learn this: Detailed explanation of the principle of Hamming code (stop memorizing it by rote)

image-20230730200907745


Step 1: Determine the number of check code digits r

The data/information has m bits, and the redundant code/check code has r bits.

At this time, a formula can be used to express the relationship between m and r ( 海明不等式): 2 r >=m+r+1.

  • A check code can be used to filter one digit in binary, so 2 r is needed to represent the filterable range, which is actually the final range.
  • At the same time, the check code and the number of bits are finally put together for transmission, so m+r.
  • When used for detection before, if you want to detect d dislocation, then you need d+1 bits.

Example : The data to be sent at this time is D = 1100.

At this time, m is 4 digits, then substitute r >=m+r+1 into formula 2, and the minimum r is 3 digits, and r = 3 at this time.

The final Hamming code has a total of 4 + 3 = 7 digits

The original data is 4 digits and the check code is 3 digits.


Step 2: Determine the location of the check code and data

The check code has 3 digits, and we represent the 7 digits from right to left: 1, 2, 3, 4, 5, 6, and 7.

image-20230730233335268

对于3位校验码依次放的位置是:20、21、22,我们这里分别标记位标识为x1、x2、x4。

image-20230730233450813

接着我们将给到的原始数据1100,依次从前往后放入到表中:

image-20230730233837119


步骤3:求出校验码的值

这步骤中关键思想是进行分组,可以看到序号上方使用了二进制来进行表示每个序号值,这个之后需要来进行分组划分用途:

image-20230730233518444

对于x1、x2、x4分别表示的是001、010、100,实际可以看到表示三位数的一位,接着我们需要将整个表中分别去匹配**1*1*1**,整个*可以表示0或者1,只要能够匹配到即可。

image-20230730233732466

接着我们对这一组采用偶校验进行编码,得到x1、x2、x4的取值:

4号  x4 0 1 1   =>  x4=0
2号  x2 0 1 1   =>  x2=0
1号  x1 0 0 1   =>  x1=1

得到了x1、x2、x4的值之后,我们将其值填入到表中:

image-20230730234146923

此时得到的海明码实际就可以进行传输了。


步骤4:接收端进行检错与纠错

此时我们这里直接将海明码中的序号5进行修改,来看是否可以去纠错找到错误的位数,并且进行改正过来:

image-20230730234303953

此时接收端收到的值(错误的值)为1110001,这里我们依旧采用偶校验来进行校验:

image-20230730234355854

  • 打x的就表示1的个数为奇数个,很明显对应的校验码检测到指定这一位数有错误!

确定错误位置有两种方法:

方法1:找到不满足奇/偶校验的分组取交集,并与符合校验的分组取差集。

通过画圈的方式来筛选指定位,可以看到1号、4号有错,那么可以通过画圈来定位到5、7中有一个是错误的。

image-20230730234847804

此时我们再使用2号校验码(对应分组的位都是正确的)最终筛选出来5是错的,那么我们将5位置的1修改为0就可以完成纠错了!

方法2:分组采用指定奇/偶校验(规定来)得到各个x1、x2、x4位数最终进行组合起来即可定位

image-20230730235045722

由于x4的分组是1**,x2的分组是*1*,x1的分组时**1,所以对应的合并位置也是如此!

It was finally filtered out that an error occurred at No. 5.


Thoughts and some questions and thoughts

Question 1 : How many digits can be detected in the above Hamming code? What if there are errors in multiple digits?

Conclusion: Standard Hamming codes can only detect 1-bit errors.

  • Standard Hamming codes (such as Hamming(7,4) codes) add 3 check digits to every 4 data bits, for a total of 7 bits. This Hamming code is designed to detect and correct single-bit errors. If a two-bit error occurs during transmission, the error correction capability may not cover this situation.
  • For the case of multiple bit errors, other more complex error correction code schemes may need to be used. The selection of error correction codes should be based on specific requirements and associated transmission error patterns.

Question 2 : The above is just an example of an error in the data bit. If an error occurs in the detection bit, can it also be detected?

Conclusion: It can also be detected. For x1, x2, and x4, their function is only to represent **1, , *1*and 1**divide and group them respectively. The actual value of itself will not affect error detection and correction. In the end, it can still be Detect and correct errors!


mind map moment

image-20230730235259213


4. Flow control and reliable transmission mechanism

4.1. Flow control, reliable transmission mechanism and sliding window mechanism

4.1.1. Understand the flow control of the data link layer (compare with the flow control of the transport layer)

Why flow control?

  • The mismatch between higher sending speed and lower receiving capability will cause transmission errors, so flow control is also an important task of the data link layer.
  • If the current receiver can no longer receive more requests, and the sender still sends out at the previous speed, then the receiver will overflow . This total overflow will cause the data sent by the sending method not to be received. It wastes both space and resources , so flow control is necessary.

The difference between flow control at the data link layer and flow control at the transport layer :

  1. The flow control of the data link layer is point-to-point, while the flow control of the transport layer is end-to-end.
  2. The flow control method of the data link layer: if the receiver cannot accept it, it will not reply with an acknowledgment. If the receiver can accept it, it will reply with an acknowledgment frame.
  3. Transport layer flow control means: the receiving end announces a window to the sending end.

4.1.2. Flow control methods (stop-wait protocol, sliding window protocol)

Contains two: 停止-等待协议, 滑动窗口协议.

  • The stop-wait protocol can actually be regarded as a special sliding window protocol. The window of this protocol is 1, and the sending and receiving windows are both 1.
  • The sliding window protocol is divided into two methods : 后退N帧协议(GBN), 选择重传协议(SR).

image-20230731110124079


stop-wait protocol

停止-等待协议: It is actually relatively inefficient, because each time a frame is sent, it needs to wait for the receiver to send back a confirmation frame before sending the next frame.

Process : The sender stops sending every time it sends a frame, waits for the other party's confirmation, and then sends the next frame after receiving the confirmation.

image-20230731110359223


sliding window protocol

滑动窗口协议: relatively efficient

The process of sliding in the window window protocol :

In the figure below, the upper data is the sending end, and the lower data is the receiving end. Each small grid marks a frame, which is sorted from frame 0 to frame 1. In the figure below, the sending window position is 6 sizes, and the receiving window is The end maintains one. At this time, the frames in the sending window can be sent continuously (there is no need to wait for the corresponding sequence number frame to receive the confirmation frame before sending), while the receiving window can only receive the corresponding sequence number frame.

image-20230731110735597

  • 发送窗口: Refers to the sender maintaining a continuous sequence number of frames that are allowed to be sent. (It can also be understood as the data currently being sent by the sender)

When the receiving window receives frame No. 0, the receiving window will move forward one space, indicating that the current receiver can receive the second frame:

image-20230731111055202

At the same time, the receiver will return a confirmation frame No. 0. When the sender receives it, it will also perform a sliding window. At this time, frame No. 5 in the window can also be sent out:

image-20230731111345641

Additional note : In fact, the stop-wait protocol is also a sliding window protocol, but there is only one window for the sender and the receiver.


Compare the window sizes of three waiting protocols

Compare the window sizes of the three waiting protocols :

  • Stop-wait protocol: send window size=1, receive window size=1.
  • Backoff N frames protocol (GBN): sending window size > 1, receiving window size = 1.
  • Select retransmission protocol (SR): sending window size >1, receiving window size >1.

注意点:在链路层的滑动窗口协议中,整个窗口(发送窗口、接收窗口)的大小 在传输过程中是固定的。


4.1.3、对可靠传输、滑动窗口、流量控制进行区分:

可靠传输:发送端发啥,接收端收啥。

  • 解决问题:这种传输方式是可靠的,若是发生帧的丢失,帧的失去与重复,那么接收端都要进行整个控制使得我们接收端失去、重复的帧回到正常状态,这也就是可靠传输要解决的问题。

流量控制:控制发送速率,使接收方有足够的缓冲空间来接收每一个帧。

  • 解决方案:滑动窗口
    • 解决问题1:流量控制(收不下就不给确认,想发也发不了)。【通过滑动窗口,我们可以每次固定一个窗口的大小,若是接收到一个确认帧窗口才会进行滑动一格,整个过程实际上就是对流量进行控制。因为若是发送端一直没有收到确认帧,它的发送窗口就一直圈在那几个帧上面,变相的控制了发送端的一个发送速率,一旦接收方收不下数据不回复确认帧,那么发送端想发送数据也发送不了,因为窗口已经固定在那里了】
    • 解决问题2:可靠传输(发送方自动重传)。【发送方若是发送了一个帧之后等待一段时间还没有收到确认帧,此时会进行自动重传】

4.1.4、对于停止-等待协议、滑动窗口协议究竟是哪一层的?

左边两本书将该协议作为是传输层的,而王道书中则是将该协议作为在数据链路层:

image-20230731113705735

在计算机网络发展前期,通信链路质量不是很好,此时链路层就需要担负起可靠传输的职责,因此链路层就会使用停止—等待协议、后退n帧协议、选择重传协议等。

随着技术发展,通信链路的质量越来越好,此时出现差错的可能并不会像之前那么大,此时链路层它就可以暂时抛弃掉可靠传输的这样一个职责,把这个责任交给传输层来实现,而链路层只需要负责一个差错控制即可,这样能够使得我们的数据在链路上传递速度更快,所用的时间,延迟也更小。

Summary : We don’t need to worry about which layer these three protocols are on, and which layer they are on. The final impact is only an object for transmitting data. For example, if these three protocols are on the transport layer, then the object is a packet , and on the link layer When transmitted, it is a frame . The essence is the data we want to transmit.


mind map moment

image-20230731113112619


4.2. Stop-wait protocol

4.2.1. Why is there stop-wait protocol and research premise?

1. Why is there a stop-and-wait protocol?

In addition to bit errors, packet loss occurs in the underlying channel.

  • Packet loss: Physical line failure, equipment failure, virus attacks, routing information errors and other reasons may cause data packet loss.

In order to solve the packet loss problem and implement flow control, it is necessary to use the stop-wait protocol.

2. What are the prerequisites for the research stop-and-wait agreement?

Although full-duplex communication is commonly used now, for the convenience of discussing the issue, only one party sends data (sender) and one party receives receipt (receiver).

Since we are discussing the principle of reliable transmission, there is no need to consider which level the transmission is at.

"Stop-wait" means to stop sending each packet after sending it, wait for the other party's confirmation, and then send the next packet after receiving the confirmation.


4.2.2. Stop-wait for the error-free and error-free conditions of the protocol

No error situation:

The figure below describes that in the case of no errors, the sender will wait every time after sending a frame. The sender will not send the next frame until the receiver returns an acknowledgment frame after receiving the frame:

image-20230731145317071

  • You can see that there are multiple zero frames, and the two frames are not the same.

Note : The sending end stops and waits every time a data frame is sent, so a 1-bit number is enough.

This error-free situation is very ideal, but some errors often occur in actual tasks, that is, packet loss problems. Some data frames are lost in the link layer.


There is an error situation

Case 1: Data frame is lost or frame error is detected

Scenario recurrence : The sender sends the first frame to the interface without any problem. At this time, the receiving end returns an acknowledgment frame of ACK 0 indicating frame 0. At this time, the sender sends the next frame after receiving the acknowledgment frame. At this time If the frame is lost during the transmission process, then the receiving end cannot receive the frame and cannot reply to the confirmation frame. At this time, the sending end will continue to wait because it cannot receive the confirmation frame. How to solve this kind of problem?

image-20230731145439364

Solution : The sending end uses a timeout timer. The timeout starts when the sending end sends a frame. If a timeout period expires and the acknowledgment frame has not been received, it will be retransmitted.

image-20230731150110579

超时计时器: Start a timer every time a frame is sent. The retransmission time set by the timeout timer should be longer than the average RTT of frame transmission.

  • RTT refers to the round-trip transmission delay.

Points to note :

  1. After sending a frame, the sender must keep a copy of it. (To prevent frame loss during transmission and retransmission. Only after receiving the confirmation frame of the corresponding frame can it be discarded and the next round of transmission begins)
  2. Data frames and acknowledgment frames must be numbered. (If the receiving end continuously receives data frames with the same transmission sequence number, it means that the receiving end has received duplicate frames. This number can be used to solve problems such as frame loss and duplication; also, if the frame is received, but after error detection, problems arise. , then the frame will be discarded at this time, no processing will be performed, and an acknowledgment frame will not be returned. At this time, the sender can only wait for a retransmission time before retransmitting)

Second case: ACK lost

Situation description : After receiving the frame sent by the sender, the receiving end returns an acknowledgment frame. What if the acknowledgment frame is lost in the process?

Solution : If the sending end does not receive an acknowledgment frame within a timeout period, it will time out and retransmit the frame just now . Then the receiving end will discard the second frame since it has already received it before. For repeated frames, retransmit and confirm frame No. 1, that is to say, an acknowledgment of frame No. 1 is performed again, then the sender receives frame No. 1.

image-20230731150629616


The third situation: ACK is late

Scenario recurrence : The sender first sends frame No. 0, and the receiving end returns the confirmation frame No. 0 (No1) after receiving frame No. 0. However, it has not arrived due to network congestion. At this time, the receiving end has expired due to the timeout timer. When the time is up, frame 0 will be retransmitted.

Then the receiving end receives frame No. 0. Since it has been received last time, it will discard the frame No. 0 this time and return a confirmation frame No. 0 (No2). This time the network does not block the sending end to receive it quickly. When this confirmation frame No. 0 arrives, frame No. 1 starts to be sent. After sending it again, frame No. 0 (No1) that was previously replied by the first receiving end is received.

The processing method for the sending end is: do not process it, just simply discard it.

image-20230731151117206

Question: What if the No. 0 confirmation frame of No1 arrives before the No. 0 confirmation frame sent for the second time?

image-20230731151345142

Answer : Then the sender will directly start sending frame No. 1 after receiving the acknowledgment frame No. 0. As for the second acknowledgment frame No. 0, the sender will do the same as above and will also discard it.


4.2.3. Stop-wait protocol performance analysis (advantages and disadvantages)

Advantages : Simple.

Disadvantages : Channel utilization is too low!


4.2.4. Understanding channel utilization in stop-and-wait protocols

Next, look at the diagram to understand the channel utilization:

image-20230731152213198

信道利用率: Refers to the ratio of the time required by the sender to effectively send data within a sending cycle to the entire sending cycle.

The formula is as follows. It can be seen that the actual channel utilization of this transmission delay in the figure is relatively low :

image-20230731152253279

The actual summary is : within a sending cycle, the time required by the sender to effectively send data accounts for the proportion of the entire sending cycle.

Simplifying the above formula (combined with the data given in the actual example), the actual calculations of the two are the same:

image-20230731152521102

In addition, there is a calculation formula related to channel utilization, which is channel utilization: 信道吞吐率 = 信道利用率 * 发送方的发送速率.


4.2.5. Practical examples of channel utilization

Topic :

image-20230731153256061

Analysis : The transmission rate is 4kb/s, then C = 4kb/s. The single propagation delay is also given to 30ms, so the round trip is 30*2 = 60ms. At this time, we set the data frame length to L.

The formula can be listed as follows:

image-20230731153411389

  • How to calculate 2 x 30ms x 4kb/s? 4kb/s = 4000bit/s, and 30ms is 30/1000 s, which corresponds to 4000bit/s to convert 30ms x 4kb/s = 120bit

Then L / (L+240) = 0.8, and finally L = 960bit can be calculated.


mind map moment

image-20230731151815454


4.3. Backward N frame protocol (GBN protocol)

4.3.1. Disadvantages of the stop-and-wait protocol (understanding pipeline technology)

First, take a look at the stop-and-wait protocol. You can see that each frame is transmitted only after the previously transmitted frame receives an acknowledgment frame. You can see that a lot of time is spent waiting:

image-20230731164956732

How can we make the channel utilization rate higher?

Solution: Assembly line technology.

After sending one data frame, you can send several data frames continuously. As shown in the figure below, three frames are sent continuously each time. At this time, you can see that the channel utilization rate becomes higher:

image-20230731165135375

The assembly line technology is not a test point, just understand it.

**Why is it called an assembly line? **Each data frame will be sent downwards after the previous data frame. This continuous sending is like pipeline work. This is called pipeline technology.

The use of pipelines also brings some impacts, and some improvements need to be made at this time :

1. The serial number range must be increased. (Each transmission data frame must have a unique sequence number. For example, in the three groups of frames transmitted above, their sequence numbers should be different, so that the receiver can return a unique frame corresponding to each of them. If it is lost, it is easier to find which frame the problem is.)

2. The sender needs to cache multiple packets. (During the transmission process, it is very easy for frames to be lost, such as frame No. 0, frame No. 1, and frame No. 2 are sent. If the three frames transmitted continuously lose No. 1 and No. 2, only frame No. 0 is sent successfully. , then actually if frames 1 and 2 need to be retransmitted without waiting, then these two frames should be cached in advance before being sent, then we need two more cached data frame locations than the stop-and-wait protocol)

在流水线下,也有可能会出现确认帧丢失、迟到等情况,那么为了解决这些差错,此时就有了后退N帧协议以及选择重传协议


4.3.2、后退N帧协议中的滑动窗口

发送方维护一个>1的窗口,接收方则是维护一个=1的窗口,接收方每接收到一个帧之后就会返回一个确认帧,并且此时窗口会移动一格,同时发送方若是接收到了确认帧之后也会移动格子。

image-20230731170842198

  • 通过发送窗口,可以来确定帧的四种状态:①发完被确认的。②已经发送但等待确认的。③还能发送的。④还不能发的。

额外特点:为了使得效率更高,接收方不用对于每一个帧都返回一个确认帧,可以进行累计确认,若是发送方将1、2、3号帧全部发送出来,接收方无需逐一确认,而是直接对三号帧确认即可,回复一个ack3,此时发送方接收到确认帧之后就知道三个帧都已经接收了,此时就应该要发送4号帧。


4.3.3、GBN发送方必须响应的三件事

1、上层的调用

上层要发送数据时,发送方先检查发送窗口是否已满,如果未满,那么产生一个帧并将其发送,如果窗口已满,发送方只需要将数据返回给上层,暗示上层窗口已满,上层等一会再发送。

  • 实际实现中,发送方是可以将上层的数据接收下来,不过是放在缓存中,等它空闲了或者整个窗口有空的时候可以发送数据的时候再将缓存中的数据帧拿出来,完成一个发送。

2、收到一个ack

GBN协议中,对n号帧的确认可以采用累计确认的方式,标明接收方已经收到了n号帧和它之前的全部帧。

  • 例如收到了ack4,那么此时接收端默认4号及之前的帧已经全部收到,之后发送端开始发送5号帧及之后的帧。

3、超时事件

协议的名字为后退N帧/回退N帧,来源于出现丢失和时延过长帧时发送方的行为。与停-等协议中一样,定时器将再次用于恢复数据帧或确认帧的丢失。如果出现超时,那么发送方会重传所有已发送但未被确认的帧

  • 对于接受端,是按照顺序来进行接受的,并不是说发送端连续发送1、2、3、4号帧时,若是4号帧先到达,接收端就会直接接收,它会首先等待1号帧的到达,若是其他帧优先到达那么此时会进行丢弃该帧,知道等待到1号帧为止。
  • **若是这个1号帧在传输过程中丢失了,那么接收端也不接受其他的帧,那么此时怎么办?**在接收端中有一个超时定时器,若是1号帧的确认帧长时间没有接收到,那么此时会进行超时重传,将当前帧以及后面的帧重新传输出去。

image-20230731172856775


4.3.4、GBN协议接收方要做的事情

1、若是正确收到n号帧,并且按照序,那么接收方为n帧发送一个ACK,并将帧中的数据部分交付给上层。

2、若是想要等待的帧一直没有收到,那么若是提前到来的其他帧都会丢弃掉,并为最近按序接收的帧重新发送ACK。接收方无需缓存任何失序帧,只需要维护一个:expectedseqnum(下一个按序接收的帧序号,也就是一直等待的那个帧)。


4.3.5、运行中的GBN(运行过程)

下面使GBN的运行过程及示例

​ 首先发送端连续发出了0帧、1帧、2帧、3帧,其中0帧、1帧成功被接收了并返回了相应的确认帧,其中2号帧在传输过程中丢失了,那么当3号帧到达接收端的时候,接收端由于目前的expectedseqnum是2号帧,此时就会丢弃掉3号帧

​ 由于0帧、1帧的确认帧都被发送端接收了,此时发送端的窗口移动了两格,此时会连续发出4号帧、5号帧,而同样由于接收端目前的expectedseqnum依旧是2号帧,那么此时同样会丢弃掉4号帧、5号帧。

At this time, the timeout timer for sending 2 frames has expired and the confirmation frame of 2 frames has not been received. At this time, the timeout will be retransmitted , and the 3 frames, 4 frames, and 5 frames after the 2 frames will also be sent again continuously. , and then wait for the receiving reply confirmation frame from the receiving end, and the cycle repeats.

image-20230731173838110


4.3.6. Question: Can the length of the sliding window be infinite?

If n bits are used to number the frame, then the size of the sending window W T should satisfy: 1<=W T <=2 n -1. If it exceeds this range, the receiver will be unable to distinguish whether it is a new frame or an old frame.

Let's take an example. Here I will take the example picture from a blog. It is very clear why the sending window of the Backoff N Steps (GBN) protocol and the Selective Retransmission (SR) protocol is limited :

Using 2 bits to number the frame, then 2 2 - 1 = 3, the window can only be up to 3, so why can't it exceed it?

  • Let's look at the following example. When the window is 4, our sender directly sends frame No. 0123. At this time, all frames from the receiver are received and corresponding confirmation frames are returned. At this time, an extreme situation occurs, four The acknowledgment frames are lost during transmission . Since the sender does not receive the acknowledgment frame, it will timeout and retransmit while waiting for the timeout timer to end. At this time, frame No. 0 will also be sent again! ! !
  • Note that the current receiver has actually received the previous set of frames and has confirmed that the frame has been returned. The frame No. 0 passed here may only be regarded as a new value for the receiver, and then transmission will occur. Wrong question! (The receiver thinks that the acknowledgment frame can be correctly received by the sender)

image-20230731182027116


4.3.7. Summary of key points of GBN protocol

1. The receiving end can confirm cumulatively and occasionally can confirm incidentally.

  • 捎带确认It means that when the receiving end wants to transmit some return data to the sending end, it can bring the corresponding confirmation frame and transmit it back.

2. The receiver only receives frames in order and ruthlessly discards them out of order.

3. Confirm the frame with the largest sequence number that arrives in sequence.

4. The maximum sending window is 2 n - 1, and the receiving window size is 1.


4.3.7. Exercises

Exercise 1

Topic :

image-20230731183028351

Parsing : C

Using the GBN protocol, the receiving end receives frames in order. In the question, frames 0, 2, and 3 are received. The absence of frame 1 is interference (it is definitely lost or delayed during the sending process of the receiving end). arrival), because the receiving end cannot jump to receive confirmation. At this time, the receiving end has actually received frames No. 0, 1, 2, and 3. At this time, the sender needs to resend frames 4, 5, 6, Frame No. 7, then the number of frames is 4.


Exercise 2

Topic :

image-20230731185808385

Parsing : C

Grab the key ones: the first frame, the last frame and the confirmation frame of the first frame.

First, let’s calculate the acknowledgment frame time of the first frame from sending + transmission:

  • Sending time of one frame: (1000 x 8)/100Mb/s = 0.08ms
  • Round trip time: 2x50 = 100ms
  • One frame sending time + round trip time = 100.08ms

So what is the maximum amount of data that can be transmitted in 100.08ms after receiving the confirmation frame of the first frame?

Let’s calculate the time it takes for all data frames of the entire window size to be sent out: (1000 x 1000 x 8) / 100Mb/s = 80ms. At this time, we can understand that after we send out all the data frames in the entire window, at this time The acknowledgment frame of the first frame has not been received yet. At this time, you still need to wait for 20ms, and then the cycle repeats. At this time, we can calculate the average data transmission rate of the maximum number.

The time from sending a frame to receiving the first frame is 100.08ms. The size of the sent data frame is 1000x1000x8 = 8 x 10 6. Let's use the total size/time = maximum average data transfer rate.

That is, (8 x 10 6 ) / 100.08ms is approximately equal to 80Mb/s.


4.3.8. GBN protocol performance analysis

Benefits : Improved channel utilization because data frames can be sent continuously.

Disadvantage : During retransmission, the original correctly transmitted data frame must be retransmitted, which reduces the transmission efficiency.

  • In order to solve the entire problem, there is a new protocol called the Selective Retransmission Protocol, which will improve this shortcoming.

mind map moment

image-20230731164313186


4.4. Select retransmission protocol (SR protocol)

4.4.1. Disadvantages of GBN protocol

In the back-off N frame protocol GBN, a better function is that the receiving end can perform cumulative determination (for example, the sending end sends 1, 2, and 3 frames, then the receiving end does not need to reply to every frame, but directly replies to one 3 frames is enough to completely determine frames 1, 2, and 3).

However, this also brings about the problem of batch retransmission : if the sender has not received a confirmation frame for a long time, the frame and other frames within the window will be retransmitted in batches, which results in loss comparison. Large, because some of the subsequent frames may have been sent once and are so old that they are wasted.

Solution :

1. Set a single acknowledgment : Confirm frames one by one, so that if a frame is wrong or a frame is lost, just retransmit the erroneous frame.

2. At the same time, increase the receiving window, set up the receiving buffer, and cache frames arriving out of order : What this means is that if frames 0, 1, 2, and 3 were sent continuously before, then the receiving end must receive frame 0 first, and other frames first. The arrival will be discarded. If there are other frames arriving here first, then we will first put them in the buffer, wait for the leftmost frame of the window to arrive, and then hand it over to the network layer (receiving end).


4.4.2. Select the sliding window in the retransmission protocol (SR protocol)

Various states of the sender’s sliding window

Different frames related to the sender's sliding window are divided into the following states :

①After being sent and confirmed.

②已经发送但等待确认的。

③还能发送的:对于这个状态是若是再给个数据,就可以将它塞到五号里面,标上5号帧发送出去。

④还不能发的:还不在滑动窗口范围中的。

image-20230731204350612

  • 对于滑动窗口中发送端能够接收确认帧并不是像GBN中一样顺序确认的(由于接收端可以乱序进行提前缓存原因),那么可以看到上图中已经发送但等待确认的是某个已经被确认的左右两边。

接收方滑动窗口的各个状态

对于接收方的滑动窗口相关的不同帧分为以下几个状态

①希望收到但没收到的。

②等待接收的。

③收到且确认的(缓存):可以看到接收方在选择重传协议中可以乱序提前缓存某个数据帧。

image-20230731204757736


4.4.3、SR发送方必须响应的三件事

1、上层的调用

从上层收到数据后,SR发送方检查下一个可用于该帧的序号,如果序号位于发送窗口内,则发送数据帧;否则就像GBN一样,要么将数据缓存,要么返回给上层之后再传输。

  • 实际实现中,发送方是可以将上层的数据接收下来,不过是放在缓存中,等它空闲了或者整个窗口有空的时候可以发送数据的时候再将缓存中的数据帧拿出来,完成一个发送。

2、收到了一个ACK

如果收到ACK,加入该帧序号在窗口内,则SR发送方将那个被确认的帧标记为已接收。

  • 如果该帧序号是窗口的下界(最左边第一个窗口对应的序号),则窗口向前移动到具有最小序号的未确认帧处,整体移动。
  • 若是窗口移动了此时在窗口内会有新的未发送帧,此时就发送这些帧。

image-20230731205608406

3、超时事件

每一个帧都有自己的定时器,一个超时事件发生后只重传一个帧。


4.4.4、SR接收方要做的事情

对于窗口内的帧来者不拒,不是顺序的也可以进行接收

Specific reception details : The SR receiver will acknowledge a normally received frame regardless of whether it is in order (provided that the frame is in the window). Out-of-sequence frames will be cached directly in the window and a confirmation frame of the frame will be returned to the sender (the confirmation frame will be returned directly to whichever frame is received) until all frames (that is, frames with smaller sequence numbers) have been received. Only then can a batch of frames be delivered to the upper layer and the sliding window moved forward.

image-20230731210817278

If a frame outside the window sequence number (less than the next window) is received, an ACK is returned. Otherwise, the frame is ignored.


4.4.5. Running SR process (involving timeout)

Assume that the sending window and receiving window sizes are both 4 .

① The sending end sends frames 0, 1, 2, and 3 in sequence from the beginning. The frame No. 2 was lost when sending. The receiving end received frames 0, 1, and 3 at this time, and returned the confirmation frames in sequence.

② The sending end first receives the confirmation frame of frame No. 0, then moves the window one frame and starts sending frame No. 4.

③The sending end receives the confirmation frame of frame No. 1 again. At this time, it moves the window one frame again and starts sending frame No. 5.

④ Note that since the No. 2 frame was lost during the transmission process, the receiving end will not send the No. 2 confirmation frame to the sending end if it does not receive the No. 2 frame. At this time, since the timer of frame No. 2 has expired , the sender will time out and retransmit frame No. 2 (this frame alone).

⑤ The sender receives the confirmation frame of frame No. 3, but because the confirmation frame of frame No. 2 has not yet been received, the window will not move at this time, and there is no frame to send (it can only continue after frame No. 2 is sent) moving window)

image-20230731210959848


4.4.6. Sliding window length calculation (including scene conditions)

Question: Can the length of the sliding window be infinite?

Conclusion : The sending window is preferably equal to the receiving window, because if it is larger, it will overflow, and if it is smaller, it is meaningless.

The formula for calculating the window : W Tmax = W Rmax = 2 (n-1) .

  • Here Tmax refers to the window of the sender, Rmax refers to the window of the receiver, and n refers to the number of bits representing the sequence number (if the sequence number is 0, 1, 2, 3, then it is a number that can be represented by 2 bits)

Two scenarios: Scenario 1 is that the receiving end cannot recognize the reception error, Scenario 2 is that the transmission is correct

Scenario 1: There is a bunch of frames with 2 bits representing the sequence number. The current window is 3. In the current scene, an error occurs and the retransmitted frame is received as a new frame in the window (error reception example)

Process description :

  1. The sender sends frames 0, 1, and 2 in sequence. At the same time, the receiver can receive them correctly and return the corresponding frames, but all three frames are lost! However, this window that does not affect the receiving end is moved by three. You can see that the latest receiving end window also contains frames with sequence numbers 0 and 1. Will there be a problem later?
  2. Since the sending end has not received any acknowledgment frame, the sending end will time out and resend frame No. 0. Pay attention! At this time, the receiving end received the frame with sequence number 0 again. However, as the receiving end has received the sequence number 0 before, the frame passed this time will mistakenly regard it as a new frame and save it to the current window buffer. middle. (Actually, this frame is a retransmitted frame!!!)

image-20230731211731110

Problem description: The retransmitted frame was incorrectly received in the window as a new frame.

Scenario 2: There is a bunch of frames with 2 bits representing the sequence number. The current window is 3. In the current scenario, the receiving end can correctly receive the new frame with sequence number 0 (example of correct reception)

Process description :

  1. The sending end sends frames 0, 1, and 2 in sequence. At the same time, the receiving end can receive them correctly and return the corresponding frames.
  2. The sender receives frame No. 0. At this time, the window moves one frame, and a new frame No. 3 appears in the window. At this time, frame No. 3 will be sent out. The red arrow indicates that the frame was lost during the sending process.
  3. At this time, the sender received confirmation frame No. 1 again, and the window moved again. At this time, a new frame No. 0 appeared in the window. The sender will also send out frame No. 0, and the receiving end can normally send this new frame at this time. Frame No. 0 is received in the new window corresponding sequence.

image-20230731212300088

It is normal to transmit frames during this process.


4.4.7. Summary of key points of SR protocol

1. Confirm the data frames one by one, and confirm each received one. (Limited to the window of the receiving end)

2. Only error frames are retransmitted. (No longer requires batch retransmission like GBN protocol)

3. The receiver has cache. (If an out-of-sequence frame in the window of the receiving end comes, the receiving end will also accommodate it, cache it first, wait until a correct frame is formed, and then deliver these consecutive frames to the network layer, and at the same time window forward)

4. W Tmax = W Rmax = 2 (n-1) . (maximum receive window)


4.4.8. Exercises

Topic :

image-20230731213952681

Analysis : A

In this question, the data link layer uses the Selective Retransmission (SR) protocol. The sender has sent frames 0-3, which are frames 0, 1, 2, and 3. Among them, frame 1 has been confirmed (at this time, due to the concurrent It is not confirmation of frame 0, so the window will not be moved), then there are still 3 frames that need to be confirmed, namely 0, 2, and 3.

The sequential timeout of frames 0 and 2 means that the sender's timeout for frame 0 and frame 2 has expired, and it needs to be retransmitted at this time. Since the status of frame 3 is not clear to us in this question, it is possible. Successfully sent, as far as the ontology is concerned, the only frames to be retransmitted are frames 0 and 2, so there are only two.


mind map moment

image-20230731203003518


4.5. Media Access Control (MAC)

4.5.1. Two types of links used to transmit data (point-to-point, broadcast)

Point-to-point link : Two adjacent nodes are connected by a link, without a third party.

Application: PPP protocol, commonly used in wide area networks.

For example: As shown in the figure below for a phone call, if two people are connected to communicate, then there is no third party involved in this point-to-point link.

image-20230801143641723

Broadcast link : All hosts share the communication medium.

Application: Early bus Ethernet, wireless LAN, commonly used in LAN.

  • Wireless LAN is what we use using mobile phones and mobile devices

For example: In a large room, people's speech is transmitted through the medium of air.

Typical topology: bus type, star type (logical bus type)

The bus type is shown in the figure below:

image-20230801145105264

Why is the star type said to be a logical bus type?

  • Also in the star structure, if host A sends a message to C, other hosts will also receive it, and other hosts will compare it to determine whether it is their own message.

image-20230801145125220


4.5.2. Understand media access control

The content of media access control : adopt certain measures to prevent the communication between two pairs of nodes from interfering with each other.

Media access control is divided into : static channel allocation and dynamic channel allocation.

  • 静态划分信道: Before we start communicating on this channel, we first divide this channel into the following, or stipulate how to communicate for everyone.
  • 动态划分信道: If you encounter a conflict during the communication process, just control it and resolve it in a timely manner.

image-20230801145617716

  • English words in statically divided channels: FDM: Frequency, TDM: Time, WDM: wave, CDM: Code.

4.5.3. Channel division medium access control (static channel division)

4.5.3.1. Understand multiplexing technology

Channel division medium access control : Isolate each device using the medium from communications from other devices on the same channel, and rationally allocate time and frequency domain resources to devices on the network.

image-20230801145801457

Let's talk about the optimization of each channel of the above host, using multiplexing technology.

多路复用技术: Combine multiple signals together for transmission on a physical channel, allowing multiple computers or terminal devices to share channel resources and improve channel utilization.

image-20230801145926678

At the sending end, our multiple hosts will each send data to a multiplexer. Then the multiplexer will merge the data together and send it out on a shared channel. After reaching the receiving end, it will pass through the demultiplexer. , and then split the data and send them to other hosts respectively.

image-20230801150112740

Characteristics of multiplexing technology : Logically dividing a broadcast channel into several non-interfering sub-channels for communication between two nodes actually transforms the broadcast channel into a point-to-point channel.

In fact, when data is transmitted on the broadcast channel, Liangliang will not interfere because we will control their access so that they will not interfere with each other.

Several ways to statically divide channels :

image-20230801150306709


Method 1: Frequency Division Multiplexing FDM

The following is the coordinate diagram of frequency division multiplexing, regarding frequency and time :

image-20230801150443179

Each frequency band will be assigned to a user. At any time, each user occupies a frequency band. After the user is assigned a certain frequency band, he will occupy this frequency band from beginning to end during the communication process.

  • All users of frequency division multiplexing occupy different bandwidth (frequency bandwidth) resources at the same time.
  • The bandwidth here is different from the sending rate and transmission rate. The bandwidth here refers to the frequency bandwidth during the communication process, in Hz.

Transmission process : Each user occupies a frequency band, and then uses this frequency band to send its own data, so that all users will not fight during the process of transmitting data.

For example, in the figure below, each frequency is different, so it can be transmitted on a shared channel :

image-20230801150916578

Evaluation of frequency division multiplexing FDM : Fully utilizing the bandwidth of the transmission medium, the system efficiency is high; because the technology is relatively mature, it is relatively easy to implement.


Method 2: Time division multiplexing TDM

Ordinary time division multiplexing TDM

Difference from FDM : Each host does not occupy such a channel at any time. You can see that the channel is used alternately, but the frequency is not differentiated, and all frequency bandwidths are the same.

image-20230801152752491

时分复用技术: Divide time into equal-length time division multiplexing frames (TDM frames). Each time-division multiplexing user occupies a fixed number of time slots in each TDM frame , and all users take turns occupying the channel.

  • The time slots of a time division multiplexed TDM frame are A, B, C, and D in a frame in the figure below
  • It can be seen that in the above figure, each host A, B, C, and D takes turns occupying a channel periodically.

TDM frames are not the same as frames in the data link layer. TDM frames are frames divided into bit streams transmitted at the physical layer, marking a cycle.

Difference between Frequency Division Multiplexing and Time Division Multiplexing :

  • Frequency Division Multiplexing: Parallel. (Each host occupies one frequency band and transmits at the same time)
  • Time-division multiplexing: concurrency. (Divide time into time division multiplexing frames of equal length)

Actual calculation question : If the transmission rate of the entire line is 8000 bit/s, then according to the above four hosts, each can only send 2000 bits in turn. When each of the four hosts sends 2000 bits, the four hosts will be 8000 bits at this time. Then the corresponding TDM frame can be made up.


Statistical Time Division Multiplexing STDM (optimized, dynamic allocation of time slots)

Since in time division multiplexing TDM, each host A needs to wait for three time slices (time slots in the TDM frame) before it can be used again, so it waits for a very long time, which results in our channel utilization comparison Low.

Improved time division multiplexing : 统计时分复用STDM.

Features : Can significantly improve channel utilization.

Since the sending time and frequency of each host are different, and part of the time the host will not send data but will send data intermittently. For this situation, the more commonly used method is to count the time points. In this case, a concentrator will be used:

  • The function of the concentrator : It can connect the four low-speed users in the figure, and then centralize their data, and then send it to the target computer through the high-speed line.

image-20230801153831428

Detailed process : The number of time slots in each STDM frame is less than the number of users connected to the concentrator. When each user has data, it is sent to the input buffer of the concentrator at any time. Then the concentrator scans the input buffer in sequence and puts the input data in the buffer into an STDM frame. When an STDM frame is full, it is sent out.

Note : It can be seen that at this time, users do not take turns to alternate, but the data sent by each user's host are gathered together and then formed into STDM frames. And what is different from the previous TDM is that one frame does not have four time slots at this time, but two time slots. The data amount of the time slots here can be set as specified.

  • Similarly, this frame is not a link layer frame. The entire frame is a frame divided by the bit stream transmitted by the physical layer.

Note: STDM frames do not allocate time slots fixedly, but dynamically allocate time slots on demand.

Practical calculation question : If the transmission rate of the entire line is 8000 bit/s, then according to the STDM statistical time division multi-channel rule above, then each of the four hosts can reach a maximum of 8000 bits at this time, because it ultimately passes through a concentrator to form an STDM frame.


Method three: Wavelength division multiplexing WDM

Wavelength division multiplexing : Wavelength division multiplexing is frequency division multiplexing of light. Optical signals of multiple different wavelengths (frequencies) are transmitted in one optical fiber. Since the wavelengths (frequencies) are different, each The optical signals of each channel do not interfere with each other, and finally the wavelength decomposition multiplexer is used to decompose the wavelengths of each channel.

  • Very similar to frequency division multiplexing technology.

image-20230801160225617

Since the various frequency bands of light are different , we can put the various frequency bands of light together and twist them onto one line to complete the transmission. The high frequency band and the low frequency band will not interfere with each other during the entire transmission process, so this is This channel multiplexing technology is called wavelength division multiplexing technology.


Method 4: Code Division Multiplexing CDM

image-20230801161046212

Similar to wavelength division multiplexing, on the public channel, all the entire data is first twisted together, and then the entire combined data is separated at the entire receiving end of the C end.

Difficulty : How to separate a and b and the data sent by all other sites from the data received by C?

One of the most commonly used methods in CDM is code division multiple access (CDMA), which is a method of code division multiplexing. At the same time, CDMA is also a protocol that is now commonly used in wireless LANs and cellular networks.

Specific operation process : Divide a bit into multiple chips/chips. Each site is assigned a unique m-bit chip sequence . When sending 1, the chip sequence is sent (usually 0 is written as -1).

image-20230801162256254

  • For each micro-timing of 1 bit, 0 is -1 and 1 is +1.

At the C end, we should get a merged data, which needs to separate different sites from the mixed data, so we need to do an operation first, that is, set up the chip sequence of AB or other sites.

The setup process is as follows :

1. When multiple sites send data at the same time, the chip sequences of each site are required to be orthogonal to each other and the normalized inner product is 0. Only when it is 0, it means orthogonal and can be sent out at this time.

image-20230801162243134

If bit zero is sent, then we replace the data 0 with 1 and 1 with 0. Finally, the vector is still in the form of 1 as +1 and 0 as -1. At this time, it can be sent to the public channel.

image-20230801162514630

2. At this time, the two vectors arrive at the common channel and are linearly added.

image-20230801162606955

3. After reaching C, how to separate the two ends?

  • The merged data and the normalized inner product of the source site.

image-20230801162806009

  • The result obtained by B is -1, which means that the data sent is 0.

How to distinguish CD from CS?

As long as the channel is dynamically allocated, CS and CS are used, but CD is not CS. CD is a static channel division.

Tips: You can think of CS as a dynamic gunfight game, then CS is dynamically allocated.


4.5.4. Dynamic channel allocation

4.5.4.1. Random access media access control

Understand Random Access Media Access Control

Media access control is an access control applied in the broadcast channel. In the broadcast channel, if each node wants to communicate, it can only be the same. Only one person is sending information at a time, but if two nodes are sending information at the same time, it will cause a conflict on the channel, and the communication will fail.

In response to this phenomenon, we need to control access to the media they share, which is mainly divided into static partitioning and dynamic partitioning. This chapter is about dynamic partitioning. This allocation method is not fixedly allocated to users during communication . For users , the bandwidth that users can occupy in this dynamic allocation channel is larger .

Features of random access media access control: All users can send information randomly, and all bandwidth is occupied when sending information.

image-20230801165136327

Disadvantage: Due to this randomness, it will lead to incoordination , because if all users can send messages randomly, then if several users do not coordinate with each other, they will send messages directly, which will lead to conflict problems. At this time, we need to use these protocols to resolve the conflict caused by this incoordination .


Method One: ALOHA Agreement
Get to know the ALOHA protocol

It is divided into : pure ALOHA protocol and slotted ALOHA protocol.

The origin of the ALOHA protocol: When a scholar went to Hawaii, he studied the communication problems of various islands, and then came up with a way to solve the communication problem. Since the local residents would say hello to each other when communicating, they named it the ALOHA protocol.

image-20230801165411089


①Pure ALOHA protocol

Pure ALOHA protocol idea : no monitoring of channels, no sending according to time slots, random resending, and sending whenever you want.

The figure below shows the process of implementing a pure ALOHA protocol :

1. First, station 1 spends T 0 time to send the data frame. Since no other station sends data during this time, the transmission is successful at this time.

2. Station 2 also spends T 0 time to send the data frame, but because station N-1 also sends data in the second half of the sending process, a conflict occurs at this time (note that the sending end of this conflict will not discover it immediately).

image-20230801170042440

  • T 0 refers to a data frame, that is, its sending time, which actually includes transmission time and propagation time, that is, from the time a frame is sent until it is successfully sent.

**It is not clear whether a conflict occurs between the two sites, so when can this conflict be discovered and detected? **After you need to wait for the station to finish sending its data frame, the receiver will receive a conflicting error data frame, so the receiver will return a NAK negative acknowledgment frame or not return an acknowledgment frame at all.

  • If it does not return, the sender will wait for a timeout period to discover it, and then it will resend.

How are conflicts resolved?

  • After the timeout, wait for a random time before retransmitting.

②Slotted ALOHA protocol

Since the pure ALOHA protocol sends data too randomly, the success rate of data frame transmission is very low. How to describe the success rate of data frame transmission?

  • Use throughput.

时隙ALOHA协议思想: Divide time into several identical time slices. All users synchronously access the network channel at the beginning of the time slice. If a conflict occurs, they must wait until the beginning of the next time slice before sending.

  • In summary: control the randomness of posting whenever you want.

过程:可以看到不同的站在帧到达的时候并没有直接发送出去,而是等待了一个<T0时间后等待时间片再发送出去,之后若是在一个时隙内两个或两个以上帧同时到达时,那么在下一个时隙就会产生碰撞,碰撞后的策略与纯ALOHA的情况时相似的。

image-20230801171041898


ALOHA协议的对比与总结

1、纯ALOHA比时隙ALOHA吞吐量更低,效率更低。

  • 纯ALOHA由于随机任意发,这种发送就会导致碰撞概率很大,自然就效率更低,吞吐量更低。

2、纯ALOHA想发就发,时隙ALOHA只有在时间片段开始时才能发。


方式二:CSMA协议(增加检测信道)
认识CSMA协议

先听后发,但是对于后来发送的过程中有没有发生冲突不能够保证。

CS:载波侦听/监听,每一个站在发送数据之前要检测以下总线上是否有其他计算机在发送数据。

  • 若是几个站同时在总线上发送数据时,总线上的信号电压摆动值将会增大(互相叠加)。当一个站检测到的信号电压摆动值超过一定门限值时,就认为总线上至少有两个站同时在发送数据,表明了产生了碰撞,即发生了冲突。

MA:多点接入,表示许多计算机以多点接入的方式连接在一根总线上。

image-20230801172327271

协议思想:发送帧之前,会先监听信道。

监听结果包含两种,根据监听结果相应的动作

  1. 信道空闲:此时会发送完整帧。
  2. 信道忙:推迟发送。

对于上面不同状态进行操作,如推迟多久立即发送这样一个完整帧,有三种不同的协议

  1. 坚持CSMA
  2. 非坚持CSMA
  3. p-坚持CSMA

①1-坚持CSMA

1-坚持CSMA:坚持指的是对于监听信道忙之后的坚持。

思想

1、如果一个主机要发送信息,那么它先监听信道。

2、空闲则直接传输,不必等待。

3、忙则一直监听,直到空闲马上传输。(坚持体现在这里,若是信道忙会一直监听

4. If there is a conflict (no positive reply is received within a period of time), wait for a random long time before listening, and repeat the above process.

Advantages : As long as the media is free, the site will send it immediately, avoiding the loss of media utilization.

  • Media utilization refers to the degree of utilization of such a channel. If the channel is idle, I can send data, and the utilization of the channel is very high.

Disadvantages : If two or more sites have data to send, conflicts are inevitable.


②Non-persistent CSM

非坚持CSMA: Non-persistent refers to not continuing to monitor after the monitoring channel is busy.

Non-adherence to CSMA thinking :

1. If a host wants to send a message, it first listens to the channel.

2. If it is idle, it will be transmitted directly without waiting.

3. If busy, wait for a random time before listening again. ( If you do not insist on withdrawing money, please come here. If the channel is busy, it will wait for a random time and then listen )

Advantages : Using random retransmission delay time can reduce the possibility of collision.

Disadvantages : It is possible that everyone is delaying the waiting time, so that the media may still be idle and the media usage is reduced.


③p-Adhere to CSMA

p-坚持CSMA: Refers to the processing of idle listening channels. (The difference from before is that the channel was detected to be busy before)

Different from the previous two CSMA protocols, it is applied to persistent channels.

  • If P=1, then the agreement remains the same at 1.
  • If P=0, then it is a non-adherence agreement.

Thoughts :

1. Before sending, first listen to the channel.

2. If it is idle, it will be transmitted directly with probability p without waiting; with probability 1-p, it will wait until the next time slot before transmitting.

3. If the channel is busy, continue to monitor until the channel is idle and then send with probability p.

4. If there is a conflict, wait until the next time slot starts before monitoring and repeat the above steps.

Advantages : This solution can both reduce conflicts like the non-persistent algorithm and reduce media idle time like the 1-persistent algorithm.

  • Non-persistent algorithm: If the channel is idle, it will be sent directly. When it is busy, it will wait for a random time to listen. [If it is idle, it will be transmitted directly with probability p without waiting; with probability 1-p, it will wait until the next time slot before transmitting.
  • 1-Persistence algorithm: If the channel is busy, it will keep listening until the channel is free, and the data will be sent directly. [If the channel is busy, continue to monitor until the channel is idle and then send with probability p]

Note : The three algorithms before this do not have a process of detecting conflicts. At this time, we do not know whether there is a conflict on the channel when sending data, or we can continue to send the data we want to send. This This will cause the data sent to be a waste.

  • Are there any ways to reduce resource waste? CSMA/CD.

Comparative summary of three CSMAs

image-20230801185246563

Let’s use a real-life example, which corresponds to adherent CSMA, non-adherent CSMA and p-adherent CSMA:

image-20230801185423061


Method 3: CSMA/CD protocol (increase detection when sending data)
Understand the CSMA/CD protocol (CS, MA, CD)

载波监听多点接入/碰撞检测CSMA/CD(carrier sense multiple access with collision detection)

CS: Carrier monitoring/monitoring, each station must detect whether there are other computers on the bus sending data before and when sending data .

  • Note: This is a little different from before. When sending data here, it will also detect whether there is a computer sending data.
  • **How ​​to monitor when sending data? **In fact, it is to detect a swing amplitude of the voltage on this channel. If the amplitude is very large, then you know that there are many channels on the entire road transmitting data. At this time, there will definitely be a conflict in the transmission.
  • **How ​​to find out whether the current channel is idle or busy? **Check whether there is a signal coming in at your own site. If there is, it means someone is sending, and sending will conflict at this time.

MA: Multipoint access, indicating that many computers are connected to a bus in a multipoint access manner.

  • Application: bus network .

CD: Collision detection (conflict detection), "monitoring while transmitting" , the adapter sends data while detecting changes in signal voltage on the channel, so as to determine whether other stations are also sending data when it is sending data.

  • The adapter just needs to be thought of as its own origin site.
  • 应用:半双工网络。确定好了谁发送谁接收,在发送数据的时候只能够有一个方向在发送数据。

为什么先听后发还会出现冲突?

电磁波在总线上是以有限速率传播的,若是有一个电磁波的形式电磁波非常快,尽管时108,但是若是总线很长的话,还是需要经过一段的时间的,所以整个电磁波的传播时间对于载波监听是有影响的,如果说整个电磁波还没有到我这里,那么我在这肯定是检测不到信号的。

image-20230801201924539


传播时延对于载波监听的影响?具体通信时间(引出2T

若是此时A给B发送数据,不过由于传输时延的影响,此时B检测到当前信号是空闲,此时也会开始发送数据:

image-20230801202342519

  • 其中单程端到端传播时延(单位读tao)指的是:信号或者电磁波从a端到b端的传播时延。

由于主机A与主机B都发送数据,那么此时就会发生冲突碰撞

image-20230801202440217

A与B之间通信的具体时间细节

首先A主机发出数据,当数据到达下面的位置:

image-20230801203514774

此时B主机也进行了检测,判断到当前的信道是空闲的(由于传输时延暂时并没有到达B主机,所以检测出空闲),此时也开始发送数据,那么势必就会出现碰撞情况,此时两个信号就会叠加在一起进而继续向目标主机传送:

image-20230801203632182

下面我们将发生碰撞的冲突数据使用黑色线来表示如下图,此时B首先检测出发生碰撞,停发,接着主机A过了一段时间也检测发现到发生了碰撞,同样进行停发:

  • 为什么错误的数据到达接收端会检测出来发生碰撞呢?
    • 对于数据帧会有一个差错控制,根据收到的数据帧来检测是否出现错误,那么这里就可以检测到。对于自然信号叠加一定会发生出问题。那么校验方法能够检测出这个帧是出错的,就能够判断发生了碰撞及冲突。

image-20230801203755526

At this point, let’s take a closer look at each time period such as the time when the collision was detected (host B’s):

image-20230801204008065

  • When B detects a collision, the time is the one-way end-to-end propagation delay: τ.
  • For the period between B sending a signal and B detecting a collision, we set it to: δ, then host B τ - δsends a signal at the time.
  • The real collision time is: τ - δ/2, why δ/2is it okay? We can see that the line sent by host B and the line B that the signal sent by host A collides with are symmetrical, so we can also set it directly δ/2.

Next, let’s look at the time when a collision is detected in host A :

image-20230801204753933

  • The time when host B sends the signal is: τ - δ, and the one-way end-to-end propagation delay is τ. The two combined are the time when A detects the collision: 2τ - δ.

Think about how long it will take at the latest until the data you send has not collided with others?

  • For A, when a collision is detected 2τ - δ , when δit approaches 0, then the latest time is .
  • If you ask how long it will take to know whether the data you sent has collided, you can give the range: (0, )

There are multiple nouns that can represent this latest time : 总线的端到端往返传播时延, 争用期/冲突窗口/碰撞窗口.

Enlightenment : As long as no collision is detected in the elapsed time, you can be sure that there will be no collision in this transmission.


How to confirm the retransmission timing after collision?

Put forward a hypothesis: Can it be retransmitted directly after detecting a conflict?

At this time, there is a special situation below. For hosts a and b, they want to send data now. At this time, both of them happen to send data at the same time, because they both detect that the channel is idle at the same time, and they act as two signals. The time point of collision during the transmission 0.5τprocess 0.5τis

image-20230801205919702

So how to solve it?

  • A truncated binary exponent avoidance algorithm is used .

Algorithm implementation process:

1. Determine the basic backoff (postponement) time as the contention period .

2. Define parameter k, which is equal to the number of retransmissions, and k does not exceed 10 , that is, k = min{number of retransmissions, 10};

  • When the number of retransmissions does not exceed 10, k equals the number of retransmissions.
  • When the number of retransmissions exceeds 10, k no longer increases and remains equal to 10.

3. Randomly pick out a number r from the discrete integer set **[0, 1, …, 2 k -1]**, and the backoff time required for retransmission is r times the basic backoff time, that is 2rτ.

  • Each range is related to the number of retransmissions k. As k gets larger, the range will get larger.

4. When the retransmission fails 16 times, it means that the network is too congested and the frame is considered to never be sent correctly. The frame is discarded and an error is reported to the higher-level.

The following is a case where k actually starts from 1, simulating multiple detections of conflicts :

image-20230801211529599

Conclusion : If conflicts occur multiple times in a row, it indicates that more stations may participate in requisitioning and sending messages. Using this algorithm can make the average time that retransmissions need to be postponed increase with the number of retransmissions, thus reducing The probability of collision is beneficial to the stability of the entire system.


Exercises (calculating collision range)

topic:

image-20230801211656116

Analysis: 1023.

There is a pitfall in the question, that is, after 11 collisions, k=11. According to the previous algorithm rules, when k exceeds 10 times, k will no longer increase and will only be equal to 10. Then we use k=10 to proceed. Substitute into the calculation, the discrete integer set is: [0, 1, 2, …, 2 11 -1], and the final result is 1023.


Minimum frame length issue

Why introduce the concept of minimum frame length?

  • In CSMA/CD, conflicts can also be detected during transmission. If there is a conflict, the transmission can be stopped directly.
  • Case: Station A sent a very short frame, but a collision occurred. However, the collision was not detected until the frame was sent. At this time, it could not stop sending because it had already been sent.

In order to enable CSMA/CS to stop and control the situation in time, it is necessary to define a minimum frame length , which is the shortest frame length.

Purpose : We hope that when a collision is detected, our frame has not yet finished sending.

Prior to this, the time it takes to detect a conflict anomaly is , then the transmission delay of our frame should be at least .

Conclusion : The transmission delay of the frame must be at least twice the propagation delay of the signal in the bus.

image-20230801212758448

That is, the formula is obtained : 最小帧长 = 总线传播时延 x 数据传输速率 x 2. (i.e. x data transfer rate)

Ethernet regulations : the shortest frame length is 64B. If the length is less than 64B, they are invalid frames terminated abnormally due to conflicts.

  • In order to achieve this minimum frame length, a relatively short frame will be padded to the 64B position before it can be placed on the link for transmission.

mind map moment

image-20230801213035665


Method 4: CSMA/CA protocol (collision avoidance)
Understand the difference between CSMA/CA and CD

CA protocol data CDs are also subordinate to the CSMA protocol.

The same point : the channel will be monitored first and then the data will be sent.

The difference : CD is for collision detection, and CA is for collision avoidance.


问题:为什么有了很全面的CD协议还需要有一个CA协议呢?

回答:主要原因是所应用的场景不一样,CA是使用于无线局域网当中的也就是无线网络,而CD协议它只能够应用于总线式以太网,它应用的是一个有线网络的情况。对于不同的两种网络,不同的传输介质,就应该使用不同的协议来进行通信上的规定,此时就有了CSMA/CA协议。

使用CSMA/CD协议应用于无线局域网中会出现的两大问题

  • 问题1:无法做到360°,全面检测碰撞。
    • 之所以在无线局域网中使用CA,而不是使用CD是因为如果我们在这个无线网络当中使用CD是很困难的,CD是对于碰撞的一个检测,而无线局域网的范围、空间是非常大的,要检测冲突的方向是十分多的,也就是360°都需要进行检测冲突,那么这种在硬件上是非常难实现的,所以使用CD是没有办法检测到无线局域网当中来自四面八方的碰撞。
  • 问题2:隐蔽站。
    • 当A和C都检测不到信号,认为信道空闲时,同时向终端B发送数据帧,就会导致冲突。在这里假如a要给b发送数据c,相对于a来说C就是一个隐蔽站,隐蔽就在于C不知道a与b发送数据,所以会导致之后出现冲突问题。
    • 希望解决隐蔽站的问题:希望让C知道a和b要发送数据了,就不要去干扰a和b,也就是让接收端它附近的一些节点都清楚目前a要和b进行通信,其他按节点不要进行干扰了。

CSMA/CA协议工作原理

CSMA/CA协议工作原理

1、发送数据钱,先检测信道是否空闲。

2、空闲则发出RTS(request to send),RTS包括发射端的地址、接收端的地址、下一份数据将持续发送的时间等信息;信道忙则等待。

  • 对于RTS是可发可不发的,但是为了解决隐蔽站的问题,就会考虑要发送一个RTS。

3. After receiving the RTS, the receiving end will respond with CTS (clear to send) .

  • When the receiving end returns a response CTS, it is equivalent to establishing a connection between the two sites. If other sites send RTS connections later, the receiving end will reject them, and other sites will continue to receive them. If the CTS is not reached, data will be unable to be sent. This solves the problem of hidden stations .

4. After receiving the CTS, the sender starts sending data frames (and reserves the channel at the same time : the sender tells other stations how long it wants to transmit data).

5. After receiving the data frame, the receiving end will use CRC to check whether the data is correct, and if it is correct, it will respond with an ACK frame .

6. After the sender receives the ACK, it can start sending the next data frame. If not, it will retransmit until the specified number of retransmissions (a binary exponential backoff algorithm is used to determine the random delay time)

Summarize three mechanisms and means to achieve collision avoidance :

1. Reserve a channel. (By reserving a channel, you can tell other sites how long they want to transmit data, which can avoid some conflicts with a high probability)

2. ACK frame. (After sending a data frame, the receiving end must return a confirmation. Only after receiving the confirmation can the sending end send new data. If the confirmation cannot be returned, the sending end will resend)

3. RTS/CTS frame (optional). (After data transmission, first let the sender and receiver shake hands. The sender will send an RTS to the receiver. When the receiver receives and returns the CTS frame, it means that a good connection has been established. At this time, other hosts cannot connect. come up)


Similarities but differences between CSMA/CD and CSMA/CA

Similar points :

CSMA/CD与CSMA/CA机制都是从属于CSMA的思路,核心都是先听再说。也就是说两个在接入信道之前都需要进行监听,只有当发现信道空闲后,才能够进行接入。

不同点

1、传输介质不同:CSMA/CD用于总线式以太网【有线】,而CSMA/CA用于无线局域网【无线】/

2、载波检测方式不同:因传输介质不同,CSMA/CD与CSMA/CA的检测方式也会不同

  • CSMA/CD是通过电缆中电压的变化来检测,当数据发生碰撞时,电缆中的电压会随着发生变化。
  • CSMA/CA采用能量检测(ED)、载波检测(CS)和能量载波混合检测三种检测信道空闲的方式。

3、CSMA/CD检测冲突,CSMA/CA避免冲突,二者出现冲突后都会进行有上限的重传


4.5.4.2、轮询访问介质访问控制

4.5.4.2.1、三种协议回顾

信道划分介质访问呢控制(MAC multiple Access Control)协议

  • 基于多路复用技术划分资源。
  • 网络负载重:共享信道效率高且公平。
    • 会将资源进行划分,若是所有的主机都在忙碌使用,说明共享信道已经被充分利用了,效率很高,其公平就在于当时分配资源的时候是平均分配的。
  • 网络负载轻:共享信道效率低。
    • 工作当中处于忙碌状态的主机或者说是节点,就很少因此有一大堆节点都是处于空闲的状态,那么信道的大部分资源就被浪费了,此时空共享信道的效率就更低一些。

随机MAC协议

  • Users can randomly send information according to their own wishes , and the sending can exclusively occupy the channel bandwidth.
  • Heavy network load: conflict overhead occurs.
    • In the random access microphone protocol, it is basically a broadcast link and broadcast messages. If the network load is heavy on the broadcast channel, it means that many hosts on the network are sending messages, and many hosts are sending messages at the same time. Messages will conflict, which will invalidate the messages we send. This is the conflict overhead generated.
  • Light network load : The shared channel is highly efficient, and a single node can utilize the entire bandwidth of the channel.
    • A single node can utilize the entire bandwidth of the channel. Because when the network load is light, only one host may be sending data, so there will be no conflict. The channel also fully occupies the bandwidth to send its own messages.

轮询访问MAC协议/轮流访问MAC协议: Integrate the advantages of the above two protocols.

  • It is necessary not only to avoid conflicts , but also to occupy the entire bandwidth when sending .

Q : Which protocols conflict? Only random access MAC protocols will conflict.

The polling access MAC protocol mainly includes two protocols: polling protocol and token passing protocol.


Method 1: Polling protocol

Core idea : The master node takes turns "inviting" the slave nodes to send data.

Process description : Host A will ask hosts B, C, D, and E in sequence. First, it will ask B if it needs to send data (send a very short data frame for the inquiry function). If so, it will connect at this time for data transmission. ;After the transmission is completed, host A will ask C if it wants to connect. If not, it will continue to ask D. When the inquiry of host E ends, it will ask host B again.

image-20230802112515039

Features : It combines the advantages of the previous two protocols. First, there will be no conflict problems. Second, only one host is allowed to send data at a time, so that one host can occupy all the bandwidth.

Question :

1. Polling overhead: If the number of hosts to be queried is huge, the overhead caused by polling and querying one by one is also very large.

2. Waiting delay: There will be another waiting delay for the later host to be asked.

3. Single point of failure: If host A in the picture above is down, then other slave nodes will not be able to survive. No one will ask them, and they will not be able to send data.

  • Solution: You can create more backup master nodes to replace broken master nodes at any time.

Method 2: Token passing protocol

Topology : logically ring-shaped, actual physical implementation is star-shaped.

Use of control channels : Ensure that only one node occupies the channel at the same time.

image-20230802114404919

  • TCU: It is a real transmission interface for transmitting data, an interface for forwarding, which can transmit all passing frames, and provides an interface for the access station to send and receive data, which is mainly a forwarding function.

Token Ring Passing Process

Token ring transfer process : If there is no host to send data at this time, the token will be transferred between hosts until there is a host to send data.

test

At this time, host D wants to send data, then it will hold this token and do two steps:

  1. Modify a flag bit of the token. (Actually, it changes the token from a free state to a busy state)
  2. Add a data frame after the token's control frame, and then send this data frame to the target host.

Host D is sending it to host A. At this time, the data frame will pass through host C and host B. When it comes to host D, host D will copy such a data and then send it to the host. A.

test

At this time, host A will check whether there is an error in the data frame. If there is an error, it needs to be retransmitted. If there is no error, the data frame will be recycled at this time, and then the frame will no longer be forwarded, and then the token will be busy. After the status is changed to the idle state, the token is passed out. The subsequent process is repeated. If the host wants to use the token when passing through a host, the two steps of host D above will be executed again. Send it out.

Advantages and questions about the Token Ring Transport Protocol

The token passing protocol combines the advantages of the channel division MAC protocol and will not cause collisions or conflicts, mainly because only one host holds the token at a time. Only the host that holds the token can send data, and no one else can send data. , there will be no collision at this time.

Question: If the host has a lot of data, will it always occupy this token and send data continuously?

  • No, there will be a limited time . If it exceeds this time, other data will need to wait for a wave. Only when it is transferred to the source host, the data from other hosts will be sent out. Each node can be sent out at a certain time . Obtaining the token holding time within the local time and thus obtaining the right to send data does not mean holding the token unlimitedly .

Problems arising from the token protocol :

1. Token overhead. (Some books say that sometimes a token needs to be generated when the token is gone; some books say that after the data is transmitted to the source site, an experience token will be generated, which is also an overhead of the token)

2. Waiting overhead: If host d is sending data, and host a also wants to send data at this time, then it needs to wait for the limited time of the token ring to end before it can reach itself. This also has a delay time.

3. Single point of failure: If one host goes down, the entire link will be broken.

  • Solution: You need to use some alternative machines to solve the problem.

Application scenarios : Networks using token transmission are often used in networks with heavy loads and large traffic volumes .


MAC protocol summary

image-20230802122600944


5. LAN

5.1. Basic concepts and architecture of LAN

5.1.1. Understanding LAN

局域网(Local Area Network): Abbreviated as LAN, it refers to a group of computers interconnected by multiple computers in a certain area, using broadcast channels.

The following are several characteristics of LAN :

  1. The geographical scope covered is small and only connected within a relatively independent local scope, such as one or a concentrated building group.
  2. Using specially laid transmission media (twisted pairs, coaxial cables) for networking, the data transmission rate is high (10Mb/s ~ 10Gb/s).
  3. The communication delay time is short, the bit error rate is low, and the reliability is high.
  4. Each station has an equal relationship and shares the transmission channel.
  5. Distributed control and broadcast communication are mostly used, capable of broadcast and multicast. (Broadcast and multicast: When a local area network uses a broadcast channel, broadcast communication will be used to share this channel.)

The main factors that determine the local area network are : 网络拓扑, 传输介质and 介质访问控制方法. The above characteristics are determined by these three factors.


5.1.2. LAN topology

image-20230802153619830

Star topology : The central node is the control center, and communication between any two nodes requires only two steps at most.

  • Advantages: fast transmission speed, simple network configuration, easy network construction, control and management.
  • Disadvantages: Low network reliability, poor network sharing capabilities, and single point of failure. (The poor sharing capability here refers to the bus topology, because the bus topology shares a main line)
    • If the hub in the star topology fails, all hosts will be unable to communicate.

Bus topology : high network reliability, fast response speed between network nodes, strong resource sharing capability, low equipment investment, low cost, easy installation and use. When a workstation node fails, it will have little impact on the entire network system.

Ring topology : Communication equipment and lines in the system are relatively economical.

  • Disadvantages: There is a single point of failure problem; because the loop is closed, it is not easy to expand, the system response delay is long, and the information transmission efficiency is relatively low.

Tree topology : easy to expand, easy to isolate faults, and prone to single points of failure.

Evaluation : The bus topology is better and is a commonly used topology in local area networks. Ethernet is a logical bus topology.


5.1.3. LAN transmission medium

image-20230802154529437


5.1.4. LAN media access control method

LAN media access control method :

1. CSMA/CD: Commonly used in bus LAN and also in tree network .

  • Listen first and speak later, listen and speak at the same time.

2. Token bus: often used in bus LANs and also in tree networks .

Why is it called a token bus?

  • Combines the features of tokens and buses. Each workstation in a bus or tree network is arranged in a certain order such as interface address size to form a logical ring. Only the token holder can control the bus and have the authority to send information.

3. Token Ring: used in ring LAN, such as Token Ring network. The physical structure is a star structure.


5.1.5. Classification of LAN

image-20230802155533357

  • The Token Ring network is said to be "a thing of the past" because if a node in the Token Ring network fails, then the ring will be unable to communicate.
  • The transmission medium used by FDDI is optical fiber .
  • The 53-byte unit length in ATM networks is variable .
  • The communication medium in wireless LAN is air or electromagnetic waves .
    • The difference between wireless LAN and WiFi: WIFI is an application of wireless LAN. Wireless LAN can cover a wider range than WIFI, which may be several kilometers.

5.1.6, IEEE802 standard

The basic introduction is as follows :

image-20230802160050959

The existing standards of the IEEE802 standard are as follows. The main thing to remember is the red line below :

image-20230802160003930

  • The standard that Ethernet conforms to is IEEE802.3.
  • IEEE802.5 is a token ring network.
  • IEEE802.8 is the FDDI protocol, and the commonly used transmission medium is optical fiber.
    • Clever trick: Expensive optical fiber means you are rich, and if you are rich, you will get 8, then it is IEEE802.8.
  • IEEE802.11: Wireless LAN.

IEEE802 and Ethernet are closely integrated.


5.1.7, MAC sublayer and LLC sublayer:

The LAN reference model values ​​described in the IEEE802 standard correspond to the data link layer and physical layer of the OSI reference model .

The actual IEEE802 divides the data link layer into 逻辑链路层LLCand介质访问控制MAC子层 .

image-20230802160546987

LLC子层: Responsible for identifying network layer protocols and encapsulating them. The LLC header tells the data link layer what to do with the data packet once the frame is received.

  • Provides services for the network layer : no connection without confirmation, connection-oriented, connection without confirmation, and high-speed transmission.

MAC子层: The main functions include data frame encapsulation/unassembly, frame addressing and identification, frame reception and transmission, link management, and frame error control.

  • The existence of the MAC sublayer shields the differences between different physical link types .

Summary : The LLC sublayer is next to the network layer and will provide services for the network layer. The MAC sublayer is next to the physical layer, so it is related to the physical layer.

  • Content related to transmission media and physical layer transmission media will be placed in this MAC sublayer.

mind map moment

image-20230802160846279


5.2. Ethernet

5.2.1. Understanding Ethernet

以太网(Ethernet)Refers to the baseband bus LAN specification created by Xerox and jointly developed by Xeror, Intel and DEC . It is the most common communication protocol standard used in existing LANs today.

  • Baseband bus LAN specification: Baseband is a specification, bus refers to a logical bus topology, and LAN specification can be a LAN technology.

Ethernet usage CSMA/CD(载波监听多路访问及冲突检测)technology.

  • If we see CSMA/CD being used, then we know it is an Ethernet network.

Ethernet occupies a dominant position among various LAN technologies:

1. Low cost (Ethernet card costs less than 100 yuan).

2. It is the most widely used LAN technology.

3. Cheaper and simpler than Token Ring and ATM.

  • Cheapness and simplicity are mainly reflected in network construction, network expansion and fixing some faults. It will be simpler and cheaper to fix some node faults.

4. Meet network speed requirements: 10Mb/s ~ 10Gb/s .

  • Traditional Ethernet 10Mbits per second, Fast Ethernet, Gigabit Ethernet, and High-speed Ethernet 10Mb/s.

5.2.2. Two standards of Ethernet

Two standards for Ethernet :

  1. DIX Ethernet V2: The first LAN product (Ethernet) protocol.
  2. IEEE802.3: The first IEEE Ethernet standard developed by the 802.3 Working Group of the IEEE 802 Committee.

The difference between the two standards is that the two bytes in the frame format are slightly different. Those that meet DIX Ethernet V2the IEEE802.3rules can be called Ethernet.

又可将以太网叫做是802.3局域网


5.2.3、以太网提供的无连接、不可靠的服务

以太网提供的无连接、不可靠的服务

无连接:发送方与接收方无"握手过程"。

无可靠:不对发送方的数据帧编号,接收方不向发送方进行确认,差错帧直接丢弃,差错正由高层负责。

  • 高层负责主要指的是传输层或者说运输层。

总结:以太网就是尽最大努力交付。以太网只实现无差错接收,不实现可靠传输

  • 以太网若是接收到数据时会进行一些差错检测,若是检测到出错就直接丢弃或者拒收,这并不是可靠传输。
    • 可靠传输指的是只要你发来的帧,我都要接收,如果这个帧丢失了,或者说帧重复了、失序了,那么这些可靠传输问题是由传输层来实现的。

5.2.4、以太网提供的无连接、不可靠的服务

以太网传输介质与拓扑结构的发展

传输介质发展:传统以太网使用的是粗同轴电缆,后面采用的是一种便宜的细的同轴电缆,再到后面则是使用造假很低廉的双绞线以及集线器这样子组合的应用。

image-20230802164527510

物理拓扑结构发展: 传统以太网和目前以太网在逻辑结构上都是总线型的结构,之后出现了集线器能够更加方便扩网与检查故障,此时物理上面会进行一个改良,由原来的总线型变成了星型。

image-20230802164708081

image-20230802164855632

  • 使用集线器的以太网在逻辑上仍然是一个总线网,各站共享逻辑上的总线,使用的还是CSMA/CD协议。

以太网拓扑:逻辑上总线型,物理上星型。


5.2.5、10Base-T以太网

10Base-T:是传送基带信号的双绞线以太网,T表示的是采用双绞线,现在10Base-T采用的是无屏蔽双绞线(UTP),传输速率为10Mb/s。

  • Base refers to the transmitted baseband signal, which is a digital signal.
  • T is twisted twisted pair.
  • The transmission rate represented by 10 is 10Mb/s.

image-20230802165314356

Features are as follows :

1. It adopts star topology physically and bus type logically. The longest length of each twisted pair is 100m.

2. Use Manchester encoding.

  • One bit corresponds to two code sources, or in one bit time range, there are two signal changes.

3. Adopt CSMA/CD media access control. (Some conflicts and collisions will occur)


5.2.6, Adapter and MAC address

Adapter : The connection between the computer and the external wired LAN.

Here is the network interface board :

image-20230802165755970

网络接口板NIC(network interface card): In the past, the graphics card needed to be installed separately, but now it is directly integrated on the motherboard, and the processor and memory (including RAM and ROM) are installed on the adapter.

  • The ROM contains the computer hardware address MAC address . This MAC address is a unique identification code in the world.

In a local area network, the hardware address is also called the physical address or MAC address. [actually an identifier]

MAC地址: Each adapter has a globally unique 48-bit binary address. The first 24 bits represent the manufacturer (IEEE regulations), and the last 24 bits are specified by the manufacturer.

  • A MAC address is commonly represented by 6 binary numbers, such as 02-60-8c-e4-b1-21.

5.2.7. Ethernet MAC frame

5.2.7.1. Understand the composition of Ethernet MAC frames

At this time, there is an IP datagram at the network layer. When it reaches the link layer, the data packet needs to be encapsulated .

The most commonly used MAC frame is DIX Ethernet V2the format of Ethernet V2 ( ) (the format under the first standard):

  • IP层—>数据链路层阶段: It can be seen that the IP datagram transmitted from the IP layer belongs to the data when it reaches the MAC layer. At this time, the destination address, source address, type and an FCS are added to the data header and the tail. [Add control fields at the beginning and end]
  • 物理层阶段:为了发送方与接收方都能够保持发送接收的同步,此时就需要把这个MAC帧之前加上一个前导码,这个前导码有8B,前面7B也就是前同步码,都是10、10、10组成,最后两位是11,表示发送方高速接收方现在可以开始准备接收我的MAC帧的一部分了。

image-20230802170324353

接下来看一下以太网MAC帧的组成部分

image-20230802171415867

  • 源地址:发送方的地址。
  • 目的地址:指的是目标地址。包含有三种情况:①单播地址,指的是一个专有的MAC地址,如发送给固定的一个主机,这个主机的MAC地址。②广播地址,也就是全1的,那么会发送给所有的主机,所有的主机若是看到这一个地址,此时就会全部收下来。③多播地址。
  • 类型:用于指明上面的网络层使用的什么协议,以便能够将收到的MAC帧的数据上交给上一层的这个协议。
  • 数据:这个长度是可变的,下限是46字节,上限是1500字节。
    • 1500B:就是事先规定好的1500B,也就是链路层的最大数据传送单元MTU。
    • 46B:就是在学习CSMA/CD协议时有提到过的最小帧长为64B,为什么这里是46呢?实际还是64B,18B就是目的地址、源地址、类型、FCS占用的字节数总和,64-18 = 46B。所以说这里的数据范围为46-1500。
  • FCS:指的是CRC循环冗余检验的四字节的帧检验序列FCS。

5.2.7.2、疑问:为什么数据链路层加头加尾,为什么没有在MAC帧后面没有一个帧结束定位符呢?

疑问:为什么数据链路层加头加尾,为什么没有在MAC帧后面没有一个帧结束定位符呢?

  • 如下图圈出来的就是帧开始定界符,后面?就是疑问为为什么这里没有一个帧结束定位符?

image-20230802172718462

原因:以太网使用的是曼彻斯特编码,其特点就是在每一个比特内都会有两个码元,在发送数据的时候是可以感受到这种电压的变化。

电压变化如下:

image-20230802172921974

But if no data is sent, the voltage will not change. When the sender completes sending the last Ethernet frame, it will not send other symbols, so the voltage on the interface of the sender's network adapter will not change again . It is precisely because of this unchanged voltage that we can clearly determine the end of the Ethernet frame. Four bytes before the end of the Ethernet frame can determine the end position of our data.

  • And there is a minimum interval between each sent frame. Each of our frames is not sent right next to each other. After sending a frame, it will stop for a while, and then send a new frame. At this time, There is a blank time. If no voltage change is detected at this time, it means that the sender has stopped sending at this time. In this way, the four bytes before stopping sending can determine the end of the data frame.

The difference between Ethernet V2 ( DIX Ethernet V2) and IEEE802.3 :

1. The third field is length/type.

2. When the length/type field value is less than 0x0600, the data field must be loaded into the LLC sublayer.


5.2.8. High-speed Ethernet (3 types)

Ethernet with a rate >= 100Mb/s is called high-speed Ethernet .

1. 100BASE-T Ethernet

Introduction: Star topology Ethernet that transmits 100Mb/s baseband signals on twisted pairsCSMA/CD协议 still uses IEEE802.3 .

Function: Support full-duplex and half-duplex , work in full-duplex mode without conflict.

  • Full-duplex Here the central node becomes a switch. This full-duplex means that each host can send and receive at the same time. It can isolate conflict domains. The port of each switch is a conflict domain . At this time, this host will not conflict in a conflict. In the case of full duplex, there is no need to use the CSMA/CD protocol .

image-20230802174050521

2. Gigabit Ethernet

Introduction: Transmitting 1Gb/s signals over optical fiber or twisted pair cables .

Function: Supports full-duplex and half-duplex, and can work in full-duplex mode without conflict.

3. 10 Gigabit

Introduction: 10 Gigabit Ethernet transmits 10Gb/s signals over optical fiber .

Function: Only supports full duplex, no contention issues.

Transmission medium: optical fiber.


mind map moment

image-20230802174929846


5.3. Wireless LAN

5.3.1. Understanding IEEE802.11

IEEE802.11It is a common standard for wireless LAN. It is a standard for wireless network communication defined by IEEE.

image-20230802193021760

It belongs to WIFI if it meets IEEE802.11b and IEEE802.11g.


5.3.2, 802.11 MAC frame header format (details of each field)

802.11 MAC frame header format :

The MAC frame header format is shown in the figure below, and the four address fields are commented as follows:

image-20230802193442972

For example : If host A communicates with host B, what is the process?

Host A (here regarded as a mobile phone), at this time, the closest to A is AP1, and then the closest to B is AP2.

  • AP refers to wireless access point, base station.

image-20230802193615045

When host A wants to send information to B through traffic, A will first send it to AP1, then AP1 will send it to the AP2 base station, and then the AP2 base station will send it to B's mobile phone. At this time, B can receive the message.

image-20230802193840931

Let’s take the above process of host A sending a message to host B. Let’s take a look at the actual fields in the corresponding MAC frame:

image-20230802194215524

  • The receiving end and transmitting end specify the MAC address of the designated base station.
  • The destination address and source address indicate the MAC addresses of host A and host B.

Additional supplement : When we enter a new place, we will actually connect to the nearest local base station. At this time, our mobile phone number will be registered in the base station and then the corresponding database will be updated. For example, when we arrive in Beijing, You will receive a "Beijing welcomes you" text message, which is newly registered in this new base station and then sent to you.


5.3.3, IEEE802.1 standard type classification (4)

The IEEE802.1 standard divides frame types into the following four categories :

The frame address written above is actually the WDS below, for all fields.

image-20230802194748945

  • For a field with a value of 0, it means that the field will not be used.
  • To APRefers to the frame sent to the AP. At this time, the receiving end of Address1 is the MAC address of the AP, represented by BSSID.
  • From APRefers to the frame sent from the AP base station: Address2 sender is the MAC address of the AP, represented by BSSID.

Practical exam : If the host wants to send a frame to the base station, then we want to know what the three corresponding addresses of the To AP are.


5.3.4. Classification of wireless LAN

1. Wireless LAN with fixed infrastructure.

2. Self-organizing network of wireless LAN without fixed infrastructure.


5.3.4.1. Wireless LAN with fixed infrastructure (BSS, ESS, services and identification)

Wireless LAN with fixed infrastructure :

基本服务集BSS: Refers to the range covered by the AP (base station) and including the host, which constitutes a basic service set BSS.

image-20230802195553681

Note : If there is a wall between the host and the AP, the signal will be weakened, and the wireless AP will be easily hindered in the signal forwarding process.

扩展服务集ESS: After several service sets are combined together (such as wired and wireless), an extended service set is formed.

image-20230802200120485

There is not only one basic server, but also a second basic server at this time. Is it possible to communicate at this time?

  • Yes, you need to use a distribution system at this time. This distribution system is equivalent to combining our wireless and wired services. If A wants to communicate with B, the distance in between will be very, very long (cross-province). At this time Host A will first send to the base station AP1 , and then the base station will be connected to such a wired cable and the signal cable. At this time, a distribution system will complete a wired communication.
  • Realized the combination of wired + wireless.

漫游: Refers to the fact that a host within the range of one base station can communicate with a host within the range of another base station.

To give a small example in life : What we can see when we turn on wifi on our computer or turn on wifi on our mobile phone is called 服务及标识符.

image-20230802200326983

服务及标识符: Each corresponds to a base station, and each corresponds to a wireless access point.


5.3.4.2. Self-organizing network of wireless LAN without fixed infrastructure

Self-organizing network of wireless LAN without fixed infrastructure :

  • No fixed infrastructure : It means that there are no transponders, hubs, routers, or base stations. There are only some hosts that form a network by themselves. Each host itself can act as a host and router, that is, it can send data and Help forward data, and the low bits between each node are equal to each other.

image-20230802200545461


5.4. Basic concepts and principles of VLAN

5.4.1. Why does VLAN exist? (Characteristics of local area network limitations)

Why do VLANs exist?

  • Traditional LAN has certain locality.

The characteristics of limitations are as follows :

1. Lack of traffic isolation: Even if group traffic is localized to a single switch, broadcast traffic will still span the entire organization network (ARP, RIP, DHCP protocols).

  • Because in a broadcast domain, if a host sends a broadcast frame, then all hosts in the broadcast domain will receive the broadcast frame. Then under the application of this protocol, you will encounter a flooding phenomenon !

2. Inconvenience for managing users: If a host moves between different groups, the physical wiring must be changed and connected to a new switch.

  • If you want to move another workgroup in one group, you must change the physical wiring. You can use physical or software changes. The hope is that the fewer changes, the better.

3. The cost of routers is high: Many routers can be used in a local area network, which costs a lot .

  • If there are a lot of broadcast frames propagating on the link, we hope to isolate them and create some broadcast domains. Broadcast domain isolation requires routers to support it. If there are many groups in a large LAN, Then we hope to isolate them, and at this time we need to use multiple routers to solve the problem.

5.4.2. Basic concepts of VLAN

虚拟局域网VLAN(Virtual Local Area Network)It is a technology that divides devices in the LAN into logical groups that have nothing to do with physical location . These logical groups have certain common requirements. Each VLAN is a separate broadcast domain/different subnet.

对交换机进行了VLAN划分之后,它连接的几个主机就可以处在不同的VLAN当中了,每一个VLAN又是一个广播域。

举例:在下面组成的两个广播域VLAN1、VLAN2中,若是A主机发送一个广播帧此时就只有A能够收到。VLAN2中的C、D主机不会受到。

image-20230802203521507

效果:原本物理上看起来四个主机都在一个广播域,经过VLAN的划分,此时这一个局域网中就可以划分出这样两个广播域。


5.4.3、VLAN实现大局域网的划分

实际我们不仅仅能够在一个交换机所连接的这些主机上进行划分,也可以在一个这样的大的局域网当中进行划分,如下图我们将黑色主机划分为VLAN2,将橙色的主机划分为VLAN1

image-20230802203821179

效果:此时就可以使用这样形式来完全打破物理上的一些限制和概念,在逻辑上构成一些广播域。


5.4.4、VLAN实现原理

5.4.4.1、一个交换机内部的VLAN实现(转发表、VLAN表,案例情景)

image-20230802204738434

上图WLAN1中的A能否直接发送给VLAN2中的C?

  • 结论:不能,因为是两个不同的子网。
  • 原因:目前是简单的对它进行一个虚拟局域网的划分,两个VLAN实质上在逻辑上可以理解为两个子网,不同的子网只有借助路由器或者三层具有路由选择和转发的交换机才可以。

上图中VLAN1中的主机A为什么不能够发送给VLAN2中的主机C?

首先交换机中有一个交换机的转发表,主要是MAC地址与端口的映射,:

image-20230802205534489

接着由于使用了VLAN虚拟局域网,此时就会附加一个VLAN表,其中是VLAN局域网与端口的映射:

image-20230802205732075

情景1:VLAN1中的主机A发送给VLAN1中的主机B。

根据VLAN表确定自己主机A的端口属于哪个VLAN,由于是属于VLAN1,那么此时就只会给VLAN1广播域中的主机发送,所以就只能够给主机B发,而不能够给VLAN2中的主机发。

情景2:VLAN1中的主机A发送给VLAN2中的主机C。(发送失败)

由于使用了VLAN进行划分子网,此时VLAN1与VLAN2是处于两个网段,实际主机A在发送的时候会首先去查对应的VLAN表,自己是属于VLAN1的,接着查看了主机C的则是VLAN2,由于只能够广播自己所处的网段,所以无法发送。

对于上面VLAN表是基于VLAN ID与端口的表此时则称为是基于接口的VLAN技术

image-20230802210350786

基于MAC地址的交换机的VLAN表:在这个表中将原本的端口替换为相应主机的MAC地址

image-20230802210546230

实际比较常用的是基于端口的VLAN技术。


5.4.4.2、交换机与交换机之间的实现

两个交换机内部实现原理

重点:对于一个主机和另外一个虚拟局域网(例如VLAN1与VLAN2是两个不同的网段)的主机,它们只有在三层交换机或者路由器的条件下才能够进行通信。

可以看到通过使用VLAN来将两组交换机进行连接,此时分为VLAN1与VLAN2两组

image-20230802211458481

举例:主机A发送给主机E。

1、此时主机A会线准备好一个帧,这个帧就是在链路层中的普通以太网帧,此时到了交换机时,就会知道这个a主机的帧是从VLAN1当中过来的,因此就会在这个帧上附加一个字段(标签),tag = 1表示的是从主机1号端口发过来的,是属于VLAN1的 。

2、此时就会经过链路发送给交换机2。

  • 为什么在链路当中没有将标签去掉,是因为在这个窗口中,叫做一个trunk(称之为主干线的端口,在交换机与交换机之间连接的端口),对于这一个trunk是不需要去掉这个tag标签的。

3. When sent to switch 2, this data frame will be received, which belongs to VLAN1 of switch 2. Then the VLAN table will be searched to determine the host in VLAN1, and then combined with some other MAC address fields to decide to send Give E or F.

image-20230802212750921

Core : During the sending process, a label is needed to indicate which network the host belongs to. When it is sent to the destination, it will be known which virtual LAN it should be sent to.


VLAN implementation: IEEE802.1Q frame (transmission between switches)

The process of labeling is to make a change to the data frame and insert it into a four-byte VLAN, as shown in the following figure :

image-20230802211937567

Interpretation of four bytes :

  • ①The first two bytes of the VLAN tag indicate that it is an IEEE802.1Q frame.
  • ②The next 4 digits are useless.
  • ③The next 12 bits are the VLAN identifier VID (used to uniquely indicate which VLAN the Ethernet frame belongs to). If it is VLAN1, it is the number 1.
    • The value range of VID is 0-4095, but neither 0 nor 4095 is used to represent VLAN , so the valid VID value range used to represent VLAN is 1-4094.

Note : IEEE802.1Q frames are processed by the switch, not by the user host. (Only ordinary Ethernet frames are exchanged between the host and the switch).


5.4.5. Practical exercise: Identify whether communication between different VLAN LANs is possible?

image-20230802213816348

image-20230802213730572

Question 1: Can A and E achieve access?

Answer: According to the diagram, we can see that the switches are connected. The following is the process between host A and host E.

First, host A creates an ordinary Ethernet frame. When it is sent to the switch, the switch will add a tag, marked as 1 (meaning VLAN1), and then send it to switch 2 through the trunk port of switch 1.

At this time, switch 2 finds the corresponding host based on the corresponding VLAN1 in the tag tag and then the corresponding VLAN table. There is indeed E, and the transmission is successful!

Question 2: Can A, D, and H be accessed?

answer:

(1) A and D cannot be accessed. The main reason is that although they are connected to a switch, they are divided into two wireless LANs through VLAN. Since there are no switches and routers between the two VLANs, the VLAN It is found in the table that there is no host D in VLAN1, so access cannot be achieved.

(2) A and H cannot achieve access. The main reason is that they will also go through the process of question 1. At this time, the Ethernet frame comes to switch 2 with a tag. At this time, switch 2 reads out that this is the Ethernet sent by VLAN1. Network frame. At this time, H is not found in VLAN1 in the VLAN table in switch 2, and access cannot be achieved at this time.

Core points : Whether there are routers and layer 3 switches between different network segments. If not, access across different network segments is not possible.


5.4.6. Multiple choice exercises

Topic :

image-20230802214748983

Analysis : The division and management of logical work groups are implemented through software, that is, a VLAN table is created.

image-20230802214809500


6. Wide Area Network

6.1. WAN concept

广域网(WAN,Wide Area Network): Usually able to span a large physical range, covering a range from dozens of kilometers to thousands of kilometers. It can connect multiple cities or countries, or span several continents and provide long-distance communications, forming an international long-distance network. network.

Technology used : The communication subnet of the WAN mainly uses packet switching technology. The communication subnet of the WAN can utilize public packet switching networks, satellite communication networks and wireless packet switching networks. It interconnects local area networks or computer systems distributed in different areas to achieve the purpose of resource sharing.

Practical application : The Internet used is a wide area network, which is the largest wide area network in the world.

image-20230803095150956

There are many nodes in the WAN, called 节点交换机(as shown in the figure below). This switch is a link layer device. It is a switch but has similar functions to a router, and is used to forward packets.

image-20230803095208375

The difference between a switch and a router : the former forwards packets within a single network, while a router forwards packets between multiple networks.

There are switches, routers, and hubs in the WAN. The following are the differences between the layers, technologies, and emphasis on the LAN :

  • The difference from the layer where the LAN is located: The network structure covered by the WAN ranges from the physical layer, the link layer to the network layer, while the LAN only covers the physical layer and the data link layer.
  • Technical differences: LAN uses multi-point access technology, a logical bus-type multi-point access technology; WAN is point-to-point, with one sender and one receiver connected through a link. Duplex or half-duplex communication mode.
  • The emphasis is different: LAN emphasizes data transmission; WAN emphasizes resource sharing.

The most commonly used protocols for WAN : PPP protocol, HDLC protocol.


6.2. PPP Agreement

6.2.1. Characteristics of PPP protocol

点对点协议PPP(Point-to-Point Protocol): It is currently the most widely used data link layer protocol. Users generally use the PPP protocol when accessing the Internet using dial-up phones.

Limitations : Only full-duplex links are supported.


6.2.2. Requirements that the PPP agreement should meet

Requirements that the PPP agreement should meet :

1. Simple : For link layer frames, there is no need for error correction, sequence numbers, or flow control.

  • The most complex part of the Internet architecture is placed in TCP. The IP protocol is also more complex and simpler than TCP. At this time, the IP protocol provides an unreliable datagram service. There is no need for the data link layer to be reliable before IP. transmission without achieving a reliable transmission.

2. Encapsulation into frames : Add frame delimiters to the frame header and tail.

3. Transparent transmission : How should data with the same bit combination as the frame delimiter be processed; asynchronous lines are filled with bytes, and synchronous lines are filled with bits .

  • Transparent transmission means that no matter what kind of bit stream is transmitted in the data part, it can be transmitted completely. Even if the data part has frame delimiters, it will be invisible.
  • Byte padding on asynchronous lines refers to sending byte by byte or character by character during transmission. The same goes for synchronization.

4. Multiple network layer protocols : The encapsulated IP datagram can use multiple protocols.

  • The link layer will also encapsulate the datagrams of the network layer. The PPP protocol encapsulated at this time does not require you to use any protocol in this network layer. It is more inclusive. Multiple protocols can be used to encapsulate IP datagrams. IP protocols , IPX protocol are all available .

5. Multiple types of links : serial/parallel, synchronous/asynchronous, electrical/optical...

6. Error detection : If an error is detected, it is discarded directly, because the PPP protocol does not need to achieve reliable transmission.

  • CRC cyclic redundancy is used, and an error detection is achieved by adding an FCS field to the frame of the PPP protocol.

7. Check the connection status : whether the link is working properly.

8. Maximum transmission unit : The maximum length of the data part, MTU, cannot exceed 1500 bytes.

9. Network layer address negotiation : Know the network layer addresses of both communicating parties.

10. Data compression : Compress the data when sending it.


6.2.3. Requirements that the PPP agreement does not need to meet

Requirements that the PPP agreement does not need to meet :

1. No error correction is required.

2. No flow control is required.

3. No numbering required.

4. Multi-point lines are not supported, and only one connection process between point-to-point needs to be defined or satisfied.


6.2.4. Three components of PPP protocol (implementation functions)

Three components of PPP protocol (implementation functions) :

1. A method of encapsulating IP datagrams into a serial link (synchronous serial/asynchronous serial).

2. 链路控制协议LCP: Establish and maintain data link connections, mainly for identity authentication .

  • For example, dial-up Internet access, this connection reflects a link connection, that is, the LCP protocol is not satisfied.

3.: 网络控制协议NCPPPP can support multiple network layer protocols. Each different network layer protocol requires a corresponding NCP to be configured to establish and configure logical connections for the network layer protocols.

Note : Based on the LCP protocol, because the Internet function can only be realized after the connection is established, the network layer datagram needs to be processed and encapsulated to the link layer.

LCP协议It's like establishing a physical connection , NCP协议like establishing a layer of logical connection .


6.2.5. How the PPP protocol works (state diagram of the PPP protocol)

First [no link between devices], you are not connected to the Internet at this time. First, click on broadband and enter your account and password (to give an example). At this time, a physical connection [physical link] is established. At this time, the LCP link When it comes out, this physical link will be constructed into an LCP link [LCP link], and then through NPC configuration negotiation, an NCP link will be formed. Only then can the network be officially accessed.

image-20230803102343481


6.2.6. PPP protocol frame format

In bytes ,

image-20230803103113611

帧定界符: There are flag fields at the beginning and end.

插入转义字符: If we encounter a flag field that is the same as the frame delimiter during the data part process, we need to add this escape character before the corresponding field.

A、C控制字段: There is no meaning given at the beginning of the design. It is mainly to facilitate subsequent improvement. A should be the address and C is the control. However, so far, these two fields have not been perfected, that is, they have not been used.

协议: Used to identify the type of information part on the right.

FCS: To implement error detection, a two-byte frame check sequence.


6.3. HDLC protocol

6.3.1. Understand the HDLC protocol

The HDLC protocol is not developed by the TCP/IP protocol suite, but is a protocol developed by OSI .

高级数据链路层控制(High-Level Data Link Control或简称HDLC): It is a data link layer protocol that synchronizes data transmission on the Internet and is specific. It was developed by the International Organization for Standardization (ISO) based on the extension of IBM's SDLC (Synchronous Data Control) protocol.

Implementation method : Data messages can be transmitted transparently, and the "0-bit insertion method" used to achieve transparent transmission is easy to implement in hardware.

  • Transparent transmission method: 0-bit insertion method.
    • The PPP protocol includes synchronous transmission and asynchronous transmission. The synchronous transmission in the PPP protocol also adopts the same 0-bit insertion method as HDLC. When encountering 5 0s, 1 is inserted. The receiving end only needs to insert the 0 bits after 5 consecutive 0s. 1 Just delete it.
    • The difference between HDLC protocol and PPP protocol: The PPP protocol differs from it in time transparent transmission and byte filling. If a character with a frame delimiter is encountered in the data, it will be inserted into the data content part. An escape character.

Communication method : full-duplex communication.

Advantages : All frames are checked using CRC , and information frames are sequentially numbered to prevent missing or repeated receptions, and the transmission reliability is high. :


6.3.2, HDLC station

1. Master station : The main function is to send command (including data information) frames, receive response frames, and is responsible for the initial startup of the entire link control system, process control, error control, error detection or recovery, etc.

2. Slave station : The main function is to receive command frames sent by the master station, send response frames to the master station, and cooperate with the master station to participate in link control such as error recovery.

3. Composite station : The main function is to send and receive command frames and response frames, and is responsible for the control of the entire link.

There are three data operation methods corresponding to the website :

1. 正常响应方式: If the slave station wants to send a message, it needs the consent of the master station. The master station commands it to send data, and then the slave station can send data.

2. 异步平衡方式: Each composite station can transmit data to other stations.

3. 异步响应方式: The slave station can transmit a data without the consent of the master station.


6.3.3. HDLC frame format

The frame format is similar to the PPP protocol, as shown below :

image-20230803104543367

  • 标志字段: An identifier field is added at the beginning and end, and the binary value of the flag field is the same, 01111110.
  • 零比特传输: Refers to the fact that if there is the same bit stream format in the transparent transmission interval, zero-bit transmission will be carried out according to the 5110 rules. If five consecutive 1-bits are detected, the sender will automatically send the message after the fifth consecutive 1-bit. A zero bit (0 bit) is inserted to distinguish the same byte pattern as the control character.
  • 地址位A: ① If the normal response mode or asynchronous response mode is used, the slave address is filled in. ② If the asynchronous balancing method is used, the address of the answering station and the other party will be filled in.
  • 控制字段C: Definitely the HDLC type. It is very similar to the protocol field of the PPP frame. This control field mainly depends on the first two digits. The rules are as follows (the degree of mastery is to know these three frames. If you remember them together, there is no monitoring):
    • If the first bit is 0 (information frame (I)), it is used to transmit data information , or use piggyback technology to confirm the data.
    • If the first two digits are 10 (supervision frame (S)), it is used for flow control and error control , and to perform functions such as acknowledging information frames, requesting retransmission, and requesting to suspend transmission.
    • If the first two digits are 11 (unnumbered frame (U)), it is used to provide various control functions such as link establishment and teardown.

6.3.4. Similarities and differences between PPP protocol & HDLC protocol

Similar points :

1. HDLC and PPP only support full-duplex links .

2. Transparent transmission can be achieved .

  • The PPP protocol can implement 零比特填充this 字节填充bit stuffing method.
  • The HDLC protocol can only implement a zero-bit padding method. (When 5 1s are encountered, the tail is filled with 0s)

3. Error detection can be achieved, but errors cannot be corrected .

  • This is mainly accomplished by borrowing the FCS frame check field.

The differences are as follows :

image-20230803110335860

image-20230803110324193

Detailed description of the differences :

  1. The PPP protocol is byte-oriented, so it is an integer number of bytes (an integer multiple of 8 bits); each frame format of the HDLC protocol is based on each bit, and when sent, it will be a series of bits. This can It's any position.
  2. 2B protocol field : PPP is the protocol field. The control field in HDLC is similar to this protocol field. They all specify the type of information part and frame.
  3. Whether there is no sequence number and confirmation mechanism : PPP does not have it; HDLC does (at this time it can be said that HDLC is a more reliable one, while the PPP protocol is unreliable)
    • **Why is the PPP protocol unreliable? **The reason is that it is relatively wasteful, because in actual life applications, the TCP protocol is mainly used to implement functions such as error control and flow control. For the network layer and data link layer, what can be basically realized is unreliable, so we must try our best to deliver it. One transmission, the reason is that people have very high speed requirements for the network, and it will take a lot of time to complete error detection and correction at the physical layer or data link layer. Therefore, most of the reliable transmission is handed over to the transport layer.
  4. Reliability : Depending on whether there is a sequence number and a confirmation mechanism, PPP is unreliable, while HDLC is reliable. (However, PPP is still used in reality. The reason is that reliable transmission is implemented by the transport layer, and the physical layer data link layer is not implemented. The transmission is completed as much as possible.)

mind map moment

image-20230803111102214


7. Link layer equipment

7.1. Physical layer extension Ethernet

Reason for expansion : Initially, multiple hosts are connected to the hub, but the distance between the host and the hub cannot exceed 100 meters. Once it exceeds 100 meters, frame loss will be very serious. In order to enable hosts that are far away to communicate, It is necessary to expand Ethernet at the physical level. :

image-20230803115852472


Expansion method one: optical fiber

方式一:采用光纤的方式来扩宽或者扩展开以太网的范围,使得两台主机进行通信距离可以变得更远。

下图中在主机与集线器之间使用了光纤,与此同时我们也可以在集线器上来增加连接一些光纤用于扩大网络范围的作用。

对于光纤之间进行光电转换则使用的是光纤调制、解调器

image-20230803120149567


扩展方式二:主干集线器

方式二: 利用集线器将许多集线器组合起来

通过集线器来将来将连接多台主机的集线器组合起来,每个集线器所构成的一个区域叫做是冲突域。

  • 冲突域指的是在这个物理层设备,所连的主机之内,若是进行通信,同一时间是只能有一台主机在发送信息的,如果有两台主机发送信息,那么就会发生冲突或者碰撞。

如下图,我们首先使用一台集线器来构建出一个冲突域,接着将多个集线器再连接到一个主干集线器上,此时就可以使第一个冲突域的计算机可以和其他两个冲突域的计算机进行连接,这种方式也就是扩展以太网的方式:

image-20230803133432090

采用这样的方式有两个好处

  • 好处1:可以实现跨冲突域跨域的通信,那么一台主机就可以和很远的主机进行通信。
  • 好处2:扩大了以太网覆盖的地理范围,原来可能是一个冲突域中只有四台主机,此时现在一个冲突域中有12台主机。

缺点:通信效率变低了,原来的一个冲突域内,有四台主机可能发生的冲突概率比较小,而此时在主干集线器中那么多主机共享一个通信信道,那么此时发生冲突的概率会更加高,效率更低。

有什么方式可以来减少冲突并且可以扩大以太网的范围?

  • Yes, an extension is made to Ethernet at the link layer. At this time, two devices are used, one is a bridge and the other is a switch .

7.2. Link layer extended Ethernet

7.2.1. Network bridge

7.2.1.1. Understand network bridges and principles

The bridge can be regarded as the predecessor of the switch. In practical applications, switches are usually used instead of bridges.

网桥: Forward and filter frames based on the destination address of the MAC frame. When the bridge receives a frame, it does not forward the frame to all interfaces. Instead, it first checks the destination MAC address of the frame, and then determines where to forward the frame. Which interface, or drop it directly (i.e. filter).

Principle : If the hub sends data from a host, it will be forwarded from all ports. In the bridge, it will consider whether it needs to be forwarded from this port and where it should be forwarded. If it cannot be forwarded, it will be discarded. .

There are usually two ports on a network bridge, and there are also four or three ports. Generally speaking, they are relatively few. The two ends of the bridge are a network segment. If a hub is used in a network segment, it also belongs to the same network segment.

image-20230803134733576

  • 网段: Generally refers to that part of a computer network that can communicate directly using the same physical layer equipment (transmission media, repeaters, hubs).

7.2.1.2. Advantages of network bridges

Advantages of bridges :

Advantages 1. Filter traffic and increase throughput.

  • This bridge is a device currently working at the data link layer . It can separate conflict domains. It has the function of filtering traffic and separating conflict domains. It can see the communications on different network segments without interacting with each other. For example, when A and B communicate, C and D can also communicate, and so can E and F.
  • If a physical layer device is connected to multiple conflict domains, such as a hub, then when a host in one conflict domain is communicating, hosts in other conflict domains cannot communicate.

The bandwidth used by different physical devices is also different:

  • When using a network bridge, if the bandwidth of each network segment is 10Mb/s, then the maximum throughput of the three network segments combined is 30Mb/s.
  • When using a hub, if the bandwidth of each network segment is 10Mb/s, then since it is connected using physical layer equipment, the maximum throughput of the entire collision domain is 10Mb/s.

Advantage 2: Expanded physical transmission range.

  • Example: For example, A in the leftmost conflict domain in the above picture can communicate with E which is very far away.

Advantage 3: Improved reliability.

  • If the cable connected to a host in a conflict domain fails, there will be no impact on the other two hosts in the conflict domain.

Advantage 4: Can interconnect different physical layers, different MAC sublayers and Ethernet at different rates.


7.2.1.3. The first type of bridge: transparent bridge (including self-learning process, three cases)

透明网桥: "Transparent" means that the stations on the Ethernet do not know which bridges the frames sent pass through. It is a plug-and-play device that can work as soon as it is plugged in.

  • how to work? It uses a self-learning algorithm.

Bridge forwarding table : The forwarding table is not always unchanged. It will be updated every few minutes. This update will delete all previous records, and then improve the new forwarding table through self-learning.

Self-learning process :

First, when we connect the bridge to the network cable, the forwarding table of each bridge is empty, with ports 1 and 2 on the left and right:

image-20230803141315507

Case 1: Host A sends a signal to Host B

When host A sends a signal to B on the network segment, hosts G and B on the left and right sides will receive the signal. At this time, B has actually received the signal.

At this time, this data will also be transmitted to the left interface 1 of the bridge. At this time, the bridge will find which port to forward based on the current frame. Since there is no address of host A in the forwarding table, it will be in the forwarding table at this time. Add a record of A in the forwarding table. Since there is no information about destination host B in the forwarding table, it will be forwarded through port 2 at this time.

image-20230803142146215

After forwarding from port 2, the hosts corresponding to network segments C and D will also receive the message. Since it is not B, they will all be discarded until it reaches port 1 of another bridge. The bridge also discovers and If there is no address of A, then such a record of A's address will be stored in the forwarding table . Since there is no host B in the forwarding, it will be forwarded from port 2 until it is forwarded to the new network segment and there will be no host B. host.

image-20230803142419836

Case 2: Host F sends data to host C

Host F sends a data frame to host C in the current network segment. At this time, because there is no host C in this network segment, no host receives it. At this time, the data frame comes to port 2 of the bridge. The bridge first checks whether there is any data in the forwarding. F host, because there is no F record added at this time, and since there is no C host, the data frame is forwarded from port 1.

image-20230803143023701

At this time, host C successfully receives the packet in the network segment forwarded by port 1 .

At the same time, because it is on a network segment, this data frame will be transmitted to port 2 of bridge 1 on the left. Also, because there is no address record of F in the forwarding table of bridge 1, the address of F will be transmitted at this time. The record is saved in the forwarding table. Since no record of the F address is found, the data frame will still be forwarded from port 1 in Bridge 1.

image-20230803143038655

Case 3: B wants to send a data frame to A

Host B directly sends a data frame to host A on the network segment. At this time, A will directly receive the data frame because it is on the network segment.

At the same time, this data frame will come to port 1 of bridge 1. First, check whether there is a record of host B in the forwarding table. If not, it will be directly recorded in the forwarding table, because there is a corresponding record of host A in the forwarding table of the bridge. The address record. At this time, the bridge knows that host A is on the bridge, and then the data frame will be discarded .

image-20230803143308053


7.2.1.4. The second type of bridge: source routing bridge (the principle is similar to the first type)

源路由网桥: When sending a frame, put detailed optimal routing information (least route/shortest time) in the header of the frame.

Method : The source station sends a discovery frame to the pre-communication destination station in broadcast mode.

Example : The maze in the picture below is similar to our actual complex network, with an entrance and an exit. The working principle of the source routing bridge is that the source station puts it on the link in the form of broadcast for propagation. This link is very complex and there may be multiple paths to the end. There are two solutions below.

image-20230803145201786

In reality, there are many solutions that can make our discovery frame go from the source station to the destination station. At this time, the destination station will return a response frame or discovery frame for principle return. At this time, the returned response frame or transmission frame will tell Starting point, how many routing options are there at this time .

Among these routing options, there will be one with the least route or the least time, which mainly depends on what we want. After determining an optimal path, it will be placed in the header of the frame as the best routing information , and then all that needs to be sent will be If the destination station is the same as this station, then this scheme will be used to send it.

image-20230803145709418


7.2.2. Ethernet switch (multi-interface bridge)

7.2.2.1. Understanding Ethernet switches

Since the original network bridge only has two ports, if you want to expand this Ethernet, you will need many bridges, which will cause a lot of waste. With the development of technology, the interfaces of network bridges are becoming more and more, and some hubs can also be connected. HUB and some hosts.

image-20230803150145825

At this time, such a multi-port network bridge becomes the current Ethernet switch . There are usually more than a dozen ports, each of which can be connected to a hub.

  • If the network is very complex and there are too many hosts connected to the switch, then you actually need to consider letting the hosts connect to the hub first, and then using the switch to connect the hubs.
  • If there are relatively few hosts, they can also be directly connected to the switch.

7.2.2.2. Advantages of Ethernet switches

Advantages of Ethernet switches : exclusive transmission media bandwidth

What are the advantages?

  • Originally, we used the physical layer device of a hub to construct a conflict domain when connecting multiple hosts. In fact, each host equally divides the bandwidth of the hub. For example, if the hub is 10Mb/s, then there are four hosts. At this time, each host All have a bandwidth of 2.5Mb/s.
  • If an Ethernet switch is used to connect multiple hosts or multiple hubs, then if the bandwidth of the Ethernet switch is 10Mb/s, then each hub (host) will exclusively occupy the 10Mb/s bandwidth.

image-20230803150353927


7.2.2.3. Two switching modes of Ethernet switches (cut-through, store-and-forward)

There are two types : cut-through switches, store-and-forward switches, and switches that use a mixture of the two.

① Cut-through switch : forward immediately after checking the destination address (6B).

  • Advantages: small delay.
  • Disadvantages: Low reliability, unable to support port switching with different rates (problems will occur if the rates on both sides are very different).

② Store-and-forward switch : Put the frame into the cache and check whether it is correct. If it is correct, it will be forwarded, and if it is wrong, it will be discarded.

  • Advantages: High reliability, can support port switching with different rates.
  • Disadvantages: large delay.

In practical applications, store-and-forward switches are used .


7.2.2.4. Switch forwarding mechanism (two examples)

In fact, it is almost the same as the self-learning ability of the network bridge .

The following is an example diagram of a switch. A switch may be connected to multiple hosts, and a switch maintains a forwarding table:

image-20230803151315274

Example 1: Host A sends a data frame to Host B.

Host A sends a piece of data to the switch. The switch first checks whether there is a record of the sending host A in the routing table. If not, it will add the record of the A address and interface 1, and then add it to the routing table. Host B is not queried. At this time, all ports in the switch will forward this data frame .

image-20230803151607326

Since hosts C and D connected to ports 3 and 4 are not destination hosts, the data frame message will eventually be received from host B in port 2 .

Example 2: Host B sends to host A

Host B sends a data frame to the switch. At this time, the switch first determines whether there is a record of host B in the routing table and records it. Then it queries the routing table to see if there is a port direction corresponding to the address of host A. If it is found, At this time, the switch will directly forward the data out of port 1 , and ports 3 and 4 will not forward it.

image-20230803151750932

Note : Each entry is set with a life cycle. Whenever this life cycle is exceeded, the entry will be deleted by the switch. :

  • The main purpose of deletion: Sometimes some new hosts will be connected to the switch, so the forwarding table needs to always be kept in an up-to-date state.

7.3. Collision domain and broadcast domain

7.3.1. Understand the conflict domain and broadcast domain

冲突域: Each node in the same collision domain can receive all frames sent. Only one device can send information at a time .

广播域: A collection of all devices on the network that can receive broadcast frames sent by any device. If a station sends out a broadcast signal, then the range of all devices that can receive the signal is called a broadcast domain .

For devices at different layers, whether the collision domain and broadcast domain are isolated is as shown in the following figure :

image-20230803152136064

  • Each port in a link layer device such as a switch is a collision domain.

7.3.2. Example: Find the number of broadcast domains and conflict domains

Identify the number of broadcast domains and conflict domains based on the picture :

image-20230803152548820

How to check the number of broadcast domains?

  • If there is a router , then the broadcast domain can be isolated; if there is no router, then there is only one broadcast domain.

How to check the number of conflict domains?

  • A hub can form a collision domain, which corresponds to the ports connected to the switch.
  • Quick look: Look at the physical link layer equipment. There are several collision domains based on how many ports there are . At this time, there are four in the picture.

Answer: 4 collision domains and 1 broadcast domain .


mind map moment

image-20230803152631674


Organizer: Long Road Time: 2023.7.30-8.3

Guess you like

Origin blog.csdn.net/cl939974883/article/details/132074014
Recommended