Disclosure of Invention
The technical problem mainly solved by the application is to provide a communication method of a gateway cluster, network equipment and a gateway cluster system, which can improve the communication efficiency between the network equipment and relieve the storage pressure of the gateway cluster system.
A technical solution adopted in the present application is to provide a communication method between gateway clusters, which is applied to a first network device, and the communication method includes: acquiring a first dynamic mapping data table, wherein the first dynamic mapping data table is sent by a plurality of second network devices which are in communication connection with the first network device; updating a first static mapping data table based on the first dynamic mapping data table, and generating a first data list corresponding to the plurality of second network devices one to one based on the first static mapping data table; responding to the state change of at least one second network device, and acquiring first target mapping data corresponding to the at least one second network device from the first data list; the first mapping data matching the first target mapping data is deleted in the first static mapping data table.
The updating of the first static mapping data table based on the first dynamic mapping data table, and the generating of the first data list corresponding to the plurality of second network devices one to one based on the first static mapping data table include: comparing the first dynamic mapping data table with the first static mapping data table, and if the first static mapping data table does not have second mapping data in the first dynamic mapping data table, adding the second mapping data in the first static mapping data table; and generating a first data list corresponding to the plurality of second network devices one by one based on the second mapping data.
The first network equipment comprises a second dynamic mapping data table; after deleting the first mapping data matched with the first target mapping data in the first static mapping data table, the method further comprises the following steps: sending request instructions to a plurality of second network devices based on the first target mapping data; and if a reply instruction associated with the request instruction is received, adding the first target mapping data in the second dynamic mapping data table.
The second network equipment comprises a second data list and a second static mapping data table, and the first network equipment comprises a second dynamic mapping data table; the communication method further comprises the following steps: and in response to generating second mapping data in the second dynamic mapping data table, sending the second mapping data to the second network devices, so that the second data list and the second static mapping data table are updated by the second network devices based on the second mapping data.
Wherein sending the second mapping data to the plurality of second network devices to enable the plurality of second network devices to update the second data list and the second static mapping data table based on the second mapping data comprises: sending second mapping data to a plurality of second network devices so that the plurality of second network devices judge whether the second mapping data exist in a second data list, and if so, updating time marks of the second mapping data; and if not, adding second mapping data in the second data list and the second static mapping data table.
The communication method further comprises the following steps: acquiring a timestamp of second target mapping data in the first data list; calculating a first difference between the timestamp and the current time; judging whether the first difference value exceeds a preset difference value or not; and if so, deleting the third mapping data matched with the second target mapping data in the first static mapping data table, and deleting the second target mapping data.
The communication method further comprises the following steps: sending heartbeat messages to a plurality of second network devices; and updating the second data list and the second static mapping data table by the plurality of second network devices based on the heartbeat messages respectively, wherein the heartbeat messages comprise the second dynamic mapping data table of the first network device.
Another technical solution adopted by the present application is to provide a network device, where the network device includes a processor and a memory connected to the processor; wherein the memory is adapted to store program data and the processor is adapted to execute the program data for implementing the communication method according to any of claims 1-7.
Another technical solution adopted in the present application is to provide a gateway cluster system, where the gateway cluster system includes a plurality of network devices, and the network devices are the network devices of claim 8.
Another technical solution adopted by the present application is to provide a readable storage medium, wherein the readable storage medium is used for storing program data, and the program data is used for implementing the method provided by the above technical solution when being executed by a processor.
The beneficial effect of this application is: different from the situation in the prior art, the communication method of the gateway cluster provided by the present application is applied to the first network device, and the communication method includes: acquiring a first dynamic mapping data table, wherein the first dynamic mapping data table is sent by a plurality of second network devices in communication connection with a first network device; updating a first static mapping data table based on the first dynamic mapping data table, and generating a first data list corresponding to the plurality of second network devices one to one based on the first static mapping data table; in response to the state change of the at least one second network device, acquiring first target mapping data corresponding to the at least one second network device from the first data list; the first mapping data matching the first target mapping data is deleted in the first static mapping data table. Through the method, on one hand, the first network equipment only synchronizes the dynamic ARP cache of the second network equipment in the gateway cluster by using a dynamic and static combined mode of ARP synchronization among the network equipment and stores the dynamic ARP cache as the own static ARP cache, so that the seamless access of the service flow after the standby node is newly added in the gateway cluster is realized, on the other hand, when at least one second network equipment in the gateway cluster cannot work, the static ARP cache corresponding to the second network equipment in the first network equipment can be deleted, the static ARP attempt is converted into the dynamic ARP, the storage pressure of the gateway cluster system is reduced, the problem that the static ARP cache cannot be refreshed is solved, and the communication efficiency among the network equipment can be improved.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. It is to be understood that the specific embodiments described herein are merely illustrative of and not restrictive on the broad application. It should be further noted that, for the convenience of description, only some of the structures associated with the present application are shown in the drawings, not all of them. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
Referring to fig. 1, fig. 1 is a schematic flowchart of a first embodiment of a communication method of a gateway cluster provided in the present application. Applied to a first network device, the method comprises:
step 11: and acquiring a first dynamic mapping data table.
The first dynamic mapping data table is sent by a plurality of second network devices which are in communication connection with the first network device. It is understood that the dynamic mapping data table is a dynamic ARP (Address Resolution Protocol) table, in which an IP (Internet Protocol, protocol for interconnection between networks) Address and a MAC (Media Access Control) Address are stored, and the IP Address and the MAC Address are in one-to-one correspondence.
In this embodiment, the gateway cluster includes a first network device and a plurality of second network devices. The first network device is communicatively coupled to a plurality of second network devices. The first network device and the second network device may be the same type of device or different types of devices. The first network device and the plurality of second network devices can be mobile terminals and PC terminals; or may be a gateway device such as a router, switch, etc.
It can be understood that, since the gateway cluster includes a plurality of second network devices, the first network device may acquire a plurality of first dynamic mapping data tables. Each first dynamic mapping data table corresponds to one second network device.
Step 12: and updating the first static mapping data table based on the first dynamic mapping data table, and generating a first data list corresponding to the plurality of second network devices one by one based on the first static mapping data table.
In some embodiments, referring to fig. 2, step 12 may specifically be the following steps:
step 121: and comparing the first dynamic mapping data table with the first static mapping data table, and if the second mapping data in the first dynamic mapping data table does not exist in the first static mapping data table, adding the second mapping data in the first static mapping data table.
In particular, the following table is referred to for illustration:
the first dynamic mapping data table comprises second mapping data a, second mapping data b, second mapping data c and second mapping data d. The first static mapping data table comprises mapping data a, mapping data d, mapping data e and second mapping data c. And comparing to find that the second mapping data b does not exist in the first static mapping data table, and adding the second mapping data b into the first static mapping data table.
And traversing the first dynamic mapping data tables to find second mapping data which does not exist in the first static mapping data table from the first dynamic mapping data tables and add the second mapping data to the first static mapping data table.
Step 122: and generating a first data list corresponding to the plurality of second network devices one by one based on the second mapping data.
Further, since the second mapping data added to the first static mapping data table is from the first dynamic mapping data table sent by the plurality of second network devices, the second mapping data is generated into the first data list corresponding to the plurality of second network devices one to one. Because a plurality of second network devices exist, a plurality of first data lists correspond to the second network devices. If the plurality of second network devices include the second network device a, the second network device b, and the second network device c, the plurality of second network devices correspond to the first dynamic mapping data table a, the first dynamic mapping data table b, and the first dynamic mapping data table c. If the second mapping data a in the first dynamic mapping data table a, the second mapping data b in the first dynamic mapping data table b, and the second mapping data c in the first dynamic mapping data table c are added to the first static mapping data table in step 121, a first data list a, a first data list b, and a first data list c are correspondingly generated. The first data list a includes information of the second network device a and the second mapping data a. The first data list b includes information of the second network device b and the second mapping data b. The first data list c includes information of the second network device c and the second mapping data c.
Through the mode, the second data in the dynamic mapping data tables in the second network devices are stored in the static mapping data table of the first network device, so that the service flow is not interrupted during working, a large amount of static mapping data can not be stored, and the storage pressure of the whole gateway cluster is relieved.
Step 13: in response to a change in status of the at least one second network device, first target mapping data corresponding to the at least one second network device is obtained from the first data list.
In some embodiments, if the second network device crashes, malfunctions, or does not operate, or is replaced, the first network device obtains the first target mapping data corresponding to the at least one second network device from the first data list in response to the state change of the at least one second network device. The information of the second network device is stored in the first data list, the first data list corresponding to the first network device is found by traversing the plurality of first data lists, and the first target mapping data is obtained from the first data list.
Step 14: first mapping data matching the first target mapping data is deleted in the first static mapping data table.
In some embodiments, referring to fig. 3, after step 14, further comprising:
step 141: request instructions are sent to a plurality of second network devices based on the first target mapping data.
In some embodiments, the status of at least one second network device changes but does not represent a change in the device to which the mapping data stored therein corresponds. Then a request needs to be sent to the plurality of second network devices based on the first target mapping data.
In some embodiments, the first network device sends a request instruction to a device associated therewith based on the first target mapping data.
Step 142: and if a reply instruction associated with the request instruction is received, adding the first target mapping data in the second dynamic mapping data table.
For example, the first target mapping data includes binding information of IP + MAC. The request instruction may here instead execute an "alert IP" command, IP being the IP address information recorded in the first target mapping data, such as alert 192.168.1.8. When this command is executed, the gateway cluster system will automatically query the mac address of the IP. And if a reply instruction of the mac address is received, adding the first target mapping data in the second dynamic mapping data table.
In some embodiments, the first network device and the second network device may be dynamically adjusted, and when the current network device is in processing work, the current network device is the first network device, and the rest of the current network device is the second network device.
In some embodiments, the first network device may be a newly added network device in the entire gateway cluster, and the steps of this embodiment may be implemented when the first network device is added to the gateway cluster. Thus, the first network device synchronizes the first dynamic mapping data table (dynamic ARP cache) from the plurality of second network devices. Therefore, as long as the service flow passing through the second network device is distributed to the first network device for bearing, the first network device can directly realize flow without learning ARP again, and the seamless access of the service flow after the standby node is newly added in the cluster is realized.
In an application scenario, a second network device a and a second network device B exist in a gateway cluster, at this time, a first network device C is newly added, the second network device a and the second network device B detect that a new device is added into the gateway cluster, the second network device a and the second network device B respectively query dynamic ARP caches in corresponding systems, and package and send the dynamic ARP caches to the newly added first network device C. After receiving the dynamic ARP sent by the second network device a and the second network device B, the first network device C queries whether a corresponding dynamic ARP cache already exists in its own system, and if not, the first network device C stores the dynamic ARP cache in a static ARP cache and stores the static ARP cache in an ARP record table (a first data list), and the ARP cache synchronized with the second network device a is stored in a record table ListA, and the ARP cache synchronized with the second network device B is stored in a record table ListB. Thus, the first network device C records the ARP caches synchronized by the second network device a and the second network device B, respectively. Therefore, if the service flow passing through the second network device a and the second network device B is allocated to the first network device C for carrying, the first network device C can directly flow through without learning the ARP again, and seamless access of the service flow after the network device is newly added in the gateway cluster is realized.
In another application field, a gateway cluster may cause a certain network device to be removed from the line during the working process for various reasons. Examples illustrate that: the gateway cluster is provided with three gateways of equipment A, B and C. At this time, the device C is removed from the cluster, and after the devices a and B detect that the device C is removed, the device a traverses the ARP table ListC that is recorded and synchronized with the device C, deletes the corresponding system static ARP cache and table entry, and lets the device learn the corresponding ARP information by sending an ARP request packet, so as to implement the conversion of ARP from static to dynamic. Therefore, the static ARP of the equipment C and the corresponding record table which are originally stored on the equipment A and the equipment B are deleted, and meanwhile, the system learns the dynamic ARP, so that the storage resource of the system is saved, and the seamless switching of the service flow which flows through the equipment C to the equipment A or the equipment B can be ensured.
Different from the situation in the prior art, the communication method of the gateway cluster provided by the present application is applied to the first network device, and the communication method includes: acquiring a first dynamic mapping data table, wherein the first dynamic mapping data table is sent by a plurality of second network devices in communication connection with a first network device; updating a first static mapping data table based on the first dynamic mapping data table, and generating a first data list corresponding to the plurality of second network devices one to one based on the first static mapping data table; in response to the state change of the at least one second network device, acquiring first target mapping data corresponding to the at least one second network device from the first data list; the first mapping data matching the first target mapping data is deleted in the first static mapping data table. Through the above manner, on one hand, the dynamic ARP cache of the second network equipment in the gateway cluster is only synchronized by the first network equipment by utilizing the dynamic and static combined manner of ARP synchronization among the network equipment and is stored as the own static ARP cache, thereby realizing the seamless access of the service flow after the new addition of the standby node in the gateway cluster, and on the other hand, when at least one second network equipment in the gateway cluster cannot work, the static ARP cache corresponding to the second network equipment in the first network equipment is deleted, and the static ARP attempt is converted into the dynamic ARP, thereby reducing the storage pressure of the gateway cluster system and solving the problem that the static ARP cache cannot be refreshed.
Referring to fig. 4, fig. 4 is a schematic flowchart of a second embodiment of a communication method of a gateway cluster provided in the present application. The communication method comprises the following steps:
step 41: and in response to generating second mapping data in the second dynamic mapping data table, sending the second mapping data to the plurality of second network devices, so that the plurality of second network devices update the second data list and the second static mapping data table based on the second mapping data.
The second network device comprises a second data list and a second static mapping data table, and the first network device comprises a second dynamic mapping data table.
In some embodiments, the second mapping data is sent to a plurality of second network devices, so that the plurality of second network devices determine whether the second mapping data exists in the second data list, and if so, update the time stamp of the second mapping data; and if not, adding second mapping data in the second data list and the second static mapping data table.
In some embodiments, the first network device is further configured to send heartbeat messages to a plurality of second network devices; and updating a second data list and a second static mapping data table by the plurality of second network devices based on heartbeat messages respectively, wherein the heartbeat messages comprise a second dynamic mapping data table of the first network device.
The devices of the gateway cluster send heartbeat messages to each other to confirm whether other devices in the gateway cluster are alive or not. The keep-alive heartbeat messages are sent out at regular time, in order to ensure that the ARP can be completely and accurately synchronized to other second network equipment in the gateway cluster, the heartbeat messages carry the dynamic ARP cache of the first network equipment to be sent to other equipment, and therefore the defect that packet loss or omission exists in the process of adding the dynamic ARP cache in the newly added network equipment and the network equipment is avoided. For example, devices a, B, and C exist in the gateway cluster. The fixed time interval between the devices sends heartbeat messages to other devices. When the device A sends heartbeat messages to the devices B and C, the dynamic ARP cache of the self system is inquired, and the ARP caches are added into the heartbeat messages. The devices B and C receive the heartbeat message of the device A, on one hand, the device A is proved to be still alive in the cluster, on the other hand, the dynamic ARP cache of the device A is analyzed, whether the items exist in the ARP table recorded in the system of the device A is inquired, if the items exist, the time stamps of the items in the record table are not updated, if the items do not exist, a static ARP cache is added to the system, and meanwhile, an item is added to the synchronous ARP record table ListA of the recording device A.
In an application scenario, three devices a, B, and C exist in the gateway cluster, and a new flow passes through the device a to generate a new ARP cache, and at this time, the device is identified as the first network device, and the devices B and C are the second network devices in this embodiment. The device A synchronizes the dynamic ARP cache information to the devices B and C in the cluster immediately, the devices B and C traverse the stored ARP information table (second data list) after receiving the ARP synchronization message, whether the same table entry already exists or not is judged, if yes, the timestamp (time mark) of the corresponding information is updated, if not, an information is added to the ARP recording table ListA, and meanwhile, an ARP static cache is configured for the system. Therefore, the newly added service flow can be ensured to be learned on one device, and all devices in the gateway cluster can learn. If the newly added service flow is switched to the device B and the device C again at this time, the ARP learning can be directly passed without being continued. Therefore, seamless switching and uninterrupted flow of the newly added service flow on any equipment in the cluster are ensured.
Referring to fig. 5, fig. 5 is a schematic flowchart of a communication method of a gateway cluster according to a third embodiment of the present application. The method comprises the following steps:
step 51: a timestamp of the second target mapping data in the first data list is obtained.
In some embodiments, in consideration of the fact that the storage time of the data in the first static mapping data table may be too long, a timing device is provided at the first network device, and when the timing device is started, the timestamp of the second target mapping data in the first data list is obtained.
Step 52: a first difference between the timestamp and the current time is calculated.
For example, the time stamp is 2020-02-28. The current time is 2020-06-17. The first difference is 109.
Step 53: and judging whether the first difference value exceeds a preset difference value.
And judging whether the first difference exceeds a preset difference, if so, executing a step 54, and if not, not changing. If the predetermined difference is 60 and the first difference is 109, go to step 54.
Step 54: and deleting the third mapping data matched with the second target mapping data in the first static mapping data table, and deleting the second target mapping data.
By the mode, system storage can be reduced, system performance is improved, and the problem of flow break after the binding relation between the service stream IP and the MAC is changed can be relieved.
In an application scenario, there are devices a, B, and C in a gateway cluster, and the ARP caches in the devices B and C are written in the device a system, and written in the system in the form of a static ARP cache. Meanwhile, an ARP record list B and a ListC are arranged in the device A and respectively record ARP caches synchronized by the device B and the device C, and a time stamp synchronized by each ARP cache is recorded in the record list. And starting a timer, judging the time stamps recorded by the entries in the ListB and the ListC, comparing the time stamps with the current system time, and comparing the difference value with the set aging time. And if the aging time is over, the ARP is considered to be aged, the corresponding ARP static cache in the equipment A system is deleted, and the ListB or the ListC is removed from the entry. Therefore, the overhead of system storage can be reduced, and the problem of flow interruption after the binding relationship between the service flow IP and the MAC is changed is solved.
Referring to fig. 6, fig. 6 is a schematic structural diagram of an embodiment of a network device provided in the present application. The network device 60 comprises a processor 61 and a memory 62 connected to the processor 61; wherein the memory 62 is adapted to store program data and the processor is adapted to execute the program data to perform the following method steps:
acquiring a first dynamic mapping data table, wherein the first dynamic mapping data table is sent by a plurality of second network devices which are in communication connection with the first network device; updating a first static mapping data table based on the first dynamic mapping data table, and generating a first data list corresponding to the plurality of second network devices one by one based on the first static mapping data table; responding to the state change of at least one second network device, and acquiring first target mapping data corresponding to the at least one second network device from the first data list; the first mapping data matching the first target mapping data is deleted in the first static mapping data table.
The network device 60 may be a first network device or a second network device.
It will be appreciated that the processor 61 is also operative to execute program data to implement any of the embodiment methods described above.
Referring to fig. 7, fig. 7 is a schematic structural diagram of an embodiment of a gateway cluster system provided in the present application. The gateway cluster system 70 comprises a plurality of network devices 71, wherein the network devices 71 are any network devices in the above embodiments to implement the method in any of the above embodiments.
Referring to fig. 8, fig. 8 is a schematic structural diagram of an embodiment of a readable storage medium provided in the present application. The readable storage medium 80 is for storing program data 81, the program data 81, when being executed by a processor, being for realizing the method steps of:
acquiring a first dynamic mapping data table, wherein the first dynamic mapping data table is sent by a plurality of second network devices in communication connection with a first network device; updating a first static mapping data table based on the first dynamic mapping data table, and generating a first data list corresponding to the plurality of second network devices one to one based on the first static mapping data table; in response to the state change of the at least one second network device, acquiring first target mapping data corresponding to the at least one second network device from the first data list; the first mapping data matching the first target mapping data is deleted in the first static mapping data table.
It will be appreciated that the program data 81, when executed by a processor, is also for implementing any of the embodiment methods described above.
In the several embodiments provided in the present application, it should be understood that the disclosed method and apparatus may be implemented in other manners. For example, the above-described device embodiments are merely illustrative, and for example, the division of the modules or units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit. The integrated unit may be implemented in the form of hardware, or may also be implemented in the form of a software functional unit.
The integrated units in the other embodiments described above may be stored in a computer-readable storage medium if they are implemented in the form of software functional units and sold or used as separate products. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, a network device, or the like) or a processor (processor) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above description is only for the purpose of illustrating embodiments of the present application and is not intended to limit the scope of the present application, and all modifications of equivalent structures and equivalent processes, which are made by the contents of the specification and the drawings of the present application or are directly or indirectly applied to other related technical fields, are also included in the scope of the present application.