CN115766510A - Testing method and readable medium for loop detection stability of switch - Google Patents

Testing method and readable medium for loop detection stability of switch Download PDF

Info

Publication number
CN115766510A
CN115766510A CN202211407526.2A CN202211407526A CN115766510A CN 115766510 A CN115766510 A CN 115766510A CN 202211407526 A CN202211407526 A CN 202211407526A CN 115766510 A CN115766510 A CN 115766510A
Authority
CN
China
Prior art keywords
loop detection
switch
port
network card
message
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202211407526.2A
Other languages
Chinese (zh)
Other versions
CN115766510B (en
Inventor
陆芬
方海勤
骆雄辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Primestone Network Technology Co ltd
Original Assignee
Shenzhen Primestone Network Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Primestone Network Technology Co ltd filed Critical Shenzhen Primestone Network Technology Co ltd
Priority to CN202211407526.2A priority Critical patent/CN115766510B/en
Publication of CN115766510A publication Critical patent/CN115766510A/en
Application granted granted Critical
Publication of CN115766510B publication Critical patent/CN115766510B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Small-Scale Networks (AREA)

Abstract

The invention discloses a testing method and a readable medium for the loop detection stability of a switch, wherein the testing method for the loop detection stability of the switch comprises the steps of constructing a cable misconnection testing topology, respectively connecting a first port and a second port of a tested switch with a first network card and a second network card of a PC (personal computer), and selecting the cable misconnection condition to be tested; issuing configuration to a tested switch, forbidding a loop detection function of a second port of the tested switch, and enabling the loop detection function of a first port of the tested switch; and sequentially judging whether all the cable misconnection conditions are selected, and carrying out loop detection stability test on the selected cable misconnection conditions. The invention uses the PC to simulate the auxiliary switch, the construction and the sending of the message can be finished by the automatic system controlling the PC, the test can be finished only by one switch and one PC, other switches can not be occupied, and the equipment resource cost is saved.

Description

一种交换机环路检测稳定性的测试方法及可读介质Test method and readable medium for loop detection stability of switch

技术领域technical field

本发明涉及环路检测技术领域,具体的说,是涉及一种交换机环路检测稳定性的测试方法及可读介质。The invention relates to the technical field of loop detection, in particular to a testing method and a readable medium for loop detection stability of an exchange.

背景技术Background technique

环路检测功能是交换机的重要功能,主要作用是当网络中存在环路时能够自动关闭出问题的端口以消除环路。The loop detection function is an important function of the switch, and its main function is to automatically close the problematic port to eliminate the loop when there is a loop in the network.

网络连接或配置的错误容易导致二层网络中出现转发环路,使设备对广播、组播以及未知单播等报文循环重复发送,造成网络资源的浪费甚至网络瘫痪,环路检测专门为了有效的防止环路,确保网络的稳定与安全。因此,环路检测功能的稳定性测试尤其重要。Network connection or configuration errors can easily lead to forwarding loops in the Layer 2 network, causing the device to repeatedly send broadcast, multicast, and unknown unicast messages, resulting in waste of network resources or even network paralysis. Loop detection is designed to effectively Prevent loops to ensure the stability and security of the network. Therefore, the stability test of the loop detection function is particularly important.

另外,环路检测功能有一个自动恢复时间,当自动恢复时间超时后,阻塞的端口会变为转发状态,这段时间内网络又会处于环路的状态,若端口处于转发状态的时间太长会对网络带来很大的负面影响,因此环路检测自动恢复时间超时后,测试阻塞端口变为转发状态后的持续时间也是尤其重要的。In addition, the loop detection function has an automatic recovery time. When the automatic recovery time expires, the blocked port will change to the forwarding state. During this period, the network will be in the loop state again. If the port is in the forwarding state for too long It will have a great negative impact on the network. Therefore, after the loop detection automatic recovery time expires, it is especially important to test the duration after the blocked port changes to the forwarding state.

目前,现有的环路检测功能的稳定性测试方式主要有两种:一、购买网络测试仪,模拟交换机来组网测试;二、使用多台交换机一起组网测试。然而,购买网络测试仪,模拟交换机来组网测试,一个测试仪端口只能模拟一台交换机,但是网络测试仪的价格较为昂贵,大大增加了测试成本;而使用多台交换机一起组网测试,因为稳定性测试需要的时间较长,这样会长时间占用实验室的设备资源,也会影响其他项目的测试进度。同时,上述的两种测试方式均需要测试人员持续盯着,要耗费很大的人力,还存在人为因素导致测试不到位或是遗漏的情况。At present, there are mainly two ways to test the stability of the existing loop detection function: 1. Purchase a network tester and simulate a switch to conduct a network test; 2. Use multiple switches to conduct a network test together. However, if you buy a network tester and simulate a switch for networking testing, one tester port can only simulate one switch, but the price of the network tester is relatively expensive, which greatly increases the test cost; and using multiple switches together for network testing, Because the stability test takes a long time, it will occupy the equipment resources of the laboratory for a long time, and it will also affect the test progress of other projects. At the same time, both of the above two test methods require testers to keep watching, which consumes a lot of manpower, and there are also cases where human factors lead to incomplete or missed tests.

因此,有必要研发一种全面自动化的交换机环路检测稳定性的测试方法,来解决以上问题。Therefore, it is necessary to develop a fully automated test method for loop detection stability of switches to solve the above problems.

发明内容Contents of the invention

为了克服现有的环路检测功能的稳定性测试方式存在价格较为昂贵、占用其他交换机、需要测试人员持续盯着的问题,本发明提供了一种交换机环路检测稳定性的测试方法及可读介质。In order to overcome the problems that the existing loop detection function stability test method is relatively expensive, occupies other switches, and requires testers to keep staring, the present invention provides a test method and readable test method for loop detection stability of switches. medium.

本发明技术方案如下所述:Technical solution of the present invention is as follows:

第一方面,本发明提供一种交换机环路检测稳定性的测试方法,包括以下步骤:In a first aspect, the present invention provides a test method for loop detection stability of a switch, comprising the following steps:

步骤S1、搭建线缆误接测试拓扑,将被测交换机的第一端口、第二端口分别连接PC的第一网卡、第二网卡,并勾选要进行测试的线缆误接情况;Step S1, build a cable misconnection test topology, connect the first port and the second port of the switch under test to the first network card and the second network card of the PC respectively, and check the cable misconnection situation to be tested;

步骤S2、向被测交换机下发配置,禁用所述被测交换机的第二端口的环路检测功能,使能所述被测交换机的第一端口的环路检测功能;Step S2, sending the configuration to the switch under test, disabling the loop detection function of the second port of the switch under test, and enabling the loop detection function of the first port of the switch under test;

步骤S3、依次判断所有的所述线缆误接情况是否勾选,并对勾选的所述线缆误接情况进行环路检测稳定性测试;Step S3, sequentially determine whether all the cable misconnection situations are checked, and perform a loop detection stability test on the checked cable misconnection situations;

步骤S4、对勾选的所述线缆误接情况进行环路检测稳定性测试时,将所述被测交换机的第一端口的环路检测状态设置为阻塞状态,然后PC的第二网卡向其第一网卡发出二层数据报文,并通过所述二层数据报文的收发时间,计算环路检测自动恢复时间超时后所述被测交换机的第一端口维持转发状态的持续时间。Step S4, when performing a loop detection stability test on the checked cable misconnection situation, the loop detection state of the first port of the switch under test is set to a blocking state, and then the second network card of the PC sends Its first network card sends the two-layer data message, and through the sending and receiving time of the two-layer data message, calculates the duration of the first port of the tested switch to maintain the forwarding state after the automatic recovery time of the loop detection is overtime.

根据上述方案的交换机环路检测稳定性的测试方法,在步骤S1中,勾选完要进行测试的所述线缆误接情况后,设定每种所述线缆误接情况的测试时间。According to the method for testing the stability of the switch loop detection in the above solution, in step S1, after the cable misconnection conditions to be tested are checked, the test time for each cable misconnection condition is set.

根据上述方案的交换机环路检测稳定性的测试方法,在步骤S1中,所述线缆误接情况包括造成交换机自环的第一种线缆误接情况、造成交换机下联设备自环的第二种线缆误接情况及造成交换机之间成环的第三种线缆误接情况。According to the testing method for the loop detection stability of the switch in the above scheme, in step S1, the cable misconnection situation includes the first cable misconnection situation that causes the self-loop of the switch, and the second situation that causes the self-loop of the downlink equipment of the switch. The first case of cable misconnection and the third case of cable misconnection causing a loop between switches.

进一步的,在步骤S4中,对所述第一种线缆误接情况进行环路检测稳定性测试的具体子步骤包括:Further, in step S4, the specific sub-steps of performing a loop detection stability test on the first cable misconnection situation include:

步骤A1、所述被测交换机的第一端口的环路检测功能为使能状态,发出第一环路检测报文,所述PC的第一网卡接收到所述第一环路检测报文后,将所述第一环路检测报文直接从所述PC的第二网卡发给所述被测交换机的第二端口,所述被测交换机接收到所述第一环路检测报文后,将其第一端口的环路检测状态设置为阻塞状态;Step A1, the loop detection function of the first port of the switch under test is in an enabled state, and sends a first loop detection message, and after the first network card of the PC receives the first loop detection message , sending the first loop detection message directly from the second network card of the PC to the second port of the switch under test, after the switch under test receives the first loop detection message, The loop detection state of its first port is set to blocking state;

步骤A2、构造第一二层数据报文,并将所述第一二层数据报文从所述PC的第二网卡发给所述PC的第一网卡;Step A2, constructing a first layer-2 data message, and sending the first layer-2 data message from the second network card of the PC to the first network card of the PC;

步骤A3、实时监测所述PC的第一网卡接收第一二层数据报文的情况,并通过所述第一二层数据报文的收发时间,计算环路检测自动恢复时间超时后所述被测交换机的第一端口维持转发状态的持续时间。Step A3, real-time monitoring of the first network card of the PC receiving the first layer-2 data message, and through the sending and receiving time of the first layer-2 data message, calculate the loop detection automatic recovery time after the overtime. The first port of the test switch maintains the duration of the forwarding state.

进一步的,在步骤A3中,当环路检测的自动恢复时间超时后,所述被测交换机的第一端口由阻塞状态变为转发状态,所述PC的第一网卡接收到所述PC的第二网卡发送的所述第一二层数据报文。Further, in step A3, when the automatic recovery time of the loop detection times out, the first port of the switch under test changes from the blocking state to the forwarding state, and the first network card of the PC receives the first port of the PC. The first layer-2 data packet sent by the second network card.

进一步的,在步骤A3中,当所述被测交换机的第一端口进入转发状态后,记录所述PC的第一网卡每一次接收到所述第一二层数据报文时的时间和报文数量,并计算每一次所述被测交换机的第一端口由阻塞状态变为转发状态时,转发状态维持的时间;Further, in step A3, after the first port of the switch under test enters the forwarding state, record the time and message when the first network card of the PC receives the first layer-2 data message every time Quantity, and calculate the time that the forwarding state maintains when the first port of described switch under test changes from blocking state to forwarding state each time;

进一步的,在步骤A3中,计算完毕后,将记录保存到excel文件中。Further, in step A3, after the calculation is completed, the records are saved in an excel file.

进一步的,在步骤S4中,对所述第二种线缆误接情况进行环路检测稳定性测试的具体子步骤包括:Further, in step S4, the specific sub-steps of performing a loop detection stability test on the second cable misconnection situation include:

步骤B1、所述被测交换机的第一端口的环路检测功能为使能状态,发出第二环路检测报文,所述PC的第一网卡接收到所述第二环路检测报文后,将所述第二环路检测报文中的上一跳字段修改为所述PC的MAC地址,再将修改后的所述第二环路检测报文从所述PC的第一网卡发给所述被测交换机的第一端口,所述被测交换机接收到修改后的所述第二环路检测报文后,将其第一端口的环路检测状态设置为阻塞状态;Step B1, the loop detection function of the first port of the tested switch is in an enabling state, and a second loop detection message is sent, and after the first network card of the PC receives the second loop detection message , modifying the last hop field in the second loop detection message to the MAC address of the PC, and then sending the modified second loop detection message from the first network card of the PC to The first port of the switch under test, after receiving the modified second loop detection message, the switch under test sets the loop detection state of its first port to a blocking state;

步骤B2、构造第二二层数据报文,并将所述第二二层数据报文从所述PC的第二网卡发给所述PC的第一网卡;Step B2, constructing a second layer-2 data message, and sending the second layer-2 data message from the second network card of the PC to the first network card of the PC;

步骤B3、实时监测所述PC的第一网卡接收所述第二二层数据报文的情况,并通过所述第二二层数据报文的收发时间,计算环路检测自动恢复时间超时后所述被测交换机的第一端口维持转发状态的持续时间。Step B3, real-time monitoring of the first network card of the PC receiving the second layer 2 data message, and through the sending and receiving time of the second layer 2 data message, calculate the loop detection automatic recovery time overtime The duration for which the first port of the switch under test maintains the forwarding state.

进一步的,在步骤B3中,当环路检测的自动恢复时间超时后,所述被测交换机的第一端口由阻塞状态变为转发状态,所述PC的第一网卡接收到所述PC的第二网卡发送的所述第二二层数据报文。Further, in step B3, when the automatic recovery time of the loop detection times out, the first port of the switch under test changes from the blocking state to the forwarding state, and the first network card of the PC receives the first port of the PC. The second layer-2 data packet sent by the second network card.

进一步的,在步骤B3中,当所述被测交换机的第一端口进入转发状态后,记录所述PC的第一网卡每一次接收到所述第二二层数据报文时的时间和报文数量,并计算每一次所述被测交换机的第一端口由阻塞状态变为转发状态时,转发状态维持的时间。Further, in step B3, when the first port of the switch under test enters the forwarding state, record the time and message when the first network card of the PC receives the second layer-2 data message each time number, and calculate the time for the forwarding state to be maintained each time the first port of the switch under test changes from the blocking state to the forwarding state.

进一步的,在步骤B3中,计算完毕后,将记录保存到excel文件中。Further, in step B3, after the calculation is completed, the records are saved into an excel file.

进一步的,在步骤S4中,对所述第三种线缆误接情况进行环路检测稳定性测试的具体子步骤包括:Further, in step S4, the specific sub-steps of performing a loop detection stability test on the third cable misconnection situation include:

步骤C1、所述被测交换机的第一端口发出第三环路检测报文,所述PC的第一网卡接收到所述第三环路检测报文后,将所述第三环路检测报文中上一跳字段修改为所述PC的MAC地址,再将修改后的所述第三环路检测报文从所述PC的第二网卡发给所述被测交换机的第二端口,所述被测交换机接收到修改后的所述第三环路检测报文后,将其第一端口的环路检测状态设置为阻塞状态;Step C1, the first port of the switch under test sends a third loop detection message, and after receiving the third loop detection message, the first network card of the PC sends the third loop detection message In the text, the last hop field is modified to the MAC address of the PC, and then the modified third loop detection message is sent from the second network card of the PC to the second port of the switch under test, so After the switch under test receives the modified third loop detection message, the loop detection state of its first port is set to blocking state;

步骤C2、构造第三二层数据报文,并将所述第三二层数据报文从所述PC的第二网卡发给所述PC的第一网卡;Step C2, constructing a third layer-2 data message, and sending the third layer-2 data message from the second network card of the PC to the first network card of the PC;

步骤C3、实时监测所述PC的第一网卡接收所述第三二层数据报文的情况,并通过所述第三二层数据报文的收发时间,计算环路检测自动恢复时间超时后所述被测交换机的第一端口维持转发状态的持续时间。Step C3, real-time monitoring of the situation of the first network card of the PC receiving the third and second layer data messages, and through the sending and receiving time of the third and second layer data messages, calculate the loop detection automatic recovery time after the overtime The duration for which the first port of the switch under test maintains the forwarding state.

进一步的,在步骤C3中,当环路检测的自动恢复时间超时后,所述被测交换机的第一端口由阻塞状态变为转发状态,所述PC的第一网卡接收到所述PC的第二网卡发送的所述第三二层数据报文。Further, in step C3, when the automatic recovery time of the loop detection times out, the first port of the switch under test changes from the blocking state to the forwarding state, and the first network card of the PC receives the first port of the PC. The third layer-2 data packet sent by the second network card.

进一步的,在步骤C3中,当所述被测交换机的第一端口进入转发状态后,记录所述PC的第一网卡每一次接收到所述第三二层数据报文时的时间和报文数量,并计算每一次所述被测交换机的第一端口由阻塞状态变为转发状态时,转发状态维持的时间。Further, in step C3, after the first port of the switch under test enters the forwarding state, record the time and message when the first network card of the PC receives the third layer two data message every time number, and calculate the time for the forwarding state to be maintained each time the first port of the switch under test changes from the blocking state to the forwarding state.

进一步的,在步骤C3中,计算完毕后,将记录保存到excel文件中。Further, in step C3, after the calculation is completed, the records are saved into an excel file.

进一步的,所述第一环路检测报文、所述第二环路检测报文及所述第三环路检测报文均包括目的MAC地址、源MAC地址、报文的协议类型、发送该报文的交换机的MAC地址、交换机发送该报文的端口号及上一跳字段。Further, the first loop detection message, the second loop detection message and the third loop detection message all include the destination MAC address, the source MAC address, the protocol type of the message, and the The MAC address of the switch of the message, the port number of the switch sending the message, and the last hop field.

第二方面,本发明提供一种计算机可读介质,存储有计算机可执行指令,所述计算机可执行指令用于执行上述的交换机环路检测稳定性的测试方法。In a second aspect, the present invention provides a computer-readable medium, which stores computer-executable instructions, and the computer-executable instructions are used to execute the above-mentioned method for testing the stability of a switch loop detection.

根据上述方案的本发明,其有益效果在于:According to the present invention of above-mentioned scheme, its beneficial effect is:

1、本发明使用PC模拟辅助交换机,报文的构造和发送,均可由自动化系统控制PC完成,无需购买任何测试仪器,只需要一台交换机和一台PC即可完成测试,不会占用其他交换机,节约设备资源成本,同时可在任意时间进行测试,例如晚上或周末,不占用正常工作时间的设备和时间,节约时间成本;1. The present invention uses a PC to simulate an auxiliary switch. The construction and sending of messages can be completed by the automation system controlling the PC. There is no need to purchase any testing instruments, and only one switch and one PC are needed to complete the test without occupying other switches. , to save equipment resource costs, and at the same time, testing can be carried out at any time, such as night or weekend, which does not occupy equipment and time during normal working hours, saving time and cost;

2、本发明构造的二层数据报文从PC网卡发出,通过报文的收发来计算环路检测自动恢复时间超时后,被测交换机端口维持转发状态的持续时间,且可以测试出毫秒单位的时间,测试精度高;2. The Layer 2 data message constructed by the present invention is sent from the PC network card, and the loop detection automatic recovery time is calculated through the sending and receiving of the message. After the automatic recovery time of the loop detection is overtime, the duration of the switch port under test maintaining the forwarding state can be tested, and the millisecond unit can be tested. Time, high test accuracy;

3、本发明测试过程中可长时间实时监测交换机环路检测的运行状态,当交换机的环路检测功能出现失效时,系统能实时监测到并记录,能更好、更全面的测试交换机环路检测功能的稳定性,同时操作步骤少,能够极大减少人为误操作。3. During the testing process of the present invention, the operating status of the switch loop detection can be monitored in real time for a long time. When the loop detection function of the switch fails, the system can monitor and record it in real time, and can test the switch loop better and more comprehensively. The stability of the detection function and less operation steps can greatly reduce human misoperation.

附图说明Description of drawings

图1为本发明中交换机环路检测稳定性的测试方法的流程示意图;Fig. 1 is the schematic flow sheet of the test method of switch loop detection stability among the present invention;

图2为图1中A部分的放大图;Fig. 2 is an enlarged view of part A in Fig. 1;

图3为图1中B部分的放大图;Fig. 3 is an enlarged view of part B in Fig. 1;

图4为第一种典型的造成环路的线缆误接示意图;FIG. 4 is a schematic diagram of the first type of typical cable misconnection causing a loop;

图5为第二种典型的造成环路的线缆误接示意图;FIG. 5 is a schematic diagram of the second typical cable misconnection causing a loop;

图6为第三种典型的造成环路的线缆误接示意图;FIG. 6 is a schematic diagram of a third typical cable misconnection that causes a loop;

图7为本发明搭建的线缆误接测试拓扑示意图。FIG. 7 is a schematic diagram of a cable misconnection test topology constructed in the present invention.

具体实施方式Detailed ways

为了使本发明所要解决的技术问题、技术方案及有益效果更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本发明,并不用于限定本发明。In order to make the technical problems, technical solutions and beneficial effects to be solved by the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present invention, not to limit the present invention.

需要说明的是,本发明的说明书和权利要求书中的术语“包括”和“具有”以及它们任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terms "comprising" and "having" and any variations thereof in the description and claims of the present invention are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes unlisted steps or units, or optionally further includes For other steps or units inherent in these processes, methods, products or apparatuses.

请参考图1至图3,本发明实施例提供一种交换机环路检测稳定性的测试方法,包括以下步骤:Please refer to FIG. 1 to FIG. 3, an embodiment of the present invention provides a test method for loop detection stability of a switch, including the following steps:

步骤S1、搭建线缆误接测试拓扑,勾选要进行测试的线缆误接情况,并设定每种线缆误接情况的测试时间。Step S1, build a cable misconnection test topology, check the cable misconnection situation to be tested, and set the test time for each cable misconnection situation.

具体的,典型的造成环路的线缆误接情况有三种,第一种为现场布线人员误将同一台交换机的两个端口用一根线缆连接在一起,造成交换机自环的线缆误接情况,如图4所示;第二种为现场布线人员误将交换机下联设备的两个端口用一根线缆连接在一起,造成交换机下联设备自环的线缆误接情况,如图5所示;第三种为现场布线人员误将被测交换机的第一端口、第二端口分别连接到辅助交换机的第一端口、第二端口,造成交换机之间成环的线缆误接情况,如图6所示。Specifically, there are three typical cases of misconnection of cables that cause loops. The first is that field wiring personnel mistakenly connect two ports of the same switch with a single cable, causing the self-loop of the switch to be misconnected. The connection situation, as shown in Figure 4; the second is that the field wiring personnel mistakenly connect the two ports of the downlink device of the switch with a cable, resulting in the wrong connection of the self-loop cable of the downlink device of the switch, as shown in Figure 5 The third is that the on-site wiring personnel mistakenly connect the first port and the second port of the switch under test to the first port and the second port of the auxiliary switch, resulting in the wrong connection of the cables forming a loop between the switches. As shown in Figure 6.

本发明根据上面三种典型的造成环路的线缆误接情况搭建线缆误接测试拓扑,如图7所示,将被测交换机的第一端口、第二端口分别连接PC的第一网卡、第二网卡,即可完成图1至图3示出的三种典型的造成环路的线缆误接情况。在本发明中,测试时,只需要一台被测交换机和一台PC即可,PC用于模拟辅助交换机,发出系统构造的环路检测报文,无需购买测试仪器,不会占用其他交换机,节约设备资源成本。The present invention builds the cable misconnection test topology according to the above three typical cable misconnection situations that cause loops, as shown in Figure 7, the first port and the second port of the switch to be tested are respectively connected to the first network card of the PC 1. The second network card can complete the three typical cable misconnection situations that cause loops shown in FIGS. 1 to 3 . In the present invention, when testing, only one switch to be tested and one PC are needed, and the PC is used to simulate the auxiliary switch to send the loop detection message of the system structure, without purchasing test instruments, and other switches will not be occupied. Save equipment resource cost.

步骤S2、调用CRT向被测交换机下发配置,禁用被测交换机的第二端口的环路检测功能,使能被测交换机的第一端口的环路检测功能。Step S2, calling the CRT to deliver the configuration to the switch under test, disabling the loop detection function of the second port of the switch under test, and enabling the loop detection function of the first port of the switch under test.

其中,CRT为串口调试工具,可以使用其通过串口向被测交换机下发配置命令。另外,之所以只使能被测交换机的第一端口,是为了消除环路,从而达到测试的效果。Among them, CRT is a serial port debugging tool, which can be used to issue configuration commands to the switch under test through the serial port. In addition, the reason why only the first port of the switch under test is enabled is to eliminate loops and achieve test results.

步骤S3、判断是否勾选了第一种线缆误接情况,若没有勾选,则说明不进行该项测试,执行步骤S7,若勾选了,则执行步骤S4。Step S3 , judging whether the first type of cable misconnection is checked, if not checked, it means that the test is not performed, and step S7 is performed, and if checked, then step S4 is performed.

步骤S4、被测交换机的第一端口发出第一环路检测报文,PC的第一网卡接收到第一环路检测报文后,将第一环路检测报文直接从PC的第二网卡发给被测交换机的第二端口,被测交换机接收到第一环路检测报文后,会认为网络存在环路,将其第一端口的环路检测状态设置为阻塞状态。Step S4, the first port of the tested switch sends out the first loop detection message, and after the first network card of the PC receives the first loop detection message, the first loop detection message is directly transmitted from the second network card of the PC Send to the second port of the switch under test, after the switch under test receives the first loop detection message, it will think that there is a loop in the network, and the loop detection state of its first port will be set to blocking state.

具体的,第一环路检测报文的内容包括目的MAC地址、源MAC地址、报文的协议类型、发送该报文的交换机的MAC地址、交换机发送该报文的端口号及上一跳字段。其中,目的MAC地址设置为广播地址,以便报文经过的其它交换机时,能当成广播报文进行广播转发。源MAC地址和发送该报文的交换机的MAC地址都是用于记录发送该环路检测报文的是哪一台交换机;交换机发送该报文的端口用于判断成环后哪一个端口阻塞,从而达到消环的作用;上一跳字段就是用于记录报文经过的上一台交换机的MAC地址。Specifically, the content of the first loop detection message includes the destination MAC address, the source MAC address, the protocol type of the message, the MAC address of the switch that sends the message, the port number that the switch sends the message, and the last hop field . Wherein, the destination MAC address is set as a broadcast address, so that when the message passes through other switches, it can be broadcast and forwarded as a broadcast message. Both the source MAC address and the MAC address of the switch that sent the message are used to record which switch sent the loop detection message; the port on which the switch sent the message is used to determine which port is blocked after the loop is formed. In this way, the function of loop elimination is achieved; the last hop field is used to record the MAC address of the last switch that the message passes through.

步骤S5、构造第一二层数据报文,并将该第一二层数据报文从PC的第二网卡发给PC的第一网卡。Step S5, constructing a first layer-2 data packet, and sending the first layer-2 data packet from the second network card of the PC to the first network card of the PC.

其中,第一二层数据报文的发送速率为1000包/秒,持续发送时间为T1,采用上述设置可以测试出毫秒单位的时间。Wherein, the sending rate of the first and second layer data packets is 1000 packets/second, and the continuous sending time is T1, and the time in millisecond unit can be tested by using the above settings.

步骤S6、实时监测PC的第一网卡接收第一二层数据报文的情况,并通过第一二层数据报文的收发时间,计算环路检测自动恢复时间超时后被测交换机的第一端口维持转发状态的持续时间。Step S6, real-time monitoring of the situation of the first network card of the PC receiving the first and second layer data messages, and through the sending and receiving time of the first and second layer data messages, calculate the first port of the switch under test after the automatic recovery time of the loop detection is overtime The duration to maintain the forwarding state.

具体的,被测交换机的第一端口处于阻塞状态时,PC的第一网卡不能接收到第二网卡发送的第一二层数据报文;当环路检测的自动恢复时间(如间隔30秒)超时后,被测交换机的第一端口会由阻塞状态变为转发状态,这时PC的第一网卡就能接收到第二网卡发送的第一二层数据报文,等待被测交换机检测时间(如间隔5秒)超时后,被测交换机的第一端口会再次发送第一环路检测报文,然后进入阻塞状态;当被测交换机的第一端口进入转发状态后,记录PC的第一网卡每一次接收到第一二层数据报文时的时间和报文数量,并计算每一次被测交换机的第一端口由阻塞状态变为转发状态时,维持转发状态的持续时间,计算方法为:报文数量/1000(包/秒);计算完毕后,将记录保存到excel文件中,方便测试人员查看。Specifically, when the first port of the switch under test is blocked, the first network card of the PC cannot receive the first layer-2 data packet sent by the second network card; when the automatic recovery time of the loop detection (such as an interval of 30 seconds) After the timeout, the first port of the switch under test will change from the blocking state to the forwarding state. At this time, the first network card of the PC can receive the first and second layer data packets sent by the second network card, and wait for the detection time of the switch under test ( If the interval is 5 seconds) after timeout, the first port of the tested switch will send the first loop detection message again, and then enter the blocking state; when the first port of the tested switch enters the forwarding state, record the first network card of the PC The time and number of packets each time the first and second layers of data packets are received, and the duration of maintaining the forwarding state when the first port of the switch under test is changed from the blocking state to the forwarding state is calculated. The calculation method is: The number of packets/1000 (packets/second); after the calculation is completed, save the records to an excel file for easy viewing by testers.

步骤S7、判断是否勾选了第二种线缆误接情况,若没有勾选,则说明不进行该项测试,执行步骤S10,若勾选了,则执行步骤S8。Step S7, judging whether the second type of cable misconnection is checked, if not checked, it means that the test is not performed, and step S10 is performed, and if checked, then step S8 is performed.

步骤S8、被测交换机的第一端口发出第二环路检测报文,PC的第一网卡接收到第二环路检测报文后,将第二环路检测报文中的上一跳字段修改为PC的MAC地址,再将修改后的第二环路检测报文从PC的第一网卡发给被测交换机的第一端口,被测交换机接收到修改后的第二环路检测报文后,会认为网络存在环路,将其第一端口的环路检测状态设置为阻塞状态。Step S8, the first port of the switch under test sends a second loop detection message, after the first network card of the PC receives the second loop detection message, the last hop field in the second loop detection message is modified is the MAC address of the PC, and then the modified second loop detection message is sent from the first network card of the PC to the first port of the switch under test, and after the switch under test receives the modified second loop detection message , it will consider that there is a loop in the network, and set the loop detection status of the first port to blocked.

其中,由于第二种线缆误接情况是交换机下联设备自环,经过了辅助交换机,本发明中使用PC来模拟辅助交换机,所以需将第二环路检测报文中的上一跳字段修改为PC的MAC地址,以实现模拟第二种线缆误接情况。而第一种线缆误接情况是交换机自环,所以上一跳还是自身,第一环路检测报文的内容不需要改变。同时,第二环路检测报文和第一环路检测报文的内容一致,同样包括目的MAC地址、源MAC地址、报文的协议类型、发送该报文的交换机的MAC地址、交换机发送该报文的端口号及上一跳字段。Among them, since the second cable misconnection is the self-loop of the downlink equipment of the switch, after passing through the auxiliary switch, the PC is used to simulate the auxiliary switch in the present invention, so the previous hop field in the second loop detection message needs to be modified is the MAC address of the PC to simulate the second cable misconnection situation. The first case of cable misconnection is the self-loop of the switch, so the previous hop is still itself, and the content of the first loop detection message does not need to be changed. At the same time, the content of the second loop detection message is the same as that of the first loop detection message, and also includes the destination MAC address, source MAC address, protocol type of the message, the MAC address of the switch that sends the message, and the switch that sends the message. The port number and last hop field of the packet.

步骤S9、构造第二二层数据报文,并将该第二二层数据报文从PC的第二网卡发给PC的第一网卡。Step S9, constructing a second layer-2 data packet, and sending the second layer-2 data packet from the second network card of the PC to the first network card of the PC.

其中,第二二层数据报文的发送速率为1000包/秒,持续发送时间为T2,采用上述设置可以测试出毫秒单位的时间。Wherein, the sending rate of the second and second layer data packets is 1000 packets/second, and the continuous sending time is T2, and the time in millisecond unit can be tested by using the above settings.

步骤S10、实时监测PC的第一网卡接收第二二层数据报文的情况,并通过第二二层数据报文的收发时间,计算环路检测自动恢复时间超时后被测交换机的第一端口维持转发状态的持续时间。Step S10, real-time monitoring of the situation of the first network card of the PC receiving the second layer 2 data message, and through the sending and receiving time of the second layer 2 data message, calculate the first port of the switch under test after the automatic recovery time of the loop detection is overtime The duration to maintain the forwarding state.

具体的,被测交换机的第一端口处于阻塞状态时,PC的第一网卡不能接收到第二网卡发送的第二二层数据报文;当环路检测的自动恢复时间(如间隔30秒)超时后,被测交换机的第一端口会由阻塞状态变为转发状态,这时PC的第一网卡就能接收到第二网卡发送的第二二层数据报文,等待被测交换机检测时间(如间隔5秒)超时后,被测交换机的第一端口会再次发送第二环路检测报文,然后进入阻塞状态;当被测交换机的第一端口进入转发状态后,记录PC的第一网卡每一次接收到第二二层数据报文时的时间和报文数量,并计算每一次被测交换机的第一端口由阻塞状态变为转发状态时,转发状态维持的时间,计算方法为:报文数量/1000(包/秒);计算完毕后,将记录保存到excel文件中,方便测试人员查看。Specifically, when the first port of the switch under test is in a blocking state, the first network card of the PC cannot receive the second layer-2 data packet sent by the second network card; when the automatic recovery time of the loop detection (such as an interval of 30 seconds) After the timeout, the first port of the switch under test will change from the blocking state to the forwarding state. At this time, the first network card of the PC can receive the second layer-2 data message sent by the second network card, and wait for the detection time of the switch under test ( After the timeout, the first port of the tested switch will send the second loop detection message again, and then enter the blocking state; when the first port of the tested switch enters the forwarding state, record the first network card of the PC The time and number of packets each time the second layer 2 data packet is received, and the time for the forwarding state to be maintained when the first port of the switch under test is changed from the blocking state to the forwarding state is calculated. The calculation method is: report The number of files/1000 (packages/second); after the calculation is completed, save the records to an excel file for easy viewing by testers.

步骤S11、判断是否勾选了第三种线缆误接情况,若没有勾选,则说明不进行该项测试,直接结束测试,若勾选了,则执行步骤S12。Step S11 , judging whether the third type of cable misconnection is checked, if not checked, it means that the test will not be performed, and the test will be ended directly, if checked, then step S12 will be executed.

步骤S12、被测交换机的第一端口发出第三环路检测报文,PC的第一网卡接收到第三环路检测报文后,将第三环路检测报文中上一跳字段修改为PC的MAC地址,再将修改后的第三环路检测报文从PC的第二网卡发给被测交换机的第二端口,被测交换机接收到修改后的第三环路检测报文后,会认为网络存在环路,将其第一端口的环路检测状态设置为阻塞状态。Step S12, the first port of the switch under test sends a third loop detection message, and after the first network card of the PC receives the third loop detection message, the last hop field in the third loop detection message is changed to MAC address of the PC, and then the modified third loop detection message is sent from the second network card of the PC to the second port of the switch under test. After the switch under test receives the modified third loop detection message, It will consider that there is a loop in the network, and set the loop detection status of the first port to blocked.

其中,由于第三种线缆误接情况是交换机之间成环,经过了辅助交换机,本发明中使用PC来模拟辅助交换机,所以需将第三环路检测报文中的上一跳字段修改为PC的MAC地址,以实现模拟第三种线缆误接情况。同时,第三环路检测报文和第一环路检测报文的内容一致,同样包括目的MAC地址、源MAC地址、报文的协议类型、发送该报文的交换机的MAC地址、交换机发送该报文的端口号及上一跳字段。Wherein, since the third cable misconnection situation is that a loop is formed between the switches, after passing through the auxiliary switch, the PC is used to simulate the auxiliary switch in the present invention, so the last hop field in the third loop detection message needs to be modified is the MAC address of the PC to simulate the third cable misconnection situation. At the same time, the content of the third loop detection message is the same as that of the first loop detection message, and also includes the destination MAC address, source MAC address, protocol type of the message, the MAC address of the switch that sends the message, and the switch that sends the message. The port number and last hop field of the packet.

步骤S13、构造第三二层数据报文,并将该第三二层数据报文从PC的第二网卡发给PC的第一网卡。Step S13 , constructing a third layer-2 data packet, and sending the third layer-2 data packet from the second network card of the PC to the first network card of the PC.

其中,第三二层数据报文的发送速率为1000包/秒,持续发送时间为T3,采用上述设置可以测试出毫秒单位的时间。Wherein, the sending rate of the third and second layer data packets is 1000 packets/second, and the continuous sending time is T3, and the time in millisecond unit can be tested by using the above settings.

步骤S14、实时监测PC的第一网卡接收第三二层数据报文的情况,并通过第三二层数据报文的收发时间,计算环路检测自动恢复时间超时后被测交换机的第一端口维持转发状态的持续时间。Step S14, real-time monitoring of the situation that the first network card of the PC receives the third and second layer data messages, and through the sending and receiving time of the third and second layer data messages, calculate the first port of the tested switch after the automatic recovery time of the loop detection is overtime The duration to maintain the forwarding state.

具体的,被测交换机的第一端口处于阻塞状态时,PC第一网卡不能接收到第二网卡发送的第三二层数据报文;当环路检测的自动恢复时间(如间隔30秒)超时后,被测交换机的第一端口会由阻塞状态变为转发状态,这时PC的第一网卡就能接收到第二网卡发送的第三二层数据报文,等待被测交换机检测时间(如间隔5秒)超时后,被测交换机的第一端口会再次发送环路检测报文,然后进入阻塞状态;当被测交换机的第一端口进入转发状态后,记录PC的第一网卡每一次接收到第三二层数据报文时的时间和报文数量,并计算每一次被测交换机的第一端口由阻塞状态变为转发状态时,转发状态维持的时间,计算方法为:报文数量/1000(包/秒);计算完毕后,将记录保存到excel文件中,方便测试人员查看。Specifically, when the first port of the switch under test is in a blocking state, the first network card of the PC cannot receive the third and second layer data packets sent by the second network card; Afterwards, the first port of the switch under test will change from the blocking state to the forwarding state, and at this moment, the first network card of the PC can receive the third and second layer data packets sent by the second network card, and wait for the detection time of the switch under test (such as interval 5 seconds) after the timeout, the first port of the tested switch will send a loop detection message again, and then enter the blocking state; when the first port of the tested switch enters the forwarding state, record every time the first network card of the PC receives The time and number of packets when reaching the third and second layers of data packets, and calculate the time for the forwarding state to be maintained when the first port of the switch under test changes from the blocking state to the forwarding state each time, the calculation method is: number of packets/ 1000 (packages/second); after the calculation is completed, save the record to an excel file, which is convenient for testers to view.

本实施例提供的交换机环路检测稳定性的测试方法,使用PC模拟辅助交换机,报文的构造和发送,均可由自动化系统控制PC完成,无需购买任何测试仪器,只需要一台交换机和一台PC即可完成测试,不会占用其他交换机,节约设备资源成本;由于本发明可自动化完成测试,所以可以在任意时间进行测试,例如晚上或周末,不占用正常工作时间的设备和时间,节约时间成本;构造的二层数据报文从PC网卡发出,通过报文的收发来计算环路检测自动恢复时间超时后,被测交换机端口维持转发状态的持续时间,可以测试出毫秒单位的时间,测试精度高;测试过程中可长时间实时监测交换机环路检测的运行状态,当交换机的环路检测功能出现失效时,系统能实时监测到并记录,能更好、更全面的测试交换机环路检测功能的稳定性,同时操作步骤少,能够极大减少人为误操作。The test method for the stability of the switch loop detection provided in this embodiment uses a PC to simulate an auxiliary switch, and the construction and sending of the message can be completed by the automation system controlling the PC without purchasing any test instruments, only one switch and one The PC can complete the test without occupying other switches, saving equipment resource costs; since the present invention can automatically complete the test, it can be tested at any time, such as night or weekend, without occupying the equipment and time of normal working hours, saving time Cost: The constructed Layer 2 data message is sent from the PC network card, and the loop detection automatic recovery time is calculated by sending and receiving the message. After the automatic recovery time of the loop detection expires, the duration of the switch port under test maintaining the forwarding state can be tested for the time in milliseconds. High precision; during the test process, the running status of the switch loop detection can be monitored in real time for a long time. When the loop detection function of the switch fails, the system can monitor and record it in real time, which can better and more comprehensively test the switch loop detection The stability of the function and less operation steps can greatly reduce human misoperation.

所属技术领域的技术人员能够理解,本发明的各个方面可以实现为系统、方法或程序产品。因此,本发明的各个方面可以具体实现为以下形式,即:完全的硬件实施方式、完全的软件实施方式(包括固件、微代码等),或硬件和软件方面结合的实施方式,这里可以统称为“电路”、“模块”或“系统”。Those skilled in the art can understand that various aspects of the present invention can be implemented as systems, methods or program products. Therefore, various aspects of the present invention can be embodied in the following forms, that is: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, which can be collectively referred to herein as "circuit", "module" or "system".

根据本实施例的模块、子模块、单元、子单元中的任意多个、或其中任意多个的至少部分功能可以在一个模块中实现。根据本实施例的模块、子模块、单元、子单元中的任意一个或多个可以被拆分成多个模块来实现。根据本实施例的模块、子模块、单元、子单元中的任意一个或多个可以至少被部分地实现为硬件电路,例如现场可编程门阵列(FPGA)、可编程逻辑阵列(PLA)、片上系统、基板上的系统、封装上的系统、专用集成电路(ASIC),或可以通过对电路进行集成或封装的任何其他的合理方式的硬件或固件来实现,或以软件、硬件以及固件三种实现方式中任意一种或以其中任意几种的适当组合来实现。或者,根据本实施例的模块、子模块、单元、子单元中的一个或多个可以至少被部分地实现为计算机程序模块,当该计算机程序模块被运行时,可以执行相应的功能。According to this embodiment, any multiple of modules, sub-modules, units, and sub-units, or at least part of the functions of any multiple of them can be implemented in one module. Any one or more of the modules, submodules, units, and subunits according to this embodiment can be implemented by being divided into multiple modules. Any one or more of modules, submodules, units, and subunits according to this embodiment may be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), an on-chip system, system-on-substrate, system-on-package, application-specific integrated circuit (ASIC), or hardware or firmware that may be implemented in any other reasonable manner by integrating or packaging circuits, or in software, hardware, and firmware Any one of the implementations or an appropriate combination of any of them. Alternatively, one or more of the modules, submodules, units, and subunits according to this embodiment may be at least partially implemented as a computer program module, and when the computer program module is executed, corresponding functions may be performed.

在一个实施例中,本发明提供一种交换机环路检测稳定性的测试设备可以包括至少一个处理单元、以及至少一个存储单元。其中,存储单元存储有程序代码,当程序代码被处理单元执行时,使得处理单元执行本说明书上述描述的根据本发明各种示例性实施方式的交换机环路检测稳定性的测试中的步骤。例如,处理单元可以执行如图1所示的交换机环路检测稳定性的测试方法的流程。In one embodiment, the present invention provides a test device for loop detection stability of a switch, which may include at least one processing unit and at least one storage unit. Wherein, the storage unit stores program codes, and when the program codes are executed by the processing unit, the processing unit executes the steps in the test of the loop detection stability of the switch according to various exemplary embodiments of the present invention described above in this specification. For example, the processing unit may execute the flow of the method for testing the stability of the switch loop detection as shown in FIG. 1 .

在一个实施例中,本发明提供一种计算机可读介质,该存储有计算机可执行指令,计算机可执行指令用于执行本说明书上述描述的根据本发明各种示例性实施方式的交换机环路检测稳定性的测试方法中的步骤。In one embodiment, the present invention provides a computer-readable medium, which stores computer-executable instructions, and the computer-executable instructions are used to perform the switch loop detection described above in this specification according to various exemplary embodiments of the present invention Steps in the Stability Test Method.

可读介质可以是可读信号介质或者可读存储介质。可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了可读程序代码。可读信号介质还可以是可读存储介质以外的任何可读介质,该可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。可读介质上包含的程序代码可以用任何适当的介质传输,包括——但不限于——无线、有线、光缆、RF等等,或者上述的任意合适的组合。The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination thereof. A readable signal medium may include a data signal carrying readable program code in baseband or as part of a carrier wave. A readable signal medium may also be any readable medium other than a readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. Program code embodied on a readable medium may be transmitted using any appropriate medium, including - but not limited to - wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

此外,尽管在附图中以特定顺序描述了本发明方法的操作,但是,这并非要求或者暗示必须按照该特定顺序来执行这些操作,或是必须执行全部所示的操作才能实现期望的结果。附加地或备选地,可以省略某些步骤,将多个步骤合并为一个步骤执行,和/或将一个步骤分解为多个步骤执行。In addition, while operations of the methods of the present invention are depicted in the figures in a particular order, there is no requirement or implication that these operations must be performed in that particular order, or that all illustrated operations must be performed, to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step for execution, and/or one step may be decomposed into multiple steps for execution.

应当理解的是,对本领域普通技术人员来说,可以根据上述说明加以改进或变换,而所有这些改进和变换都应属于本发明所附权利要求的保护范围。It should be understood that those skilled in the art can make improvements or changes based on the above description, and all these improvements and changes should belong to the protection scope of the appended claims of the present invention.

上面结合附图对本发明专利进行了示例性的描述,显然本发明专利的实现并不受上述方式的限制,只要采用了本发明专利的方法构思和技术方案进行的各种改进,或未经改进将本发明专利的构思和技术方案直接应用于其它场合的,均在本发明的保护范围内。The patent of the present invention has been exemplarily described above in conjunction with the accompanying drawings. Obviously, the implementation of the patent of the present invention is not limited by the above-mentioned method, as long as the method concept and technical solutions of the patent of the present invention are adopted. Various improvements are made, or there is no improvement Directly applying the concepts and technical solutions of the patent of the present invention to other occasions is within the protection scope of the present invention.

Claims (10)

1. A method for testing the loop detection stability of a switch is characterized by comprising the following steps:
s1, building a cable misconnection test topology, connecting a first port and a second port of a tested switch with a first network card and a second network card of a PC (personal computer) respectively, and selecting the misconnection condition of the cable to be tested;
s2, issuing configuration to a tested switch, forbidding a loop detection function of a second port of the tested switch, and enabling the loop detection function of a first port of the tested switch;
s3, sequentially judging whether all the cable misconnection conditions are subjected to hook selection, and carrying out loop detection stability test on the hooked cable misconnection conditions;
and S4, when the hooked cable misconnection condition is subjected to a loop detection stability test, setting the loop detection state of the first port of the tested switch to be a blocking state, then sending a two-layer data message to the first network card by the second network card of the PC, and calculating the duration time of the first port of the tested switch maintaining the forwarding state after the loop detection automatic recovery time is overtime through the transceiving time of the two-layer data message.
2. The method for testing the loop detection stability of the switch according to claim 1, wherein in step S1, after the cable misconnection condition to be tested is selected, a test time for each cable misconnection condition is set.
3. The method for testing the loop detection stability of the switch according to claim 1, wherein in step S1, the cable misconnection conditions include a first cable misconnection condition causing a self-loop of the switch, a second cable misconnection condition causing a self-loop of a device connected under the switch, and a third cable misconnection condition causing a loop between the switches.
4. The method for testing the loop detection stability of the switch according to claim 3, wherein in step S4, the specific sub-step of performing the loop detection stability test on the first cable miswire condition includes:
step A1, a loop detection function of a first port of a tested switch is in an enabling state, a first loop detection message is sent out, after a first network card of the PC receives the first loop detection message, the first loop detection message is directly sent to a second port of the tested switch from a second network card of the PC, and after the tested switch receives the first loop detection message, the loop detection state of the first port of the tested switch is set to be in a blocking state;
a2, constructing a first two-layer data message, and sending the first two-layer data message to a first network card of the PC from a second network card of the PC;
and A3, monitoring the condition that the first network card of the PC receives the first two-layer data message in real time, and calculating the duration time of the first port of the tested switch maintaining the forwarding state after the loop detection automatic recovery time is overtime according to the receiving and sending time of the first two-layer data message.
5. The method for testing the loop detection stability of the switch according to claim 4, wherein the first loop detection message includes a destination MAC address, a source MAC address, a protocol type of the message, an MAC address of a switch sending the message, a port number of the switch sending the message, and a previous hop field.
6. The method according to claim 4, wherein in step A3, when the automatic recovery time of the loop detection is over, the first port of the switch under test is changed from a blocking state to a forwarding state, and the first network card of the PC receives the first layer data packet sent by the second network card of the PC.
7. The method according to claim 4, wherein in step A3, after the first port of the switch under test enters the forwarding state, the time and the number of packets of the first layer data packet received by the first network card of the PC each time are recorded, and the time for maintaining the forwarding state when the first port of the switch under test changes from the blocking state to the forwarding state each time is calculated.
8. The method for testing the loop detection stability of the switch according to claim 3, wherein in step S4, the specific sub-step of performing the loop detection stability test on the second cable miswire condition includes:
step B1, the loop detection function of the first port of the detected switch is in an enabling state, a second loop detection message is sent out, after the first network card of the PC receives the second loop detection message, the last hop field in the second loop detection message is modified into the MAC address of the PC, the modified second loop detection message is sent to the first port of the detected switch from the first network card of the PC, and after the detected switch receives the modified second loop detection message, the loop detection state of the first port of the detected switch is set to be in a blocking state;
b2, constructing a second layer data message, and sending the second layer data message to the first network card of the PC from the second network card of the PC;
and step B3, monitoring the condition that the first network card of the PC receives the second layer data message in real time, and calculating the duration time of the first port of the tested switch maintaining the forwarding state after the loop detection automatic recovery time is overtime according to the receiving and sending time of the second layer data message.
9. The method for testing the loop detection stability of the switch according to claim 3, wherein in step S4, the specific sub-step of performing the loop detection stability test on the third cable misconnection condition includes:
step C1, a first port of the tested switch sends a third loop detection message, a first network card of the PC receives the third loop detection message, a first hop field in the third loop detection message is modified into an MAC address of the PC, the modified third loop detection message is sent to a second port of the tested switch from a second network card of the PC, and the loop detection state of the first port of the tested switch is set to be a blocking state after the modified third loop detection message is received by the tested switch;
c2, constructing a third two-layer data message, and sending the third two-layer data message to the first network card of the PC from the second network card of the PC;
and step C3, monitoring the condition that the first network card of the PC receives the third two-layer data message in real time, and calculating the duration time of the first port of the tested switch maintaining the forwarding state after the loop detection automatic recovery time is overtime according to the receiving and sending time of the third two-layer data message.
10. A computer-readable medium storing computer-executable instructions for performing the method for testing the stability of loop detection of a switch according to any one of claims 1 to 9.
CN202211407526.2A 2022-11-10 2022-11-10 A test method and readable medium for switch loop detection stability Active CN115766510B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211407526.2A CN115766510B (en) 2022-11-10 2022-11-10 A test method and readable medium for switch loop detection stability

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211407526.2A CN115766510B (en) 2022-11-10 2022-11-10 A test method and readable medium for switch loop detection stability

Publications (2)

Publication Number Publication Date
CN115766510A true CN115766510A (en) 2023-03-07
CN115766510B CN115766510B (en) 2024-11-22

Family

ID=85369164

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211407526.2A Active CN115766510B (en) 2022-11-10 2022-11-10 A test method and readable medium for switch loop detection stability

Country Status (1)

Country Link
CN (1) CN115766510B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116866250A (en) * 2023-09-05 2023-10-10 空间液态金属科技发展(江苏)有限公司 Local area network data storm suppression method based on spacecraft application

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101848121A (en) * 2010-06-09 2010-09-29 神州数码网络(北京)有限公司 Automatic port loop detecting and protecting method based on a plurality of VLANs
US20110026394A1 (en) * 2007-04-27 2011-02-03 SUPCON GROUP CO., LTD. Zhejiang University Distributed ethernet system and method for detecting fault based thereon
CN115118645A (en) * 2022-06-24 2022-09-27 北京志凌海纳科技有限公司 Virtual two-layer network loop detection method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110026394A1 (en) * 2007-04-27 2011-02-03 SUPCON GROUP CO., LTD. Zhejiang University Distributed ethernet system and method for detecting fault based thereon
CN101848121A (en) * 2010-06-09 2010-09-29 神州数码网络(北京)有限公司 Automatic port loop detecting and protecting method based on a plurality of VLANs
CN115118645A (en) * 2022-06-24 2022-09-27 北京志凌海纳科技有限公司 Virtual two-layer network loop detection method

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116866250A (en) * 2023-09-05 2023-10-10 空间液态金属科技发展(江苏)有限公司 Local area network data storm suppression method based on spacecraft application
CN116866250B (en) * 2023-09-05 2023-11-14 空间液态金属科技发展(江苏)有限公司 Suppression method of LAN network data storm based on spacecraft application

Also Published As

Publication number Publication date
CN115766510B (en) 2024-11-22

Similar Documents

Publication Publication Date Title
WO2016095718A1 (en) Method for detecting communication link, base station, network manager, system and storage medium
CN108965123A (en) A kind of link switch-over method and network communicating system
CN101094121B (en) Method, system and device for detecting Ethernet links among not direct connected devices
CN108683578B (en) In-place device ring network communication test method and test system
CN104065526B (en) A kind of method and apparatus of server failure alarm
CN106487813A (en) Industry control network safety detecting system and detection method
CN111314180B (en) Ethernet link test method, terminal and storage medium
CN103684835A (en) Link fault reporting method and processing method, and transmission node and primary node
CN103139012A (en) Ethernet port test method and network devices
CN103957138B (en) A kind of method for monitoring network, device and its system
CN109005080B (en) Distributed packet forwarding implementation method, implementation system and automatic test method
CN115766510A (en) Testing method and readable medium for loop detection stability of switch
WO2017193763A1 (en) Testing method, apparatus and system
US7719992B1 (en) System for proactive time domain reflectometry
US20080267080A1 (en) Fault Verification for an Unpaired Unidirectional Switched-Path
CN104539348B (en) PON system link loopback detection method and device
CN105281927A (en) Method and device for multilink protection switching
CN114070799B (en) Processing method and processing device of priority pause frame and target network equipment
CN107426755B (en) Base station problem troubleshooting method and device, computer readable storage medium and computer equipment
CN109412851A (en) Link layer path detection method, apparatus and system
WO2016161716A1 (en) Multicast data stream monitoring method and device, and multicast forwarding device
CN102291266A (en) Loopback (LB) detection method and device
CN109379133A (en) The processing method and system of PON network packet loss
WO2012119416A1 (en) Method for testing electronic device, and electronic device
JP6725117B2 (en) Communication device, communication system, communication method, and program

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant