Method and device for determining topology relationship of multi-machine cluster, electronic equipment and storage medium
By enabling devices to autonomously create and update topology relationship record tables, the problem of master device dependence in existing technologies is solved, and a fast and simplified communication connection is achieved in a multi-machine cluster system where devices autonomously learn network topology relationships.
Patent Information
- Application Number
- CN202311791153.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-22
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-12-22
AI Technical Summary
Existing technologies in multi-machine cluster systems require the selection of a master device to collect and transmit topology relationships, which increases the complexity of communication connections and makes it difficult for devices to quickly learn about network topology relationships, especially under bandwidth-limited conditions.
Each device creates a topology record table based on its own information, receives data packets from neighboring devices to update the topology, periodically checks whether neighboring devices have sent topology record tables, and updates or deletes entries as necessary, enabling devices to autonomously learn network topology.
Without needing to select a master device, the device can quickly and autonomously learn and maintain network topology relationships, simplifying communication connections and improving the efficiency of topology acquisition under bandwidth-constrained conditions.
Smart Images

Figure CN117729117B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network communication, and more specifically, to a method, apparatus, electronic device, and storage medium for determining the topology of a multi-machine cluster. Background Technology
[0002] With the widespread adoption of networks and various services, stacked cluster systems are increasingly being used in daily life. In the development of multi-machine cluster systems, each cluster member device needs to understand the status of other devices besides itself in order to send data packets to the appropriate member device for processing. In other words, each cluster member device needs to understand the network topology. To address this, existing technology provides a stacked cluster topology collection technique. This technique requires selecting a master device, which collects the topology and distributes it to other member devices. Summary of the Invention
[0003] The purpose of this application is to provide a method, apparatus, electronic device, and storage medium for determining the topology of a multi-machine cluster, so as to enable member devices in a multi-machine cluster to actively learn the network topology without the need to select a master device, thereby achieving rapid completion of multi-machine cluster topology learning.
[0004] In a first aspect, the present invention provides a method for determining the topology of a multi-machine cluster, the method comprising:
[0005] A first topology relationship record table is created based on the device's own information. The initial data of the first topology relationship record table includes the device number of the device, the path length of the device, and the MAC address of the device.
[0006] Receive data packets sent by neighboring devices, wherein the data packets carry topology information, including the device number of the neighboring device, the path length of the neighboring device, and the MAC address of the neighboring device;
[0007] The first topology record table is updated based on the device number, path length, and MAC address of the neighboring device.
[0008] The system periodically determines whether the neighboring device has sent a second topology relationship record table. If the neighboring device has sent the second topology relationship record table, the system receives the second topology relationship record table and updates the first topology relationship record table based on the second topology relationship record table. If the neighboring device has not sent the second topology relationship record table, the system deletes the neighbor entries in the first topology relationship record table.
[0009] This application can create a first topology relationship record table based on its own device information. The initial data of the first topology relationship record table includes the device ID, path length, and MAC address of the device itself. It can also receive data packets sent by neighboring devices, where each data packet carries topology information, including the device ID, path length, and MAC address of the neighboring devices. Furthermore, it can update the first topology relationship record table based on the device ID, path length, and MAC address of the neighboring devices. It can also periodically determine whether a neighboring device has sent a second topology relationship record table. If a neighboring device has sent a second topology relationship record table, it receives the second topology relationship record table and updates the first topology relationship record table based on it. If a neighboring device has not sent a second topology relationship record table, it deletes the neighbor entry in the first topology relationship record table. Finally, by updating and maintaining the first topology relationship record table, it can automatically learn the device topology relationships in the network. Compared with existing technologies, this application does not require selecting a master device, nor does it require a master device to inform other member devices of the device topology relationships in the network.
[0010] In an optional implementation, after updating the first topology record table based on the second topology record table, or after deleting neighbor entries in the first topology record table, the method further includes:
[0011] The first topology record table is periodically sent to the neighboring devices.
[0012] This optional implementation can periodically send the first topology relationship record table to the neighboring devices, thereby enabling the neighboring devices to update their own record tables based on the first topology relationship record table, and enabling the neighboring devices to automatically learn the device topology relationships in the network.
[0013] In an optional implementation, updating the first topology relationship record table based on the second topology relationship record table includes:
[0014] The first device number is determined based on the second topology relationship record table, wherein the first device number is a device number that is not recorded in the first topology relationship record table;
[0015] Increment the path length associated with the first device number by one;
[0016] The first topology record table is updated based on the first device number, the path length associated with the first device number, and the MAC address associated with the first device number.
[0017] This optional implementation can determine the first device number based on the second topology relationship record table, wherein the first device number is a device number not recorded in the first topology relationship record table. Then, by adding one to the path length associated with the first device number, the first topology relationship record table can be updated based on the first device number, the path length associated with the first device number, and the MAC address associated with the first device number, so that the first topology relationship record table accurately records the information of neighboring devices.
[0018] In an optional implementation, updating the first topology relationship record table based on the second topology relationship record table includes:
[0019] The second device number is determined based on the second topology relationship record table, wherein the second device number is the device number that is recorded in the first topology relationship record table;
[0020] The path length associated with the second device number in the second topology record table is taken as the first path length of the second device number, and the first path length of the second device number is reduced by one.
[0021] Compare the first path length of the second device number with the second path length of the second device number, wherein the second path length of the second device number is the path length associated with the second device number in the first topology record table;
[0022] When the first path length of the second device number is not equal to the second path length of the second device number, the second path length of the second device number is updated based on the first path length of the second device number.
[0023] This optional implementation can determine the second device number based on the second topology relationship record table, wherein the second device number is the device number recorded in the first topology relationship record table. Then, by using the path length associated with the second device number in the second topology relationship record table as the first path length of the second device number, and subtracting one from the first path length of the second device number, the first path length of the second device number can be compared with the second path length of the second device number, wherein the second path length of the second device number is the path length associated with the second device number in the first topology relationship record table. Thus, when the first path length of the second device number is not equal to the second path length of the second device number, the second path length of the second device number is updated based on the first path length of the second device number, ultimately avoiding recording the same data in the first topology relationship record table.
[0024] Secondly, the present invention provides a device for determining the topology of a multi-machine cluster, the device comprising:
[0025] A creation module is used to create a first topology relationship record table based on the device's own information. The initial data of the first topology relationship record table includes the device number of the device, the path length of the device, and the MAC address of the device.
[0026] A receiving module is used to receive data packets sent by neighboring devices, wherein the data packets carry topology information, including the device number of the neighboring device, the path length of the neighboring device, and the MAC address of the neighboring device;
[0027] The update module is used to update the first topology record table based on the device number of the neighboring device, the path length of the neighboring device, and the MAC address of the neighboring device;
[0028] The judgment module is used to periodically determine whether the neighboring device has sent the second topology relationship record table. If the neighboring device has sent the second topology relationship record table, the module receives the second topology relationship record table and updates the first topology relationship record table based on the second topology relationship record table. If the neighboring device has not sent the second topology relationship record table, the module deletes the neighbor table entries in the first topology relationship record table.
[0029] This application can create a first topology relationship record table based on its own device information. The initial data of the first topology relationship record table includes the device ID, path length, and MAC address of the device itself. It can also receive data packets sent by neighboring devices, where each data packet carries topology information, including the device ID, path length, and MAC address of the neighboring devices. Furthermore, it can update the first topology relationship record table based on the device ID, path length, and MAC address of the neighboring devices. It can also periodically determine whether a neighboring device has sent a second topology relationship record table. If a neighboring device has sent a second topology relationship record table, it receives the second topology relationship record table and updates the first topology relationship record table based on it. If a neighboring device has not sent a second topology relationship record table, it deletes the neighbor entry in the first topology relationship record table. Finally, by updating and maintaining the first topology relationship record table, it can automatically learn the device topology relationships in the network. Compared with existing technologies, this application does not require selecting a master device, nor does it require a master device to inform other member devices of the device topology relationships in the network.
[0030] In an optional embodiment, the apparatus further includes:
[0031] The sending module is configured to periodically send the first topology relationship record table to the neighboring device after the first topology relationship record table is updated based on the second topology relationship record table, or after the neighbor table entry in the first topology relationship record table is deleted.
[0032] This optional implementation can periodically send the first topology relationship record table to the neighboring devices, thereby enabling the neighboring devices to update their own record tables based on the first topology relationship record table, and enabling the neighboring devices to automatically learn the device topology relationships in the network.
[0033] In an optional implementation, the determination module includes:
[0034] The first determining submodule is used to determine the first device number based on the second topology relationship record table, wherein the first device number is a device number that is not recorded in the first topology relationship record table;
[0035] The first calculation submodule is used to add one to the path length associated with the first device number;
[0036] The first update submodule is used to update the first topology record table based on the first device number, the path length associated with the first device number, and the MAC address associated with the first device number.
[0037] This optional implementation can determine the first device number based on the second topology relationship record table, wherein the first device number is a device number not recorded in the first topology relationship record table. Then, by adding one to the path length associated with the first device number, the first topology relationship record table can be updated based on the first device number, the path length associated with the first device number, and the MAC address associated with the first device number, so that the first topology relationship record table accurately records the information of neighboring devices.
[0038] In an optional implementation, the determination module includes:
[0039] The second determining submodule is used to determine the second device number based on the second topology relationship record table, wherein the second device number is the device number that is recorded in the first topology relationship record table;
[0040] The second calculation submodule is used to take the path length associated with the second device number in the second topology relationship record table as the first path length of the second device number, and to subtract one from the first path length of the second device number;
[0041] The comparison submodule is used to compare the first path length of the second device number with the second path length of the second device number, wherein the second path length of the second device number is the path length associated with the second device number in the first topology relationship record table;
[0042] The second update submodule is used to update the second path length of the second device number based on the first path length of the second device number when the first path length of the second device number is not equal to the second path length of the second device number.
[0043] This optional implementation can determine the second device number based on the second topology relationship record table, wherein the second device number is the device number recorded in the first topology relationship record table. Then, by using the path length associated with the second device number in the second topology relationship record table as the first path length of the second device number, and subtracting one from the first path length of the second device number, the first path length of the second device number can be compared with the second path length of the second device number, wherein the second path length of the second device number is the path length associated with the second device number in the first topology relationship record table. Thus, when the first path length of the second device number is not equal to the second path length of the second device number, the second path length of the second device number is updated based on the first path length of the second device number, ultimately avoiding recording the same data in the first topology relationship record table.
[0044] Thirdly, the present invention provides an electronic device, comprising:
[0045] Processor; and
[0046] The memory is configured to store machine-readable instructions that, when executed by the processor, perform the multi-machine cluster topology determination method as described in any of the foregoing embodiments.
[0047] The electronic device of this application, by executing a multi-machine cluster topology relationship determination method, can create a first topology relationship record table based on its own device information. The initial data of the first topology relationship record table includes the device ID, path length, and MAC address of the device itself. It can also receive data packets sent by neighboring devices, where each data packet carries topology information, including the device ID, path length, and MAC address of the neighboring devices. Furthermore, it can update the first topology relationship record table based on the device ID, path length, and MAC address of the neighboring devices. It can also periodically determine whether a neighboring device has sent a second topology relationship record table. If a neighboring device has sent a second topology relationship record table, it receives the second topology relationship record table and updates the first topology relationship record table based on it. If a neighboring device has not sent a second topology relationship record table, it deletes the neighbor entry in the first topology relationship record table. Finally, by updating and maintaining the first topology relationship record table, it can automatically learn the device topology relationships in the network. Compared with existing technologies, this application does not require selecting a master device, nor does it require a master device to inform other member devices of the device topology relationships in the network.
[0048] Fourthly, the present invention provides a storage medium storing a computer program, the computer program being executed by a processor using the multi-machine cluster topology determination method as described in any of the foregoing embodiments.
[0049] The storage medium of this application, by executing a multi-machine cluster topology relationship determination method, can create a first topology relationship record table based on its own device information. The initial data of the first topology relationship record table includes the device number, path length, and MAC address of the device itself. It can also receive data packets sent by neighboring devices, where each data packet carries topology information, including the device number, path length, and MAC address of the neighboring devices. Furthermore, it can update the first topology relationship record table based on the device number, path length, and MAC address of the neighboring devices. It can also periodically determine whether a neighboring device has sent a second topology relationship record table. If a neighboring device has sent a second topology relationship record table, it receives the second topology relationship record table and updates the first topology relationship record table based on it. If a neighboring device has not sent a second topology relationship record table, it deletes the neighbor entry in the first topology relationship record table. Finally, by updating and maintaining the first topology relationship record table, it can automatically learn the device topology relationships in the network. Compared with existing technologies, this application does not require the selection of a master device, nor does it require other member devices to know the device topology in the network through the master device. Attached Figure Description
[0050] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0051] Figure 1 This is a flowchart illustrating a method for determining the topology of a multi-machine cluster disclosed in an embodiment of this application;
[0052] Figure 2 This is a schematic diagram of the structure of a multi-machine cluster topology determination device disclosed in an embodiment of this application;
[0053] Figure 3 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of this application. Detailed Implementation
[0054] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.
[0055] Example 1
[0056] Please see Figure 1 , Figure 1This is a flowchart illustrating a method for determining the topology of a multi-machine cluster disclosed in an embodiment of this application, as shown below. Figure 1 As shown, the method in this application embodiment includes the following steps:
[0057] 101. Create a first topology relationship record table based on its own device information, wherein the initial data of the first topology relationship record table includes the device number of its own device, the path length of its own device, and the MAC address of its own device;
[0058] 102. Receive data packets sent by neighboring devices, wherein the data packets carry topology information, including the device number of the neighboring device, the path length of the neighboring device, and the MAC address of the neighboring device;
[0059] 103. Update the first topology record table based on the device ID, path length, and MAC address of the neighboring device;
[0060] 104. Periodically determine whether the neighboring device has sent the second topology relationship record table. If the neighboring device has sent the second topology relationship record table, receive the second topology relationship record table and update the first topology relationship record table based on the second topology relationship record table. If the neighboring device has not sent the second topology relationship record table, delete the neighbor table entry in the first topology relationship record table.
[0061] This application embodiment can create a first topology relationship record table based on its own device information. The initial data of the first topology relationship record table includes the device ID, path length, and MAC address of the device itself. It can also receive data packets sent by neighboring devices, where each data packet carries topology information, including the device ID, path length, and MAC address of the neighboring devices. Furthermore, it can update the first topology relationship record table based on the device ID, path length, and MAC address of the neighboring devices. It can also periodically determine whether a neighboring device has sent a second topology relationship record table. If a neighboring device has sent a second topology relationship record table, it receives the second topology relationship record table and updates the first topology relationship record table accordingly. If a neighboring device has not sent a second topology relationship record table, the neighbor entry in the first topology relationship record table is deleted. Finally, by updating and maintaining the first topology relationship record table, the device topology relationships in the network can be automatically learned. Compared with existing technologies, this application does not require selecting a master device, nor does it require a master device to inform other member devices of the device topology relationships in the network.
[0062] In this embodiment, as an example, dummy devices A, B, and C constitute a multi-machine cluster network. Device A needs to learn the topology of the multi-machine cluster network. Device A cannot communicate directly with device C, while device B communicates directly with both devices A and C. To address this, existing technologies first select a device as the master device, for example, device B. Then, device B informs device C of device A's status, and device B informs device A of device C's status. Thus, in this existing technology, a master device needs to be selected. Furthermore, this method of informing devices of the network topology through the master device has the following problems in some scenarios. For example, it requires all devices to be connected to the master device, which increases the complexity of communication connections. In addition, it can cause some devices to be unable to quickly learn the network topology, especially under bandwidth-limited conditions. The master device needs to notify each device sequentially, and some devices, due to bandwidth limitations, cannot interact with the master device in a timely manner. Therefore, the devices cannot know the status of other devices. To address this scenario, this application enables devices to build their own topology relationship record table. This table allows them to understand the status of other devices and update their own record table based on the record tables of neighboring devices, thus automatically learning the network topology and quickly understanding it. In the same example, device A can update its own record table based on device B's record table. Since device B's record table can be updated based on device C's record table, device A's updated record table also records device C's information. Finally, through this network connection, device A can learn the status of all devices through its own record table. In this process, it is not necessary to determine the master device, thereby avoiding various problems caused by the need to determine the master device.
[0063] In this embodiment, a multi-machine cluster refers to a cluster composed of multiple computer devices working collaboratively, such as a cluster composed of 100 computer devices. Furthermore, the multi-machine cluster topology refers to the network connection relationship between computer devices and other computer devices within the multi-machine cluster.
[0064] In this embodiment of the application, for step 101, "self-device" refers to the computer device running the multi-machine cluster topology relationship determination method in the multi-machine cluster, wherein the self-device can be any computer device in the multi-machine cluster.
[0065] In this embodiment of the application, for step 101, please refer to Table 1, which is a first topology relationship record table. As shown in Table 1, the initial data of the first topology relationship record table includes the device number of the device itself, the path length of the device itself, and the MAC address of the device itself.
[0066] Equipment Number Path length MAC address A 0 M1
[0067] Table 1
[0068] In this embodiment of the application, for step 102, the computer devices in the multi-machine cluster can negotiate with neighboring devices in advance the data that the message needs to carry and the format of the data, so that the two can transmit messages carrying device number, path length and MAC address through the protocol.
[0069] In this embodiment of the application, for steps 102 and 103, the neighboring device refers to a computer device that is directly connected to the device itself. By receiving the device number, path length and MAC address of the neighboring device, the device itself can record the neighboring devices that are directly connected to it.
[0070] In this embodiment of the application, for step 104, periodically determining whether the neighboring device sends the second topology relationship record table can mean determining whether the neighboring device sends the second topology relationship record table every day, or it can mean determining whether the neighboring device sends the second topology relationship record table every week. This embodiment of the application does not limit the specific setting of the period.
[0071] In this embodiment of the application, regarding step 104, if the neighboring device sends the second topology relationship record table within the period, it indicates that the neighboring device is active within the period. If the neighboring device does not send the second topology relationship record table within the period, it indicates that the neighboring device is inactive within the period. At this time, the relevant information of the neighboring device can be deleted from the first topology relationship record table to ensure that the first topology relationship record table records the active neighboring device.
[0072] In this embodiment of the application, deleting a neighbor entry in the first topology relationship record table means deleting the data related to the neighboring device in the first topology relationship record table. This related data includes the device number, MAC address, and path length.
[0073] In an optional implementation, after updating the first topology record table based on the second topology record table, or after deleting neighbor entries in the first topology record table, the method of this application embodiment further includes the following steps:
[0074] The first topology record table is periodically sent to neighboring devices.
[0075] This optional implementation can periodically send the first topology relationship record table to neighboring devices, thereby enabling neighboring devices to update their own record tables based on the first topology relationship record table, and enabling neighboring devices to automatically learn the device topology relationships in the network.
[0076] For the above optional implementation methods, periodically sending the first topology relationship record table to the neighboring device can mean sending the first topology relationship record table to the neighboring device every other record, or every week.
[0077] In an optional implementation, the step of updating the first topology relationship record table based on the second topology relationship record table includes:
[0078] The first device number is determined based on the second topology relationship record table, wherein the first device number is a device number that is not recorded in the first topology relationship record table;
[0079] Increment the path length associated with the first device number by one;
[0080] The first topology record table is updated based on the first device number, the path length associated with the first device number, and the MAC address associated with the first device number.
[0081] This optional implementation can determine the first device number based on the second topology relationship record table, wherein the first device number is a device number not recorded in the first topology relationship record table. Then, by adding one to the path length associated with the first device number, the first topology relationship record table can be updated based on the first device number, the path length associated with the first device number, and the MAC address associated with the first device number, so that the first topology relationship record table accurately records the information of neighboring devices.
[0082] For the above optional implementation methods, please refer to Tables 1, 2, and 3 as examples. Table 1 is a first topology relationship record table, Table 2 is a second topology relationship record table, and Table 3 is an updated first topology relationship record table. As shown in Tables 1 and 2, in the second topology relationship record table, the path length associated with device number B is 0, that is, the path length of device B relative to itself is 0. Based on this, if the first topology relationship record table is updated based on the second topology relationship record table to obtain the updated first topology relationship record table, then in the updated first topology relationship record table shown in Table 3, the path length of device number B is updated to 1, that is, the path length of device number B is increased by 1. In this way, the updated first topology relationship record table can accurately record the path length between device B and device A, avoiding recording the path length of device B as 0 in the updated first topology relationship record table.
[0083] Equipment Number Path length MAC address B 0 M2 A 1 M1 C 1 M3
[0084] Table 2
[0085] Equipment Number Path length MAC address A 0 M1 B 1 M2 C 2 M3
[0086] Table 3
[0087] In an optional implementation, the step of updating the first topology relationship record table based on the second topology relationship record table further includes the following sub-steps:
[0088] The second device number is determined based on the second topology relationship record table, wherein the second device number is the device number that is recorded in the first topology relationship record table;
[0089] The path length associated with the second device number in the second topology record table is used as the first path length of the second device number, and the first path length of the second device number is reduced by one.
[0090] Compare the first path length of the second device number with the second path length of the second device number, where the second path length of the second device number is the path length associated with the second device number in the first topology record table;
[0091] When the first path length of the second device number is not equal to the second path length of the second device number, the second path length of the second device number is updated based on the first path length of the second device number.
[0092] This optional implementation can determine the second device number based on the second topology relationship record table, wherein the second device number is the device number recorded in the first topology relationship record table. Then, by using the path length associated with the second device number in the second topology relationship record table as the first path length of the second device number, and subtracting one from the first path length of the second device number, the first path length of the second device number can be compared with the second path length of the second device number, wherein the second path length of the second device number is the path length associated with the second device number in the first topology relationship record table. Thus, when the first path length of the second device number is not equal to the second path length of the second device number, the second path length of the second device number is updated based on the first path length of the second device number, ultimately avoiding recording the same data in the first topology relationship record table.
[0093] Regarding the above optional implementation method, please further refer to Tables 1, 2 and 3. Tables 1 and 2 simultaneously record the path length of device number A, that is, the first topology relationship record table and the second topology relationship record table simultaneously record the path length of device number A. At this time, subtracting 1 from the path length of device number A recorded in the second topology relationship record table results in the same path length of device number A recorded in the first topology relationship record table. Therefore, it is not necessary to update the information of device number A recorded in the second topology relationship record table to the first topology relationship record table.
[0094] Example 2
[0095] Please see Figure 2 , Figure 2This is a schematic diagram of the structure of a multi-machine cluster topology determination device disclosed in an embodiment of this application, as shown below. Figure 2 As shown, the apparatus in this embodiment includes the following functional modules:
[0096] The creation module 201 is used to create a first topology relationship record table based on its own device information. The initial data of the first topology relationship record table includes the device number of its own device, the path length of its own device, and the MAC address of its own device.
[0097] The receiving module 202 is used to receive data packets sent by neighboring devices. The data packets carry topology information, which includes the device number of the neighboring device, the path length of the neighboring device, and the MAC address of the neighboring device.
[0098] Update module 203 is used to update the first topology record table based on the device number of the neighboring device, the path length of the neighboring device, and the MAC address of the neighboring device;
[0099] The judgment module 204 is used to periodically determine whether the neighboring device has sent the second topology relationship record table. If the neighboring device has sent the second topology relationship record table, the module receives the second topology relationship record table and updates the first topology relationship record table based on the second topology relationship record table. If the neighboring device has not sent the second topology relationship record table, the module deletes the neighbor table entries in the first topology relationship record table.
[0100] This application embodiment can create a first topology relationship record table based on its own device information. The initial data of the first topology relationship record table includes the device ID, path length, and MAC address of the device itself. It can also receive data packets sent by neighboring devices, where each data packet carries topology information, including the device ID, path length, and MAC address of the neighboring devices. Furthermore, it can update the first topology relationship record table based on the device ID, path length, and MAC address of the neighboring devices. It can also periodically determine whether a neighboring device has sent a second topology relationship record table. If a neighboring device has sent a second topology relationship record table, it receives the second topology relationship record table and updates the first topology relationship record table accordingly. If a neighboring device has not sent a second topology relationship record table, the neighbor entry in the first topology relationship record table is deleted. Finally, by updating and maintaining the first topology relationship record table, the device topology relationships in the network can be automatically learned. Compared with existing technologies, this application does not require selecting a master device, nor does it require a master device to inform other member devices of the device topology relationships in the network.
[0101] In optional embodiments, the apparatus of this application further includes the following functional modules:
[0102] The sending module is used to periodically send the first topology relationship record table to neighboring devices after updating the first topology relationship record table based on the second topology relationship record table, or after deleting neighbor entries in the first topology relationship record table.
[0103] This optional implementation can periodically send the first topology relationship record table to neighboring devices, thereby enabling neighboring devices to update their own record tables based on the first topology relationship record table, and enabling neighboring devices to automatically learn the device topology relationships in the network.
[0104] In an optional implementation, the determination module includes the following sub-functional modules:
[0105] The first determining submodule is used to determine the first device number based on the second topology relationship record table, wherein the first device number is a device number that is not recorded in the first topology relationship record table;
[0106] The first calculation submodule is used to add one to the path length associated with the first device number;
[0107] The first update submodule is used to update the first topology record table based on the first device number, the path length associated with the first device number, and the MAC address associated with the first device number.
[0108] This optional implementation can determine the first device number based on the second topology relationship record table, wherein the first device number is a device number not recorded in the first topology relationship record table. Then, by adding one to the path length associated with the first device number, the first topology relationship record table can be updated based on the first device number, the path length associated with the first device number, and the MAC address associated with the first device number, so that the first topology relationship record table accurately records the information of neighboring devices.
[0109] In an optional implementation, the determination module further includes the following sub-functional modules:
[0110] The second determination submodule is used to determine the second device number based on the second topology relationship record table, wherein the second device number is the device number that is recorded in the first topology relationship record table;
[0111] The second calculation submodule is used to take the path length associated with the second device number in the second topology record table as the first path length of the second device number, and to subtract one from the first path length of the second device number.
[0112] The comparison submodule is used to compare the first path length of the second device number with the second path length of the second device number, wherein the second path length of the second device number is the path length associated with the second device number in the first topology relationship record table;
[0113] The second update submodule is used to update the second path length of the second device number based on the first path length of the second device number when the first path length of the second device number is not equal to the second path length of the second device number.
[0114] This optional implementation can determine the second device number based on the second topology relationship record table, wherein the second device number is the device number recorded in the first topology relationship record table. Then, by using the path length associated with the second device number in the second topology relationship record table as the first path length of the second device number, and subtracting one from the first path length of the second device number, the first path length of the second device number can be compared with the second path length of the second device number, wherein the second path length of the second device number is the path length associated with the second device number in the first topology relationship record table. Thus, when the first path length of the second device number is not equal to the second path length of the second device number, the second path length of the second device number is updated based on the first path length of the second device number, ultimately avoiding recording the same data in the first topology relationship record table.
[0115] Example 3
[0116] Please see Figure 3 , Figure 3 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of this application, such as... Figure 3 As shown, the electronic device in this application embodiment includes:
[0117] Processor 301; and
[0118] The memory 302 is configured to store machine-readable instructions, which, when executed by the processor 301, perform a multi-machine cluster topology determination method as described in any of the foregoing embodiments.
[0119] The electronic device in this embodiment of the application, by executing a multi-machine cluster topology relationship determination method, can create a first topology relationship record table based on its own device information. The initial data of the first topology relationship record table includes the device ID, path length, and MAC address of the device itself. It can also receive data packets sent by neighboring devices, where the data packets carry topology information, including the device ID, path length, and MAC address of the neighboring devices. Furthermore, it can update the first topology relationship record table based on the device ID, path length, and MAC address of the neighboring devices. It can also periodically determine whether neighboring devices have sent a second topology relationship record table. If a neighboring device has sent a second topology relationship record table, it receives the second topology relationship record table and updates the first topology relationship record table based on it. If a neighboring device has not sent a second topology relationship record table, it deletes the neighbor entry in the first topology relationship record table. Finally, by updating and maintaining the first topology relationship record table, it can automatically learn the device topology relationships in the network. Compared with the prior art, this application does not require selecting a master device, nor does it require a master device to inform other member devices of the device topology relationships in the network.
[0120] Example 4
[0121] This application provides a storage medium storing a computer program, which is executed by a processor as a multi-machine cluster topology determination method according to any of the foregoing embodiments.
[0122] The storage medium in this embodiment of the application, by executing a multi-machine cluster topology relationship determination method, can create a first topology relationship record table based on its own device information. The initial data of the first topology relationship record table includes the device number, path length, and MAC address of the device itself. It can also receive data packets sent by neighboring devices, where the data packets carry topology information, including the device number, path length, and MAC address of the neighboring devices. Furthermore, it can update the first topology relationship record table based on the device number, path length, and MAC address of the neighboring devices. It can also periodically determine whether neighboring devices send a second topology relationship record table. If a neighboring device sends a second topology relationship record table, it receives the second topology relationship record table and updates the first topology relationship record table based on it. If a neighboring device does not send a second topology relationship record table, the neighbor entry in the first topology relationship record table is deleted. Finally, by updating and maintaining the first topology relationship record table, it can automatically learn the device topology relationships in the network. Compared with the prior art, this application does not require selecting a master device, nor does it require a master device to inform other member devices of the device topology relationships in the network.
[0123] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and there may be other division methods in actual implementation. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the coupling or direct coupling or communication connection shown or discussed may be through some communication interface; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0124] Furthermore, the units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0125] Furthermore, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0126] It should be noted that if a function is implemented as a software module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0127] In this document, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, without necessarily requiring or implying any such actual relationship or order between these entities or operations.
[0128] The above are merely embodiments of this application and are not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A method for determining a topology relationship of a multi-computer cluster, characterized in that, The method includes: A first topology relationship record table is created based on the device's own information. The initial data of the first topology relationship record table includes the device number of the device, the path length of the device, and the MAC address of the device. Receive data packets sent by neighboring devices, wherein the data packets carry topology information, including the device number of the neighboring device, the path length of the neighboring device, and the MAC address of the neighboring device; The first topology record table is updated based on the device number, path length, and MAC address of the neighboring device. Periodically determine whether the neighboring device sends the second topology relationship record table. If the neighboring device sends the second topology relationship record table, receive the second topology relationship record table and update the first topology relationship record table based on the second topology relationship record table. If the neighboring device does not send the second topology relationship record table, delete the neighbor table entry in the first topology relationship record table. Updating the first topology record table based on the second topology record table includes: The first device number is determined based on the second topology relationship record table, wherein the first device number is a device number that is not recorded in the first topology relationship record table; Increment the path length associated with the first device number by one; The first topology record table is updated based on the first device number, the path length associated with the first device number, and the MAC address associated with the first device number. And, updating the first topology relationship record table based on the second topology relationship record table includes: The second device number is determined based on the second topology relationship record table, wherein the second device number is the device number that is recorded in the first topology relationship record table; The path length associated with the second device number in the second topology record table is taken as the first path length of the second device number, and the first path length of the second device number is reduced by one. Compare the first path length of the second device number with the second path length of the second device number, wherein the second path length of the second device number is the path length associated with the second device number in the first topology record table; When the first path length of the second device number is not equal to the second path length of the second device number, the second path length of the second device number is updated based on the first path length of the second device number.
2. The method of claim 1, wherein, After updating the first topology record table based on the second topology record table, or after deleting the neighbor entry in the first topology record table, the method further includes: The first topology record table is periodically sent to the neighboring devices.
3. A device for determining the topology of a multi-machine cluster, characterized in that, The device includes: A creation module is used to create a first topology relationship record table based on the device's own information. The initial data of the first topology relationship record table includes the device number of the device, the path length of the device, and the MAC address of the device. A receiving module is used to receive data packets sent by neighboring devices, wherein the data packets carry topology information, including the device number of the neighboring device, the path length of the neighboring device, and the MAC address of the neighboring device; The update module is used to update the first topology record table based on the device number of the neighboring device, the path length of the neighboring device, and the MAC address of the neighboring device; The judgment module is used to periodically determine whether the neighboring device has sent the second topology relationship record table. If the neighboring device has sent the second topology relationship record table, the module receives the second topology relationship record table and updates the first topology relationship record table based on the second topology relationship record table. If the neighboring device has not sent the second topology relationship record table, the module deletes the neighbor table entry in the first topology relationship record table. And, the determination module includes: The first determining submodule is used to determine the first device number based on the second topology relationship record table, wherein the first device number is a device number that is not recorded in the first topology relationship record table; The first calculation submodule is used to add one to the path length associated with the first device number; The first update submodule is used to update the first topology record table based on the first device number, the path length associated with the first device number, and the MAC address associated with the first device number. And, the determination module includes: The second determining submodule is used to determine the second device number based on the second topology relationship record table, wherein the second device number is the device number that is recorded in the first topology relationship record table; The second calculation submodule is used to take the path length associated with the second device number in the second topology relationship record table as the first path length of the second device number, and to subtract one from the first path length of the second device number; The comparison submodule is used to compare the first path length of the second device number with the second path length of the second device number, wherein the second path length of the second device number is the path length associated with the second device number in the first topology relationship record table; The second update submodule is used to update the second path length of the second device number based on the first path length of the second device number when the first path length of the second device number is not equal to the second path length of the second device number.
4. The apparatus of claim 3, wherein, The device further includes: The sending module is configured to periodically send the first topology relationship record table to the neighboring device after the first topology relationship record table is updated based on the second topology relationship record table, or after the neighbor table entry in the first topology relationship record table is deleted.
5. An electronic device, characterized in that, include: processor; as well as A memory configured to store machine-readable instructions, which, when executed by the processor, perform the multi-machine cluster topology determination method as described in any one of claims 1-2.
6. A storage medium, characterized in that, The storage medium stores a computer program, which is executed by a processor as described in any one of claims 1-2, the method for determining the topology of a multi-machine cluster.
Citation Information
Patent Citations
Method and device for obtaining multi-hop neighbor node
CN106712995A
Computer-implemented system and method for updating network's knowledge of network's topology
CN110199500A
