A local network topology generation method, device, equipment, medium and product

CN122601480APending Publication Date: 2026-08-18SHEN ZHOU SHU MA WANG LUO BEI JING YOU XIAN GONG SI +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610923153.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-25
Publication Date
2026-08-18

AI Technical Summary

Technical Problem

[0004]因此,传统方式下链路数据分散存储、拓扑视图不统一,最终造成整体运行效率偏低

Benefits of technology

在本申请中,通过采集角色状态数据、任期数据和心跳校验数据,结合三类数据判定设备身份,把全网设备划分为主节点、候选节点、跟随节点,不同角色执行对应任务。候选节点监听参选报文与主节点心跳报文,跟随节点完成链路信息采集上报与本地拓扑缓存更新,主节点处理邻接链路信息、拓扑通告报文封装并向外下发。整套运行模式让网络设备各司其职,各类相关功能相互配合开展工作。网络中的邻接链路信息可以集中汇总处理,全网设备获取相同的拓扑内容,拓扑视图保持一致。同时各类业务环节衔接运转,减少网络内多余的数据交互与重复运算,改善原有运行模式存在的不足,提升网络拓扑探测与数据同步的整体运行效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122601480A_ABST
    Figure CN122601480A_ABST
Patent Text Reader

Abstract

The application discloses a local network topology generation method, device, equipment, medium and product, relates to the technical field of communication, and comprises the following steps: acquiring role state data, term data and heartbeat check data; determining a node role according to the role state data, the term data and the heartbeat check data; if the node role is a candidate node, continuously listening to a candidate message and a heartbeat message of a master node in a layer 2 broadcast domain; if the node role is a follower node, collecting link information by using a link layer discovery protocol and reporting the link information to the master node, receiving a topology announcement message and updating a local topology cache; and if the node role is the master node, receiving adjacent link information reported by the layer 2 broadcast domain and generating a topology announcement message, and the topology announcement message is sent to all non-master nodes in the layer 2 broadcast domain. The method can improve overall operation efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technology, and in particular to a method, apparatus, device, medium and product for generating local network topology. Background Technology

[0002] In Layer 2 broadcast domain networking scenarios, heterogeneous devices such as switches, wireless access points, and gateways are widely used together. Relying on link layer discovery protocols to achieve topology detection is a common technical means for network operation and maintenance and status monitoring.

[0003] Currently, most networks only allow each device to independently detect and display direct links locally, or allow all nodes to synchronize topology data with each other, with various network function modules operating independently.

[0004] Therefore, in the traditional approach, data is stored in a scattered manner and the topology view is not unified, which ultimately results in low overall operating efficiency. Summary of the Invention

[0005] This application provides a method, apparatus, device, medium, and product for generating local network topology, which can improve overall operating efficiency.

[0006] To achieve the above objectives, this application adopts the following technical solution: Firstly, this application provides a method for generating a local network topology, including: Acquire role status data, tenure data, and heartbeat verification data; Node roles are determined based on role status data, term data, and heartbeat verification data; among which, node roles include master nodes, candidate nodes, and follower nodes; If the node role is a candidate node, it will continuously listen for candidate messages and heartbeat messages of the master node in the Layer 2 broadcast domain; If the node role is a follower node, it collects adjacent link information based on the link layer discovery protocol and reports the adjacent link information to the master node; it receives the topology announcement message issued by the master node and updates the local topology cache based on the topology announcement message; If a node is a master node, it receives the adjacency link information reported by each following node in the Layer 2 broadcast domain, encapsulates the message based on the adjacency link information to obtain a topology announcement message, and sends the topology announcement message to all non-master nodes in the Layer 2 broadcast domain.

[0007] In some possible implementations, adjacent link information is collected based on a link-layer discovery protocol and reported to the master node, including: After detecting that the master node's heartbeat message is valid, the link layer discovery protocol is enabled; The Link Layer Discovery Protocol (LLDIP) receives LLDIP messages and determines neighboring devices and their corresponding port information based on these messages; the neighboring devices and their corresponding port information are then used as adjacent link information.

[0008] In some possible implementations, adjacent link information is reported to the master node, including: Generate an adjacency record table based on the adjacent link information; Encapsulate the adjacency record table into an adjacency reporting message; The adjacency reporting message is sent to the master node via Layer 2 multicast.

[0009] In some possible implementations, the local topology cache is updated based on the topology announcement message, including: The network topology information is obtained by parsing the topology announcement message; The network topology information is compared and verified with the locally cached data; Update the local topology cache based on the verified network topology information.

[0010] In some possible implementations, topology announcement messages are obtained by encapsulating messages based on adjacent link information, including: Extract the original link information from the adjacent link information; The original link information is deduplicated to obtain preliminary link information; Perform bidirectional reconciliation of the data at both ends of the same physical link in the preliminary link information to obtain valid link data; Construct a network topology model based on valid link data; Information is extracted from the entire network topology model to obtain network topology information; Network topology information is encapsulated into topology announcement messages.

[0011] In some possible implementations, the acquisition of role status data, tenure data, and heartbeat verification data includes: Listen for master node election protocol messages transmitted within the Layer 2 broadcast domain; Parse the master node election protocol message to obtain the local role identifier, network term number, and heartbeat message validity verification result; Based on the local role identifier, network term number, and heartbeat message validity verification results, determine the role status data, term data, and heartbeat verification data.

