Self-adaptive networking method, device and equipment and computer readable storage medium
By employing an adaptive networking method led by the server-side device, and by searching and matching the hardware addresses of terminal devices and updating IP configurations, the stability of connections between devices in different network segments is resolved, thereby achieving network system stability and reliability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-01
- Publication Date
- 2026-04-03
AI Technical Summary
When the server and terminal devices are on different network segments, existing technologies rely on the terminal devices' IP adaptive technology to obtain IP addresses and establish network connections. This can easily lead to IP conflicts and result in weak network connection stability.
By using an adaptive networking method led by the server-side device, the system searches for addable terminal devices in each network segment, obtains their hardware addresses, matches them with the hardware addresses of already connected devices, determines whether a device is the first or second terminal device, updates or connects the device based on its IP address, and repeats the search steps after hibernation to ensure the stability of the network system.
It improves the stability of network connections between server devices and terminal devices, especially by quickly responding and updating configurations when IP addresses change, ensuring the reliability of the network system.
Smart Images

Figure CN121792425A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to adaptive networking methods, apparatus, devices and computer-readable storage media. Background Technology
[0002] The stability of the network connection between server-side devices and terminal devices has a significant impact on the network system. For example, in a security network system with an NVR (Network Video Recorder) as the core gateway, the stability of the network connection between the NVR and IPC (IP-CAMERA) directly determines the reliability and maintenance cost of the entire security network system. When server-side devices and terminal devices are on different network segments, how to establish a network connection between them and ensure the stability of the network connection is extremely important for building a reliable network system.
[0003] The conventional approach is to use the IP adaptive technology of the terminal device to obtain an IP address (Internet Protocol) that is in the same network segment as the server device within the local area network, and then connect the terminal device and the server device to build a network system.
[0004] However, the solution of obtaining IP through IP adaptive technology of terminal devices is prone to IP conflict. As a result, the network connection stability between server devices and terminal devices in the network system built by this solution is relatively weak.
[0005] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention
[0006] The main objective of this application is to provide an adaptive networking method, apparatus, device, and computer-readable storage medium, which aims to build a network system dominated by server-side devices and terminal devices, thereby improving the stability of the network connection between server-side devices and terminal devices.
[0007] To achieve the above objectives, this application provides an adaptive networking method, the steps of which include:
[0008] Search for addable terminal devices in each network segment, and obtain the hardware address of the addable terminal device and the hardware address of the terminal device that has been connected to the server device;
[0009] Based on the matching result between the hardware address of the addable terminal device and the hardware address of the added terminal device, when it is determined that the addable terminal device is the first terminal device that has been connected to the server device, the IP configuration of the channel of the server device corresponding to the first terminal device is updated according to the IP address of the first terminal device, and the first terminal device and the server device are connected.
[0010] When it is determined that the addable terminal device is a second terminal device that has not been connected to the server device, the second terminal device is connected to the server device;
[0011] After the addable terminal device establishes a connection with the server device, it sleeps for a preset time and then returns to perform the steps of searching for addable terminal devices in each network segment and subsequent steps.
[0012] Optionally, the step of updating the IP configuration of the channel of the server device corresponding to the first terminal device based on the IP address of the first terminal device includes:
[0013] Obtain the IP address of the first terminal device and the IP address of the added terminal device;
[0014] When the IP address of the first terminal device is the same as the IP address of the added terminal device, connect the first terminal device and the server device, and execute the step of sleeping for a preset duration.
[0015] When the IP address of the first terminal device is inconsistent with the IP address of the added terminal device, the IP configuration of the channel of the server device corresponding to the first terminal device is updated according to the network segment where the IP address of the first terminal device is located.
[0016] Optionally, the step of updating the IP configuration of the channel of the server device corresponding to the first terminal device according to the network segment where the IP address of the first terminal device is located includes:
[0017] Determine whether the network segment where the first terminal device is located is reachable;
[0018] When the network segment where the first terminal device is located is reachable, update the channel IP configuration of the server device corresponding to the first terminal device according to the IP address of the first terminal device.
[0019] When the network segment where the first terminal device is located is unreachable, a virtual IP address consistent with the network segment where the first terminal device is located is created, and the channel IP configuration of the server device corresponding to the first terminal device is updated according to the virtual IP address.
[0020] Optionally, the step of connecting the second terminal device and the server device includes:
[0021] Determine whether the server device has an available channel;
[0022] If the server device has an idle channel, then the second terminal device and the server device are connected through the idle channel;
[0023] If the server device does not have an idle channel, then the step of sleeping for a preset duration is executed.
[0024] Optionally, the step of connecting the second terminal device and the server device through the idle channel includes:
[0025] Obtain the IP address of the second terminal device and the IP address of the server device;
[0026] When the second terminal device and the server device are in the same network segment, the second terminal device and the server device are connected through the idle channel;
[0027] When the second terminal device and the server device are not on the same network segment, the IP address of the second terminal device is changed to the IP address of the network segment where the server device is located, and the second terminal device and the server device are connected through the idle channel.
[0028] Optionally, the step of changing the IP address of the second terminal device to the IP address of the network segment where the server device is located includes:
[0029] Based on the IP address of the terminal device in the network segment where the server device is located, obtain the unassigned available IP address in the network segment where the server device is located;
[0030] Send a change command to change the IP address of the second terminal device to the available IP address.
[0031] Optionally, the step of searching for addable terminal devices in each network segment includes:
[0032] Obtain the IP addresses of each network segment within the local area network, and send search packets to each network segment using the IP addresses of each network segment to detect all terminal devices within the local area network;
[0033] When a response packet from the terminal device is received, the terminal device that sent the response packet is marked as an addable terminal device.
[0034] This application also provides an adaptive networking device, the adaptive networking device comprising:
[0035] The search module is used to search for addable terminal devices in each network segment, and to obtain the hardware address of the addable terminal device and the hardware address of the added terminal device that has been connected to the server device.
[0036] The update module is used to update the IP configuration of the channel of the server device corresponding to the first terminal device based on the IP address of the first terminal device when it is determined that the addable terminal device is the first terminal device that has been connected to the server device, according to the matching result of the hardware address of the addable terminal device and the hardware address of the added terminal device, and connect the first terminal device and the server device.
[0037] A connection module is used to connect the second terminal device to the server device when it is determined that the addable terminal device is a second terminal device that has not been connected to the server device before.
[0038] The hibernation module is used to hibernate for a preset time after the addable terminal device establishes a connection with the server device, and then return to perform the steps of searching for addable terminal devices in each network segment and subsequent steps.
[0039] This application also provides an adaptive networking device, the adaptive networking device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the adaptive networking method as described in any of the preceding claims.
[0040] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the adaptive networking method as described in any of the preceding claims.
[0041] An embodiment of this application proposes an adaptive networking method that searches for addable terminal devices in each network segment, obtains the hardware address of the addable terminal device and the hardware address of the added terminal device that has been connected to the server device, and based on the matching result of the hardware address of the addable terminal device and the hardware address of the added terminal device, when it is determined that the addable terminal device is a first terminal device that has been connected to the server device, the IP configuration of the channel of the server device corresponding to the first terminal device is updated according to the IP address of the first terminal device, and the first terminal device and the server device are connected. When it is determined that the addable terminal device is a second terminal device that has not been connected to the server device, the second terminal device and the server device are connected. After the addable terminal device and the server device establish a connection, the system sleeps for a preset time and then returns to the steps of searching for addable terminal devices in each network segment and subsequent steps.
[0042] In conventional technologies, terminal devices typically obtain IP addresses on the same network segment as the server devices within the local area network (LAN) using IP auto-adaptive technology. This is then used to connect the terminal devices and the server devices to build a network system. However, for medium to large-scale network systems built using IP networks, this approach is prone to IP conflicts. Consequently, the network connection stability between the server devices and terminal devices in such systems is relatively weak.
[0043] Compared to conventional network setup solutions, this application establishes a network system for the server device and connected terminal devices using a server-side device. First, it searches for addable terminal devices in each network segment, obtaining the hardware addresses of both addable and previously connected terminal devices. Then, it matches the hardware addresses of the addable and connected terminal devices, determining whether the found addable terminal device is the first terminal device previously connected to the server. If it is, the IP configuration of the server device's channel is updated based on the IP address of the first terminal device. If it is not, the addable terminal device is connected to the server, adding it to the network system of the server device. After completing these steps, the system sleeps for a preset time, then returns to the previous state and repeats the steps of searching for addable terminal devices in each network segment and subsequent steps.
[0044] Unlike conventional technologies that rely on terminal devices' IP adaptive technology to obtain IP addresses and establish connections with server devices, this application is led by the server device. It categorizes searched, addable terminal devices into first-terminal devices that have previously connected to the server device and second-terminal devices that have not. This ensures that the server device can quickly respond when the IP address of an added terminal device changes. Based on the changed IP address of the first-terminal device, the server device modifies the IP configuration of the channel corresponding to the previously added terminal device. Simultaneously, it can promptly connect to second-terminal devices not yet added to the network system. This establishes a server-driven network system between the server and terminal devices, effectively improving the stability of network connections between them. Attached Figure Description
[0045] Figure 1 This is a schematic diagram of the structure of the adaptive networking device for the hardware operating environment involved in the embodiments of this application;
[0046] Figure 2This is a flowchart illustrating the first embodiment of this application;
[0047] Figure 3 This is a schematic diagram of the first embodiment of this application;
[0048] Figure 4 This is a flowchart illustrating the solution of an embodiment of this application;
[0049] Figure 5 This is a schematic diagram of the functional modules of the adaptive networking device involved in the embodiments of this application.
[0050] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0051] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.
[0052] Reference Figure 1 , Figure 1 This is a schematic diagram of the adaptive networking device structure of the hardware operating environment involved in the embodiments of this application.
[0053] like Figure 1 As shown, the adaptive networking device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen or an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be a high-speed random access memory (RAM) or a stable non-volatile memory (NVM), such as a disk drive. The memory 1005 may also optionally be a storage device independent of the aforementioned processor 1001.
[0054] Those skilled in the art will understand that Figure 1 The structure shown does not constitute a limitation on adaptive networking devices and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0055] like Figure 1As shown, the memory 1005, which serves as a storage medium, may include an operating system, a network communication module, a user interface module, and computer programs.
[0056] exist Figure 1 In the adaptive networking device shown, the network interface 1004 is mainly used for data communication with other devices; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and memory 1005 in the adaptive networking device of this application can be set in the adaptive networking device, and the adaptive networking device calls the adaptive networking program stored in the memory 1005 through the processor 1001 and executes the adaptive networking method provided in the embodiment of this application:
[0057] Search for addable terminal devices in each network segment, and obtain the hardware address of the addable terminal device and the hardware address of the terminal device that has been connected to the server device;
[0058] Based on the matching result between the hardware address of the addable terminal device and the hardware address of the added terminal device, when it is determined that the addable terminal device is the first terminal device that has been connected to the server device, the IP configuration of the channel of the server device corresponding to the first terminal device is updated according to the IP address of the first terminal device, and the first terminal device and the server device are connected.
[0059] When it is determined that the addable terminal device is a second terminal device that has not been connected to the server device, the second terminal device is connected to the server device;
[0060] After the addable terminal device establishes a connection with the server device, it sleeps for a preset time and then returns to perform the steps of searching for addable terminal devices in each network segment and subsequent steps.
[0061] In one embodiment, the processor 1001 may invoke a computer program stored in the memory 1005 and further perform the following operations:
[0062] Obtain the IP address of the first terminal device and the IP address of the added terminal device;
[0063] When the IP address of the first terminal device is the same as the IP address of the added terminal device, connect the first terminal device and the server device, and execute the step of sleeping for a preset duration.
[0064] When the IP address of the first terminal device is inconsistent with the IP address of the added terminal device, the IP configuration of the channel of the server device corresponding to the first terminal device is updated according to the network segment where the IP address of the first terminal device is located.
[0065] In one embodiment, the processor 1001 may invoke a computer program stored in the memory 1005 and further perform the following operations:
[0066] Determine whether the network segment where the first terminal device is located is reachable;
[0067] When the network segment where the first terminal device is located is reachable, update the channel IP configuration of the server device corresponding to the first terminal device according to the IP address of the first terminal device.
[0068] When the network segment where the first terminal device is located is unreachable, a virtual IP address consistent with the network segment where the first terminal device is located is created, and the channel IP configuration of the server device corresponding to the first terminal device is updated according to the virtual IP address.
[0069] In one embodiment, the processor 1001 may invoke a computer program stored in the memory 1005 and further perform the following operations:
[0070] Determine whether the server device has an available channel;
[0071] If the server device has an idle channel, then the second terminal device and the server device are connected through the idle channel;
[0072] If the server device does not have an idle channel, then the step of sleeping for a preset duration is executed.
[0073] In one embodiment, the processor 1001 may invoke a computer program stored in the memory 1005 and further perform the following operations:
[0074] Obtain the IP address of the second terminal device and the IP address of the server device;
[0075] When the second terminal device and the server device are in the same network segment, the second terminal device and the server device are connected through the idle channel;
[0076] When the second terminal device and the server device are not on the same network segment, the IP address of the second terminal device is changed to the IP address of the network segment where the server device is located, and the second terminal device and the server device are connected through the idle channel.
[0077] In one embodiment, the processor 1001 may invoke a computer program stored in the memory 1005 and further perform the following operations:
[0078] Based on the IP address of the terminal device in the network segment where the server device is located, obtain the unassigned available IP address in the network segment where the server device is located;
[0079] Send a change command to change the IP address of the second terminal device to the available IP address.
[0080] In one embodiment, the processor 1001 may invoke a computer program stored in the memory 1005 and further perform the following operations:
[0081] Obtain the IP addresses of each network segment within the local area network, and send search packets to each network segment using the IP addresses of each network segment to detect all terminal devices within the local area network;
[0082] When a response packet from the terminal device is received, the terminal device that sent the response packet is marked as an addable terminal device.
[0083] This application provides an adaptive networking method, referring to... Figure 2 , Figure 2 This is a flowchart illustrating a first embodiment of an adaptive networking method according to this application.
[0084] In a typical application scenario, the adaptive networking method described in this application is used to build a security network system. The server device is an NVR (Network Video Recorder), and the terminal device is an IPC (IP-CAMERA). In a security network system with the NVR as the core gateway, the stability of the network connection between the NVR and the IPC directly determines the reliability and maintenance cost of the entire security network system. By applying the adaptive networking method described in this application, the NVR automatically connects to IPCs in each network segment that are not yet part of the security network system and listens to the IPCs connected to the NVR. When the IP address (Internet Protocol Address) of the IPC changes, the IP configuration of the NVR channel corresponding to that IPC is modified according to the changed IP address, thus building a security network system led by the NVR and improving the stability of the network connection between the NVR and the IPCs connected to the NVR.
[0085] In this embodiment, the adaptive networking method includes the following steps:
[0086] Step S10: Search for addable terminal devices in each network segment, and obtain the hardware address of the addable terminal device and the hardware address of the added terminal device that has been connected to the server device;
[0087] In this embodiment, the server device searches for addable terminal devices in each network segment and obtains the hardware address (Media Access Control Address, MAC) of the addable terminal devices and the hardware address of the added terminal devices that have been connected to the server device. Here, addable terminal devices refer to terminal devices in each network segment that can be searched by the server device but have not been connected to the server device, and added terminal devices refer to terminal devices that have been connected to the server device and have joined the network system where the server device is located.
[0088] Reference Figure 3 The system adds the discovered addable terminal devices to the server's discovery list, retrieves the server's list of added devices, and compares the MAC addresses of the addable terminal devices in the discovery list with the MAC addresses of each added terminal device in the added device list. Using the device's MAC address as a unique identifier, by checking if a device with the same MAC address exists in both the discovery and added device lists, it can distinguish whether an addable terminal device is a second terminal device that has not previously connected to the server.
[0089] Step S20: Based on the matching result between the hardware address of the addable terminal device and the hardware address of the added terminal device, when it is determined that the addable terminal device is the first terminal device that has been connected to the server device, update the IP configuration of the channel of the server device corresponding to the first terminal device according to the IP address of the first terminal device, and connect the first terminal device and the server device.
[0090] In this embodiment, when it is determined that the addable terminal device is the first terminal device that has been connected to the server device, the IP configuration of the channel of the server device corresponding to the first terminal device is updated according to the IP address of the first terminal device. By changing the channel after the IP configuration, the first terminal device and the server device are connected.
[0091] Based on the matching results between the hardware addresses of the addable terminal devices and the hardware addresses of the already added terminal devices, if there is an already added terminal device with the same hardware address as the addable terminal device among the already added terminal devices that have been connected to the server device, it means that the addable terminal device is the first terminal device that has been connected to the server device, that is, the already added terminal device that has been disconnected from the server device. The IP configuration of the channel in the server device corresponding to the first terminal device is the same as the IP configuration of the channel in the server device corresponding to the already added terminal device.
[0092] It is understandable that terminal devices already in the network system may be found by the server device again due to reasons such as IP address changes or power outages and reconnections. If the IP address of the terminal device has not changed, there is no need to update the IP configuration of the channel, and the connection with the server device can be established directly through the original channel.
[0093] Reference Figure 3 , Figure 3 The addable terminal device whose MAC address is the same as that of a terminal device already added to the list is the first terminal device involved in this application. Matching and comparing the MAC addresses of addable terminal devices in the list with those of terminal devices in the list of added devices reveals that if there are both addable and added terminal devices with the same MAC address, then the addable terminal device is the first terminal device. Based on the IP address of the addable terminal device, the IP configuration of the channel of the server device corresponding to the addable terminal device is updated, and the addable terminal device and the server device are reconnected.
[0094] Step S30: When it is determined that the addable terminal device is a second terminal device that has not been connected to the server device, connect the second terminal device to the server device;
[0095] In this embodiment, based on the matching result between the hardware address of the addable terminal device and the hardware address of the already added terminal devices, if there is no terminal device with the same hardware address as the addable terminal device among the already added terminal devices that have been connected to the server device, then it is determined that the addable terminal device is a second terminal device that has not been connected to the server device. The second terminal device is then connected to the server device, and the second terminal device is added to the network system.
[0096] Reference Figure 3 , Figure 3 The addable terminal device whose MAC address is different from that of the terminal devices already added to the list is the second terminal device involved in this application. By comparing the MAC addresses of the addable terminal devices in the list with those of the added terminal devices in the list of added devices, if the MAC address of the added terminal device is different from that of the addable terminal device, then the addable terminal device is connected to the server device.
[0097] Step S40: After the addable terminal device establishes a connection with the server device, it sleeps for a preset time and then returns to the step of searching for addable terminal devices in each network segment and subsequent steps.
[0098] In this embodiment, after the addable terminal device establishes a connection with the server device, it sleeps for a preset time, and then returns to perform the steps of searching for addable terminal devices in each network segment and subsequent steps. The preset time can be adjusted according to actual conditions. For example, refer to... Figure 3 After connecting the addable terminal device to the server device, it sleeps for 10 seconds and then returns to the steps of searching for addable terminal devices and adding them to the discovery list.
[0099] An embodiment of this application proposes an adaptive networking method that searches for addable terminal devices in each network segment, obtains the hardware address of the addable terminal device and the hardware address of the added terminal device that has been connected to the server device, and based on the matching result of the hardware address of the addable terminal device and the hardware address of the added terminal device, when it is determined that the addable terminal device is a first terminal device that has been connected to the server device, the IP configuration of the channel of the server device corresponding to the first terminal device is updated according to the IP address of the first terminal device, and the first terminal device and the server device are connected. When it is determined that the addable terminal device is a second terminal device that has not been connected to the server device, the second terminal device and the server device are connected. After the addable terminal device and the server device establish a connection, the system sleeps for a preset time and then returns to the steps of searching for addable terminal devices in each network segment and subsequent steps.
[0100] In conventional technologies, terminal devices typically obtain IP addresses on the same network segment as the server devices within the local area network (LAN) using IP auto-adaptive technology. This is then used to connect the terminal devices and the server devices to build a network system. However, for medium to large-scale network systems built using IP networks, this approach is prone to IP conflicts. Consequently, the network connection stability between the server devices and terminal devices in such systems is relatively weak.
[0101] Compared to conventional network setup solutions, this application establishes a network system for the server device and connected terminal devices using a server-side device. First, it searches for addable terminal devices in each network segment, obtaining the hardware addresses of both addable and previously connected terminal devices. Then, it matches the hardware addresses of the addable and connected terminal devices, determining whether the found addable terminal device is the first terminal device previously connected to the server. If it is, the IP configuration of the server device's channel is updated based on the IP address of the first terminal device. If it is not, the addable terminal device is connected to the server, adding it to the network system of the server device. After completing these steps, the system sleeps for a preset time, then returns to the previous state and repeats the steps of searching for addable terminal devices in each network segment and subsequent steps.
[0102] Unlike conventional technologies that rely on terminal devices' IP adaptive technology to obtain IP addresses and establish connections with server devices, this application is led by the server device. It categorizes searched, addable terminal devices into first-terminal devices that have previously connected to the server device and second-terminal devices that have not. This ensures that the server device can quickly respond when the IP address of an added terminal device changes. Based on the changed IP address of the first-terminal device, the server device modifies the IP configuration of the channel corresponding to the previously added terminal device. Simultaneously, it can promptly connect to second-terminal devices not yet added to the network system. This establishes a server-driven network system between the server and terminal devices, effectively improving the stability of network connections between them.
[0103] Optionally, in the second embodiment, based on the first embodiment described above, the step of updating the IP configuration of the channel of the server device corresponding to the first terminal device according to the IP address of the first terminal device includes:
[0104] Obtain the IP address of the first terminal device and the IP address of the added terminal device;
[0105] When the IP address of the first terminal device is the same as the IP address of the added terminal device, connect the first terminal device and the server device, and execute the step of sleeping for a preset duration.
[0106] When the IP address of the first terminal device is inconsistent with the IP address of the added terminal device, the IP configuration of the channel of the server device corresponding to the first terminal device is updated according to the network segment where the IP address of the first terminal device is located.
[0107] In one embodiment, the IP address of the first terminal device and the IP address of the added terminal device are obtained. If the IP address of the first terminal device and the IP address of the added terminal device are consistent, the first terminal device and the server device are connected, and a step of sleeping for a preset time is performed. If the IP address of the first terminal device and the IP address of the added terminal device are inconsistent, the IP configuration of the channel of the server device corresponding to the first terminal device is updated according to the network segment where the IP address of the first terminal device is located.
[0108] After determining that the hardware addresses of the addable terminal device and the already added terminal device are the same, it is determined that the addable terminal device is the first terminal device that is already in the network system but has lost connection with the server device. Then, the IP address of the first terminal device and the IP address used by the already added terminal device with the same MAC address as the first terminal device when connecting to the server device are obtained, and it is determined whether the reason for the first terminal device's disconnection is that the IP address of the first terminal device has changed.
[0109] If the IP addresses are the same, it means the first terminal device that lost connection can directly reconnect using the existing channel IP configuration for the added terminal device. If the IP addresses are different, it means the channel IP configuration for the added terminal device needs to be updated before the connection between the server device and the first terminal device can be re-established. By reconnecting to a terminal device whose IP address has not changed, or updating the channel IP configuration for the added terminal device before reconnecting to the first terminal device, the stability of the network connection between the added terminal devices and the server device in the network system where the server device is located is effectively maintained.
[0110] Reference Figure 4 , Figure 4 The addable terminal device whose MAC address matches that of the already added terminal device is the first terminal device in the adaptive networking method involved in this application. After determining that the MAC addresses of the addable terminal device and the already added terminal device are the same, it is determined whether the IP addresses of the addable terminal device and the already added terminal device are the same. If the IP addresses are the same, the connection is re-established and the step of sleeping for 10 seconds is executed; if the IP addresses are different, the IP configuration of the channel corresponding to the addable terminal device is updated according to the network segment where the addable device's IP address is located, and then the server device and the addable terminal device are reconnected.
[0111] Optionally, in the third embodiment, based on the second embodiment described above, the step of updating the IP configuration of the channel of the server device corresponding to the first terminal device according to the network segment where the IP address of the first terminal device is located includes:
[0112] Determine whether the network segment where the first terminal device is located is reachable;
[0113] When the network segment where the first terminal device is located is reachable, update the channel IP configuration of the server device corresponding to the first terminal device according to the IP address of the first terminal device.
[0114] When the network segment where the first terminal device is located is unreachable, a virtual IP address consistent with the network segment where the first terminal device is located is created, and the channel IP configuration of the server device corresponding to the first terminal device is updated according to the virtual IP address.
[0115] In one embodiment, it is determined whether the network segment where the IP address of the first terminal device is located is reachable. If it is determined that the network segment where the first terminal device is located is reachable, the channel IP configuration of the server device corresponding to the added terminal device is modified according to the IP address of the first terminal device. If it is determined that the network segment where the first terminal device is located is unreachable, a virtual IP address consistent with the network segment where the first terminal device is located is created, and the channel IP configuration of the server device corresponding to the first terminal device is updated according to the virtual IP address.
[0116] Specifically, determining whether the network segment where the IP address of the first terminal device is located is reachable is equivalent to determining whether the server device can establish a connection with the first terminal device. The server device creates a virtual IP address that can establish a connection with the network segment where the terminal device is located through network interface card multiple access (NIC) technology. The server device communicates with the terminal device through the virtual IP address, which effectively improves the flexibility and stability of the network connection between the server device and the terminal device in the network system.
[0117] Reference Figure 4 , Figure 4The addable terminal device whose MAC address matches that of an already added terminal device is the first terminal device in the adaptive networking method involved in this application. After determining that the IP address of the addable terminal device is different from that of an already added terminal device with the same MAC address, it is determined whether the network segment where the IP address of the addable terminal device is located is reachable. If the network segment where the IP address of the addable terminal device is located is reachable, the channel IP configuration corresponding to the addable terminal device is updated directly according to the IP address of the addable terminal device, and the first terminal device and the server device are connected. If the network segment where the IP address of the addable terminal device is located is not reachable, a virtual IP address that is reachable from the network segment where the IP address of the addable terminal device is located is created for the server device, and then the IP configuration of the channel corresponding to the addable terminal device is updated. The server device reconnects to the addable terminal device through the virtual IP address.
[0118] Optionally, in the fourth embodiment, based on the first embodiment described above, the step of connecting the second terminal device and the server device includes:
[0119] Determine whether the server device has an available channel;
[0120] If the server device has an idle channel, then the second terminal device and the server device are connected through the idle channel;
[0121] If the server device does not have an idle channel, then the step of sleeping for a preset duration is executed.
[0122] In one embodiment, it is determined whether the server device has an idle channel. If the server device has an idle channel, the second terminal device is connected to the server device through the idle channel. If the server device does not have an idle channel, the device directly executes a sleep preset time and returns to the step of searching for addable terminal devices in each network segment and subsequent steps. The terminal device establishes a network connection with the server device through the channel allocated by the server device. An idle channel refers to a channel in the server device that is not connected to the terminal device. For example, the NVR in the security network system includes 16 connection channels and can establish network connections with 16 IPCs to receive messages transmitted by the 16 IPCs. After the NVR is connected to 13 IPCs, the NVR still has 3 unconnected idle channels.
[0123] By determining whether the server-side device has an available channel, a connection is established with the discovered second terminal device when an available channel exists, and the device goes into hibernation when no available channel exists. This improves the flexibility of the server-side device and prevents it from consuming excessive search bandwidth. Furthermore, if the server-side device loses connection with an added terminal device, and that added terminal device is subsequently discovered, it can quickly reconnect through the previously established channel. Understandably, in medium to large-scale network systems, detecting the channel connectivity of the server-side device can quickly identify disconnected added terminal devices, helping to maintain the stability of the network connection between the server-side device and added terminal devices.
[0124] Optionally, in the fifth embodiment, based on the fourth embodiment described above, the step of connecting the second terminal device and the server device through the idle channel includes:
[0125] Obtain the IP address of the second terminal device and the IP address of the server device;
[0126] When the second terminal device and the server device are in the same network segment, the second terminal device and the server device are connected through the idle channel;
[0127] When the second terminal device and the server device are not on the same network segment, the IP address of the second terminal device is changed to the IP address of the network segment where the server device is located, and the second terminal device and the server device are connected through the idle channel.
[0128] In one embodiment, the IP address of the second terminal device and the IP address of the server device are obtained. If the IP address of the second terminal device and the IP address of the server device are determined to be in the same network segment, the second terminal device and the server device are connected through an idle channel. If the IP address of the second terminal device and the IP address of the server device are determined to be in different network segments, the IP address of the second terminal device is changed to the IP address of the network segment where the server device is located, and the second terminal device and the server device are connected through an idle channel.
[0129] Compared to network connections established across network segments, network connections established within the same network segment are more stable. Therefore, by changing the IP address of the second terminal device, which is located in a different network segment from the server device, to an IP address in the same network segment as the server device, and then connecting the second terminal device and the server device, the second terminal device is added to the network system where the server device is located, effectively improving the stability of the connection between the server device and the terminal device.
[0130] Reference Figure 4 , Figure 4 The addable terminal device whose MAC address is inconsistent with that of the already added terminal devices is the second terminal device in the adaptive networking method involved in this application. After determining that the addable terminal device's MAC address is inconsistent with that of the already added terminal devices, it is determined whether the server device has an idle channel. If an idle channel exists, it is determined whether the network segment where the addable terminal device is located is consistent with the network segment where the server device is located. If the network segment where the addable terminal device is located is consistent with the network segment where the server device is located, the addable device is added to the network system; if the network segment where the addable terminal device is located is inconsistent with the network segment where the server device is located, the IP address of the addable terminal device is changed to an IP address consistent with the network segment where the server device is located.
[0131] Optionally, in the sixth embodiment, based on the fifth embodiment described above, the step of changing the IP address of the second terminal device to the IP address of the network segment where the server device is located includes:
[0132] Based on the IP address of the terminal device in the network segment where the server device is located, obtain the unassigned available IP address in the network segment where the server device is located;
[0133] Send a change command to change the IP address of the second terminal device to the available IP address.
[0134] In one embodiment, the IP addresses of terminal devices in the network segment where the server device is located are scanned. Based on the IP addresses of terminal devices in the network segment where the server device is located, an unallocated available IP address in the network segment where the server device is located is obtained. A change instruction is sent to change the IP address of the second terminal device to the available IP address. The change instruction is a broadcast instruction.
[0135] By obtaining an unassigned available IP address, the available IP address is assigned to a second terminal device located on a different network segment than the server device. This ensures that there will be no IP conflict between the second terminal device and the added terminal device in the same network segment, and that the added terminal device and the server device are on the same network segment before network connection is established, effectively improving the stability of the network connection between the server device and the terminal device.
[0136] Optionally, in the seventh embodiment, based on the first embodiment described above, the step of searching for addable terminal devices in each network segment includes:
[0137] Obtain the IP addresses of each network segment within the local area network, and send search packets to each network segment using the IP addresses of each network segment to detect all terminal devices within the local area network;
[0138] When a response packet from the terminal device is received, the terminal device that sent the response packet is marked as an addable terminal device.
[0139] In one embodiment, the server device obtains the IP addresses of each network segment within the local area network (LAN) based on NIC multiple access technology. Using these IP addresses, it sends search packets to each network segment to probe all terminal devices within the LAN. When the server device receives a response packet from a terminal device, it marks the terminal device that sent the response packet as an addable terminal device. The search packets can be sent via broadcast or multicast. The search packet is a data packet used to search for addable terminal devices that can establish a connection with the server device, and the response packet is a data packet sent by the terminal device that can establish a connection with the server device.
[0140] If a response is received from the terminal device, it indicates that the terminal device is online and can establish a connection with the server device. The server device marks the terminal device as an addable terminal device, enabling cross-network segment search for addable terminal devices, effectively expanding the search scope, allowing addable terminal devices in each network segment to establish network connections with the server device, join the network system of the server device and terminal devices, and maintain the stability of the connections of the added terminal devices.
[0141] Reference Figure 5 This application also provides an adaptive networking device, the adaptive networking device comprising:
[0142] The search module M1 is used to search for addable terminal devices in each network segment and obtain the hardware address of the addable terminal device and the hardware address of the added terminal device that has been connected to the server device.
[0143] The update module M2 is used to update the IP configuration of the channel of the server device corresponding to the first terminal device based on the IP address of the first terminal device when it is determined that the addable terminal device is the first terminal device that has been connected to the server device, according to the matching result of the hardware address of the addable terminal device and the hardware address of the added terminal device, and connect the first terminal device and the server device.
[0144] The connection module M3 is used to connect the second terminal device and the server device when it is determined that the addable terminal device is a second terminal device that has not been connected to the server device before.
[0145] The hibernation module M4 is used to hibernate for a preset time after the addable terminal device establishes a connection with the server device, and then return to perform the steps of searching for addable terminal devices in each network segment and subsequent steps.
[0146] Preferably, the update module is further configured to:
[0147] Obtain the IP address of the first terminal device and the IP address of the added terminal device;
[0148] When the IP address of the first terminal device is the same as the IP address of the added terminal device, connect the first terminal device and the server device, and execute the step of sleeping for a preset duration.
[0149] When the IP address of the first terminal device is inconsistent with the IP address of the added terminal device, the IP configuration of the channel of the server device corresponding to the first terminal device is updated according to the network segment where the IP address of the first terminal device is located.
[0150] Preferably, the update module is further configured to:
[0151] Determine whether the network segment where the first terminal device is located is reachable;
[0152] When the network segment where the first terminal device is located is reachable, update the channel IP configuration of the server device corresponding to the first terminal device according to the IP address of the first terminal device.
[0153] When the network segment where the first terminal device is located is unreachable, a virtual IP address consistent with the network segment where the first terminal device is located is created, and the channel IP configuration of the server device corresponding to the first terminal device is updated according to the virtual IP address.
[0154] Preferably, the connection module is further used for:
[0155] Determine whether the server device has an available channel;
[0156] If the server device has an idle channel, then the second terminal device and the server device are connected through the idle channel;
[0157] If the server device does not have an idle channel, then the step of sleeping for a preset duration is executed.
[0158] Preferably, the connection module is further used for:
[0159] Obtain the IP address of the second terminal device and the IP address of the server device;
[0160] When the second terminal device and the server device are in the same network segment, the second terminal device and the server device are connected through the idle channel;
[0161] When the second terminal device and the server device are not on the same network segment, the IP address of the second terminal device is changed to the IP address of the network segment where the server device is located, and the second terminal device and the server device are connected through the idle channel.
[0162] Preferably, the connection module is further used for:
[0163] Based on the IP address of the terminal device in the network segment where the server device is located, obtain the unassigned available IP address in the network segment where the server device is located;
[0164] Send a change command to change the IP address of the addable terminal device to the available IP address.
[0165] Preferably, the search module is further used for:
[0166] Obtain the IP addresses of each network segment within the local area network, and send search packets to each network segment using the IP addresses of each network segment to detect all terminal devices within the local area network;
[0167] When a response packet from the terminal device is received, the terminal device that sent the response packet is marked as an addable terminal device.
[0168] The adaptive networking device provided in this application employs the adaptive networking method described in the above embodiments, aiming to build a network system dominated by the server device and connecting server devices and terminal devices, thereby improving the stability of the network connection between the server device and terminal devices. Compared with conventional technologies, the beneficial effects of the adaptive networking device provided in this application are the same as those of the adaptive networking method provided in the above embodiments, and other technical features in the adaptive networking device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0169] This application also provides an adaptive networking device, the adaptive networking device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the adaptive networking method as described in any of the preceding claims.
[0170] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the adaptive networking method as described in any of the preceding claims.
[0171] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0172] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0173] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0174] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. An adaptive networking method, characterized in that, The steps of the adaptive networking method include: Search for addable terminal devices in each network segment, and obtain the hardware address of the addable terminal device and the hardware address of the terminal device that has been connected to the server device; Based on the matching result between the hardware address of the addable terminal device and the hardware address of the added terminal device, when it is determined that the addable terminal device is the first terminal device that has been connected to the server device, the IP configuration of the channel of the server device corresponding to the first terminal device is updated according to the IP address of the first terminal device, and the first terminal device and the server device are connected. When it is determined that the addable terminal device is a second terminal device that has not been connected to the server device, the second terminal device is connected to the server device; After the addable terminal device establishes a connection with the server device, it sleeps for a preset time and then returns to perform the steps of searching for addable terminal devices in each network segment and subsequent steps.
2. The adaptive networking method as described in claim 1, characterized in that, The step of updating the IP configuration of the channel of the server device corresponding to the first terminal device based on the IP address of the first terminal device includes: Obtain the IP address of the first terminal device and the IP address of the added terminal device; When the IP address of the first terminal device is the same as the IP address of the added terminal device, connect the first terminal device and the server device, and execute the step of sleeping for a preset duration. When the IP address of the first terminal device is inconsistent with the IP address of the added terminal device, the IP configuration of the channel of the server device corresponding to the first terminal device is updated according to the network segment where the IP address of the first terminal device is located.
3. The adaptive networking method as described in claim 2, characterized in that, The step of updating the IP configuration of the channel of the server device corresponding to the first terminal device according to the network segment where the IP address of the first terminal device is located includes: Determine whether the network segment where the first terminal device is located is reachable; When the network segment where the first terminal device is located is reachable, update the channel IP configuration of the server device corresponding to the first terminal device according to the IP address of the first terminal device. When the network segment where the first terminal device is located is unreachable, a virtual IP address consistent with the network segment where the first terminal device is located is created, and the channel IP configuration of the server device corresponding to the first terminal device is updated according to the virtual IP address.
4. The adaptive networking method as described in claim 1, characterized in that, The step of connecting the second terminal device and the server device includes: Determine whether the server device has an available channel; If the server device has an idle channel, then the second terminal device and the server device are connected through the idle channel; If the server device does not have an idle channel, then the step of sleeping for a preset duration is executed.
5. The adaptive networking method as described in claim 4, characterized in that, The step of connecting the second terminal device and the server device through the idle channel includes: Obtain the IP address of the second terminal device and the IP address of the server device; When the second terminal device and the server device are in the same network segment, the second terminal device and the server device are connected through the idle channel; When the second terminal device and the server device are not on the same network segment, the IP address of the second terminal device is changed to the IP address of the network segment where the server device is located, and the second terminal device and the server device are connected through the idle channel.
6. The adaptive networking method as described in claim 5, characterized in that, The step of changing the IP address of the second terminal device to the IP address of the network segment where the server device is located includes: Based on the IP address of the terminal device in the network segment where the server device is located, obtain the unassigned available IP address in the network segment where the server device is located; Send a change command to change the IP address of the second terminal device to the available IP address.
7. The adaptive networking method as described in claim 1, characterized in that, The steps for searching for addable terminal devices in each network segment include: Obtain the IP addresses of each network segment within the local area network, and send search packets to each network segment using the IP addresses of each network segment to detect all terminal devices within the local area network; When a response packet from the terminal device is received, the terminal device that sent the response packet is marked as an addable terminal device.
8. An adaptive networking device, characterized in that, The adaptive networking device includes: The search module is used to search for addable terminal devices in each network segment, and to obtain the hardware address of the addable terminal device and the hardware address of the added terminal device that has been connected to the server device. The update module is used to update the IP configuration of the channel of the server device corresponding to the first terminal device based on the IP address of the first terminal device when it is determined that the addable terminal device is the first terminal device that has been connected to the server device, according to the matching result of the hardware address of the addable terminal device and the hardware address of the added terminal device, and connect the first terminal device and the server device. A connection module is used to connect the second terminal device to the server device when it is determined that the addable terminal device is a second terminal device that has not been connected to the server device before. The hibernation module is used to hibernate for a preset time after the addable terminal device establishes a connection with the server device, and then return to perform the steps of searching for addable terminal devices in each network segment and subsequent steps.
9. An adaptive networking device, characterized in that, The adaptive networking device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the adaptive networking method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the adaptive networking method as described in any one of claims 1 to 7.