CN112491642A - Loop detection method, loop detection device, switch and storage medium - Google Patents

Loop detection method, loop detection device, switch and storage medium Download PDF

Info

Publication number
CN112491642A
CN112491642A CN202011224693.4A CN202011224693A CN112491642A CN 112491642 A CN112491642 A CN 112491642A CN 202011224693 A CN202011224693 A CN 202011224693A CN 112491642 A CN112491642 A CN 112491642A
Authority
CN
China
Prior art keywords
port
switch
loop
condition
mode
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.)
Pending
Application number
CN202011224693.4A
Other languages
Chinese (zh)
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 Sundray Technologies Co ltd
Original Assignee
Shenzhen Sundray Technologies 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 Sundray Technologies Co ltd filed Critical Shenzhen Sundray Technologies Co ltd
Priority to CN202011224693.4A priority Critical patent/CN112491642A/en
Publication of CN112491642A publication Critical patent/CN112491642A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/18Loop-free operations
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/50Testing arrangements

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The embodiment of the invention is suitable for the technical field of communication, and provides a loop detection method, a device, a switch and a storage medium, wherein the loop detection method comprises the following steps: under the condition that the first switch meets the set conditions, controlling the first switch to enter a first mode; the set condition represents that the configuration of the first switch is modified; under the condition that the first switch is in the first mode, when a link corresponding to a first port of the first switch is communicated, controlling the first port to be in a blocking state; the first switch comprises at least one port, and the first port is any one of the at least one port; performing loop detection based on the first port to obtain a detection result; and the detection result represents whether a loop exists in the first port.

Description

