VLAN (Virtual Local Area Network) label distribution method based on Raft election
Automatically negotiate VLAN tag allocation in the switch network through the Raft election mechanism, solving the problem of large workload and errors caused by manual configuration, and achieving efficient and stable VLAN tag configuration.
Patent Information
- Application Number
- CN202510714551.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-30
- Publication Date
- 2025-08-29
AI Technical Summary
The VLAN configuration of existing switch devices relies on manual configuration, resulting in high workload and error-proneness, and security vulnerabilities.
The VLAN tag allocation method based on Raft election is adopted to elect the leader switch nodes through the switch nodes in the network. The leader switch node collects and broadcasts the global VLAN configuration policy, and the switch nodes automatically negotiate to configure the VLAN tags that are consistent across the network.
It significantly reduces configuration workload and management complexity, reduces VLAN tag configuration errors, ensures stable network operation, and can still change configurations synchronously in some failed nodes.
Smart Images

Figure CN120567686A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of virtual local area network label allocation methods, and in particular to a VLAN label allocation method based on Raft election. Background Art
[0002] Virtual Local Area Network (VLAN) technology divides the actual network into multiple isolated logical subnets through logical segmentation without changing the physical structure, and creates multiple independent broadcast domains to isolate the traffic between different services and users, thereby improving network operation efficiency, security and maintainability.
[0003] VLANs in existing switch devices rely on manual configuration, which requires network administrators to configure the port VLAN of each switch one by one and assign corresponding VLAN tags to them. Manually configuring a large number of switch ports increases the workload of network administrators and is prone to errors, which can cause the devices under the ports to be unable to communicate and easily lead to security vulnerabilities. Summary of the Invention
[0004] The purpose of the present invention is to provide a VLAN tag allocation method based on Raft election, which does not require the administrator to manually configure VLAN tags for each switch device port. It can enable each switch device to automatically negotiate and configure VLAN tags that are consistent across the entire network, significantly reducing the configuration workload and management complexity, and reducing the occurrence of VLAN tag configuration errors on switch device ports.
[0005] To achieve the above object, the present invention provides a VLAN tag allocation method based on Raft election, comprising: all switch nodes in the network participate in the election and select a leader switch node;
[0006] The leader switch node requests the label allocation policy from each switch node. After receiving the request, each switch node uploads its current label allocation policy to the leader switch node.
[0007] The leader switch node selects the label allocation policy with the most switches reported as the global VLAN configuration policy from the label allocation policies uploaded by all switch nodes, and submits the global VLAN configuration policy to all switch nodes.
[0008] After receiving the submission request, the switch node obtains and applies the global VLAN configuration policy and sends a confirmation message of successful configuration back to the leader switch node;
[0009] The leader switch node receives the configuration success information sent back by the node, records the number of nodes that sent back the information, and considers that the global VLAN configuration policy has taken effect globally if it exceeds the preset value. It then sends a final confirmation instruction to all switch nodes.
[0010] After the global VLAN configuration policy takes effect globally, switch nodes that have not yet obtained the configuration obtain the global VLAN configuration policy from neighboring switch nodes.
[0011] After the global VLAN configuration policy takes effect globally, the switch nodes that have not yet obtained the configuration obtain the global VLAN configuration policy from neighboring switch nodes, and the following steps are also included:
[0012] When there is a new switch node or a switch node that needs to modify the label allocation policy, the label allocation policy is resubmitted to the leader switch node. The leader switch node reselects the same label allocation policy reported by the most nodes as the global VLAN configuration policy.
[0013] When a new switch node is connected or a label allocation policy needs to be modified, the label allocation policy is resubmitted to the leader switch node, and the leader switch node reselects the same label allocation policy reported by the most nodes as the global VLAN configuration policy. The following steps are also included:
[0014] When the leader switch node fails, the leader switch node election is triggered again, and a new leader switch node is generated to restart the configuration of the global VLAN configuration policy.
[0015] All switch nodes in the network participate in the election. The specific steps to select a leader switch node include:
[0016] After each switch node in the system starts, it periodically sends a hello message with the destination address being the system's preset broadcast address. The hello message content includes the source IP address, destination IP address, protocol message identifier, local node network element ID, the network element ID of the currently elected leader switch node, and an election completion flag.
[0017] After receiving hello messages from other switch nodes, the switch node stores them in the neighbor list. When the total number of neighbors stabilizes, the leader election is initiated.
[0018] The switch node selects a leader switch node from its neighbor list and its own information. After the election is complete, the switch node fills in the selected leader network element ID in the hello message and sets the election completion flag;
[0019] If a switch node receives a hello message containing the leader network element ID and finds that the ID is consistent with its own IP address, it counts the votes for electing the switch node as the leader switch node. When more than half of the switch nodes in the system vote for a switch node, the switch node becomes the leader switch node.
[0020] The leader switch node requests a label allocation policy from each switch node. After receiving the request, each switch node uploads its current label allocation policy to the leader switch node. The specific steps include:
[0021] After the election is completed, each switch node sends the local default VLAN tag configuration policy to the leader switch node. The leader switch node starts the configuration reception timer and receives the policy information reported by all switch nodes within the valid time. The reported information uses the strategy message, which includes the source IP address, destination IP address, protocol message identifier, node network element ID, VLAN tag allocation policy and policy status bit.
[0022] The leader switch node selects the label allocation policy with the most switches reported as the global VLAN configuration policy from the label allocation policies uploaded by all switch nodes, and submits the global VLAN configuration policy to all switch nodes. The specific steps include:
[0023] After the acceptance timer configured on the leader switch node expires, the leader switch node selects the most adopted strategy from the received VLAN tag allocation strategies as the global VLAN configuration strategy, and encapsulates it into a strategy message for broadcast.
[0024] After receiving the submission request, the switch node obtains and applies the global VLAN configuration policy and sends a confirmation message of successful configuration back to the leader switch node. The specific steps include:
[0025] After receiving the strategy message, the non-leader switch node confirms whether the message comes from the leader switch node. If it is sent by the non-leader switch node, it is discarded. If it is sent by the leader switch node, it parses and stores the global VLAN configuration policy.
[0026] After the switch node completes the configuration of the global VLAN configuration policy, it broadcasts a strategy ack message to the entire network, indicating that the global VLAN configuration policy has been successfully applied. The strategy ack message content includes: source IP address, destination IP address, protocol message identifier, node network element ID and VLAN tag allocation policy summary.
[0027] The leader switch node receives the configuration success information sent back by the node, records the number of nodes that sent back the information, and considers that the global VLAN configuration policy has taken effect globally if the number exceeds the preset value. The specific steps of sending the final confirmation instruction to all switch nodes include:
[0028] After the leader switch node receives strategy ack messages from more than 50% of the switch nodes, it determines that the entire network has reached a consensus on the global VLAN configuration policy. The leader switch node sends a strategy fin message to all switch nodes to notify the entire network that the global VLAN configuration policy has taken effect. The message content includes the source IP address, destination IP address, protocol message identifier, node network element ID and VLAN tag allocation policy summary.
[0029] The present invention discloses a VLAN tag allocation method based on Raft elections. This method utilizes a configuration negotiation algorithm that uses the Raft mechanism to enable a leader switch node to lead data synchronization, with the remaining nodes accepting synchronization requests and ultimately achieving global consistency. This process involves an election between network nodes to generate a leader switch node. The leader switch node collects the VLAN tag configuration policies of all system nodes, selects the most widely adopted policy as the global policy, and then broadcasts it to the entire network. Through an automatic policy-based distribution mechanism, administrators no longer need to manually configure VLAN tags for each device port. This allows each switch node to automatically negotiate and configure a consistent VLAN tag across the entire network, significantly reducing configuration workload and management complexity, and minimizing the occurrence of VLAN tag configuration errors on switch ports. When the VLAN tag allocation policy needs to be adjusted, only more than 50% of the switch nodes need to be updated to ensure synchronized changes to the global VLAN configuration. Even if some nodes in the system fail, as long as the number of failed nodes does not exceed 50% of the entire system, the remaining normal nodes can still negotiate and reach a consistent VLAN tag allocation policy, ensuring stable network operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art.
[0031] Figure 1 This is a flow chart of the VLAN tag allocation method based on Raft election of the present invention.
[0032] Figure 2 This is a flow chart of all switch nodes in the network of the present invention participating in an election and selecting a leader switch node.
[0033] Figure 3This is a flow chart of the switch node of the present invention, after receiving a submission request, obtaining and applying a global VLAN configuration policy, and returning confirmation information of successful configuration to the leader switch node.
[0034] Figure 4 It is a schematic diagram of an implementation scheme when the switch of the present invention is a three-layer switch.
[0035] Figure 5 It is a schematic diagram of an implementation scheme when the switch of the present invention is a layer 2 switch.
[0036] Figure 6 1 is a schematic diagram of a state machine of a VLAN tag allocation method based on Raft election according to the present invention. DETAILED DESCRIPTION
[0037] The embodiments of the present invention are described in detail below. Examples of the embodiments are shown in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, but should not be understood as limiting the present invention.
[0038] See also Figures 1-6 The present invention provides a VLAN tag allocation method based on Raft election, comprising:
[0039] All switch nodes in the S100 network participate in the election and select a leader switch node;
[0040] The specific steps include:
[0041] After each switch node in the S101 system starts, it periodically sends a hello message with the destination address being the system's preset broadcast address. The hello message content includes the source IP address, destination IP address, protocol message identifier, local node network element ID, the network element ID of the currently elected leader switch node, and an election completion flag.
[0042] In an embodiment of the present invention, an auto-negotiated VLAN tag allocation strategy is provided. Configuration delivery software is designed to run on a switch device or an external management device, enabling the device to automatically configure VLAN tags based on the tag allocation strategy. To implement this strategy, the switch node used in the present invention must meet any of the following conditions:
[0043] Condition 1: The switch must be a Layer 3 switch and support running custom software locally.
[0044] Condition 2: The switch is a Layer 2 switch, but can receive configuration commands from external devices through the network port.
[0045] Based on condition one, the implementation scheme of the present invention is shown in the figure. The switches running this scheme must be interconnected and locally run the software provided by this invention. Each switch must be assigned a unique network element ID (e.g., its Layer 3 routing address) for identification during the election process. In this scenario, each switch is considered a switch node and participates in the negotiation and actual configuration of the label allocation scheme.
[0046] Based on condition 2, the implementation scheme of the present invention is shown in the figure. Each switch running this scheme needs to be connected to an external terminal device, which runs the software provided by this invention and is assigned a unique ID within the system as an identifier for identity confirmation during the election process. In this case, the combined system of each switch and its connected external terminal device is regarded as a switch node, participating in the negotiation and actual configuration process of the label allocation scheme.
[0047] The software provided by the present invention must have the following functions:
[0048] Data communication capability: Ability to send data to other Layer 3 switches or terminal devices in the form of IP packets, and correctly parse and process the data content from other Layer 3 switches or terminal devices.
[0049] 2) Distributed policy negotiation: The distributed VLAN policy negotiation algorithm provided by the present invention is run to ensure that network devices can automatically reach a consistent VLAN tag allocation solution.
[0050] 3) VLAN configuration management: Based on the negotiation results, the switch is automatically configured with VLAN to achieve a consistent tag allocation strategy across the entire network.
[0051] In step S101, after startup, each switch node periodically sends a hello message (a Layer 3 protocol message) with the destination address being the system's preset broadcast address. The hello message includes: source IP address, destination IP address, protocol message identifier, local node network element ID, the network element ID of the currently elected leader switch node, and an election completion flag.
[0052] Neighbor list establishment and stabilization: After a switch node receives a hello message from another node, it stores it in the neighbor list. When the total number of neighbors stabilizes (for example, no new neighbors are added or reduced within three consecutive hello message cycles), leader election is initiated.
[0053] After receiving hello messages from other switch nodes, switch node S102 stores them in the neighbor list. When the total number of neighbors stabilizes, it starts leader election.
[0054] In the embodiment of the present invention, after receiving hello messages from other nodes, the switch node stores them in the neighbor list. When the total number of neighbors is stable (for example, no new neighbors or no new neighbors are added or reduced within three consecutive hello message cycles), the leader election is started.
[0055] S103 The switch node selects a leader switch node from its neighbor list and its own information. After the election is complete, the switch node fills in the selected leader network element ID in the hello message and sets the election completion flag;
[0056] In this embodiment of the present invention, a switch node selects a leader switch node from its neighbor list and its own information. Specifically, the node selects the device with the smallest (or largest) NE ID as the leader. After the election is complete, the node enters the selected leader NE ID in its hello message and sets the election completion flag.
[0057] In step S104, if the switch node receives a hello message containing the leader network element ID and finds that the ID is consistent with its own IP address, it counts the votes for electing the switch node as the leader switch node. When more than half of the switch nodes in the system vote for a switch node, the switch node becomes the leader switch node.
[0058] In this embodiment of the present invention, if a switch node receives a hello message containing the leader NE ID and finds that the ID matches its own IP address, it counts the votes electing the node as leader. When the vote count exceeds (N+1) / 2 (a majority of the system's nodes voted for the node), the node officially becomes the leader switch node and sends an election completion flag and an enabled hello message to the entire network, notifying all nodes of the election result. Upon receiving this message, other nodes update their local leader information and simultaneously modify their own hello messages to match the leader NE ID and election completion flag in the message.
[0059] S200 The leader switch node requests a label allocation policy from each switch node. After receiving the request, each switch node uploads its current label allocation policy to the leader switch node.
[0060] The specific steps include: after the election is completed, each switch node sends the local default VLAN tag configuration policy to the leader switch node, the leader switch node starts the configuration reception timer, and receives the policy information reported by all nodes within the valid time. The reported information uses the strategy message, which includes the source IP address, destination IP address, protocol message identifier, node network element ID, VLAN tag allocation strategy and policy status bit.
[0061] In this embodiment of the present invention, after the election is complete, each switch node sends its local default VLAN tag configuration policy to the leader switch node. The leader switch node starts a configuration reception timer and receives policy information reported by all nodes within the valid time. This information is reported in a strategy message (a Layer 3 protocol message) containing: source IP address, destination IP address, protocol message identifier, node network element ID, VLAN tag allocation policy, and policy status bit (set to "upload"). The VLAN tag allocation policy includes the port VLAN tag information and the VLAN interface IP address.
[0062] The S300 leader switch node selects the label allocation policy with the most labels reported by all switch nodes from the label allocation policies uploaded by all switch nodes as the global VLAN configuration policy, and submits the global VLAN configuration policy to all switch nodes.
[0063] The specific steps include: after the acceptance timer configured by the leader switch node expires, the leader switch node selects the most adopted strategy from the received VLAN tag allocation strategies as the global VLAN configuration strategy, and encapsulates it into a strategy message for broadcasting.
[0064] In the embodiment of the present invention, the strategy message structure in step S300 is the same as the strategy message in step S200, but the strategy status bit is set to "issued", indicating that the strategy has been selected as the consistent strategy for the entire network.
[0065] After receiving the submission request, the S400 switch node obtains and applies the global VLAN configuration policy and sends a confirmation message of successful configuration back to the leader switch node;
[0066] The specific steps include:
[0067] S401: After receiving the strategy message, the non-leader switch node confirms whether the message comes from the leader switch node. If it is sent by the non-leader switch node, it is discarded. If it is sent by the leader switch node, it parses and stores the global VLAN configuration policy.
[0068] In this embodiment of the present invention, upon receiving a strategy message, a non-leader switch node first confirms whether it originates from the leader switch node. If so, the message is discarded. If it originates from the leader switch node, the VLAN configuration policy is parsed and stored. The device locally stores two policies: a global policy configured based on the VLAN configuration policy issued by the leader switch node, and a local policy for nodes with special VLAN requirements. Nodes with local policies are configured only according to the local policy but participate in the global policy negotiation process. If the device already has a local policy, only the global policy is stored, but the device still configures according to the local policy.
[0069] After completing the configuration of the global VLAN configuration policy, switch node S402 broadcasts a strategy ack message to the entire network, indicating that the global VLAN configuration policy has been successfully applied. The strategy ack message content includes: source IP address, destination IP address, protocol message identifier, node network element ID and VLAN tag allocation policy summary.
[0070] In this embodiment of the present invention, after a switch node completes the configuration of a global VLAN configuration policy, it broadcasts a strategy ack message to the entire network, indicating that the configuration has been successfully applied. The strategy ack message (a Layer 3 protocol message) includes the source IP address, destination IP address, protocol message identifier, node network element ID, and VLAN tag allocation policy summary (hash value).
[0071] The S500 leader switch node receives the configuration success information sent back by the node, records the number of nodes that sent back the information, and considers that the global VLAN configuration policy has taken effect globally if it exceeds the preset value. It then sends a final confirmation instruction to all switch nodes.
[0072] The specific steps include: After the leader switch node receives strategy ack messages from more than 50% of the nodes, it determines that the entire network has reached a consensus on the global VLAN configuration policy. The leader switch node sends a strategy fin message (a three-layer protocol message) to all nodes to notify the entire network that the global VLAN configuration policy has taken effect. The message content includes the source IP address, destination IP address, protocol message identifier, node network element ID, and VLAN tag allocation policy summary.
[0073] After the global VLAN configuration policy of the S600 takes effect globally, switch nodes that have not yet obtained the configuration obtain the global VLAN configuration policy from neighboring switch nodes;
[0074] In this embodiment of the present invention, when a switch node fails to obtain the global VLAN configuration policy, it periodically sends strategy-req messages to its neighbors, requesting the global policy after receiving a strategy-fin message or after a period of waiting. If a neighboring node also fails to obtain the global policy, it continues forwarding strategy-req messages to its neighbors until a node is able to provide the global policy. Upon receiving a strategy-req message, a node stores it in a global policy request list and periodically checks whether a negotiated global policy exists locally. If a global policy is already available locally, the node responds to the requesting node with a strategy message and clears the request list, ensuring global policy synchronization.
[0075] When a new switch node is added to the S700 or a label allocation policy needs to be modified, the label allocation policy is resubmitted to the leader switch node. The leader switch node reselects the same label allocation policy reported by the most nodes as the global VLAN configuration policy.
[0076] In this embodiment of the present invention, for a newly joined switch node, since the system has already selected a leader, there is no need to re-elect. The new node can parse the leader information by receiving the hello message and perform the following steps:
[0077] 1. Parse the hello message and obtain the network ID of the leader switch node.
[0078] 2. Send its own VLAN policy information to the leader switch node.
[0079] 3. After receiving the policy submitted by the new device, the leader switch node recalculates the policy voting results:
[0080] 1) If the new policy changes the original global VLAN configuration policy, the new global VLAN configuration policy is selected and broadcast (ie, step S300 is executed).
[0081] 2) If there is no change, the leader switch node continues to send hello messages periodically to maintain its leadership position.
[0082] When a node modifies the VLAN policy, it will resend a strategy report message to the leader switch node. After receiving the message, the leader switch node will adjust the node's strategy vote to the new strategy. The way the leader switch node recalculates the global strategy is the same as the behavior after the newly joined device submits the strategy, so it will not be repeated here.
[0083] When the leader switch node fails, S800 re-triggers the leader switch node election, generates a new leader switch node, and restarts the configuration of the global VLAN configuration policy;
[0084] In this embodiment of the present invention, when a leader switch node fails (no longer sending any messages), the remaining nodes in the system will not be able to detect its hello packets or messages related to its policy delivery, triggering a re-election process after a timeout. Upon detecting the failure of the leader switch node, the device will re-elect a new leader (i.e., execute step S100) to select a new leader switch node and redistribute VLAN policies according to standard procedures to ensure network configuration consistency.
[0085] When non-leader switch nodes fail, they may be unable to send messages or distribute configurations. If they are unable to send hello messages, other nodes will be unaware of their presence and will remove them from their neighbor lists. If they are unable to send strategy messages, the leader node receives fewer strategy selection votes, but they will still ultimately select a strategy with the most votes. If they are unable to send strategy ack messages, as long as the leader node receives strategy ack messages from more than 50% of functioning nodes, the global configuration distribution is considered successful, without affecting the system configuration negotiation and consensus distribution process.
[0086] In combination with the above steps, the state machine of the VLAN tag allocation method provided by the present invention is shown in the figure, wherein the definitions of each state are as follows:
[0087] init: Status initialization is completed and hello messages start to be sent;
[0088] detect: detects neighboring switch nodes through hello messages;
[0089] select: selects the leader switch node based on the list of neighbor switch nodes;
[0090] Collect: The leader switch node collects the VLAN tag allocation policies uploaded by the system nodes;
[0091] commit: Submits the negotiated policy to other switch nodes.
[0092] Leader finish: The negotiated policy is successfully synchronized to the system switch node, and the VLAN is set according to the configuration.
[0093] upload: uploads the VLAN tag allocation policy to the leader switch node;
[0094] sync: obtains the global policy that has been successfully negotiated from the neighboring switch node;
[0095] finish: The neighboring switch node receives the global policy and completes VLAN configuration according to the configuration.
[0096] The conditions that trigger the state change are as follows:
[0097] ①: When a switch node receives a hello packet from another node, it will switch from init to detect, meaning it begins detecting neighbors. At this point, the node will add the other node to its neighbor list based on the NE ID in the hello packet.
[0098] ②: When the number of neighbors of a switch node remains stable for a period of time (such as 5 hello packet cycles) and there is no leader node in the system, the process switches from detect to select, indicating that the system needs to elect a neighbor node. At this point, the node will begin to elect a leader switch node based on the neighbor list.
[0099] ③: When a switch node becomes the leader, it switches from select to collect, meaning it begins collecting VLAN tag allocation policies submitted by other nodes for negotiation. The leader node then modifies the hello packet, replacing the leader node with itself and enabling the election complete bit.
[0100] ④: When the leader switch node completes its policy collection cycle and selects a global policy, it transitions from collect to commit, indicating that the global policy has been negotiated and needs to be submitted to the entire system for data consensus. At this point, the leader switch node sends a strategy packet to all nodes in the system.
[0101] ⑤: When the leader switch node receives strategy acks from more than 50% of the devices, it transitions from commit to leader finish, indicating that the negotiated strategy has been accepted and configured by the majority of nodes. The leader switch node then enters a stable state and only needs to periodically send hello packets.
[0102] ⑥: When a switch node receives a Hello packet from another leader switch node and is not itself the leader, it transitions from select to upload. This means the node has detected the leader switch node and begins submitting the global VLAN policy for negotiation. At this point, the node sends a strategy packet to the leader switch node, submitting the policy. Note that if a leader switch node receives Hello packets from other leader switch nodes, it compares the network element IDs to determine the system's unique leader. The node with the larger ID will continue to send Hello packets as the leader, while the leader switch node with the smaller ID will become a non-leader and enter the upload state.
[0103] ⑦: When a non-leader switch node receives the strategy packet from the leader switch node, it transitions from upload to finish, indicating that the leader switch node has issued the negotiated VLAN policy and can be configured according to this policy. The node then configures the VLAN based on the information in the strategy packet and responds with a strategyack packet to the leader switch node. (If the node has a local policy, it only needs to configure the VLAN based on the local policy and then respond with a strategyack packet.)
[0104] ⑧: When a switch node receives a hello packet from the leader switch node while discovering its neighbors, it indicates that it is a new node. Since a leader switch node already exists in the system, no election is performed. After the number of neighbors remains stable for a period of time (e.g., five hello packet cycles), the node transitions from detect to sync, indicating that the newly joined node has identified the leader switch node and requires synchronization and configuration negotiation. At this point, the node uploads the global VLAN policy for negotiation in the form of a strategy packet and sends a strategyreq packet to its neighbor requesting the negotiated global VLAN policy.
[0105] ⑨: When a non-leader switch node uploads the global VLAN policy to be negotiated, and after a period of time (e.g., 10 hello packet cycles) fails to receive the global VLAN policy negotiation result from the leader node, it assumes that the system is capable of generating the negotiation result but has not yet received it for some reason. The node then transitions from upload to sync, indicating that it needs to synchronize the negotiated configuration with its neighbor. At this point, the node sends a strategy req packet to its neighbor requesting the negotiated global VLAN policy.
[0106] ⑩: When a switch node obtains the negotiated global VLAN policy from its neighbor and receives a strategy packet from the neighbor, it transitions from sync to finish, indicating that the negotiation result has been received and configuration synchronization is complete. The node then configures the VLAN based on the information in the strategy packet and responds with a strategyack packet to the leader switch node. (If the node has a local policy, it only needs to configure the VLAN based on the local policy and then respond with a strategyack packet.)
[0107] When the leader switch node receives a strategy packet in the leaderfinish state or detects a neighbor timeout, the configuration negotiation result may change. The leader switch node will modify the votes corresponding to the negotiation strategy based on the content of the strategy packet or the network element ID corresponding to the neighbor timeout. If this causes the negotiation result to change, it will enter the commit state. At this time, the node will resend the configuration distribution strategy packet to all neighbors to ensure that the system applies the new consistent VLAN configuration strategy.
[0108] When a switch node is in the finish or leaderfinish state, if it receives a strategyack packet, it will reply with the negotiated strategy through the strategy packet without changing the state.
[0109] The present invention discloses a VLAN tag allocation method based on Raft elections. This method uses a configuration negotiation algorithm that utilizes the Raft mechanism to enable a leader switch node to lead data synchronization, with the remaining nodes accepting synchronization requests and ultimately achieving global consistency. This process involves an election between network nodes to generate a leader switch node. The leader switch node collects the VLAN tag configuration policies of all system nodes, selects the most widely adopted policy as the global policy, and then broadcasts it to the entire network. Through an automatic distribution mechanism based on configuration policies, administrators no longer need to manually configure VLAN tags for each device port. This allows each switch device to automatically negotiate and configure a consistent VLAN tag across the entire network, significantly reducing configuration workload and management complexity, and reducing the occurrence of VLAN tag configuration errors on switch device ports. When the VLAN tag allocation policy needs to be adjusted, only more than 50% of the devices need to update the policy to ensure synchronized changes to the global VLAN configuration. Even if some faulty nodes exist within the system, as long as the number of faulty nodes does not exceed 50% of the entire system, the remaining normal devices can still negotiate and reach a consistent VLAN tag allocation policy, ensuring stable network operation.
[0110] The above disclosure is merely one or more preferred embodiments of the present application and is not intended to limit the scope of the present application. A person skilled in the art will understand that all or part of the processes of the above embodiments and equivalent changes made in accordance with the claims of the present application are still within the scope of the present application.
Claims
1. A VLAN tag allocation method based on Raft election, characterized in that: include: All switch nodes in the network participate in the election and select a leader switch node; The leader switch node requests the label allocation policy from each switch node. After receiving the request, each switch node uploads its current label allocation policy to the leader switch node. The leader switch node selects the label allocation policy with the most switches reported as the global VLAN configuration policy from the label allocation policies uploaded by all switch nodes, and submits the global VLAN configuration policy to all switch nodes. After receiving the submission request, the switch node obtains and applies the global VLAN configuration policy and sends a confirmation message of successful configuration back to the leader switch node; The leader switch node receives the configuration success information sent back by the node, records the number of nodes that sent back the information, and considers that the global VLAN configuration policy has taken effect globally if it exceeds the preset value. It then sends a final confirmation instruction to all switch nodes. After the global VLAN configuration policy takes effect globally, switch nodes that have not yet obtained the configuration obtain the global VLAN configuration policy from neighboring switch nodes.
2. The VLAN tag allocation method based on Raft election according to claim 1, characterized in that: After the global VLAN configuration policy takes effect globally, the switch nodes that have not yet obtained the configuration obtain the global VLAN configuration policy from neighboring switch nodes, and the following steps are also included: When there is a new switch node or a switch node that needs to modify the label allocation policy, the label allocation policy is resubmitted to the leader switch node. The leader switch node reselects the same label allocation policy reported by the most nodes as the global VLAN configuration policy.
3. The VLAN tag allocation method based on Raft election according to claim 2, characterized in that: When a new switch node is connected or the label allocation policy needs to be modified, the label allocation policy is resubmitted to the leader switch node. After the leader switch node reselects the same label allocation policy reported by the most nodes as the global VLAN configuration policy, the following steps are also included: When the leader switch node fails, the leader switch node election is triggered again, and a new leader switch node is generated to restart the configuration of the global VLAN configuration policy.
4. The VLAN tag allocation method based on Raft election according to claim 3, characterized in that: All switch nodes in the network participate in the election. The specific steps to select a leader switch node include: After each switch node in the system starts, it periodically sends a hello message with the destination address being the system's preset broadcast address. The hello message content includes the source IP address, destination IP address, protocol message identifier, local node network element ID, the network element ID of the currently elected leader switch node, and an election completion flag. After receiving hello messages from other switch nodes, the switch node stores them in the neighbor list. When the total number of neighbors stabilizes, the leader election is initiated. The switch node selects a leader switch node from its neighbor list and its own information. After the election is complete, the switch node fills in the selected leader network element ID in the hello message and sets the election completion flag; If a switch node receives a hello message containing the leader network element ID and finds that the ID is consistent with its own IP address, it counts the votes for electing the switch node as the leader switch node. When more than half of the switch nodes in the system vote for a switch node, the switch node becomes the leader switch node.
5. The VLAN tag allocation method based on Raft election according to claim 4, characterized in that: The leader switch node requests the label allocation policy from each switch node. After receiving the request, each switch node uploads its current label allocation policy to the leader switch node. The specific steps include: After the election is completed, each switch node sends the local default VLAN tag configuration policy to the leader switch node. The leader switch node starts the configuration reception timer and receives the policy information reported by all switch nodes within the valid time. The reported information uses the strategy message, which includes the source IP address, destination IP address, protocol message identifier, node network element ID, VLAN tag allocation policy and policy status bit.
6. The VLAN tag allocation method based on Raft election according to claim 5, characterized in that: The leader switch node selects the label allocation policy with the most switches reported as the global VLAN configuration policy from the label allocation policies uploaded by all switch nodes, and submits the global VLAN configuration policy to all switch nodes. The specific steps include: After the acceptance timer configured on the leader switch node expires, the leader switch node selects the most adopted strategy from the received VLAN tag allocation strategies as the global VLAN configuration strategy, and encapsulates it into a strategy message for broadcast.
7. The VLAN tag allocation method based on Raft election according to claim 6, characterized in that: After receiving the submission request, the switch node obtains and applies the global VLAN configuration policy and sends a confirmation message of successful configuration back to the leader switch node. The specific steps include: After receiving the strategy message, the non-leader switch node confirms whether the message comes from the leader switch node. If it is sent by the non-leader switch node, it is discarded. If it is sent by the leader switch node, it parses and stores the global VLAN configuration policy. After the switch node completes the configuration of the global VLAN configuration policy, it broadcasts a strategy ack message to the entire network, indicating that the global VLAN configuration policy has been successfully applied. The strategy ack message content includes: source IP address, destination IP address, protocol message identifier, node network element ID and VLAN tag allocation policy summary.
8. The VLAN tag allocation method based on Raft election according to claim 7, characterized in that: The leader switch node receives the configuration success information sent back by the node, records the number of nodes that sent the information back, and considers that the global VLAN configuration policy has taken effect globally if the number exceeds the preset value. The specific steps of sending the final confirmation instruction to all switch nodes are as follows: After the leader switch node receives strategy ack messages from more than 50% of the switch nodes, it determines that the entire network has reached a consensus on the global VLAN configuration policy. The leader switch node sends a strategy fin message to all switch nodes to notify the entire network that the global VLAN configuration policy has taken effect. The message content includes the source IP address, destination IP address, protocol message identifier, node network element ID and VLAN tag allocation policy summary.