[0012] Secondly, this application provides a local network topology generation apparatus, comprising: The acquisition module is used to acquire role status data, tenure data, and heartbeat verification data; The role determination module is used to determine node roles based on role status data, term data, and heartbeat verification data; among which, node roles include master nodes, candidate nodes, and follower nodes; The topology generation module is used to continuously listen for candidate messages and heartbeat messages from the master node in the Layer 2 broadcast domain if the node's role is a candidate node; if the node's role is a follower node, it collects adjacent link information based on the link layer discovery protocol and reports the adjacent link information to the master node; it receives topology announcement messages from the master node and updates the local topology cache based on the topology announcement messages; if the node's role is the master node, it receives adjacent link information reported by each follower node in the Layer 2 broadcast domain, encapsulates the messages based on the adjacent link information to obtain topology announcement messages; and sends the topology announcement messages to all non-master nodes in the Layer 2 broadcast domain.

[0013] Thirdly, this application provides a computing device, including a memory and a processor; The memory stores one or more computer programs, the one or more computer programs including instructions; when the instructions are executed by the processor, the computing device performs the method as described in any one of the first aspects.

[0014] Fourthly, this application provides a computer-readable storage medium for storing a computer program for performing the method as described in any one of the first aspects.

[0015] Fifthly, this application provides a computer program product comprising one or more computer instructions, wherein when the computer instructions are executed by a computer, the computer performs the method as described in any one of the first aspects.

[0016] As can be seen from the above technical solution, this application has at least the following beneficial effects: In this application, device identity is determined by collecting role status data, term data, and heartbeat verification data, and classifying all network devices into master nodes, candidate nodes, and follower nodes, with each role performing corresponding tasks. Candidate nodes listen to candidate messages and master node heartbeat messages, follower nodes complete link information collection and reporting and local topology cache updates, and master nodes process adjacent link information, encapsulate topology announcement messages, and distribute them externally. This entire operating mode allows network devices to perform their respective functions, with various related functions working together. Adjacent link information in the network can be centrally aggregated and processed, ensuring that all network devices obtain the same topology content and maintain a consistent topology view. Simultaneously, various business processes operate seamlessly, reducing redundant data interaction and repetitive calculations within the network, addressing the shortcomings of the original operating mode, and improving the overall efficiency of network topology detection and data synchronization.

[0017] It should be understood that the descriptions of technical features, technical solutions, beneficial effects, or similar language in this application do not imply that all features and advantages can be achieved in any single embodiment. Rather, it is understood that the description of a feature or beneficial effect means that a specific technical feature, technical solution, or beneficial effect is included in at least one embodiment. Therefore, the descriptions of technical features, technical solutions, or beneficial effects in this specification do not necessarily refer to the same embodiment. Furthermore, the technical features, technical solutions, and beneficial effects described in this embodiment can be combined in any suitable manner. Those skilled in the art will understand that embodiments can be implemented without one or more specific technical features, technical solutions, or beneficial effects of a particular embodiment. In other embodiments, additional technical features and beneficial effects may be identified in specific embodiments that do not embody all embodiments. Attached Figure Description

[0018] Figure 1 This application provides an example of an local network topology generation method. Figure 2 A flowchart illustrating a local network topology generation method provided in this application embodiment; Figure 3 A structural diagram of a local network topology generation device provided in an embodiment of this application; Figure 4 This is a schematic diagram of a computing device provided in an embodiment of this application. Detailed Implementation

[0019] The terms "first," "second," and "third," etc., used in this application specification and accompanying drawings are used to distinguish different objects, not to limit a specific order.

[0020] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0021] To ensure clarity and conciseness in the description of the following embodiments, a brief introduction to the related technologies is given first: Link layer discovery protocols are general protocols deployed on Ethernet devices. Devices use this protocol to exchange messages and can automatically identify directly connected peripheral devices and interconnection port information. It is often used for network topology exploration and daily status monitoring.

[0022] A Layer 2 broadcast domain refers to a local area network (LAN) consisting of heterogeneous devices such as gateways, Layer 2 switches, and wireless access points. Protocol messages such as candidate messages and heartbeat messages are transmitted within this domain via Layer 2 multicast or broadcast, and all devices within the domain can receive these messages normally.

[0023] Currently, topology probing within the Layer 2 broadcast domain is mostly performed independently by a single device or relies on data transmission between nodes across the network. This approach results in link information being scattered across different devices, preventing the formation of a unified network topology view. Furthermore, various network functions operate independently, lacking coordination. These combined factors lead to a significant amount of useless data exchange within the network, ultimately resulting in low overall efficiency for topology probing and data synchronization.

[0024] In view of this, embodiments of this application provide a local network topology generation method. To make the technical solution of this application clearer and easier to understand, the application scenarios of the technical solution of this application are described below with reference to the accompanying drawings. Figure 1 As shown, this figure is an application environment diagram provided by an embodiment of this application.