Loop detection method, loop detection device, switch and storage medium
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a loop detection method, an apparatus, a switch, and a storage medium.
Background
Switches are easily looped when opening, especially when configuring cross device link aggregation groups (MLAGs) and stacks. When the message is forwarded in the loop, a broadcast storm is formed, which affects the service in the whole network. At present, a switch has two anti-loop modes, one mode is that the switch defaults all ports to open a single-port anti-loop mode, and the port defaults to be in a Forwarding (Forwarding) state in the single-port anti-loop mode, so that congestion and packet loss of opposite-end equipment can be caused due to impact of a large amount of service flow, and a loop detection message is lost, so that the loop cannot be detected. The other is that the switch is configured by default to start a Spanning Tree Protocol (STP) ring, but the STP requires that the function is started in the whole network, and when some devices do not start the STP, the STP detection message is discarded, so that a loop cannot be detected.
Disclosure of Invention
In order to solve the above problems, embodiments of the present invention provide a loop detection method, an apparatus, a switch, and a storage medium, so as to at least solve the problems that the related art cannot detect a loop in some scenarios and the loop detection accuracy is low.
The technical scheme of the invention is realized as follows:
in a first aspect, an embodiment of the present invention provides a loop detection method, where the method includes:
under the condition that the first switch meets the set conditions, controlling the first switch to enter a first mode; the set condition represents that the configuration of the first switch is modified;
under the condition that the first switch is in the first mode, when a link corresponding to a first port of the first switch is communicated, controlling the first port to be in a blocking state; the first switch comprises at least one port, and the first port is any one of the at least one port;
performing loop detection based on the first port to obtain a detection result; and the detection result represents whether a loop exists in the first port.
In the above scheme, the method further comprises:
under the condition that the detection result indicates that the first port does not have a loop, controlling the first port to enter a forwarding state from the blocking state; and maintaining the blocking state by the first port under the condition that the detection result indicates that a loop exists in the first port.
In the foregoing solution, the performing loop detection based on the first port to obtain a detection result includes:
sending a setting message based on the first port; the setting message is used for detecting whether a loop exists in the first port;
and determining that a loop exists in the first port under the condition that the first port receives the set message within a first set time length.
In the foregoing solution, the sending a setting packet based on the first port includes:
and sending the setting message based on the subinterfaces of the aggregation port under the condition that the first port is the aggregation port.
In the foregoing solution, the determining that the first switch satisfies the setting condition includes any one of:
determining that the first switch meets a set condition under the condition that the first switch is in an open-loop mode;
under the condition that a first user instruction is received, determining that the first switch meets a set condition; the first user instruction is used to control the first switch to enter the first mode.
In the above scheme, the method further comprises:
configuring a second switch based on the first port in the first mode; the second switch is cascaded with the first switch based on the first port.
In the above scheme, the method further comprises:
and when the at least one port is in the forwarding state and the configuration of the first switch is not modified within a second set time length, controlling the first switch to exit the first mode.
In the above scheme, the method further comprises:
under the condition that a second user instruction is received, controlling the first switch to exit the first mode; the second user instruction is used for controlling the first switch to exit the first mode.
In a second aspect, an embodiment of the present invention provides a loop detection apparatus, including:
the determining module is used for controlling the first switch to enter a first mode under the condition that the first switch meets the set conditions; the set condition represents that the configuration of the first switch is modified;
the control module is used for controlling the first port to be in a blocking state when a link corresponding to the first port of the first switch is communicated under the condition that the first switch is in the first mode; the first switch comprises at least one port, and the first port is any one of the at least one port;
the detection module is used for carrying out loop detection based on the first port to obtain a detection result; and the detection result represents whether a loop exists in the first port.
In a third aspect, an embodiment of the present invention provides a switch, including a processor and a memory, where the processor and the memory are connected to each other, where the memory is used to store a computer program, and the computer program includes program instructions, and the processor is configured to call the program instructions to execute the steps of the loop detection method provided in the first aspect of the embodiment of the present invention.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, including: the computer-readable storage medium stores a computer program. Which when executed by a processor performs the steps of the loop detection method as provided by the first aspect of an embodiment of the present invention.
The embodiment of the invention controls the first switch to enter the first mode under the condition that the first switch meets the set condition. And under the condition that the first switch is in the first mode, controlling the first port to be in a blocking state when the link corresponding to the first port of the first switch is communicated. Then, loop detection is carried out based on the first port to obtain a detection result; the detection result represents whether a loop exists in the first port. Wherein the setting condition represents that the configuration of the first switch is modified; the first switch includes at least one port, and the first port is any one of the at least one port. The embodiment of the invention enters the first mode when the switch modifies the configuration, and detects the loop in the first mode, so that the loop detection accuracy is high. The exchanger does not need to wait for the loop detection when the configuration of the exchanger is modified and the exchanger runs, so that the effect of detecting the loop in advance can be achieved, a user is timely informed to repair the loop when the loop is detected, and the exchanger is ensured not to have the loop when the configuration of the exchanger is modified and the exchanger runs.
Drawings
Fig. 1 is a schematic flow chart illustrating an implementation of a loop detection method according to an embodiment of the present invention;
fig. 2 is a schematic flow chart illustrating an implementation of another loop detection method according to an embodiment of the present invention;
fig. 3 is a topology connection diagram of a switch according to an embodiment of the present invention;
FIG. 4 is a schematic flow chart of loop detection according to an embodiment of the present invention;
FIG. 5 is a schematic flow chart of another loop detection provided by an embodiment of the present invention;
fig. 6 is a schematic diagram of a loop detection apparatus according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a switch provided by an embodiment of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Switch loops are created by a vicious circle of switches broadcasting information, and the loops are usually caused by subscriber wiring errors. For example, when an exchange is opened, when a cross device link aggregation Group (MLAG) and a stack are configured, network cables need to be frequently plugged and unplugged, and port configuration needs to be modified, so that a loop is easily formed.
When the message is forwarded in the loop, a broadcast storm is formed, which causes network congestion and affects the service in the whole network. Therefore, the loop of the switch needs to be detected in time. At present, in the switch in the related art, there are two loop detection methods, one is that the switch defaults to a single-port first mode in which all ports open, and the port defaults to a Forwarding state in the single-port first mode, and once the port enters the Forwarding state, the port can forward any data, and also performs address learning and receiving, processing and sending of Bridge Protocol Data Unit (BPDU) configuration messages. In the Forwarding state, since a port may forward any data, congestion and packet loss of an opposite end device may result in loss of a loop detection packet sent by the port due to a large amount of service traffic impact, so that a loop cannot be detected. The other loop detection method is that a switch is configured with a Spanning Tree Protocol (STP) by default to detect a loop, the STP Protocol can be applied to a loop network, path redundancy is realized through a certain algorithm, and the loop network is pruned into a loop-free tree network, so that proliferation and infinite circulation of a message in the loop network are avoided. However, the STP protocol requires that all devices in the whole network start the function, and some devices may discard the STP detection packet when not starting STP, resulting in failure to detect a loop.
In summary, both of the above methods have certain defects, and in some cases, the loop cannot be detected, and the loop detection accuracy is low.
In view of the above drawbacks of the related art, embodiments of the present invention provide a loop detection method, which can at least improve the detection accuracy of a loop and ensure that no loop is generated in the use process of a switch. In order to explain the technical means of the present invention, the following description will be given by way of specific examples.
Referring to fig. 1, fig. 1 is a schematic diagram of an implementation flow of a loop detection method according to an embodiment of the present invention, where an execution main body of the method is a switch, and the loop detection method includes:
s101, controlling the first switch to enter a first mode under the condition that the first switch meets set conditions; the set condition characterizes that the configuration of the first switch is modified.
Here, the switch is controlled to enter the first mode when the configuration of the switch needs to be modified.
In an embodiment, the determining that the first switch satisfies the set condition includes any one of:
determining that the first switch meets a set condition under the condition that the first switch is in an open-loop mode;
under the condition that a first user instruction is received, determining that the first switch meets a set condition; the first user instruction is used to control the first switch to enter the first mode.
The opening refers to a process that a user firstly connects and configures the line by using a switch which is configured by default when leaving a factory, and when the first switch is opened, the first switch automatically enters a first mode. Because the first switch is the default configuration when leaving the factory, as long as the first switch is in the default configuration, the first switch automatically enters the first mode. The first switch can restore the default configuration after the configuration is modified, and the first switch automatically enters the first mode after the default configuration is restored.
Alternatively, the user may manually control the first switch to enter the first mode. In the actual reference, the first switch is connected with the controller, the user can issue a first user instruction to the first switch through the controller, and the first user instruction is used for controlling the first switch to enter the first mode. And the first switch enters a first mode after receiving the first user instruction.
S102, under the condition that the first switch is in the first mode, when a link corresponding to a first port of the first switch is communicated, controlling the first port to be in a blocking state; the first switch comprises at least one port, and the first port is any one of the at least one port.
The first switch includes at least one port through which the first switch is used to connect with other devices, e.g., the first switch and the second switch are cascaded through the first port.
Under the condition that the first switch is in the first mode, when a link of the first port is communicated, the first port is controlled to be in a Blocking (Blocking) state. In the related art, a port in a Blocking state cannot participate in forwarding a data packet, but can receive a BPDU configuration message.
In practical application, a plurality of indicator lamps can be arranged on the first switch, and when a link corresponding to the first port is connected (link up), the indicator lamp corresponding to the first port is lighted; when the link corresponding to the first port is not connected, the indicator light corresponding to the first port is in an off state. For example, when the first switch and the second switch are cascaded through the first port, if the link between the first switch and the second switch is in a connected state and data can be transmitted, the indicator light corresponding to the first port is turned on. And when the indicator lamp corresponding to the first port is turned on, controlling the first port to be in a Blocking (Blocking) state.
S103, performing loop detection based on the first port to obtain a detection result; and the detection result represents whether a loop exists in the first port.
When the first port is in link connection, the first port is in a Blocking state, and therefore, it is necessary to detect whether a loop exists in the first port in the Blocking (Blocking) state.
The embodiment of the invention can detect whether the first port has a loop or not when the first port is in a blocking state, and can also detect whether the first port has a loop or not when the first port is in a forwarding state.
Referring to fig. 2, in an embodiment, the performing loop detection based on the first port to obtain a detection result includes:
s201, sending a setting message based on the first port; the setting message is used for detecting whether a loop exists in the first port.
And sending a setting message from the first port to a link corresponding to the first port, wherein the setting message is used for detecting whether a loop exists in the first port. Here, the setting message is a private two-layer communication protocol message, and may be, for example, an sdp (session discovery protocol) protocol, which can be used for communication between two switches, has a characteristic of being propagated across vlans and being capable of penetrating a port in a blocking state, and does not forward the protocol message.
Further, in the above embodiment, the sending a setting message based on the first port includes:
and sending the setting message based on the sub-port of the aggregation port under the condition that the first port is the aggregation port.
Here, if the first port is an aggregation port, the detection packet is sent in units of subinterfaces of the aggregation port. The aggregation port aggregates a group of physical ports to be used as a logical channel, so that the switch considers the logical channel to be a port, and the aggregation port is composed of a plurality of sub-ports. The setting message is sent through the sub-port of the aggregation port, so that the problem that a loop is easy to occur when the M-LAG and the LAG are connected can be solved.
S202, determining that a loop exists in the first port under the condition that the first port receives the set message within a first set time length.
After the first port sends the setting message, the first port receives the setting message again within the first setting duration, which indicates that the first port has a loop. For example, in practical applications, the first set time period may be set to 3 seconds, the switch continuously sends a plurality of set messages from the first port, and if the switch receives any one set message from the first port within 3 seconds, it indicates that a loop exists in the first port.
If the first port does not receive the set message within the first set time length, it indicates that the first port does not have a loop.
The embodiment of the invention controls the first switch to enter the first mode under the condition that the first switch meets the set condition. And under the condition that the first switch is in the first mode, controlling the first port to be in a blocking state when the link corresponding to the first port of the first switch is communicated. Then, loop detection is carried out based on the first port to obtain a detection result; the detection result represents whether a loop exists in the first port. Wherein the setting condition represents that the configuration of the first switch is modified; the first switch includes at least one port, and the first port is any one of the at least one port. The embodiment of the invention enters the first mode when the switch modifies the configuration, and detects the loop in the first mode, so that the loop detection accuracy is high. The exchanger does not need to wait for the loop detection when the configuration of the exchanger is modified and the exchanger runs, so that the effect of detecting the loop in advance can be achieved, a user is timely informed to repair the loop when the loop is detected, and the exchanger is ensured not to have the loop when the configuration of the exchanger is modified and the exchanger runs.
In one embodiment, the loop detection method further includes:
under the condition that the detection result indicates that the first port does not have a loop, controlling the first port to enter a forwarding state from the blocking state; and maintaining the blocking state by the first port under the condition that the detection result indicates that a loop exists in the first port.
And under the condition that the first port does not have a loop, controlling the first port to enter a forwarding state from a blocking state, wherein the first port can forward any data in the forwarding state. If the first port has a link, the first port continues to maintain the blocked state. Therefore, whether the first switch has a loop can be judged according to the state of the first port, and when the port of the first switch is in the blocking state, the first switch is considered to have the loop. When all ports of the switch are in the forwarding state, the first switch is considered to have no loop.
In the first mode, the first port is controlled to enter the blocking state when the link corresponding to the first port is communicated, then loop detection is carried out on the first port, and if no loop exists, the first port is controlled to enter the forwarding state from the blocking state. The embodiment of the invention can only carry out loop detection on a single port of the switch, and when the first port is in a forwarding state, the first port does not have a loop, so that the message can be forwarded on the first port without worrying about the occurrence of broadcast storm.
Further, in an embodiment, the loop detection method further includes:
and when the at least one port is in the forwarding state and the configuration of the first switch is not modified within a second set time length, controlling the first switch to exit the first mode.
When all the ports of the first switch are in the forwarding state, it means that no loop exists in all the ports of the first switch. And if the configuration of the first switch is not modified within the second set time length, the configuration of the first switch by the user is finished. For example, the second set time period may be 48 hours. And when the two conditions are simultaneously met, the switch is controlled to exit the first mode.
In one embodiment, the loop detection method further includes:
under the condition that a second user instruction is received, controlling the first switch to exit the first mode; the second user instruction is used for controlling the first switch to exit the first mode.
In addition to the above-mentioned first switch automatically exiting the first mode, the user may also issue a second user instruction to the first switch through the controller, and control the first switch to exit the first mode.
The first switch needs to exit the first mode after completing opening, because the first port is in a blocking state for 3 seconds by default when the link is connected, but the opposite terminal device is not necessarily in the blocking state by default, under the condition, the opposite terminal device does not know that the first port is in the blocking state, and the first port can be mistakenly considered to be capable of normally forwarding the message, so that packet loss is caused. Therefore, after the opening is completed, the first switch needs to exit the first mode.
Further, in an embodiment, the loop detection method further includes:
configuring a second switch based on the first port in the first mode; the second switch is cascaded with the first switch based on the first port.
Referring to fig. 3, fig. 3 is a topology connection diagram of a switch according to an embodiment of the present invention. The second switch is cascaded with the first switch based on the first port, the first port of the first switch is in link connection with the second port of the second switch, and the controller is connected with the first switch.
The user can send configuration parameters to and from the controller to the first switch to configure the first switch. The controller can also issue configuration parameters to the first switch, and configure the second switch based on the first port of the first switch.
If the first switch and the second switch are both in an inactivated state and the first port and the second port are in a link connection state, even if the first port and the second port are both in a blocking state at the moment or one of the first port and the second port is in the blocking state, the controller can activate and configure the first switch and the second switch to issue, the controller can also send a loop detection message through the first port, and the loop detection message can cross the first port in the blocking state to detect a loop.
If the first switch opens the single network port ring prevention mode or the STP ring prevention mode, the second switch is in an inactivated state, and the first port and the second port are in a link connection state, at the moment, no matter what the single network port ring prevention or the STP ring prevention result is, even if the first port and the second port are both in a blocking state or one of the first port and the second port is in the blocking state, the controller can activate and configure the first switch and the second switch to issue, and can also send a loop detection message through the first port.
If the second switch opens the single-port ring-prevention mode or the STP ring prevention mode, the first switch is in an inactivated state, and the first port and the second port are in a link connection state. Even if the first port and the second port are both in a blocking state or one of the first port and the second port is in a blocking state, the controller can activate and configure the first switch and the second switch to issue, and can also send a loop detection message through the first port.
In the embodiment of the invention, loop detection and configuration issuing can also be carried out during MLAG or stacking.
Referring to fig. 4, fig. 4 is a schematic diagram of a loop detection process provided in an application embodiment of the present invention, where the loop detection process includes:
s401, the switch is in a default configuration state.
The first mode is automatically entered when the switch is in a default configuration.
S402, the switch is in a non-default configuration state.
The switch is in a non-default configuration state, and a user can manually control the switch to enter the first mode.
S403, enter the first mode.
In the first mode, when the port link is communicated, the port enters a blocking state, and the switch sends a detection message to detect whether the port has a loop.
S404, configuration and issuing.
And S405, activating.
In the first mode, the controller can issue configuration and activate the switch even if the port is in a blocked state. For example, by SDP protocol activation and configuration delivery.
S406, whether the first mode is manually exited.
If the switch needs to automatically exit the first mode, S408 is performed. And if the manual exit is performed, S407 is executed.
S407, the first mode is exited.
S408, whether all ports are in a forwarding state and the configuration is not modified after the set time is exceeded.
And when all ports are in a forwarding state and the configuration is not modified beyond the set time, exiting the first mode.
Referring to fig. 5, fig. 5 is a schematic diagram of another loop detection process provided in the application embodiment of the present invention, where the loop detection process is applied in step S403, and the loop detection process includes:
s501, when the port link is communicated, the control port enters a blocking state.
In the first mode, the control port enters a blocking state when the port link is connected.
S502, sending a loop detection message.
And sending a loop detection message from the port, and detecting whether the port has a loop. If the port is the aggregation port, the loop detection message is sent by taking the sub-port as a unit.
S503, whether the loop detection message is received within the set time is judged.
If the loop detection message is received within the set time, the port is indicated to have a loop.
If not, it indicates that the port does not have a loop.
If not, S504 is executed. If so, S505 is performed.
S504, the control port is in a forwarding state.
If no loop exists, the control port enters a forwarding state. When the port is in the Forwarding state, the loop detection message is not sent any more. The port has no difference with the forwarding of the ordinary port. The port in the Forwarding state can establish a traditional discovery activation channel and a TCP tunnel with the controller.
And S505, controlling the port to be in a blocking state.
If a loop exists, the port continues to maintain the blocked state.
While the port is in the blocking state, the first port is repeatedly checked for the presence of a loop. When the port is in a Blocking state, the service message cannot be forwarded, and the loop detection message is continuously sent until the loop is detected to be released.
And S506, normally activating and configuring and issuing.
If the port is in the forwarding state, the controller can be activated and configured to issue normally, or activated and configured to issue through the SDP protocol.
And S507, activating and configuring and issuing through an SDP protocol.
If the port is in the blocking state, the port can only be activated and configured to be issued through the SDP protocol.
In the application embodiment of the invention, the switch automatically enters the first mode when opening the exchange, the loop is detected in the first mode, the switch does not need to wait until the configuration and modification of the switch are finished and then carry out the loop detection, the effect of detecting the loop in advance can be achieved, a user is timely informed to repair the loop when the loop is detected, and the loop does not exist in the switch when the configuration and modification of the switch are finished. The port can also detect the loop in the blocking state, so that the loop cannot be identified due to port congestion and packet loss, and the loop detection accuracy is high. And single-port loop detection can be realized, the ring prevention is not required to be opened in the whole network, and the first mode can be simultaneously used with STP and single-port ring prevention.
In practical application, no matter whether a switch is newly added in a network or an existing switch is modified, the loop can be detected through the first mode, the effect of detection in advance is achieved, and the loop is not generated when the switch runs after configuration is completed.
Compared with the single-network-port anti-loop mode, the single-network-port anti-loop mode is post detection, and the switch already has a loop. And the single network port ring-prevention mode can not completely solve the problem of MLAG and stacked open loop scenes, and the situation that the loop is generated again after two ends release Blocking ports simultaneously is easy to occur. And the single network port anti-loop mode can continuously send loop detection messages, thereby additionally consuming network resources. The first mode provided by the invention is to detect whether a loop exists in advance during configuration, and ensure that no loop exists when the switch runs after the configuration is completed. And the loop detection message can detect a loop across the aggregation port, and is suitable for MLAG and stacked open loop scenes. The loop detection message can cross the port of the Blocking state to detect the loop, and the situation that the two ends recover and re-loop at the same time after Blocking does not occur. The invention only sends the detection message when the port link is communicated, has small consumption on network resources and is more suitable for solving the problem of loop caused by open wiring. And the first mode supports simultaneous use with STP and single-network-port anti-ring, so that the use of other functions is not influenced in the deployment process, and the system is completely transparent to customers.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
The technical means described in the embodiments of the present invention may be arbitrarily combined without conflict.
In addition, in the embodiments of the present invention, "first", "second", and the like are used for distinguishing similar objects, and are not necessarily used for describing a specific order or a sequential order.
Referring to fig. 6, fig. 6 is a schematic diagram of a loop detection apparatus according to an embodiment of the present invention, and as shown in fig. 6, the apparatus includes: the device comprises a determining module, a control module and a detecting module.
The determining module is used for controlling the first switch to enter a first mode under the condition that the first switch meets the set conditions; the set condition represents that the configuration of the first switch is modified;
the control module is used for controlling the first port to be in a blocking state when a link corresponding to the first port of the first switch is communicated under the condition that the first switch is in the first mode; the first switch comprises at least one port, and the first port is any one of the at least one port;
the detection module is used for carrying out loop detection based on the first port to obtain a detection result; and the detection result represents whether a loop exists in the first port.
The control module is further configured to:
under the condition that the detection result indicates that the first port does not have a loop, controlling the first port to enter a forwarding state from the blocking state; and maintaining the blocking state by the first port under the condition that the detection result indicates that a loop exists in the first port.
The detection module is specifically configured to:
sending a setting message based on the first port; the setting message is used for detecting whether a loop exists in the first port;
and determining that a loop exists in the first port under the condition that the first port receives the set message within a first set time length.
The detection module is specifically configured to: and sending the setting message based on the subinterfaces of the aggregation port under the condition that the first port is the aggregation port.
The determining module is specifically configured to:
determining that the first switch meets a set condition under the condition that the first switch is in an open-loop mode; or
Under the condition that a first user instruction is received, determining that the first switch meets a set condition; the first user instruction is used to control the first switch to enter the first mode.
The device further comprises:
a configuration module configured to configure a second switch based on the first port in the first mode; the second switch is cascaded with the first switch based on the first port.
The control module is further configured to:
and when the at least one port is in the forwarding state and the configuration of the first switch is not modified within a second set time length, controlling the first switch to exit the first mode.
The control module is further configured to:
under the condition that a second user instruction is received, controlling the first switch to exit the first mode; the second user instruction is used for controlling the first switch to exit the first mode.
In practical applications, the determining module, the control module and the detecting module may be implemented by a Processor in a switch, such as a Central Processing Unit (CPU), a Digital Signal Processor (DSP), a Micro Control Unit (MCU), or a Programmable gate array (FPGA).
It should be noted that: in the loop detection device provided in the above embodiment, when performing loop detection, only the division of the above modules is used for illustration, and in practical applications, the above processing may be distributed to different modules according to needs, that is, the internal structure of the device is divided into different modules to complete all or part of the above described processing. In addition, the loop detection apparatus and the loop detection method provided by the above embodiments belong to the same concept, and specific implementation processes thereof are described in the method embodiments and are not described herein again.
Based on the hardware implementation of the program module, and in order to implement the method of the embodiment of the present application, an embodiment of the present application further provides a switch. Fig. 7 is a schematic diagram of a hardware component structure of a switch according to an embodiment of the present application, and as shown in fig. 7, the switch includes:
the communication interface can carry out information interaction with other equipment such as network equipment and the like;
and the processor is connected with the communication interface to realize information interaction with other equipment, and is used for executing the method provided by one or more technical schemes of the exchange side when running a computer program. And the computer program is stored on the memory.
In practice, of course, the various components in the switch are coupled together by a bus system. It will be appreciated that a bus system is used to enable communications among the components. The bus system includes a power bus, a control bus, and a status signal bus in addition to a data bus. For clarity of illustration, however, the various buses are labeled as a bus system in fig. 7.
The memory in the embodiments of the present application is used to store various types of data to support the operation of the switch. Examples of such data include: any computer program for operating on a switch.
It will be appreciated that the memory can be either volatile memory or nonvolatile memory, and can include both volatile and nonvolatile memory. Among them, the nonvolatile Memory may be a Read Only Memory (ROM), a Programmable Read Only Memory (PROM), an Erasable Programmable Read-Only Memory (EPROM), an Electrically Erasable Programmable Read-Only Memory (EEPROM), a magnetic random access Memory (FRAM), a flash Memory (flash Memory), a magnetic surface Memory, an optical disk, or a Compact Disc Read-Only Memory (CD-ROM); the magnetic surface storage may be disk storage or tape storage. The volatile Memory may be a Random Access Memory (RAM) which serves as an external cache. By way of illustration and not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM, Double Data Synchronous Random Access Memory), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM, Enhanced Synchronous Dynamic Random Access Memory), Synchronous link Dynamic Random Access Memory (SLDRAM, Synchronous Dynamic Random Access Memory), Direct Memory (DRmb Random Access Memory, Random Access Memory). The memory 130 described in embodiments herein is intended to comprise, without being limited to, these and any other suitable types of memory.
The method disclosed in the embodiments of the present application may be applied to a processor, or may be implemented by a processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or instructions in the form of software. The processor described above may be a general purpose processor, a DSP, or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like. The processor may implement or perform the methods, steps, and logic blocks disclosed in the embodiments of the present application. A general purpose processor may be a microprocessor or any conventional processor or the like. The steps of the method disclosed in the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium located in a memory where a processor reads the programs in the memory and in combination with its hardware performs the steps of the method as previously described.
Optionally, when the processor executes the program, the processor implements a corresponding process implemented by the switch in each method of the embodiment of the present application, and details are not described herein for brevity.
In an exemplary embodiment, the present application further provides a storage medium, specifically a computer storage medium, for example, a first memory storing a computer program, where the computer program is executable by a processor of a switch to perform the steps of the foregoing method. The computer readable storage medium may be Memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface Memory, optical disk, or CD-ROM.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus, switch, and method may be implemented in other ways. The above-described device embodiments are merely illustrative, for example, the division of the unit is only a logical functional division, and there may be other division ways in actual implementation, such as: multiple units or components may be combined, or may be integrated into another system, or some features may be omitted, or not implemented. In addition, the coupling, direct coupling or communication connection between the components shown or discussed may be through some interfaces, and the indirect coupling or communication connection between the devices or units may be electrical, mechanical or other forms.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed on a plurality of network units; some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be separately regarded as one unit, or two or more units may be integrated into one unit; the integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
Those of ordinary skill in the art will understand that: all or part of the steps for implementing the method embodiments may be implemented by hardware related to program instructions, and the program may be stored in a computer readable storage medium, and when executed, the program performs the steps including the method embodiments; and the aforementioned storage medium includes: a removable storage device, a ROM, a RAM, a magnetic or optical disk, or various other media that can store program code.
Alternatively, the integrated units described above in the present application may be stored in a computer-readable storage medium if they are implemented in the form of software functional modules and sold or used as independent products. Based on such understanding, the technical solutions of the embodiments of the present application may be essentially implemented or portions thereof contributing to the prior art may be embodied in the form of a software product stored in a storage medium, and including several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a removable storage device, a ROM, a RAM, a magnetic or optical disk, or various other media that can store program code.
The technical means described in the embodiments of the present application may be arbitrarily combined without conflict.
In addition, in the examples of the present application, "first", "second", and the like are used for distinguishing similar objects, and are not necessarily used for describing a specific order or a sequential order.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (11)

