Gateway dynamic switching method and system, and storage medium
By generating dynamic multicast groups and automatically detecting link quality, the problem of cumbersome manual operations between gateway devices is solved, realizing automated link communication and path switching, and improving user experience and security.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XIAMEN INTRETECH
- Filing Date
- 2026-03-04
- Publication Date
- 2026-05-29
AI Technical Summary
The existing link communication connections and path switching between gateway devices require manual operation by the user, resulting in a poor user experience.
By generating dynamic multicast groups, multicast groups are generated using the home identifier of the gateway device, multicast messages and discovery messages are exchanged, multicast server and client are identified, key exchange and login are performed, and link quality detection and path switching are automatically performed.
It enables automatic link communication and path switching between gateway devices, improves user experience, ensures that the communication path is always intelligently optimal, and provides end-to-end security.
Smart Images

Figure CN122120048A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication network technology, and in particular to a gateway dynamic switching method, system, and storage medium. Background Technology
[0002] With the rapid development of smart home and IoT technologies, deploying multiple gateway devices in home or small business environments has become commonplace. These gateway devices need to work collaboratively to provide stable network connectivity for various smart devices.
[0003] In the current use of gateway devices, users typically need to manually connect and switch link paths between gateway devices, which is cumbersome and reduces the user experience. Summary of the Invention
[0004] The purpose of this invention is to provide a gateway dynamic switching method, system, and storage medium to solve the problem of poor user experience in the prior art.
[0005] This invention is implemented as follows: a gateway dynamic switching method, the method comprising: A dynamic multicast group is generated based on the home identifier of the gateway device, and when any of the gateway devices joins the dynamic multicast group, multicast messages and discovery messages are sent to the gateways in the dynamic multicast group. When any of the gateway devices receives the discovery message, it determines the multicast server and multicast client between different gateway devices based on the discovery message, and controls the multicast client to initiate a transmission control connection to the multicast server. The system controls the multicast client to exchange keys with the multicast server to obtain an encryption key, and controls the multicast client and the multicast server to log in to the gateway based on the encryption key. After both the multicast client and the multicast server successfully log in to the gateway, they establish link communication, perform link quality checks on the multicast server and the multicast client, and switch link paths for the multicast server and the multicast client based on the link quality check results.
[0006] Preferably, after sending multicast messages and discovery messages to the gateways within the dynamic multicast group, the method further includes: Upon receiving the multicast message, any of the gateway devices shall perform message verification on the multicast message; If the message verification of the multicast message is successful, a feedback message is sent to the transmitting gateway corresponding to the multicast message.
[0007] Preferably, sending multicast messages and discovery messages to the gateways within the dynamic multicast group includes: The multicast message is generated based on the identity information of the gateway device, and the multicast message is sent to the gateways within the dynamic multicast group; Obtain the device information of the gateway device, and generate the discovery message based on the device information. The device information includes protocol version, home identifier, device identifier, capability set bitmap, real-time performance indicators and digital signature. Start a timer with a time interval based on the Fibonacci sequence, and periodically send the discovery message to the gateway in the dynamic multicast group according to the timer.
[0008] Preferably, determining the multicast server and multicast client between different gateway devices based on the discovery message includes: Calculate the connection initiation weight value for each of the different gateway devices; The gateway device corresponding to the largest connection initiation weight value is identified as the multicast server, and the remaining gateway devices are identified as the multicast clients. The formula used to calculate the connection initiation weight value of different gateway devices includes:
[0009] in, This indicates the connection initiation weight value. , , This indicates the preset weighting coefficient. This indicates the ranking of the IP addresses of the corresponding gateway devices after normalization. This represents the hardware capability score of the corresponding gateway device. This indicates the utilization rate of the central processing unit of the corresponding gateway device.
[0010] Preferably, controlling the multicast client and the multicast server to exchange keys to obtain an encryption key includes: Control the multicast client to exchange public keys with the multicast server, and control the multicast client to generate Advanced Encryption Standard (AES) keys; In the multicast client, the Advanced Encryption Standard key is encrypted using the public key of the multicast server to obtain the encryption key, and the encryption key is sent to the multicast client.
[0011] Preferably, after link communication, it also includes: The multicast client is controlled to send heartbeat packets to the multicast server according to a preset time interval, and when the multicast server receives the heartbeat packets, the multicast server is controlled to send a heartbeat response to the multicast client. If the number of times the multicast server fails to respond to a heartbeat exceeds a threshold, the communication link between the multicast client and the multicast server is disconnected. If the multicast server does not receive a communication message from the multicast client within a preset time, the link communication between the multicast server and the multicast client is disconnected.
[0012] Preferably, link quality detection is performed on the multicast server and the multicast client, and link path switching is performed on the multicast server and the multicast client based on the link quality detection results, including: Link quality detection is performed on the local link communication and cloud link communication between the multicast server and the multicast client respectively to obtain link quality detection results, which include a first link quality score and a second link quality score. The link path is switched between the multicast server and the multicast client based on the first link quality score and the second link quality score.
[0013] Preferably, the link path switching between the multicast server and the multicast client is performed based on the first link quality score and the second link quality score, including: The hysteresis score is calculated based on the second link quality score and the preset hysteresis factor. When the first link quality score is less than the first link quality threshold, or the second link quality score is less than the hysteresis score, the local link communication is switched to the cloud link communication. When the first link quality score is greater than the second link quality threshold, and the second link quality score is greater than the hysteresis score, a handover timer is started to obtain the handover duration. When the timing switching duration exceeds the duration threshold, the cloud link communication is switched to the local link communication.
[0014] Another objective of this invention is to provide a gateway dynamic switching system, the system comprising: The dynamic multicast module is used to generate a dynamic multicast group based on the home identifier of the gateway device, and when any of the gateway devices joins the dynamic multicast group, it sends multicast messages and discovery messages to the gateways in the dynamic multicast group. The transmission connection module is used to determine the multicast server and multicast client between different gateway devices based on the discovery message when any of the gateway devices receives the discovery message, and to control the multicast client to initiate a transmission control connection to the multicast server. The gateway login module is used to control the multicast client and the multicast server to exchange keys, obtain an encryption key, and control the multicast client and the multicast server to perform gateway login based on the encryption key; The link path switching module is used to perform link communication after both the multicast client and the multicast server have successfully logged into the gateway, to perform link quality detection on the multicast server and the multicast client, and to switch the link path between the multicast server and the multicast client based on the link quality detection results.
[0015] In this embodiment of the invention, a dynamic multicast group can be automatically generated based on the home identifier of the gateway device. By controlling the gateway device to send multicast messages and discovery messages to gateways within the dynamic multicast group, mutual discovery between different gateway devices is effectively facilitated. The discovery messages can effectively identify the multicast server and multicast client between different gateway devices. By controlling the multicast client and multicast server to exchange keys, the encryption key can be effectively obtained. When both the multicast client and multicast server successfully log in to the gateway, link communication is automatically controlled. By performing link quality detection on the multicast server and multicast client, and based on the link quality detection results, the link path can be automatically switched between the multicast server and multicast client. Users do not need to manually connect link communication between gateway devices or switch link paths, thus improving the user experience. Attached Figure Description
[0016] Figure 1 This is a flowchart of the gateway dynamic switching method provided in the first embodiment of the present invention; Figure 2 This is a schematic diagram of the multicast discovery timing provided in the first embodiment of the present invention; Figure 3 This is a TCP connection timing diagram provided in the first embodiment of the present invention; Figure 4 This is a schematic diagram of the relationship between the gateway device and the cloud service provided in the first embodiment of the present invention; Figure 5 This is a schematic diagram of the gateway dynamic switching system provided in the second embodiment of the present invention; Figure 6 This is a schematic diagram of the structure of the terminal device provided in the third embodiment of the present invention. Detailed Implementation
[0017] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0018] To illustrate the technical solution described in this invention, specific embodiments are described below.
[0019] Example 1 Please see Figure 1 This is a flowchart of a gateway dynamic switching method provided in the first embodiment of the present invention. This gateway dynamic switching method can be applied to any device or system, and includes the following steps: Step S10: Generate a dynamic multicast group based on the home identifier of the gateway device, and when any of the gateway devices joins the dynamic multicast group, send multicast messages and discovery messages to the gateways in the dynamic multicast group. Among them, dynamic multicast groups are dynamically generated based on family identifiers. To avoid address conflicts, the multicast address is not hard-coded. After the gateway device starts up, it uses the globally unique "family identifier" as a seed and uses a lightweight hash algorithm (such as taking the first 24 bits of the SHA-256 hash value) to dynamically generate a unique multicast address within the management range address block (such as 239.1.0.0 / 14) to obtain the dynamic multicast group.
[0020] For example, please see Figure 2 Gateway devices A and B start up and join the dynamic multicast group 239.1.1.1 generated by the family identifier. It should be noted that gateway devices A and B simultaneously act as both multicast clients and multicast servers. The client and server join the same multicast group 239.1.1.1, but listen on different ports. The client uses port 10000 and the server uses port 9999. First, a multicast service start message is sent. After the message is successfully verified, a multicast discovery message is sent. When a multicast discovery message is received, the message is verified. After successful verification, a response message is sent.
[0021] Optionally, after sending multicast messages and discovery messages to the gateways within the dynamic multicast group, the method further includes: Upon receiving the multicast message, any of the gateway devices performs message verification on the multicast message; for example, when gateway device B receives the multicast message sent by gateway device A as a server, it begins message verification. If the message verification of the multicast message is successful, a feedback message is sent to the transmitting gateway corresponding to the multicast message; wherein, if the message verification of the multicast message is successful, a feedback message is actively sent, which can be a discovery message, the purpose of which is to enable gateway device A to also receive the discovery message in a timely manner.
[0022] Furthermore, sending multicast messages and discovery messages to the gateways within the dynamic multicast group includes: The multicast message is generated based on the identity information of the gateway device, and the multicast message is sent to the gateways within the dynamic multicast group; The device information of the gateway device is obtained, and the discovery message is generated based on the device information. The device information includes protocol version, family identifier, device identifier, capability set bitmap, real-time performance indicators, and digital signature. The discovery message adopts TLV (Type-Length-Value) format and includes: protocol version, family identifier, device identifier, capability set bitmap (such as TLS support, maximum bandwidth), real-time performance indicators (CPU load, memory margin, average latency to the cloud, TCP listening port), and digital signature based on pre-shared key. Start a timer with a time interval based on the Fibonacci sequence, and periodically send the discovery message to the gateway in the dynamic multicast group according to the timer. For example, after gateway device A joins the dynamic multicast group as a server, it first sends a multicast message with identity verification. At the same time, after joining the multicast group as a client, it starts a timer with a time interval based on the Fibonacci sequence to periodically send discovery messages to the group. Gateway device B starts the process in the same way.
[0023] Step S20: When any of the gateway devices receives the discovery message, it determines the multicast server and multicast client between different gateway devices based on the discovery message, and controls the multicast client to initiate a transmission control connection to the multicast server. Upon receiving the discovery message, the gateway device verifies the signature and family identifier, and then calculates a "service capability score" based on its own load (such as the current number of connections). The response message is not sent immediately, but rather a random delay window (e.g., 0-200ms) is introduced. Gateways with higher service capability scores (more suitable as servers) have smaller delay windows, thus sending out responses earlier to prompt the other party to initiate a connection, thereby achieving the effect of a distributed and optimized role negotiation mechanism.
[0024] Preferably, this embodiment also includes a connection conflict detection and graceful resolution protocol: Detection: This "conflict" event can be detected when both gateway devices send synchronization data packets almost simultaneously, causing the connection to fail. Solution: Both gateway devices suspend new attempts and exchange their respective Connection Initiation Weights (CIWs) through a temporary User Datagram Protocol (UDP) channel. The gateway device with the higher CIW value proactively closes its incomplete connections and resumes listening, while the gateway device with the lower CIW value waits for a short, random period before re-initiating the connection. This ensures deterministic connection establishment and avoids deadlock.
[0025] Optionally, determining the multicast server and multicast client between different gateway devices based on the discovery message includes: Calculate the connection initiation weight value for each of the different gateway devices; The gateway device corresponding to the largest connection initiation weight value is identified as the multicast server, and the remaining gateway devices are identified as the multicast clients. The formula used to calculate the connection initiation weight value of different gateway devices includes:
[0026] in, This indicates the connection initiation weight value. , , This indicates the preset weighting coefficient. This indicates the ranking of the IP addresses of the corresponding gateway devices after normalization. This represents the hardware capability score of the corresponding gateway device. This indicates the utilization rate of the central processing unit of the corresponding gateway device.
[0027] For example, when gateway device B receives a discovery message from gateway device A, it begins parsing the message and calculates the peer's CIW value based on the information carried in the message. If the peer's CIW value is higher than its own, it, as a multicast client, proactively initiates a local path connection. If its own CIW is higher than the peer's, further judgment is needed. If a connection already exists and it is a multicast client, the connection is closed, and a unicast response message is sent to gateway device A. After receiving the unicast response from gateway multicast B, gateway multicast A proactively initiates a local path connection to gateway multicast B.
[0028] Step S30: Control the multicast client and the multicast server to exchange keys to obtain an encryption key, and control the multicast client and the multicast server to log in to the gateway based on the encryption key; The encryption key can be effectively obtained by controlling the multicast client and the multicast server to exchange keys. Optionally, controlling the multicast client and the multicast server to exchange keys to obtain the encryption key includes: The system controls the multicast client to exchange public keys with the multicast server and controls the multicast client to generate an Advanced Encryption Standard (AES) key. Specifically, after a connection is established on the local path, gateway device A and gateway device B enter the data encryption key exchange phase. Gateway device A and gateway device B first exchange their public keys. After the public key exchange is completed, the multicast client generates an AES key. In the multicast client, the Advanced Encryption Standard (AES) key is encrypted using the public key of the multicast server to obtain the encryption key, and the encryption key is sent to the multicast client. Specifically, the AES key is used to encrypt the AES key, and the encryption key is then sent to the multicast server. Subsequent communication between gateway devices uses AES encryption.
[0029] Please see Figure 3 When the control multicast client transmits the control connection (Transmission Control Protocol, TCP) to the multicast server, the TCP connection between the TCP client (TCPClient) and the TCP server (TCPtServer) is successfully established. The client public key is generated and sent, the server public key is generated and generated, encrypted using the client public key, sent, an AES key is generated and encrypted using the server public key, sent, and AES key encryption is performed. The key exchange is completed, and a login request is made based on AES encryption. After login verification, a login success response and business communication are performed based on AES encryption.
[0030] Step S40: After both the multicast client and the multicast server successfully log in to the gateway, link communication is performed, link quality is checked for the multicast server and the multicast client, and link path switching is performed for the multicast server and the multicast client based on the link quality check results. After the key exchange is successful, the gateway device acting as the multicast client begins the login process. Upon receiving the login message, the gateway device acting as the multicast server verifies the gateway identity again. If the verification is successful, the normal communication phase begins; if the verification fails, the connection is directly disconnected.
[0031] Optionally, after link communication is established, the following may also be included: The multicast client is controlled to send heartbeat packets to the multicast server according to a preset time interval, and when the multicast server receives the heartbeat packets, the multicast server is controlled to send a heartbeat response to the multicast client. If the number of times the multicast server fails to respond to a heartbeat exceeds a threshold, the communication link between the multicast client and the multicast server is disconnected. If the multicast server does not receive a communication message from the multicast client within a preset time, the link communication between the multicast server and the multicast client is disconnected. In this step, after the gateway device enters the communication phase, the multicast client will send heartbeat packets periodically. If it does not receive a heartbeat response multiple times, it will actively disconnect from the server. The multicast server starts a message timeout timer, and the timeout period is set to 3 times the duration of the no heartbeat. If the multicast server does not receive any messages from the multicast client within this time period, it will treat the connection as a zombie connection and actively close the connection.
[0032] The multicast client has an automatic reconnection function. When the heartbeat packet fails to respond multiple times, the multicast client will actively start a reconnection timer with a time interval of Fibonacci sequence (maximum reconnection count 15 times) to initiate a reconnection to the current multicast server after disconnection.
[0033] Further, link quality testing is performed on the multicast server and the multicast client, and link path switching is performed on the multicast server and the multicast client based on the link quality testing results, including: Link quality detection is performed on the local link communication and cloud link communication between the multicast server and the multicast client respectively to obtain the link quality detection results, wherein the link quality detection results include a first link quality score and a second link quality score. Based on the first link quality score and the second link quality score, the multicast server and the multicast client are switched via link paths. The formula for calculating the Link Quality Score (LQS) includes:
[0034] Where a, b, and c are pre-set weight values. This represents the link quality score, and SRTT represents the smooth round-trip delay. Indicates delayed jitter. This indicates the heartbeat packet loss rate.
[0035] Furthermore, based on the first link quality score and the second link quality score, link path switching is performed between the multicast server and the multicast client, including: The hysteresis score is calculated based on the second link quality score and the preset hysteresis factor; the hysteresis factor is used to prevent the "ping-pong effect" from occurring when the network fluctuates. When the first link quality score is less than the first link quality threshold, or the second link quality score is less than the hysteresis score, the local link communication is switched to the cloud link communication; wherein, the first link quality threshold can be set according to requirements; When the first link quality score is greater than the second link quality threshold, and the second link quality score is greater than the hysteresis score, a handover timing is initiated to obtain the handover duration; wherein, the second link quality threshold can be set according to requirements; When the timing switching duration exceeds the duration threshold, the cloud link communication is switched to the local link communication; wherein, the duration threshold can be set according to requirements, and when the timing switching duration exceeds the duration threshold, the communication switches back to the low-latency, low-cost local path; For example, gateway device A and gateway device B continuously perform link quality detection. When the quality score of the first link drops due to local area network congestion, the switching conditions are met, and subsequent data packets are sent through the established cloud link communication connection with better quality. Fault recovery: After the LAN quality is restored, traffic is automatically switched back to the local path connection, and the cloud link communication connection is maintained as a backup.
[0036] Please see Figure 4 In this embodiment, the gateway device not only has network communication capabilities, but also has a built-in link quality probe, policy decision engine and connection session manager. Its software architecture includes an independent communication management layer, which is responsible for maintaining the state synchronization of local path connection sessions and cloud MQTT connection sessions.
[0037] As a cloud-based link communication proxy, cloud services can also provide lightweight network coordinate services to help gateways estimate the baseline latency of WAN paths.
[0038] In this embodiment, secure multicast discovery and a multi-factor weighting algorithm achieve optimal role allocation and deterministic connection establishment among devices without manual intervention. Dynamic switching based on real-time, quantitative link quality assessment ensures that the communication path is always intelligently optimal, significantly improving user experience. Dual hot backup paths, conflict resolution protocols, hysteresis-based switching criteria, and disconnection reconnection mechanisms collectively guarantee high availability of services in complex network environments, providing end-to-end security from digital signatures in the device discovery phase to TLS encryption in the communication phase.
[0039] In this embodiment, a dynamic multicast group can be automatically generated based on the home identifier of the gateway device. By controlling the gateway device to send multicast messages and discovery messages to gateways within the dynamic multicast group, mutual discovery between different gateway devices is effectively facilitated. The discovery messages can effectively identify the multicast server and multicast client between different gateway devices. By controlling the multicast client and multicast server to exchange keys, the encryption key can be effectively obtained. When both the multicast client and multicast server successfully log in to the gateway, link communication is automatically controlled. By performing link quality detection on the multicast server and multicast client, the link path can be automatically switched based on the link quality detection results. Users do not need to manually connect link communication between gateway devices or switch link paths, which improves the user experience.
[0040] Example 2 Please see Figure 5 This is a schematic diagram of the gateway dynamic switching system 100 provided in the second embodiment of the present invention, including: The dynamic multicast module 10 is used to generate a dynamic multicast group based on the home identifier of the gateway device, and when any of the gateway devices joins the dynamic multicast group, it sends multicast messages and discovery messages to the gateways in the dynamic multicast group.
[0041] Optionally, the dynamic multicast module 10 is further configured to: upon receiving the multicast message, any of the gateway devices performs message verification on the multicast message; If the message verification of the multicast message is successful, a feedback message is sent to the transmitting gateway corresponding to the multicast message.
[0042] Furthermore, the dynamic multicast module 10 is also used to: generate the multicast message based on the identity information of the gateway device, and send the multicast message to the gateways within the dynamic multicast group; Obtain the device information of the gateway device, and generate the discovery message based on the device information. The device information includes protocol version, home identifier, device identifier, capability set bitmap, real-time performance indicators and digital signature. Start a timer with a time interval based on the Fibonacci sequence, and periodically send the discovery message to the gateway in the dynamic multicast group according to the timer.
[0043] The transmission connection module 11 is used to determine the multicast server and multicast client between different gateway devices based on the discovery message when any of the gateway devices receives the discovery message, and to control the multicast client to initiate a transmission control connection to the multicast server.
[0044] Optionally, the transmission connection module 11 is further configured to: calculate connection initiation weight values for different gateway devices respectively; The gateway device corresponding to the largest connection initiation weight value is identified as the multicast server, and the remaining gateway devices are identified as the multicast clients. The formula used to calculate the connection initiation weight value of different gateway devices includes:
[0045] in, This indicates the connection initiation weight value. , , This indicates the preset weighting coefficient. This indicates the ranking of the IP addresses of the corresponding gateway devices after normalization. This represents the hardware capability score of the corresponding gateway device. This indicates the utilization rate of the central processing unit of the corresponding gateway device.
[0046] The gateway login module 12 is used to control the multicast client and the multicast server to exchange keys, obtain an encryption key, and control the multicast client and the multicast server to perform gateway login according to the encryption key.
[0047] Optionally, the gateway login module 12 is further configured to: control the multicast client to exchange public keys with the multicast server, and control the multicast client to generate an Advanced Encryption Standard key; In the multicast client, the Advanced Encryption Standard key is encrypted using the public key of the multicast server to obtain the encryption key, and the encryption key is sent to the multicast client.
[0048] The link path switching module 13 is used to perform link communication after both the multicast client and the multicast server have successfully logged into the gateway, perform link quality detection on the multicast server and the multicast client, and switch the link path between the multicast server and the multicast client based on the link quality detection results.
[0049] Optionally, the link path switching module 13 is further configured to: control the multicast client to send a heartbeat packet to the multicast server according to a preset time interval, and when the multicast server receives the heartbeat packet, control the multicast server to send a heartbeat response to the multicast client; If the number of times the multicast server fails to respond to a heartbeat exceeds a threshold, the communication link between the multicast client and the multicast server is disconnected. If the multicast server does not receive a communication message from the multicast client within a preset time, the link communication between the multicast server and the multicast client is disconnected.
[0050] Furthermore, the link path switching module 13 is also used to: perform link quality detection on the local link communication and cloud link communication between the multicast server and the multicast client respectively, and obtain the link quality detection result, wherein the link quality detection result includes a first link quality score and a second link quality score; The link path is switched between the multicast server and the multicast client based on the first link quality score and the second link quality score.
[0051] Furthermore, the link path switching module 13 is also used to: calculate a hysteresis score based on the second link quality score and a preset hysteresis factor; When the first link quality score is less than the first link quality threshold, or the second link quality score is less than the hysteresis score, the local link communication is switched to the cloud link communication. When the first link quality score is greater than the second link quality threshold, and the second link quality score is greater than the hysteresis score, a handover timer is started to obtain the handover duration. When the timing switching duration exceeds the duration threshold, the cloud link communication is switched to the local link communication.
[0052] This embodiment also includes: The communication session management module maintains a unified communication session table, which records the communication status of all peer gateways and dynamically manages two parallel communication paths for each session: a local long-lived connection and a cloud-based connection. When the application layer sends a message, it only needs to specify the target gateway ID, and this module selects the optimal path for data transmission based on real-time policies.
[0053] The intelligent discovery and authentication module is responsible for automatically discovering legitimate peer gateways within the local area network. This module uses a secure multicast discovery protocol and integrates a lightweight authentication mechanism to ensure that only authorized devices can join the communication network.
[0054] The link quality monitoring and decision engine continuously performs multi-dimensional quality detection on local and cloud link communication paths, and calculates path quality scores in real time based on configurable algorithms, serving as the basis for intelligent switching.
[0055] The data routing and forwarding engine is responsible for executing the instructions of the decision engine, performing seamless and reliable data routing and forwarding between two paths, and ensuring that messages are not lost or out of order.
[0056] In this embodiment, a dynamic multicast group can be automatically generated based on the home identifier of the gateway device. By controlling the gateway device to send multicast messages and discovery messages to gateways within the dynamic multicast group, mutual discovery between different gateway devices is effectively facilitated. The discovery messages can effectively identify the multicast server and multicast client between different gateway devices. By controlling the multicast client and multicast server to exchange keys, the encryption key can be effectively obtained. When both the multicast client and multicast server successfully log in to the gateway, link communication is automatically controlled. By performing link quality detection on the multicast server and multicast client, the link path can be automatically switched based on the link quality detection results. Users do not need to manually connect link communication between gateway devices or switch link paths, which improves the user experience.
[0057] Example 3 Figure 6 This is a structural block diagram of a terminal device 2 provided in the third embodiment of this application. For example... Figure 6 As shown, the terminal device 2 in this embodiment includes: a processor 20, a memory 21, and a computer program 22 stored in the memory 21 and executable on the processor 20, such as a program for a gateway dynamic switching method. When the processor 20 executes the computer program 22, it implements the steps in the various embodiments of the above-described gateway dynamic switching methods.
[0058] For example, the computer program 22 may be divided into one or more modules, which are stored in the memory 21 and executed by the processor 20 to complete this application. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program 22 in the terminal device 2. The terminal device may include, but is not limited to, the processor 20 and the memory 21.
[0059] The processor 20 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0060] The memory 21 can be an internal storage unit of the terminal device 2, such as a hard drive or memory of the terminal device 2. The memory 21 can also be an external storage device of the terminal device 2, such as a plug-in hard drive, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the terminal device 2. Furthermore, the memory 21 can include both internal and external storage units of the terminal device 2. The memory 21 is used to store the computer program and other programs and data required by the terminal device. The memory 21 can also be used to temporarily store data that has been output or will be output.
[0061] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0062] If an integrated module is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. This computer-readable storage medium can be non-volatile or volatile. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable storage medium can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the contents of a computer-readable storage medium may be appropriately added to or subtracted from the contents as required by the legislation and patent practice in a jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, a computer-readable storage medium may not include electrical carrier signals and telecommunication signals.
[0063] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A method for dynamic gateway switching, characterized in that, The method includes: A dynamic multicast group is generated based on the home identifier of the gateway device, and when any of the gateway devices joins the dynamic multicast group, multicast messages and discovery messages are sent to the gateways in the dynamic multicast group. When any of the gateway devices receives the discovery message, it determines the multicast server and multicast client between different gateway devices based on the discovery message, and controls the multicast client to initiate a transmission control connection to the multicast server. The system controls the multicast client to exchange keys with the multicast server to obtain an encryption key, and controls the multicast client and the multicast server to log in to the gateway based on the encryption key. After both the multicast client and the multicast server successfully log in to the gateway, they establish link communication, perform link quality checks on the multicast server and the multicast client, and switch link paths for the multicast server and the multicast client based on the link quality check results.
2. The gateway dynamic switching method as described in claim 1, characterized in that, After sending multicast messages and discovery messages to the gateways within the dynamic multicast group, the process also includes: Upon receiving the multicast message, any of the gateway devices shall perform message verification on the multicast message; If the message verification of the multicast message is successful, a feedback message is sent to the transmitting gateway corresponding to the multicast message.
3. The gateway dynamic switching method as described in claim 1, characterized in that, Sending multicast messages and discovery messages to the gateways within the dynamic multicast group, including: The multicast message is generated based on the identity information of the gateway device, and the multicast message is sent to the gateways within the dynamic multicast group; Obtain the device information of the gateway device, and generate the discovery message based on the device information. The device information includes protocol version, home identifier, device identifier, capability set bitmap, real-time performance indicators and digital signature. Start a timer with a time interval based on the Fibonacci sequence, and periodically send the discovery message to the gateway in the dynamic multicast group according to the timer.
4. The gateway dynamic switching method as described in claim 1, characterized in that, Determining the multicast server and multicast client between different gateway devices based on the discovery message includes: Calculate the connection initiation weight value for each of the different gateway devices; The gateway device corresponding to the largest connection initiation weight value is identified as the multicast server, and the remaining gateway devices are identified as the multicast clients. The formula used to calculate the connection initiation weight value of different gateway devices includes: in, This indicates the connection initiation weight value. , , This indicates the preset weighting coefficient. This indicates the ranking of the IP addresses of the corresponding gateway devices after normalization. This represents the hardware capability score of the corresponding gateway device. This indicates the utilization rate of the central processing unit of the corresponding gateway device.
5. The gateway dynamic switching method as described in claim 1, characterized in that, Controlling the multicast client to exchange keys with the multicast server to obtain an encryption key includes: Control the multicast client to exchange public keys with the multicast server, and control the multicast client to generate Advanced Encryption Standard (AES) keys; In the multicast client, the Advanced Encryption Standard key is encrypted using the public key of the multicast server to obtain the encryption key, and the encryption key is sent to the multicast client.
6. The gateway dynamic switching method as described in claim 1, characterized in that, After link communication is established, the following also includes: The multicast client is controlled to send heartbeat packets to the multicast server according to a preset time interval, and when the multicast server receives the heartbeat packets, the multicast server is controlled to send a heartbeat response to the multicast client. If the number of times the multicast server fails to respond to a heartbeat exceeds a threshold, the communication link between the multicast client and the multicast server is disconnected. If the multicast server does not receive a communication message from the multicast client within a preset time, the link communication between the multicast server and the multicast client is disconnected.
7. The gateway dynamic switching method as described in claim 1, characterized in that, Perform link quality testing on the multicast server and the multicast client, and switch the link path between the multicast server and the multicast client based on the link quality testing results, including: Link quality detection is performed on the local link communication and cloud link communication between the multicast server and the multicast client respectively to obtain link quality detection results, which include a first link quality score and a second link quality score. The link path is switched between the multicast server and the multicast client based on the first link quality score and the second link quality score.
8. The gateway dynamic switching method as described in claim 7, characterized in that, Based on the first link quality score and the second link quality score, the multicast server and the multicast client are switched via link path, including: The hysteresis score is calculated based on the second link quality score and the preset hysteresis factor. When the first link quality score is less than the first link quality threshold, or the second link quality score is less than the hysteresis score, the local link communication is switched to the cloud link communication. When the first link quality score is greater than the second link quality threshold, and the second link quality score is greater than the hysteresis score, a handover timer is started to obtain the handover duration. When the timing switching duration exceeds the duration threshold, the cloud link communication is switched to the local link communication.
9. A gateway dynamic switching system, characterized in that, The system includes: The dynamic multicast module is used to generate a dynamic multicast group based on the home identifier of the gateway device, and when any of the gateway devices joins the dynamic multicast group, it sends multicast messages and discovery messages to the gateways in the dynamic multicast group. The transmission connection module is used to determine the multicast server and multicast client between different gateway devices based on the discovery message when any of the gateway devices receives the discovery message, and to control the multicast client to initiate a transmission control connection to the multicast server. The gateway login module is used to control the multicast client and the multicast server to exchange keys, obtain an encryption key, and control the multicast client and the multicast server to perform gateway login based on the encryption key; The link path switching module is used to perform link communication after both the multicast client and the multicast server have successfully logged into the gateway, to perform link quality detection on the multicast server and the multicast client, and to switch the link path between the multicast server and the multicast client based on the link quality detection results.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 8.