[0025] This application environment is built within a Layer 2 broadcast domain, which includes n networking devices. These devices can be heterogeneous, such as gateways, Layer 2 switches, and wireless access points. The devices are functionally categorized into three types: master nodes, candidate nodes, and follower nodes. All devices within the Layer 2 broadcast domain continuously collect data related to role status, term of office, and heartbeat verification to determine their own node identity. Candidate nodes continuously monitor election messages (i.e., master node election protocol messages, periodically sent by candidate devices to announce their intention to run for master node) and master node heartbeat messages within the domain, gaining real-time awareness of the network status. Each follower node runs a link-layer discovery protocol, collects adjacent link information, encapsulates it into an adjacency reporting message, and sends it to the master node. Simultaneously, it continuously receives topology announcement messages from the master node, parses the network topology information, compares and verifies it with locally cached data, and updates its own local topology cache. The master node receives the adjacent link information reported by all follower nodes, performs deduplication of the original link information and bidirectional reconciliation to obtain valid link data, constructs the entire network topology model and extracts network topology information, encapsulates and generates a topology announcement message, and sends it to candidate nodes and follower nodes in the domain through Layer 2 multicast to complete the synchronization of the entire network topology information.

[0026] To make the technical solution of this application clearer and easier to understand, the following describes a local network topology generation method provided by an embodiment of this application, taking any one of the network devices as the execution subject, in conjunction with the above application scenarios. Figure 2 As shown, this figure is a flowchart illustrating a local network topology generation method provided in an embodiment of this application. The local network topology generation method includes: S201. Obtain role status data, term data, and heartbeat verification data.

[0027] One possible approach is to monitor master node election protocol messages transmitted within a Layer 2 broadcast domain; parse the master node election protocol messages to obtain the local role identifier, network term number, and heartbeat message validity verification result; and determine role status data, term data, and heartbeat verification data based on the local role identifier, network term number, and heartbeat message validity verification result.

[0028] Role status data is used to identify the current operating identity of the device, corresponding to the three roles of master node, candidate node, and follower node in the network division; term data corresponds to the network term number generated by the master node election protocol, which can distinguish master nodes generated in different rounds of election and avoid the interference of messages from old version master nodes with the current network topology operation; heartbeat verification data is used to determine whether the master node is online and whether its working status is normal.

[0029] The local role identifier, network term number, and heartbeat message validity verification result are all output in real time by the master node election protocol. The local role identifier directly corresponds to the node identity, the network term number corresponds to the master node's generation, and the heartbeat message validity verification result corresponds to the master node's online status.

[0030] For example, after the Layer 2 broadcast domain network is operating normally, each network device will run a master node election protocol in the background. This protocol continuously monitors the election status of the entire network and the online status of master nodes, and outputs three basic results in real time: local role identifier, network term number, and heartbeat message validity verification result. After actively polling or passively receiving the above three types of results pushed by the protocol, the device's upper-layer module performs data classification and transformation: mapping the local role identifier to role status data to clarify the device's current basic identity; directly using the network term number as term data to record the generation of the currently effective master node; and organizing the heartbeat message validity verification result into heartbeat verification data to retain the basis for the master node's survival status. These three types of data are temporarily stored locally.

[0031] It should be noted that the Master Election Protocol (MEP) is a private master election protocol operating within the Layer 2 broadcast domain. It is primarily used in local area network (LAN) environments composed of heterogeneous devices such as gateways, Layer 2 switches, wireless controllers, and wireless access points. Its core function is to automatically elect a unique master node from among the devices within the domain and continuously maintain the stability of the master node's identity through mechanisms such as leases, heartbeats, and tenure. All control messages of this protocol are transmitted via the Layer 2 multicast domain, and its overall operational logic is decoupled from the link-layer discovery protocol, allowing it to independently complete master election and state maintenance.

[0032] MEP defines three types of basic interactive messages, which respectively handle the functions of candidate announcement, master node identity declaration, and online status detection. The candidate announcement message is actively and periodically sent by the device upon startup or after detecting the failure of the existing master node. The message carries the device identifier, election priority, and election decision field. All devices within the Layer 2 broadcast domain can use this message to collect information on all candidate devices across the network. The master node declaration message is periodically multicast by the elected master node, containing the device identifier, election priority, network term number, and message sequence number, allowing other devices to identify the legitimate master node and synchronize term information across the network. The master node heartbeat message can be sent independently or combined with the master node declaration message to continuously announce the master node's online status to the entire network. All non-master nodes and candidate nodes rely on the heartbeat message to determine whether the master node is functioning correctly.

[0033] The protocol establishes unified election rules, with all devices across the network following the same decision-making logic: First, candidate devices are selected based on their election priority, with devices having higher priority values ​​being elected first. When multiple devices have the same priority, their device identifiers are compared to determine the final master node, ensuring that only one valid master node is generated within the Layer 2 broadcast domain at any given time. To avoid frequent master node re-elections caused by momentary link jitter and occasional packet loss, the protocol adds a jitter suppression mechanism. After a device initially identifies a master node, it enters a state observation phase. Only after continuously receiving multiple valid master node declaration messages or heartbeat messages does it officially switch to a stable operating state. In a stable state, the device directly ignores candidate messages with lower priority, effectively suppressing network oscillations.