1. A loop detection method is applied to a first switch, and is characterized by comprising the following steps:
under the condition that the first switch meets the set conditions, controlling the first switch to enter a first mode; the set condition represents that the configuration of the first switch is modified;
under the condition that the first switch is in the first mode, when a link corresponding to a first port of the first switch is communicated, controlling the first port to be in a blocking state; the first switch comprises at least one port, and the first port is any one of the at least one port;
performing loop detection based on the first port to obtain a detection result; and the detection result represents whether a loop exists in the first port.
2. The method of claim 1, further comprising:
under the condition that the detection result indicates that the first port does not have a loop, controlling the first port to enter a forwarding state from the blocking state; and maintaining the blocking state by the first port under the condition that the detection result indicates that a loop exists in the first port.
3. The method of claim 1, wherein performing loop detection based on the first port to obtain a detection result comprises:
sending a setting message based on the first port; the setting message is used for detecting whether a loop exists in the first port;
and determining that a loop exists in the first port under the condition that the first port receives the set message within a first set time length.
4. The method of claim 3, wherein sending the configuration message based on the first port comprises:
and sending the setting message based on the sub-port of the aggregation port under the condition that the first port is the aggregation port.
5. The method of claim 1, wherein the determining that the first switch satisfies a set condition comprises any one of:
determining that the first switch meets a set condition under the condition that the first switch is in an open-loop mode;
under the condition that a first user instruction is received, determining that the first switch meets a set condition; the first user instruction is used to control the first switch to enter the first mode.
6. The method of claim 1, further comprising:
configuring a second switch based on the first port in the first mode; the second switch is cascaded with the first switch based on the first port.
7. The method of claim 1, further comprising:
and when the at least one port is in the forwarding state and the configuration of the first switch is not modified within a second set time length, controlling the first switch to exit the first mode.
8. The method of claim 1, further comprising:
under the condition that a second user instruction is received, controlling the first switch to exit the first mode; the second user instruction is used for controlling the first switch to exit the first mode.
9. A loop detection device, comprising:
the determining module is used for controlling the first switch to enter a first mode under the condition that the first switch meets the set conditions; the set condition represents that the configuration of the first switch is modified;
the control module is used for controlling the first port to be in a blocking state when a link corresponding to the first port of the first switch is communicated under the condition that the first switch is in the first mode; the first switch comprises at least one port, and the first port is any one of the at least one port;
the detection module is used for carrying out loop detection based on the first port to obtain a detection result; and the detection result represents whether a loop exists in the first port.
10. A switch comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the loop detection method of any of claims 1 to 8 when executing the computer program.
11. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program comprising program instructions that, when executed by a processor, cause the processor to carry out the loop detection method according to any one of claims 1 to 8.
CN202011224693.4A 2020-11-05 2020-11-05 Loop detection method, loop detection device, switch and storage medium Pending CN112491642A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011224693.4A CN112491642A (en) 2020-11-05 2020-11-05 Loop detection method, loop detection device, switch and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011224693.4A CN112491642A (en) 2020-11-05 2020-11-05 Loop detection method, loop detection device, switch and storage medium

