A two-layer networking loop isolation method, device and readable medium
By constructing custom Layer 2 Ethernet packet headers and custom packet fields, the switch itself calculates and detects loops and blocks misconnected ports, solving the network paralysis problem caused by loops in industrial Ethernet Layer 2 networking, maintaining efficient forwarding and preventing packet duplication from rampant.
Patent Information
- Application Number
- CN202211325271.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-27
- Publication Date
- 2025-12-23
- Estimated Expiration
- 2042-10-27
AI Technical Summary
In existing industrial Ethernet Layer 2 networks, misconnected network cables or optical fibers can create loops that cause network paralysis. Existing protocols also suffer from issues such as device compatibility, low forwarding efficiency, and rampant packet copying and forwarding.
By constructing custom Layer 2 Ethernet packet headers and custom packet fields, the switch can use its own calculations to detect loops, block misconnected ports, and set source MAC addresses and hop count limits in the packets to prevent packets from being copied and forwarded multiple times.
It enables precise loop detection on a single switch, blocks misconnected ports, prevents network paralysis, maintains forwarding efficiency, prevents packet overload, and protects normal data transmission.
Smart Images

Figure CN116455845B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of communication technology, in particular to a two-layer networking loop isolation method, device and readable medium. BACKGROUND
[0002] In the real industrial Ethernet two-layer networking, there are occasionally misconnection of network cable or loop formed by fiber, such as misconnection of two ports of a switch to form a loop or misconnection of a network externally connected to a port of a switch to form a loop, if the switch cannot isolate itself from the loop, it will cause storm paralysis of the entire network. In order to solve the above problems, currently most of the protocols are used, such as token ring, spanning tree (including spanning tree, rapid spanning tree, multiple spanning tree), ERPS or private detection protocol, etc., to realize the isolation of the switch and the loop, so as to avoid the storm paralysis of the entire network.
[0003] However, the above-mentioned protocols have the following problems: 1. Most of the protocols require each device processor to participate in the calculation; 2. Even if the devices of different manufacturers in the networking all enable the same protocol standard, there are compatibility problems, which may cause the isolation or destruction with a certain probability, resulting in the paralysis of the entire network; 3. The token ring protocol will cause low network forwarding efficiency; 4. The protocol message is copied and forwarded multiple times. SUMMARY
[0004] In order to overcome the problems of the existing protocols, such as the need for each device processor to participate in the calculation, the probability of causing the isolation or destruction, the low network forwarding efficiency and the multiple copying and forwarding of the protocol message, the present application provides a two-layer networking loop isolation method, device and readable medium.
[0005] The technical scheme of the present application is as follows:
[0006] In a first aspect, the present application provides a two-layer networking loop isolation method, comprising the following steps:
[0007] Step S1, constructing a two-layer Ethernet message header and a custom message field of the message, decoding the custom message field after coding, and sending the message out;
[0008] Step S2, receiving the message, decoding and restoring the custom field after coding, and detecting whether the MAC address of the source port information in the custom field and the CPU MAC address+1 of the local machine are consistent; if consistent, blocking the port according to the slot number and port number in the source port information; if not consistent, coding the custom message field, and sending the message out from other ports.
[0009] Further, before step S1, it further comprises:
[0010] Step S0, initialization, set the Ethernet type of broadcast message.
[0011] Further, after step S2, further comprising:
[0012] Step S3, by manual or timing, restore the blocked port to forwarding state.
[0013] Further, after step S3, further comprising:
[0014] Step S4, when the blocked port is restored to forwarding state, if the port opens loop isolation function, send a message from the port.
[0015] Further, step S1 comprises the following sub-steps:
[0016] Step S101, start the timer, set the period of sending message;
[0017] Step S102, construct the two-layer Ethernet message header;
[0018] Step S103, judge whether the port sending message opens the loop avoidance function, if yes, proceed to step S104; if not, return to step S101;
[0019] Step S104, construct the custom message content of the port;
[0020] Step S105, code the custom message field;
[0021] Step S106, send the message from the specified port.
[0022] Further, step S1 further comprises the following sub-steps:
[0023] Step S107, start the timer, enter the next message sending period.
[0024] Further, step S2 comprises the following sub-steps:
[0025] Step S201, create a socket, and receive messages through the socket, if the message is received, proceed to step S202; if no message is received, continue to receive;
[0026] Step S202, decode the custom field after coding;
[0027] Step S203, check the custom field, if not legal, discard the message; if legal, proceed to step S204;
[0028] Step S204, detecting whether the MAC address of the source port information in the custom field and the CPU MAC address+1 of the local machine are consistent, if consistent, blocking the port according to the slot number and the port number in the source port information; if not, entering step S205;
[0029] Step S205, judging whether the total hop count in the custom field reaches the maximum value, if the total hop count reaches the maximum value, discarding the packet; if the total hop count does not reach the maximum value, entering step S206;
[0030] Step S206, judging whether the MAC address of the switch information in the custom field is the CPU MAC address of the local machine, if yes, entering step S207; if not, modifying the total hop count as the original hop count+1, modifying the MAC address of the switch information in the custom field as the CPU MAC address of the local machine, setting the hop count of the switch information in the custom field as 0, and entering step S208;
[0031] Step S207, judging whether the hop count of the switch information in the custom field reaches the maximum value, if the hop count reaches the maximum value, discarding the packet; if the hop count does not reach the maximum value, modifying the hop count as the original hop count+1, modifying the MAC address of the switch information in the custom field as the CPU MAC address of the local machine, and entering step S208;
[0032] Step S208, transcoding the custom packet field;
[0033] Step S209, transmitting the packet from other ports.
[0034] Further, the two-layer Ethernet packet header includes a destination MAC address and a source MAC address, the destination MAC address is set as a broadcast address 0xFFFFFFFFFFFF, and the source MAC address is set as the CPU MAC address+1 of the switch which initially sends the packet.
[0035] Further, the two-layer Ethernet packet header further includes a tag and an eth type, the tag is set as a standard 802.1Q, and the eth type is set as 0x268F.
[0036] Further, the custom packet content includes source port information, total hop count, and switch information.
[0037] The source port information includes a MAC address, a port number, and a slot number, the MAC address of the source port information is set as the CPU MAC address+1 of the switch which initially sends the packet, the port number of the source port information is set as the port number of the switch which initially sends the packet, and the slot number of the source port information is set as the slot number of the switch which initially sends the packet.
[0038] The total hop count is the maximum number of times a message can be forwarded.
[0039] The switch information includes a MAC address and a hop count. The MAC address of the switch information is set to the CPU MAC address of the switch that recently forwarded the packet and modified the custom field. The hop count is the maximum number of times the packet is forwarded within the same switch.
[0040] Furthermore, the custom message content also includes the protocol version number, reservation, and checksum. The reservation is used to reserve some bytes, and the checksum is used to verify the message.
[0041] In a second aspect, the present invention provides a two-layer network loop isolation device, comprising:
[0042] The initialization module is used to set the Ethernet type that meets the requirements of broadcast messages during initialization;
[0043] The sending module is used to construct the Layer 2 Ethernet header and custom message fields of the message, and after transcoding the custom message fields, send the message out.
[0044] The receiving module receives packets, decodes and restores the transcoded custom fields, and checks whether the MAC address of the source port information in the custom field matches the CPU MAC address + 1 of the local machine. If they match, the port is blocked according to the slot number and port number in the source port information. If they do not match, the custom packet field is transcoded and the packet is forwarded from another port.
[0045] The recovery module is used to restore a blocked port to a forwarding state, either manually or periodically.
[0046] The port forwarding event triggering module is used to trigger the sending module to send a message from the port when the port in the blocked state is restored to the forwarding state, if the loop isolation function of the port is enabled.
[0047] Thirdly, the present invention provides a computer-readable medium storing computer-executable instructions for performing the above-described Layer 2 network loop isolation method.
[0048] According to the above-described solution, the beneficial effects of this invention are as follows:
[0049] The application provides a two-layer network loop isolation method, which can accurately detect the situation that a loop is formed by misconnection of two ports of a switch or misconnection of a network connected to a port of the switch, and can block the misconnected port of the switch or a certain external port (the switch connected to the port has a loop), so as to realize isolation of the port and the loop, thereby maximizing protection of normal data forwarding of the local port and avoiding paralysis of the entire network storm; meanwhile, the network forwarding efficiency is not affected, and the message is automatically stopped from being forwarded after being forwarded multiple times to a certain number of times, so as to avoid flooding of the message. BRIEF DESCRIPTION OF DRAWINGS
[0050] Figure 1 FIG. 1 is a flowchart of a two-layer network loop isolation method according to the application.
[0051] Figure 2 FIG. 2 is a specific flowchart of step S2 in the two-layer network loop isolation method according to the application. Figure 1
[0052] Figure 3 FIG. 3 is a specific flowchart of step S3 in the two-layer network loop isolation method according to the application. Figure 1
[0053] Figure 4 FIG. 4 is a structural diagram of a two-layer network loop isolation device according to the application. DETAILED DESCRIPTION
[0054] In order to make the technical problems, technical solutions and beneficial effects of the application clearer, the application is further described in detail below with reference to the drawings and examples. It should be understood that the specific examples described herein are only used to explain the application and do not limit the application.
[0055] It should be noted that the terms "include" and "have" and any variations thereof in the specification and claims of the application are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but can optionally include steps or units not listed or can optionally include other steps or units inherent to the process, method, product or device.
[0056] Please refer to Figure 1 The embodiment provides a two-layer network loop isolation method, which comprises the following steps:
[0057] Step S1, during initialization, an Ethernet type meeting a broadcast message is set.
[0058] Specifically, during initialization, the Ethernet type is set to 0x268F.
[0059] In step S2, a two-layer Ethernet message header and a custom message field of the message are constructed, the custom message field is transcoded, and the message is sent out.
[0060] Please refer to Figure 2 Further, step S2 includes the following sub-steps (steps S201-S207):
[0061] In step S201, a timer is started, and a period for sending the message is set.
[0062] The default sending period is 5 seconds, and the period can be set at will, which is not limited by the present application.
[0063] In step S202, a two-layer Ethernet message header is constructed.
[0064] The format of the two-layer Ethernet message header is shown in the following table:
[0065] Destination MAC Address Source MAC Address tag eth type 6 bytes 6 bytes 0 or 4 bytes 2 bytes 0xFFFFFFFFFFFF CPU MAC+1 Standard 802.1Q 0x268F
[0066] The two-layer Ethernet message header adopts a frame header of a standard two-layer Ethernet data frame, and includes a destination MAC address, a source MAC address, a tag, and an eth type. Among them,
[0067] The destination MAC address is set to a broadcast address 0xFFFFFFFFFFFF, so that when the message passes through a switch of another manufacturer or a dumb switch, the message can be broadcasted and forwarded as a broadcast message.
[0068] The source MAC address is set to the CPU MAC address of the switch that originally sends the message + 1, for example, if the CPU MAC address of the switch is 0x000000000001, the 6 bytes are set to 0x000000000002. If the source MAC address directly adopts the CPU MAC address of the switch that originally sends the message, the CPU MAC address learning of the chip will cause the CPU MAC address to drift on a misconnected port, which affects the normal sending and receiving of the management data of the switch. After the source MAC address is set to the CPU MAC address of the switch that originally sends the message + 1, the above address drift problem can be solved.
[0069] The tag is set to a standard 802.1Q, 0 or 4 bytes;
[0070] The eth type is set to 0x268F, which does not conflict with the IEEE802.3 division, so that other manufacturers' switches can forward the message as a normal Ethernet broadcast message.
[0071] Step S203, determine whether the port sending the message is open to avoid ring function, if open, then proceed to step S204; if not open, then return to step S201.
[0072] Step S204, construct the custom message content of the port.
[0073] The format of the custom message content is shown in the following table:
[0074]
[0075] The custom message content includes the version number of the protocol, source port information, total hop count, switch information, reserved, and checksum. Among them,
[0076] The source port information includes MAC address, port number, and slot number. The MAC address is set to the switch CPU MAC address + 1 of the initial message sending. The port number is set to the port number of the switch sending the message, for example, port 17, which is 0x11. The slot number is set to the slot number of the switch sending the message, which can support multi-slot switches, and this value is the slot ID. If there is no multi-slot, this value is 0x0. In addition, the role of the source port information is to determine the port information of the switch that initially sends the message, so it is not modified during message forwarding, so that the port can be accurately blocked after the loop is formed. For example, after the home switch receives the message, it decodes, analyzes, and if the analysis matches the CPU MAC address + 1 of the local machine, it calculates the existence of a loop outside the port according to the port number + slot number, which may be a self-loop or an external loop, and then blocks the port. If the analysis is not a message sent by the local machine, it is broadcasted and forwarded.
[0077] The total hop count is the maximum forwarding number of the message, which is used to prevent the message from being copied and forwarded indefinitely, reduce the waste of effective bandwidth, and reduce the occupation of CPU resources. The total hop count is set to 64 by default, and this value can be set arbitrarily according to actual conditions. The value of the total hop count will be incremented by 1 after the message is forwarded through the home switch, and it will not be forwarded when it reaches the maximum value (such as 64).
[0078] Switch information includes MAC address and hop count. The MAC address is set as the CPU MAC address of the switch that forwards the packet and modifies the custom field. The hop count is used to prevent the packet from being forwarded repeatedly in the same switch, and is applicable to the case where the switch that forwards the packet has a self-loop and the self-loop port does not have the loop avoidance function enabled. The hop count is set as 2 by default, and the value can be set at will according to the actual situation. When the received packet is sent by the local switch (i.e., the MAC address of the switch information in the packet is consistent with the CPU MAC address of the switch), if the hop count reaches the maximum value (such as 2), the packet is not forwarded any more to avoid repeated forwarding of the packet in the local switch, otherwise the hop count is increased by 1 and the packet is broadcasted. When the received packet is not sent by the local switch (i.e., the MAC address of the switch information in the packet is inconsistent with the CPU MAC address of the switch), the MAC address in the switch information is modified to the CPU MAC address of the forwarding switch and the hop count is set to 0 when the packet is forwarded.
[0079] Reserved is used to reserve some bytes, which is currently set to 0x0.
[0080] Checksum is used to check the packet, which is a common packet checking method and can reduce the reception of error packets.
[0081] Step S205, transcoding the custom packet field.
[0082] Specifically, the custom packet field in the packet is transcoded by a private algorithm to avoid being identified, and only the switch of the home can receive the transcoded custom packet field and decode and restore the custom packet field by the private algorithm.
[0083] Step S206, sending the packet from the specified port.
[0084] Specifically, the CPU of the switch specifies the port from which the packet is sent, for example, a packet of 1 slot and 2 ports is constructed, and the packet is sent from 1 slot and 2 ports.
[0085] Step S207, starting a timer and entering the next packet sending period.
[0086] Step S3, receiving the packet, decoding and restoring the transcoded custom field, and detecting whether the MAC address of the source port information in the custom field is consistent with the CPU MAC address+1 of the local machine; if consistent, blocking the port according to the slot number and port number in the source port information; if not consistent, transcoding the custom packet field and sending the packet from other ports.
[0087] Please refer to Figure 3 , further, step S3 includes the following sub-steps (step S301~step S307):
[0088] Step S301, a socket is created, and a message is received through the socket. If a message is received, step S302 is performed. If no message is received, the receiving continues.
[0089] Step S302, the custom field after transcoding is decoded and restored.
[0090] Specifically, the custom message field information in the message is obtained by decoding and restoring the custom message field after transcoding during sending through a private algorithm.
[0091] Step S303, the custom field is checked for legality. If the custom field is not legal, the message is discarded. If the custom field is legal, step S304 is entered.
[0092] Step S304, it is detected whether the MAC address of the source port information in the custom field is consistent with the CPU MAC address + 1 of the local machine. If the MAC address of the source port information is consistent with the CPU MAC address + 1 of the local machine, the port is blocked according to the slot number and the port number in the source port information, and an alarm is triggered to notify the operation and maintenance personnel. If the MAC address of the source port information is not consistent with the CPU MAC address + 1 of the local machine, step S305 is entered.
[0093] Step S305, it is judged whether the total hop count in the custom field reaches the maximum value (default 64, which can be set). If the total hop count reaches the maximum value, the message is discarded and is not forwarded, so as to prevent the message from being infinitely copied and forwarded, reduce the waste of effective bandwidth, and reduce the occupation of CPU resources. If the total hop count does not reach the maximum value, step S306 is entered.
[0094] Step S306, it is judged whether the MAC address of the switch information in the custom field is the CPU MAC address of the local machine. If the MAC address of the switch information in the custom field is the CPU MAC address of the local machine, step S307 is entered. If the MAC address of the switch information in the custom field is not the CPU MAC address of the local machine, the total hop count is modified to be the original hop count plus 1, the MAC address of the switch information in the custom field is modified to be the CPU MAC address of the local machine, the hop count of the switch information in the custom field is set to 0, and step S308 is entered.
[0095] Step S307, it is judged whether the hop count of the switch information in the custom field reaches the maximum value (default 2, which can be set). If the hop count reaches the maximum value, the message is discarded and is not forwarded any more, so as to avoid the message being continuously copied and forwarded in the local machine for multiple times, which is suitable for the case that the switch forwarding the message exists a self-loop, and the self-loop port does not have an anti-loop function enabled. If the hop count does not reach the maximum value, the hop count is modified to be the original hop count plus 1, the MAC address of the switch information in the custom field is modified to be the CPU MAC address of the local machine, and step S308 is entered.
[0096] Step S308, the custom message field is transcoded.
[0097] Specifically, the private algorithm is used to convert the custom message field in the message, so that the plaintext is not identified. Only the home switch can receive the converted custom message field and decode and restore it through the private algorithm.
[0098] Step S309, the message is sent out from other ports. For example, the message received from port 10 is sent out from all ports except port 10.
[0099] Step S4, the blocked port is restored to the forwarding state by manual or timing.
[0100] Specifically, if the maintenance personnel want to restore the blocked port to the forwarding state, the following two ways can be used: manual and timing:
[0101] Manual recovery: the operator logs in to the switch and issues a manual recovery command.
[0102] Timing recovery: the system supports timing (default 30 seconds, configurable) to change the port blocking to forwarding.
[0103] After the blocked port is restored to the forwarding state by the above two ways, the restored port triggers the sending module to send a message from the port. If there is still a loop, the port will be blocked again.
[0104] Step S5, when the blocked port is restored to the forwarding state, if the port has enabled the loop isolation function, the port will send a message to timely detect whether there is still a loop and isolate the loop as soon as possible; if there is still a loop, the port will be blocked again.
[0105] The two-layer network loop isolation method provided in this embodiment can accurately detect the case that the two ports of the switch are misconnected to form a loop or the network connected to a port of the switch is misconnected to form a loop, and can block the misconnected port of the switch or block a port connected to a switch with a loop, so as to isolate the port and the loop, thereby maximizing the protection of normal data forwarding of the local port and avoiding the paralysis of the entire network storm; at the same time, the network forwarding efficiency is not affected, and the message is automatically stopped after being forwarded to a certain number of times, so as to avoid excessive forwarding. In the constructed message, the custom field is set with the CPU MAC address and the hop count of the switch that has recently modified the custom field content, and through the two information, the multiple forwarding of the message in a switch can be terminated, so as to avoid a large number of protocol messages in the network.
[0106] Please refer to Figure 4In one embodiment, the application provides a two-layer network loop isolation device, comprising an initialization module 10, a sending module 20, a receiving module 30, a recovery module 40 and a port forwarding event triggering module 50.
[0107] The initialization module 10 is configured to set the Ethernet type of the broadcast message during initialization.
[0108] The sending module 20 is configured to construct a two-layer Ethernet message header and a custom message field of the message, and send the message after transcoding the custom message field.
[0109] The receiving module 30 is configured to receive the message, decode and restore the custom field after transcoding, and detect whether the MAC address of the source port information in the custom field and the CPU MAC address+1 of the local machine are consistent; if consistent, block the port according to the slot number and port number in the source port information; if inconsistent, transcode the custom message field, and send the message from other ports.
[0110] The recovery module 40 is configured to restore the blocked port to a forwarding state by manual or timing.
[0111] The port forwarding event triggering module 50 is configured to, when the blocked port is restored to the forwarding state, if the port has enabled the loop isolation function, trigger the sending module 20 to send a message from the port once, so as to discover whether there is still a loop in time and isolate the loop as soon as possible; if there is still a loop in the port, the port will be blocked again.
[0112] The two-layer network loop isolation device provided by the embodiment of the application can execute the method embodiment, and has similar implementation principles and technical effects, which will not be described here.
[0113] Those skilled in the art can understand that each aspect of the application can be implemented as a system, a method or a program product. Therefore, each aspect of the application can be specifically implemented as a complete hardware embodiment, a complete software embodiment (including firmware, microcode, etc.), or an embodiment combining hardware and software, which can be collectively referred to as "circuitry", "module" or "system".
[0114] Any of the modules, sub-modules, units, sub-units according to the embodiments, or at least part of functionalities of any of them, can be implemented in one module. Any of the modules, sub-modules, units, sub-units according to the embodiments can be split up into multiple modules. Any of the modules, sub-modules, units, sub-units according to the embodiments can be implemented at least in part as a hardware circuit, for example, a Field-Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a System on Chip, a System on Board, a System in Package, an Application-Specific Integrated Circuit (ASIC), or any other reasonable way of integrating or packaging hardware or firmware, or in software, hardware and firmware in any one of them or in a proper combination of any of them. Alternatively, one or more of the modules, sub-modules, units, sub-units according to the embodiments can be implemented at least in part as computer program modules, which, when executed, can perform the corresponding functions.
[0115] In one embodiment, the present application provides a computer readable medium having stored computer executable instructions for performing the steps of the method for loop isolation in two-layer networking according to various exemplary embodiments of the present application described in the present specification. Figure 1
[0116] In one embodiment, the present application provides a computer readable medium having stored computer executable instructions for performing the steps of the method for loop isolation in two-layer networking according to various exemplary embodiments of the present application described in the present specification.
[0117] The computer readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the above. The readable signal medium can include a computer readable program code in a baseband or propagated as a carrier wave in a packet, or any suitable combination of the above. The readable signal medium can also be any readable medium that can be used to carry program code for use by or in connection with an instruction execution system, apparatus, or device. The program code carried by the readable medium can be transmitted by any suitable medium, including, but not limited to, wireless, wired, optical, RF, or any suitable combination of the above.
[0118] Furthermore, although the operations of the method of the present application are described in a particular, sequential order, this order is not meant to be a limitation and is not intended to imply that there is an absolute requirement that the operations be performed in the order described. On the contrary, many of the operations can be performed in any order, added to, or omitted from the operations described. Also, in some implementations, aspects of two or more of the operations can be combined into a single operation, and / or a single operation can be separated into two or more operations.
[0119] It is to be understood that all such modifications and variations that can be made by those of ordinary skill in the art are intended to be encompassed by the present application.
[0120] The above description of the present application has been presented for the purpose of illustration and description. It is not intended to be exhaustive or to limit the application to the precise form disclosed. Many modifications and variations are possible in light of this disclosure. It is intended that the scope of the application be limited not by this detailed description, but rather by the claims appended hereto.
Claims
1. A method for loop isolation in a two-layer networking, the method comprising: The method comprises the following steps: Step S1, constructing a two-layer Ethernet message header and a custom message field of the message, and sending the message after transcoding the custom message field; Step S2, receiving the message, decoding and restoring the transcoded custom field, and detecting whether the MAC address of the source port information in the custom field and the CPU MAC address+1 of the local machine are consistent; if consistent, blocking the port according to the slot number and the port number in the source port information; If not consistent, transcoding the custom message field, and sending the message from other ports; The two-layer Ethernet message header comprises a destination MAC address and a source MAC address, the destination MAC address is set as a broadcast address 0xFFFFFFFFFFFF, and the source MAC address is set as the CPU MAC address+1 of the switch that initially sends the message; the custom message content comprises source port information, total hop count, and switch information; the source port information comprises a MAC address, a port number, and a slot number, the MAC address of the source port information is set as the CPU MAC address+1 of the switch that initially sends the message, the port number of the source port information is set as the port number of the switch that initially sends the message, and the slot number of the source port information is set as the slot number of the switch that initially sends the message; and the total hop count is the maximum forwarding number of the message. The switch information comprises a MAC address and a hop count, the MAC address of the switch information is set as the CPU MAC address of the switch that most recently forwards the message and modifies the custom field, and the hop count is the maximum forwarding number of the message in the same switch.
2. The method of claim 1, wherein, Before step S1, the method further comprises: Step S0, during initialization, setting an Ethernet type satisfying a broadcast message.
3. The method of claim 1 or 2, wherein, After step S2, the method further comprises: Step S3, restoring the port in the blocking state to a forwarding state by manual operation or timing.
4. The method of claim 3, wherein, After step S3, the method further comprises: Step S4, when the port in the blocking state is restored to the forwarding state, if the port has started a loop isolation function, sending a message from the port once.
5. The method of claim 1, wherein, Step S1 comprises the following substeps: Step S101, starting a timer, and setting a period of sending the message; Step S102, constructing a two-layer Ethernet message header; Step S103, judging whether the port that sends the message has started an anti-loop function, if yes, proceeding to step S104; if not, returning to step S101; Step S104, constructing custom message content of the port; Step S105, transcoding the custom message field; Step S106, sending the message from the specified port.
6. The method of claim 1, wherein, Step S2 comprises the following substeps: Step S201, creating a socket, and receiving the message through the socket, if the message is received, proceeding to step S202; if the message is not received, continuing to receive; Step S202, decoding and restoring the transcoded custom field; Step S203, checking the custom field, if illegal, discarding the message; if legal, proceeding to step S204; Step S204, judging whether the MAC address of the source port information and the CPU MAC address+1 of the local machine are consistent; if consistent, blocking the port according to the slot number and the port number in the source port information; if not consistent, transcoding the custom message field, and sending the message from other ports. Step S204, detecting whether the MAC address of the source port information in the custom field and the CPU MAC address+1 of the local machine are consistent, if consistent, blocking the port according to the slot number and the port number in the source port information; if not, entering step S205; Step S205, judging whether the total hop count in the custom field reaches the maximum value, if the total hop count reaches the maximum value, discarding the message; if the total hop count does not reach the maximum value, entering step S206; Step S206, judging whether the MAC address of the switch information in the custom field is the CPU MAC address of the local machine, if yes, entering step S207; if not, modifying the total hop count as the original hop count+1, modifying the MAC address of the switch information in the custom field as the CPU MAC address of the local machine, setting the hop count of the switch information in the custom field as 0, and entering step S208; Step S207, judging whether the hop count of the switch information in the custom field reaches the maximum value, if the hop count reaches the maximum value, discarding the message; if the hop count does not reach the maximum value, modifying the hop count as the original hop count+1, modifying the MAC address of the switch information in the custom field as the CPU MAC address of the local machine, and entering step S208; Step S208, transcoding the custom message field; Step S209, transmitting the message from other ports.
7. A two-layer networking loop isolation device, comprising: Comprise: An initialization module, configured to set the Ethernet type meeting the broadcast message during initialization; A sending module, configured to construct a two-layer Ethernet message header and a custom message field of the message, transcode the custom message field, and transmit the message after transcoding; A receiving module, configured to receive the message, decode and restore the transcoded custom field, and detect whether the MAC address of the source port information in the custom field and the CPU MAC address+1 of the local machine are consistent; if consistent, block the port according to the slot number and the port number in the source port information; if not, transcode the custom message field, and transmit the message from other ports; A recovery module, configured to restore the blocked port to the forwarding state by manual or timing mode; A port forwarding event triggering module, configured to trigger the sending module to transmit a message from the port if the port opens the loop isolation function after the blocked port is restored to the forwarding state. The two-layer Ethernet message head comprises a destination MAC address and a source MAC address, the destination MAC address is set as a broadcast address 0xFFFFFFFFFFFF, and the source MAC address is set as a CPU MAC address+1 of a switch that initially sends the message; the custom message content comprises source port information, total hop counts, and switch information; the source port information comprises a MAC address, a port number, and a slot number, the MAC address of the source port information is set as a CPU MAC address+1 of a switch that initially sends the message, the port number of the source port information is set as a port number of a switch that initially sends the message, and the slot number of the source port information is set as a slot number of a switch that initially sends the message; and the total hop counts are maximum forwarding times of the message. The switch information comprises a MAC address and hop counts, the MAC address of the switch information is set as a CPU MAC address of a switch that most recently forwards the message and modifies the custom field, and the hop counts are maximum forwarding times of the message in the same switch.
8. A computer readable medium storing computer executable instructions, wherein the instructions comprise: The computer executable instructions are used to execute the two-layer networking loop isolation method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Method and packet data network (PDN) system for sending operation administration maintenance (OAM) message
CN101997711A
Loop detection message packaging method as well as loop detecting method and device
CN102420721A