[0034] The protocol introduces a network term numbering mechanism to manage the master node iteration process. When an existing master node voluntarily resigns, loses connection due to heartbeat message timeout, or a higher-priority candidate device emerges, a new round of master node election is immediately triggered across the entire network. After the new master node is elected, it will monotonically update the network term number. All devices within the domain use the term number to distinguish master nodes from different rounds, and combine it with the topology version number to jointly complete message verification, preventing delayed messages from the old term master node from interfering with the current network topology operation.

[0035] Based on the election and operational results, the master node election protocol outputs three types of device roles to the upper-layer business modules: master node, candidate node, and follower node. Each role corresponds to a different working logic: candidate nodes continuously monitor election messages within the domain and master node heartbeat messages, maintaining a standby state for the election; follower nodes initiate the link layer discovery protocol to collect adjacent link information and report it to the master node, while simultaneously receiving topology announcement messages to update their local cache; the master node is responsible for summarizing all network link data, constructing the topology model, and distributing topology information. When the master node changes, the term number is updated synchronously, and the topology version number is linked to trigger the re-reporting of all network link information and topology reconstruction, achieving coordinated linkage between the master node election process and the topology generation process.

[0036] S202. Determine the node role based on the role status data, term data, and heartbeat verification data.

[0037] Node roles are the final working identities of devices in Layer 2 broadcast domain networking. These include master nodes responsible for summarizing the adjacency link information of the entire network and generating and distributing the network topology, candidate nodes participating in master node election and listening to network packets, and follower nodes collecting and reporting adjacency link information and synchronously updating the local topology cache.

[0038] For example, compliance verification is performed on the initial identity of the device to avoid misjudgment of identity caused by network packet loss and instantaneous link jitter. In normal scenarios where the network is operating normally, the device first reads the initial identity given by the master node election protocol based on role status data, and then verifies that the master node generation corresponding to this identity is a valid generation recognized by the entire network through the network term number. At the same time, it uses heartbeat verification data to confirm that the master node is continuously online and the lease is in a valid state. When the initial identity is a master node and both auxiliary data are verified as passed, the device officially establishes its master node identity and will subsequently be fully responsible for the collection of adjacent link information, topology model construction, and topology packet distribution. When the initial identity is a candidate node and there are no abnormalities in the master node generation and online status, the device maintains its candidate identity, continues to listen to network packets, and maintains an election standby state. When the initial identity is a follower node and the verification result is normal, the device is fixed as a follower node and performs routine tasks such as link collection, data reporting, and topology cache updates.

[0039] When heartbeat verification data detects that the master node has not sent a valid master node heartbeat message for an extended period or that the lease has timed out, and the existing master node is deemed invalid, all current verification results are immediately invalidated. Devices, based on term data, mark the original master node generation as invalid and simultaneously update their own role status. All devices in the entire network (Layer 2 broadcast domain network) eligible for election uniformly activate the election process, conducting a new round of master node election according to preset election priorities and device identification winning rules. After a new master node is generated and the network-wide term data is updated, all devices re-execute the joint verification in this step to re-determine their respective node roles, ensuring continuous operation of network topology services.

[0040] S203. If the node role is a candidate node, then continuously listen for candidate messages and heartbeat messages of the master node in the Layer 2 broadcast domain.

[0041] The candidate message is a special message defined in the master node election protocol, namely the candidate announcement message. It is actively sent by the candidate device and carries information such as device identifier and election priority. It is used to indicate its intention to run for master node to the Layer 2 broadcast domain. When multiple devices participate in the election at the same time, all devices will send and receive this type of message to complete the priority comparison.

[0042] The master node's heartbeat message is a protocol message periodically sent by the currently elected master node to announce its online status and the validity of its lease to the entire network. During normal operation, the master node sends master node heartbeat messages at fixed intervals.

[0043] For example, after a device completes role determination and identifies itself as a candidate node, it will run a persistent message listening process in the background. This process is independent of regular business operations and captures, parses, and analyzes protocol messages in the Layer 2 broadcast domain throughout the process. It is the link in which candidate nodes perceive the status of the entire network and trigger election actions.

[0044] When listening for master node heartbeat messages, the device does not simply receive messages, but performs continuous verification according to the timeout threshold preset in the protocol. The device counts the reception interval between two adjacent master node heartbeat messages. If the message is always delivered normally within the specified period and the message fields are compliant, it can be determined that the current master node lease is valid and the operation is stable. The candidate node continues to remain in standby state and does not trigger any election actions. Once a valid master node heartbeat message is not captured for more than the preset time, or an invalid master node heartbeat message with abnormal fields or corresponding to the old network term number is received, the device determines that the original master node is offline and the lease has expired, and then enters the election preparation state.

[0045] The monitoring of candidate announcement messages is primarily used to collect real-time information on the overall network election situation. The device parses important fields such as election priority and device identifier carried in each candidate announcement message, compiling a list of all currently participating devices and their competitive ranking. During the normal operation of the master node, candidate nodes only record relevant information and do not actively send candidate announcement messages. When the original master node is confirmed to be invalid, the device combines the previously monitored election information with its own election priority and device identifier against other candidate devices according to the established winning rules of the protocol. After confirming its own election ranking, it actively sends a candidate message, officially initiating a new round of master node election.