Publications (1)

Publication Number Publication Date
CN112491642A true CN112491642A (en) 2021-03-12

Family

ID=74928419

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011224693.4A Pending CN112491642A (en) 2020-11-05 2020-11-05 Loop detection method, loop detection device, switch and storage medium

Country Status (1)

Country Link
CN (1) CN112491642A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113238855A (en) * 2021-07-13 2021-08-10 浙江大华技术股份有限公司 Path detection method and device

Citations (4)

* 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
US20160020974A1 (en) * 2014-07-18 2016-01-21 Allied Telesis Holdings K.K. Network device, communication method, program, and recording medium
CN105933180A (en) * 2016-04-12 2016-09-07 上海斐讯数据通信技术有限公司 Switch-based loop detection device and loop detection method
CN110391957A (en) * 2019-07-26 2019-10-29 新华三技术有限公司合肥分公司 Loop detecting method and device

Patent Citations (4)

* 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
US20160020974A1 (en) * 2014-07-18 2016-01-21 Allied Telesis Holdings K.K. Network device, communication method, program, and recording medium
CN105933180A (en) * 2016-04-12 2016-09-07 上海斐讯数据通信技术有限公司 Switch-based loop detection device and loop detection method
CN110391957A (en) * 2019-07-26 2019-10-29 新华三技术有限公司合肥分公司 Loop detecting method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113238855A (en) * 2021-07-13 2021-08-10 浙江大华技术股份有限公司 Path detection method and device
CN113238855B (en) * 2021-07-13 2022-07-08 浙江大华技术股份有限公司 Path detection method and device