[0046] The entire listening process is repeated cyclically. On the one hand, it relies on the heartbeat messages of the master node to monitor the operating status of all nodes in the network. On the other hand, it relies on the election messages to grasp the competitive landscape. The two work together to realize the adaptive operating logic of candidate nodes "normally on standby and abnormally starting the election", avoiding the accidental triggering of the election due to temporary network disconnection or occasional message loss, and improving the stability of the entire network operation.

[0047] S204. If the node role is a follower node, it collects adjacent link information based on the link layer discovery protocol and reports the adjacent link information to the master node; it receives the topology announcement message issued by the master node and updates the local topology cache based on the topology announcement message.

[0048] The methods for collecting adjacent link information can be: After detecting that the master node's heartbeat message is valid, the link layer discovery protocol is enabled; the link layer discovery protocol message is received based on the link layer discovery protocol, and the neighboring device and its corresponding port information are determined based on the link layer discovery protocol message; the neighboring device and its corresponding port information are used as the adjacent link information.

[0049] The method for reporting adjacent link information to the master node can be as follows: An adjacency record table is generated based on the adjacency link information; the adjacency record table is encapsulated into an adjacency reporting message; and the adjacency reporting message is sent to the master node via Layer 2 multicast.

[0050] The method for updating the local topology cache based on topology announcement messages can be: The topology announcement message is parsed to obtain network topology information; the network topology information is compared and verified with the local cached data; and the local topology cache is updated based on the verified network topology information.

[0051] Adjacent link information is obtained by following the node through parsing the Link Layer Discovery Protocol (LLDP) message, which contains information about neighboring devices and their corresponding ports.

[0052] Topology announcement messages are messages that the master node encapsulates network topology information and sends to all non-master nodes in the domain via Layer 2 multicast.

[0053] The local topology cache is a storage area that follows the node in storing network topology information locally.

[0054] Local cache data is the network topology information stored historically in the local topology cache of the node.

[0055] The adjacency record table is a structured form that follows nodes by parsing neighboring devices and their corresponding port information through LLDP messages. It can be used to uniformly store all link information of the local machine.

[0056] The adjacency reporting message is a special message that follows the node to encapsulate the adjacency record table and reports to the master node via Layer 2 multicast.

[0057] Network topology information is standardized and structured data that includes the identifiers of all devices in the Layer 2 broadcast domain, the physical link connections between devices, and the current effective network term number.

[0058] For example, when a device determines that its role is a follower node, the system will simultaneously start two independent background tasks, which are responsible for link information collection and reporting, topology message listening, and cache update, respectively. The two tasks run in parallel for a long time without interfering with each other, ensuring that data upload and local topology synchronization continue.

[0059] During the adjacency link information collection and reporting phase, after the device detects the validity of the master node's heartbeat message, it activates the link layer discovery protocol and runs it continuously, probing all directly connected devices on all physical ports in real time. The protocol actively exchanges standard LLDP messages with neighboring devices, capturing the identity of the neighboring device and the interconnection port number corresponding to each port, and summarizing them to form complete adjacency link information. To solve the problem of inconsistent data formats between devices from different manufacturers and the difficulty for the master node to summarize and reconcile, the device will organize all adjacency link information into a standardized adjacency record table according to the standardized format preset in this solution. Then, the entire record table is encapsulated into a dedicated adjacency reporting message and transmitted in the broadcast domain using Layer 2 multicast technology. Combined with the network topology rules, this multicast message can be received by the master node, and other follower nodes will not process the reported data repeatedly, ensuring that adjacency link information reaches important nodes directly and avoiding redundancy of messages across the entire network. At the same time, the device will repeatedly perform the reporting action at a fixed period. If the local port connection relationship changes, it will also trigger an immediate report, ensuring that the master node can grasp the dynamics of the entire network links in real time.

[0060] During the topology message reception and cache update phase, the device continuously monitors topology announcement messages sent by the master node within the Layer 2 broadcast domain. Upon receiving a message, the device first parses the message to extract the network topology information it carries. The device then cross-references the extracted network topology information with its local cached data. During this comparison and verification process, the follower node primarily compares whether the network term number, topology version number, and link connection relationships carried in the topology announcement message conflict with existing local records.

[0061] When the network term number in the topology announcement message is inconsistent with the network term number recorded locally, for example, if the follower node has synchronized the new term number corresponding to the new master node elected in the new round, but receives the topology announcement message from the old master node after network delay, the follower node will determine that the message belongs to the expired data of the old term and discard it directly to prevent the outdated information of the old master node from interfering with the operation of the current network topology.

[0062] When the network term number in the topology announcement message matches the local record, but the topology version number is lower than the locally cached topology version number, for example, when the follower node has received a topology announcement message with an updated version number and completed the local topology cache update, but then receives a topology announcement message with an older version number, the follower node determines that the topology information carried in the message is outdated and will no longer use the message to update the local topology cache.

[0063] When the network term number and topology version number in the topology announcement message are both up-to-date and consistent with the local record, the follower node further cross-compares the link connection relationship in the message with the adjacent link information collected locally through the link layer discovery protocol. If the link information in the message conflicts with the physical connection relationship actually collected locally, for example, if the message claims that a certain port is connected to a neighboring device, but the information collected locally shows that the port is actually connected to another device, the follower node determines that the topology information carried in the message is abnormal and does not accept it.

[0064] Only when the network term number in the topology announcement message matches the local record, the topology version number is not lower than the local version, and there are no obvious conflicts in the link connections, will the follower node determine that the comparison and verification has passed, and update its local topology cache using the network topology information carried in the message. For new devices accessing the Layer 2 broadcast domain for the first time, their local topology cache is empty, with no historical data available for comparison. In this case, the new device directly trusts the first received topology announcement message and completes the initialization of its local topology cache. Through the above comparison and verification mechanism, the follower node can effectively filter out outdated topology announcement messages delayed by the master node of the old term, duplicate low-version topology announcement messages, and abnormal messages that may carry incorrect link information. This ensures that the network topology information stored in the local topology cache is always consistent with the overall network topology issued by the master node, avoiding topology view chaos caused by message delays, master node switching, or abnormal link data.

[0065] After confirming the message's validity, the device uses the new network topology information within the message to completely overwrite the original local topology cache. The updated cached data supports the device's local topology visualization function, ensuring, from a data perspective, that the local topology of all following nodes is completely synchronized with the overall network topology issued by the master node.

[0066] S205. If the node role is the master node, it receives the adjacency link information reported by each following node in the Layer 2 broadcast domain, and encapsulates the message based on the adjacency link information to obtain the topology announcement message; and sends the topology announcement message to all non-master nodes in the Layer 2 broadcast domain.

[0067] The method for obtaining a topology announcement message by encapsulating a message based on adjacent link information can be as follows: Extract the original link information from the adjacent link information; perform deduplication on the original link information to obtain preliminary link information; perform bidirectional reconciliation on the data at both ends of the same physical link in the preliminary link information to obtain valid link data; construct a network topology model based on the valid link data; extract information from the network topology model to obtain network topology information; and encapsulate the network topology information into a topology announcement message.

[0068] The raw link information is the unprocessed neighbor link information obtained by the master node from the neighbor reporting message. It includes the reporting device identifier, local port, neighbor device and neighbor port, etc. The same physical link will be reported by the two end devices respectively, so there is duplicate and unverified data.

[0069] Preliminary link information is a set of data obtained by the master node after deduplicating the original link information, eliminating redundant content that is repeatedly reported, but the link legality verification has not yet been completed.

[0070] Two-way reconciliation is a link verification rule that cross-checks the link information reported by devices at both ends of the same physical link. For example, if a switch and a wireless access point are directly connected, the master node will compare the interconnection ports and device identifiers reported by the two devices to determine whether the link record is true and valid.

[0071] Valid link data refers to link data that has been confirmed to exist after deduplication and two-way reconciliation. Records that are inconsistent in reconciliation, reported only on one side and cannot be verified will be removed.

[0072] The network topology model is a graph structure topology built by the master node based on valid link data, with vertices representing devices and edges representing physical links.

[0073] Network topology information includes the identifiers of all devices within the Layer 2 broadcast domain, the physical link connections between devices, and the current effective network term number. This information is extracted by the master node from the overall network topology model and encapsulated in a topology announcement message before being sent out. Follower nodes can reconstruct the exact same network topology information by parsing the topology announcement message. Device identifiers are used to uniquely distinguish different network devices within the domain, preferably using the device's Media Access Control Address (MAC).

[0074] For example, once a device is identified as the master node, it becomes the core of topology data aggregation, processing, and distribution within the entire Layer 2 broadcast domain. The entire data processing, modeling, and message delivery process will be executed cyclically as a resident task, continuously responding to changes in the entire network link and ensuring real-time synchronization of topology data.

[0075] During the link data reception and preprocessing phase, the master node monitors all adjacency reporting messages sent by all follower nodes within the domain around the clock, collects all adjacent link information reported by follower nodes, and extracts the raw link information. Since a single physical link is reported separately by follower nodes at both ends, and some devices periodically report repeatedly, the collected raw link information contains a large amount of duplicate data. Therefore, the master node first performs global deduplication on all raw link information, eliminating redundant content from the same source and in duplicate reports, thus simplifying the data to obtain preliminary link information.

[0076] After deduplication, the master node performs bidirectional reconciliation and verification on the initial link information. This is a crucial step in ensuring the authenticity and validity of link data. Based on device identifiers and port information, the master node performs correlation matching, cross-checking two sets of reported data belonging to the same physical link. Only data where both ends can corroborate each other is considered valid link data. Abnormal records with mismatched information on one end are directly filtered and discarded to prevent false links from affecting the accuracy of the topology.

[0077] After data verification, the master node uses the device identifiers of all devices in the network as topology vertices and the filtered valid link data as topology edges to build a complete network topology model according to graph structure rules, intuitively reproducing the physical connection relationships of all devices in the domain. Once the network port status or device interconnection relationship changes, the new adjacent link information will be pushed to the master node in real time, triggering a dynamic update of the network topology model.

[0078] After the network topology model is updated, the master node extracts the structured network topology information from the model and encapsulates it into a topology announcement message according to a unified message format. Finally, the master node sends the message outward using Layer 2 multicast. This transmission method allows all candidate nodes and follower nodes within the Layer 2 broadcast domain to receive data synchronously, achieving a unified network topology view. The entire process operates in a closed loop, solving the problems of messy and unreliable data reported by multiple devices, and ensuring that all nodes in the network receive a consistent and up-to-date network topology through standardized messages and comparison verification.