Similar Documents

Publication Publication Date Title
JP4437984B2 (en) Network relay device and control method thereof
US8411690B2 (en) Preventing data traffic connectivity between endpoints of a network segment
US9473382B2 (en) Method and system for link aggregation
JP2006270839A (en) Setting control device of layer 2 instrument
WO2017054547A1 (en) Bidirectional forwarding detection method and apparatus
CN108512751A (en) A kind of port status processing method and the network equipment
US8467403B2 (en) Coordinated updating of forwarding information bases in a multistage packet switching device
EP2850789B1 (en) Optimization for trill lan hellos
US20200044964A1 (en) Defect detection in ip/mpls network tunnels
CN112491642A (en) Loop detection method, loop detection device, switch and storage medium
WO2017059715A1 (en) Data configuration method and device for protecting ring network
CN109379239B (en) Method and device for configuring access switch in OpenStack environment
CN107204888B (en) Method and device for switching timeout time and communication equipment
EP2525527A2 (en) Network relay device and network relay method
CN113709068B (en) Switch system and execution processing method of switch
CN115037670A (en) Network convergence method and device, electronic equipment and storage medium
CN114531396B (en) Fault back switching method and device in Ethernet virtual private network
US20110096784A1 (en) Controlled Propagation of VLAN Declarations
CN108111419B (en) Path selection method and device
CN113904975B (en) Method, equipment and storage medium for realizing dual-homing link
CN108259289B (en) Loop network abnormity protection method and device
JPH09149068A (en) Switching hub
WO2015154357A1 (en) Method, device and system for preventing network node ageing
CN115333974B (en) Loop detection method and device based on VSI in DRNI network
JP4585560B2 (en) Network failure detection method, data communication network system, and node device

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210312