[0079] After the master node re-election is completed, the new master node can request all network devices to re-report adjacent link information, and can also temporarily freeze the topology message distribution during the handover window to avoid temporary inconsistencies in the network topology; at the same time, the network term number is used to distinguish between the old and new master nodes, and receiving devices can directly discard delayed messages with mismatched term numbers.

[0080] Based on the above, the local network topology generation method collects role status data, term data, and heartbeat verification data, combining these three types of data to determine device identity. It divides all network devices into master nodes, candidate nodes, and follower nodes, with each role performing corresponding tasks. Candidate nodes listen to candidate messages and master node heartbeat messages; follower nodes complete link information collection and reporting, and local topology cache updates; master nodes process adjacent link information, encapsulate topology announcement messages, and distribute them externally. This entire operating mode allows network devices to perform their respective functions, with various related functions cooperating to carry out their work. Adjacent link information in the network can be centrally aggregated and processed, ensuring all network devices obtain the same topology content and maintain a consistent topology view. Simultaneously, various business processes operate seamlessly, reducing redundant data interaction and repetitive calculations within the network, addressing the shortcomings of the original operating mode, and improving the overall efficiency of network topology detection and data synchronization.

[0081] The above text combined Figures 1 to 2 The local network topology generation method provided in the embodiments of this application has been described in detail. The apparatus and devices provided in the embodiments of this application will be described below with reference to the accompanying drawings.

[0082] This application also provides a local network topology generation device, such as... Figure 3 As shown, this figure is a structural diagram of a local network topology generation device provided in an embodiment of this application. The device includes: The acquisition module 301 is used to acquire role status data, tenure data, and heartbeat verification data. The role determination module 302 is used to determine the node role based on the role status data, term data, and heartbeat verification data; wherein, the node role includes the master node, the candidate node, and the follower node; The topology generation module 303 is used to continuously listen to candidate messages and heartbeat messages of the master node in the Layer 2 broadcast domain if the node role is a candidate node; if the node role is a follower node, it collects adjacent link information based on the link layer discovery protocol and reports the adjacent link information to the master node; it receives the topology announcement message sent by the master node and updates the local topology cache based on the topology announcement message; if the node role is the master node, it receives the adjacent link information reported by each follower node in the Layer 2 broadcast domain, encapsulates the message based on the adjacent link information to obtain the topology announcement message; and sends the topology announcement message to all non-master nodes in the Layer 2 broadcast domain.

[0083] In some possible implementations, the topology generation module 303 is specifically used for: After detecting that the master node's heartbeat message is valid, the link layer discovery protocol is enabled; The Link Layer Discovery Protocol (LLDIP) receives LLDIP messages and determines neighboring devices and their corresponding port information based on these messages; the neighboring devices and their corresponding port information are then used as adjacent link information.

[0084] In some possible implementations, the topology generation module 303 is specifically used for: Generate an adjacency record table based on the adjacent link information; Encapsulate the adjacency record table into an adjacency reporting message; The adjacency reporting message is sent to the master node via Layer 2 multicast.

[0085] In some possible implementations, the topology generation module 303 is specifically used for: The network topology information is obtained by parsing the topology announcement message; The network topology information is compared and verified with the locally cached data; Update the local topology cache based on the verified network topology information.

[0086] In some possible implementations, the topology generation module 303 is specifically used for: Extract the original link information from the adjacent link information; The original link information is deduplicated to obtain preliminary link information; Perform bidirectional reconciliation of the data at both ends of the same physical link in the preliminary link information to obtain valid link data; Construct a network topology model based on valid link data; Information is extracted from the entire network topology model to obtain network topology information; Network topology information is encapsulated into topology announcement messages.

[0087] In some possible implementations, module 301 is specifically used for: Listen for master node election protocol messages transmitted within the Layer 2 broadcast domain; Parse the master node election protocol message to obtain the local role identifier, network term number, and heartbeat message validity verification result; Based on the local role identifier, network term number, and heartbeat message validity verification results, determine the role status data, term data, and heartbeat verification data.

[0088] The local network topology generation apparatus according to the embodiments of this application can correspond to the execution of the method described in the embodiments of this application, and the other operations and / or functions of each module / unit of the local network topology generation apparatus are respectively for implementing Figure 2 For the sake of brevity, the corresponding processes of each method in the illustrated embodiments will not be described in detail here.

[0089] This application also provides a computing device. For example... Figure 4 As shown in the figure, this is a schematic diagram of a computing device provided in an embodiment of this application. The computing device 400 includes a bus 401, a processor 402, a communication interface 403, and a memory 404. The processor 402, the memory 404, and the communication interface 403 communicate with each other via the bus 401.

[0090] Bus 401 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 4 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0091] Processor 402 can be any one or more of the following processors: central processing unit (CPU), graphics processing unit (GPU), microprocessor (MP), or digital signal processor (DSP).

[0092] Communication interface 403 is used for communication with external devices.

[0093] Memory 404 may include volatile memory, such as random access memory (RAM). Memory 404 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).

[0094] The memory 404 stores executable code, and the processor 402 executes the executable code to perform the aforementioned local network topology generation method.

[0095] Specifically, in achieving Figure 3 In the case of the illustrated embodiment, and Figure 3 When the modules or units of the local network topology generation device described in the embodiments are implemented by software, the following steps are performed: Figure 3 The software or program code required for the functions of each module / unit can be partially or wholly stored in memory 404. Processor 402 executes the program code corresponding to each unit stored in memory 404 to execute the aforementioned local network topology generation method.

[0096] This application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium capable of being stored by a computing device, or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive). The computer-readable storage medium includes instructions that instruct the computing device to execute the aforementioned local network topology generation method.

[0097] This application also provides a computer program product comprising one or more computer instructions. When the computer instructions are loaded and executed on a computing device, all or part of the processes or functions described in this application are generated.

[0098] The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, or data center to another website, computer, or data center via wired (e.g., coaxial cable, fiber optic) or wireless (e.g., infrared, wireless, microwave, etc.) means.

[0099] When the computer program product is executed by a computer, the computer performs any of the aforementioned local network topology generation methods. The computer program product can be a software installation package; when any of the aforementioned local network topology generation methods needs to be used, the computer program product can be downloaded and executed on the computer.

[0100] The descriptions of the processes or structures corresponding to the above figures each have their own emphasis. For parts of a process or structure that are not described in detail, please refer to the relevant descriptions of other processes or structures.

[0101] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be covered within the scope of protection of this application.

Claims

1. A method of local network topology generation, characterized by, The method includes: Acquire role status data, tenure data, and heartbeat verification data; Node roles are determined based on role status data, term data, and heartbeat verification data; wherein, the node roles include master nodes, candidate nodes, and follower nodes; If the node role is a candidate node, it will continuously listen for candidate messages and heartbeat messages of the master node in the Layer 2 broadcast domain; If the node role is a follower node, it collects adjacent link information based on the link layer discovery protocol and reports the adjacent link information to the master node; it receives the topology announcement message issued by the master node and updates the local topology cache based on the topology announcement message; If a node is a master node, it receives the adjacency link information reported by each following node in the Layer 2 broadcast domain, encapsulates the message based on the adjacency link information to obtain a topology announcement message, and sends the topology announcement message to all non-master nodes in the Layer 2 broadcast domain.

2. The method according to claim 1, characterized in that, The process of collecting adjacent link information based on the link layer discovery protocol and reporting the adjacent link information to the master node includes: After detecting that the master node's heartbeat message is valid, the link layer discovery protocol is enabled; The Link Layer Discovery Protocol (LLDIP) receives LLDIP messages and determines neighboring devices and their corresponding port information based on these messages; the neighboring devices and their corresponding port information are then used as adjacent link information.

3. The method according to claim 1, characterized in that, The step of reporting the adjacent link information to the master node includes: Generate an adjacency record table based on the adjacent link information; Encapsulate the adjacency record table into an adjacency reporting message; The adjacency reporting message is sent to the master node via Layer 2 multicast.

4. The method according to claim 1, characterized in that, The update of the local topology cache based on the topology announcement message includes: The network topology information is obtained by parsing the topology announcement message; The network topology information is compared and verified with the locally cached data; Update the local topology cache based on the verified network topology information.

5. The method according to claim 1, characterized in that, The topology announcement message obtained by encapsulating messages based on adjacent link information includes: Extract the original link information from the adjacent link information; The original link information is deduplicated to obtain preliminary link information; Perform bidirectional reconciliation of the data at both ends of the same physical link in the preliminary link information to obtain valid link data; Construct a network topology model based on valid link data; Information is extracted from the entire network topology model to obtain network topology information; Network topology information is encapsulated into topology announcement messages.

6. The method according to claim 1, characterized in that, The acquisition of role status data, term data, and heartbeat verification data includes: Listen for master node election protocol messages transmitted within the Layer 2 broadcast domain; Parse the master node election protocol message to obtain the local role identifier, network term number, and heartbeat message validity verification result; Based on the local role identifier, network term number, and heartbeat message validity verification result, the role status data, term data, and heartbeat verification data are determined.

7. A local network topology generation device, characterized in that, The device includes: The acquisition module is used to acquire role status data, tenure data, and heartbeat verification data; The role determination module is used to determine node roles based on role status data, term data, and heartbeat verification data; wherein, the node roles include master nodes, candidate nodes, and follower nodes; The topology generation module is used to continuously listen for candidate messages and heartbeat messages from the master node in the Layer 2 broadcast domain if the node's role is a candidate node; if the node's role is a follower node, it collects adjacent link information based on the link layer discovery protocol and reports the adjacent link information to the master node; it receives topology announcement messages from the master node and updates the local topology cache based on the topology announcement messages; if the node's role is the master node, it receives adjacent link information reported by each follower node in the Layer 2 broadcast domain, encapsulates the messages based on the adjacent link information to obtain topology announcement messages; and sends the topology announcement messages to all non-master nodes in the Layer 2 broadcast domain.

8. A computing device, characterized in that, Including memory and processor; The memory stores one or more computer programs, the one or more computer programs including instructions; when the instructions are executed by the processor, the computing device performs the method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store a computer program for performing the method as described in any one of claims 1 to 6.

10. A computer program product, characterized in that, The computer program product includes one or more computer instructions that, when executed by a computer, perform the method as described in any one of claims 1 to 6.