Internet protocol address allocation method, network device, and storage medium
Patent Information
- Application Number
- PCT/CN2025/076772
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-03-06
- Filing Date
- 2025-02-11
- Publication Date
- 2025-10-02
AI Technical Summary
When there are multiple devices with IP address allocation functions in a local area network, the existing technology is prone to IP address allocation errors and conflicts, and the terminal devices cannot connect to the network normally.
After receiving the IP address request message, the network device determines whether to respond based on the destination address information in the message, and allocates an IP address to the terminal device if it determines to respond. At the same time, it discards the IP address request message to be sent to other devices to ensure that only the network device is responsible for IP address allocation.
It avoids errors and conflicts caused by assigning IP addresses to multiple devices at the same time, and ensures normal network communication of terminal devices in the local area network.
Smart Images

Figure CN2025076772_02102025_PF_FP_ABST
Abstract
Description
Internet protocol address allocation method, network device, and storage medium
[0001] This disclosure claims priority to Chinese patent application No. 202410258450.4, filed on March 6, 2024, the entire contents of which are incorporated herein by reference. Technical Field
[0002] The present disclosure relates to the field of communication technology, and in particular to an Internet Protocol (IP) address allocation method, a network device, and a storage medium. Background Art
[0003] After accessing the network device, the terminal device will apply for an Internet Protocol (IP) address from the network device responsible for allocating IP addresses, and then perform normal network communication based on the allocated IP address.
[0004] When there are multiple devices with IP address allocation functions (eg, routers) in a local area network, these devices will all perform IP allocation operations in response to received IP address request messages. Summary of the Invention
[0005] In one aspect, an IP address allocation method is provided, which is applied to a network device. The IP address allocation method includes: receiving an IP address request message sent by a terminal device connected to the network device, the IP address request message being used to request allocation of an IP address; and, upon determining a response to the IP address request message based on destination address information carried in the IP address request message, allocating an IP address to the terminal device based on the IP address request message, and discarding the IP address request message to be sent to other devices.
[0006] In another aspect, a network device is provided. The network device includes: a processing unit and a communication unit; the communication unit is configured to receive an IP address request message sent by a terminal device connected to the network device, the IP address request message being used to request allocation of an IP address; the processing unit is configured to, upon determining to respond to the IP address request message based on destination address information carried in the IP address request message, allocate an IP address to the terminal device based on the IP address request message, and discard the IP address request message to be sent to other devices.
[0007] In another aspect, a network device is provided. The network device is connected to a terminal device and includes a memory and a processor, the memory and the processor being coupled, the memory being configured to store a computer program, and the processor implementing the IP address allocation method described in the above aspect when executing the computer program.
[0008] In another aspect, a computer-readable storage medium is provided, wherein computer program instructions are stored on the computer-readable storage medium, and when the computer program instructions are executed by a processor, the method for allocating IP addresses described in the above aspect is implemented.
[0009] In another aspect, a computer program product is provided, which includes computer program instructions, and when the computer program instructions are executed by a processor, the method for allocating IP addresses described in the above aspect is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] To more clearly illustrate the technical solutions of the present disclosure, the following briefly introduces the drawings required for use in some embodiments of the present disclosure. Obviously, the drawings described below are only drawings of some embodiments of the present disclosure, and those skilled in the art can also derive other drawings based on these drawings.
[0011] FIG1 is a schematic diagram of the architecture of an IP address allocation system according to some embodiments of the present disclosure.
[0012] FIG2 is a schematic structural diagram of a first network device according to some embodiments of the present disclosure.
[0013] FIG3 is a flow chart of an IP address allocation method according to some embodiments of the present disclosure.
[0014] FIG4 is a flowchart of another IP address allocation method according to some embodiments of the present disclosure.
[0015] FIG5 is a flowchart of another IP address allocation method according to some embodiments of the present disclosure.
[0016] FIG6 is a schematic structural diagram of a network device according to some embodiments of the present disclosure.
[0017] FIG7 is a schematic structural diagram of another network device according to some embodiments of the present disclosure. DETAILED DESCRIPTION
[0018] To help those skilled in the art better understand the technical solutions of the embodiments of the present disclosure, the technical solutions of the present disclosure will be clearly and completely described below in conjunction with the drawings in the present disclosure. Obviously, the embodiments described are only some of the embodiments of the present disclosure, not all of them. Based on the embodiments of the present disclosure, all other embodiments obtained by those of ordinary skill in the art without making any creative efforts shall fall within the scope of protection of the present disclosure.
[0019] It should be noted that in this disclosure, words such as "exemplarily" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described in this disclosure as "exemplary" or "for example" should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplarily" or "for example" is intended to present the relevant concepts in a concrete manner.
[0020] In the following, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the quantity of the technical features being referred to. Therefore, a feature defined with the terms "first," "second," etc., may explicitly or implicitly include one or more of such features.
[0021] In the description of this disclosure, unless otherwise specified, the symbol " / " represents an "or" relationship. For example, A / B can mean A or B. "And / or" in this document simply represents a relationship describing associated objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: only A, only B, and A and B. In addition, "at least one" means one or more, and "a plurality" means two or more.
[0022] The Dynamic Host Configuration Protocol (DHCP) is an application-layer LAN protocol that uses the User Datagram Protocol (UDP) for message encapsulation and transmission. DHCP is used to manage and maintain node devices and network resources within a LAN, such as assigning IP addresses to node devices. The device responsible for managing and maintaining the LAN is called a DHCP server, and the managed device is called a DHCP client.
[0023] Customer premise equipment (CPE) refers to the equipment that directly connects the user's front end to the carrier's network. In other words, CPE describes the location of network equipment within a communications network and does not limit the type of network equipment. For example, CPE can be a router, computer, or optical modem.
[0024] After accessing the network device, the terminal device will apply for an IP address from the network device responsible for IP address allocation, and then perform normal network communication based on the allocated IP address.
[0025] However, when there are multiple devices with IP address allocation capabilities (e.g., routers) in a local area network, each of these devices will perform IP address allocation operations in response to received IP address request messages. Under normal circumstances, IP address allocation is usually performed by a master device. If other devices assign IP addresses to terminal devices, this will cause problems in IP address allocation, making it impossible for the terminal device to connect to the network normally.
[0026] In view of this, in the technical solution provided by the present disclosure, after receiving an IP address request message sent by a terminal device connected to the network device, the network device makes a judgment based on the destination address information carried in the IP address request message. If it is determined to respond to the IP address request message, the network device can allocate an IP address to the terminal device based on the IP address request message and discard the IP address request message to be sent to other devices. In other words, when the network device determines that it needs to respond to the IP message, it allocates an IP address to the terminal device and no longer forwards the IP address request message to other devices. In this way, even if all messages sent by the terminal device need to be forwarded to the network device to which it is connected, based on the above solution, the network device can prevent other devices from receiving the IP address request message sent by the terminal device and allocating IP addresses, thereby ensuring that only the network device is responsible for allocating IP addresses to terminal devices in the current local area network, avoiding problems such as IP address allocation errors / conflicts caused by allocating IP addresses to multiple devices.
[0027] The following describes in detail the implementation of the embodiments of the present disclosure in conjunction with the accompanying drawings.
[0028] FIG1 is a schematic diagram of the architecture of an IP address allocation system 10 provided in an embodiment of the present disclosure. As shown in FIG1 , the IP address allocation system 10 may include, but is not limited to: a first network device 101 , a second network device 102 , and a terminal device 103 .
[0029] The terminal device 103 and the first network device 101 may be connected via any appropriate communication link. The first network device 101 and the second network device 102 may be connected via any appropriate communication link.
[0030] The communication link may be a wired communication link or a wireless communication link, which is not limited in the present disclosure.
[0031] Exemplarily, the terminal device 103 and the first network device 101 can be directly connected, that is, there are no other relay nodes in the communication link between the terminal device 103 and the first network device 101, and all messages sent by the terminal device 103 are forwarded to other devices through the first network device 101. The first network device 101 and the second network device 102 can be directly connected or indirectly connected. For example, the second network device 102 can be connected to the local area network (LAN) interface of the first network device 101 via a network cable.
[0032] The first network device 101 and the second network device 102 may have an IP address allocation function. For example, the first network device 101 and the second network device 102 may be routers.
[0033] The first network device 101 in the present disclosure may be a device that manages the IP addresses of devices in the local area network corresponding to the IP address allocation system 10, or may not be a device that manages the IP addresses of devices in the local area network corresponding to the IP address allocation system 10. The following describes the solution proposed in the present disclosure using two scenarios as examples.
[0034] In some implementations, the first network device 101 is used to manage IP addresses for devices in the local area network corresponding to the IP address allocation system 10. For example, the first network device 101 may be a CPE and, acting as a DHCP server, is responsible for network operation and maintenance management of the local area network corresponding to the IP address allocation system 10. For another example, in a wireless mesh network, the first network device 101 may serve as a mesh master node, and the second network device 102 may serve as a mesh child node.
[0035] The terminal device 103 is configured to send an IP address request message after establishing a communication connection with the first network device 101 .
[0036] The IP address request message is used to request allocation of an IP address. The IP address request message sent by the terminal device 103 can be a broadcast message or a unicast message.
[0037] The first network device 101 is configured to receive an IP address request message from the terminal device 103. The first network device 101 is further configured to determine whether to respond to the IP address request message based on the destination address information carried in the IP address request message.
[0038] When the first network device 101 determines to respond to the IP address request message based on the destination address information carried in the IP address request message, it allocates an IP address to the terminal device 103 based on the IP address request message and discards the IP address request message to be sent to other devices (for example, the second network device 102).
[0039] The first network device 101 is further configured to send the allocated IP address to the terminal device 103 so that the terminal device 103 can perform normal network communication based on the IP address.
[0040] It should be noted that since the second network device 102 also has an IP address allocation function, if the second network device 102 receives the IP address request message, it will also allocate an IP address to the terminal device 103 based on the IP address request message. This may cause IP address allocation errors / conflicts due to multiple devices being allocated IP addresses. Therefore, the first network device 101 in the present disclosure can discard the IP address request message to prevent other devices from receiving the IP address request message, thereby avoiding the above-mentioned problem.
[0041] Exemplarily, the first network device 101 has two local area network (LAN) interfaces, namely LAN1 and LAN2. The first network device 101 is connected to the terminal device 103 via LAN1 and to the second network device 102 via LAN2. The first network device 101 is powered on and initialized, and at this time, the first network device 101 and the second network device 102 are both in a ready state. The terminal device 103 sends an IP address request message via LAN1. For example, the IP address request message can be a UDP message with a source port of 68 and a destination port of 67. On the one hand, the first network device 101 allocates an IP address to the terminal device 103 in response to the IP address request message. On the other hand, when it detects that the IP address request message will be sent to other devices in the local area network (for example, the second network device 102), it discards the IP address request message to prevent the second network device 102 from allocating an IP address to the terminal device 103.
[0042] In some implementations, the second network device 102 is used to manage the IP addresses of devices in the local area network corresponding to the IP address allocation system 10. For example, the second network device 102 may be a CPE and, acting as a DHCP server, is responsible for network operation and maintenance management of the local area network corresponding to the IP address allocation system 10. For another example, in a wireless mesh network, the first network device 101 may serve as a mesh child node, and the second network device 102 may serve as a mesh master node.
[0043] After establishing a communication connection with the first network device 101, the terminal device 103 sends an IP address request message.
[0044] The IP address request message is used to request allocation of an IP address. The IP address request message sent by the terminal device 103 can be a broadcast message or a unicast message.
[0045] The first network device 101 is configured to receive an IP address request message from the terminal device 103. The first network device 101 is further configured to forward the IP address request message to a corresponding device based on the destination address information carried in the IP address request message.
[0046] The destination address information may be at least one of a destination IP address and a destination Media Access Control (MAC) address.
[0047] For example, the device corresponding to the destination address information carried in the IP address request message is the second network device 102 , and the first network device 101 may forward the IP address request message to the second network device 102 .
[0048] The second network device 102 receives the IP address request message and allocates an IP address to the terminal device 103 .
[0049] In some implementations, as shown in FIG. 2 , the first network device 101 may include a determination module 1011 , a filtering module 1012 , and an allocation module 1013 .
[0050] The determination module 1011 is configured to determine whether the IP address request message sent by the terminal device 103 needs to be sent to other devices except the first network device 101. For example, the other device may be the second network device 102.
[0051] The filtering module 1012 is configured to discard the IP address request message when the IP address request message needs to be sent to a device other than the first network device 101 .
[0052] The allocation module 1013 is configured to allocate a device IP address to the terminal device 103 based on the IP address request message.
[0053] The terminal device 103 is a device with wireless communication capabilities that can be deployed on land, including indoors or outdoors, handheld or vehicle-mounted. The terminal device 103 can also be deployed on the water (e.g., on a ship, etc.); it can also be deployed in the air (e.g., on an airplane, balloon, and satellite, etc.). The terminal device 103 is also called user equipment (UE), mobile station (MS), mobile terminal (MT), and terminal, and is a device that provides voice and / or data connectivity to users. For example, the terminal device 103 includes a handheld device with wireless connection capabilities, a vehicle-mounted device, etc. Currently, the terminal device 103 can be: a mobile phone, a tablet computer, a laptop computer, a PDA, a mobile internet device (MID), a wearable device (for example, a smart watch, a smart bracelet, a pedometer, etc.), an in-vehicle device (for example, a car, a bicycle, an electric car, an airplane, a ship, a train, a high-speed train, etc.), a virtual reality (VR) device, an augmented reality (AR) device, a wireless terminal device in industrial control, a smart home device (for example, a refrigerator, a television, an air conditioner, an electric meter, etc.), an intelligent robot, workshop equipment, a wireless terminal device in self-driving, a wireless terminal device in remote medical surgery, a wireless terminal device in a smart grid, a wireless terminal device in transportation safety, a wireless terminal device in a smart city, a wireless terminal device in a smart home, an aerial device (for example, an intelligent robot, a hot air balloon, a drone, an airplane), etc. In some application scenarios of the present disclosure, the terminal device 103 is a terminal device that often operates on the ground, such as an in-vehicle device. In this disclosure, for ease of description, chips deployed in the above-mentioned devices, such as system-on-a-chip (SOC), baseband chips, etc., or other chips with communication functions can also be referred to as terminal devices.
[0054] It should be pointed out that the various embodiments of the present disclosure can refer to each other, for example, the same or similar operations, method embodiments, system embodiments and device embodiments can refer to each other without limitation.
[0055] Figure 3 is a flow chart of an IP address allocation method provided by an embodiment of the present disclosure. As shown in Figure 3, the method is applied to a network device and may include steps 301-303.
[0056] 301. Receive an IP address request message sent by a terminal device connected to a network device.
[0057] The IP address request message is used to request the allocation of an IP address. The network device and the terminal device are connected through a wired link or a wireless link.
[0058] For example, the network device may be a router, and the network device and the terminal device may be connected via a network cable connected to a LAN interface of the network device. The network device and the terminal device may also be connected via Wi-Fi (wireless fidelity).
[0059] Exemplarily, the IP address request message may be a DHCP-based UDP message, such as a DHCP Discover message.
[0060] It should be noted that a connection between a network device and a terminal device means that the network device and the terminal device are directly connected. Therefore, messages sent by the terminal device are transmitted directly to the network device, and there are no other forwarding nodes between the terminal device and the network device. In other words, all messages sent by the terminal device to devices other than the network device must be forwarded through the network device.
[0061] In some implementations, a network device receives a message sent by a terminal device, and when the port information carried in the message is preset port information, the network device determines that the message is an IP address request message.
[0062] The port information carried in the message may be at least one of source port information and destination port information.
[0063] Taking the DHCP protocol as an example, when the source port information in the message is 68 and the destination port information is 67, it indicates that the message is used to request an IP address. Therefore, the network device can determine the IP address request message from the received message based on the port information.
[0064] In some implementations, after receiving a message sent by a terminal device, the network device may also determine whether the received message is an IP address request message based on the message type.
[0065] 302. Determine whether to respond to the IP address request message based on the destination address information carried in the IP address request message.
[0066] The destination address information includes at least one of a destination IP address and a destination Media Access Control (MAC) address.
[0067] It should be understood that since the IP address request message carries destination address information, this destination address information represents the address of the device to which the IP address request message is to be sent. Therefore, the network device can determine whether to respond to the IP address request message and allocate an IP address to the terminal device based on the destination address information carried in the IP address request message. In this way, when a terminal device requests an IP address from the network device, the network device determines whether to allocate an IP address to the terminal device based on the IP address request message, thereby avoiding the issue of multiple devices allocating IP addresses to the terminal device.
[0068] In some implementations, the network device may also determine whether to respond to the IP address request message and allocate an IP address to the terminal device based on the configuration information.
[0069] Configuration information is used to indicate whether the network device is used to manage the IP addresses of devices in the LAN.
[0070] For example, in a mesh networking scenario, the mesh master node needs to manage the IP addresses of devices in the local area network, while the mesh child nodes do not. When a network device is configured as a mesh master node, it will respond to the IP address request message; when a network device is configured as a mesh child node, it will not respond to the IP address request message.
[0071] Exemplarily, the network device in the present disclosure may further combine the above two methods, that is, make a judgment based on the target address information and configuration information carried in the IP address request message.
[0072] In some embodiments, when determining to respond to the IP address request message based on the destination address information carried in the IP address request message, the network device executes 303.
[0073] 303. Allocate an IP address to the terminal device based on the IP address request message, and discard the IP address request message to be sent to other devices.
[0074] The network device is connected to other devices via a wired link or a wireless link. For example, the wired link connection method may be that the network device is connected to other devices via a network cable of a LAN interface, and the wireless link connection method may be that the network device is connected to other devices via Wi-Fi.
[0075] Furthermore, the present disclosure does not limit the manner in which a network device allocates IP addresses. For example, a network device may allocate an IP address to a terminal device based on the DHCP protocol. The network device selects an available IP address from an IP address pool and sends an IP allocation message containing the IP address to the terminal device. For example, the IP allocation message may be a DHCP Offer message.
[0076] It should be noted that the network device discarding (dropping) the IP address request message to be sent to other devices means that the network device no longer forwards the IP address request message to other devices, that is, performs an interception operation on the forwarding of the IP address request message.
[0077] In some implementations, the network device may remove the IP address request message from the message buffer queue to discard the IP address request message.
[0078] The message buffer queue is used to store messages to be sent by the network device.
[0079] Based on the above technical solution, after a network device receives an IP address request message sent by a terminal device connected to the network device, when it determines to respond to the IP address request message based on the destination address information carried in the IP address request message, the network device can allocate an IP address to the terminal device based on the IP address request message and discard the IP address request message to be sent to other devices. In other words, when the network device determines that it needs to respond to the IP message, it allocates an IP address to the terminal device and no longer forwards the IP address request message to other devices. In this way, even if the message sent by the terminal device needs to be forwarded to the network device connected to it, based on the above solution, the network device can prevent other devices from receiving the IP address request message sent by the terminal device and allocating IP addresses, thereby ensuring that only the network device is responsible for the IP address allocation of terminal devices in the current local area network, avoiding the problem of IP address allocation errors caused by allocating IP addresses to multiple devices.
[0080] The following describes the process by which a network device determines whether to respond to an IP address request message.
[0081] In some implementations, as shown in FIG4 in combination with FIG3 , the above 302 may also be implemented through the following operations.
[0082] 401. Determine a sending method of the IP address request message according to the destination address information carried in the IP address request message.
[0083] The sending mode includes at least one of unicast and broadcast.
[0084] Exemplarily, the destination IP address is 255.255.255.255, and / or the destination MAC address is FF-FF-FF-FF-FF-FF, indicating that the IP address request message is a broadcast message, that is, the specific device to which the IP address request message is to be sent is not specified. In some embodiments, the destination IP address and the destination MAC address are specific addresses, for example, the destination IP address is 192.168.0.39, and / or the destination MAC address is A3-B4-E5-53-45-C1, indicating that the IP address request message is a unicast message, that is, the device to which the IP address request message is to be sent is the device with the destination IP address 192.168.0.39 and / or the destination MAC address A3-B4-E5-53-45-C1.
[0085] 402. Determine whether to respond to the IP address request message based on the sending mode.
[0086] If the IP address request message is a broadcast message, it means that the terminal device has not specified the object to which the IP address is requested. Therefore, the network device can respond to the IP address request message and allocate an IP address to the terminal device to ensure normal communication of the terminal device, and at the same time discard the IP address request message to be sent to other devices to avoid other devices receiving the IP address request message and allocating an IP address to the terminal device, resulting in an incorrect IP address allocation problem.
[0087] In some embodiments, when the transmission mode is broadcast, the network device determines to respond to the IP address request message. When determining to respond to the IP address request message, the network device executes the above 303.
[0088] It should be noted that if the IP address request message is a unicast message, it means that the terminal device has already specified the object for which the IP address is being requested. Therefore, the network device can further determine whether it needs to respond to the IP address request message by determining whether the object for which the IP address is being requested by the terminal device is itself.
[0089] In some other embodiments, when the sending mode is unicast, the network device executes the following 403.
[0090] 403. Determine whether the destination address information is the same as the address information of the network device.
[0091] If the destination address information is the same as the address information of the network device, it means that the object of the IP address requested by the terminal device is the network device; otherwise, if the destination address information is different from the address information of the network device, it means that the object of the IP address requested by the terminal device is not the network device.
[0092] In some embodiments, if the destination address information is the same as the address information of the network device, the network device determines to respond to the IP address request message. Alternatively, if the destination address information is different from the address information of the network device, the network device determines not to respond to the IP address request message.
[0093] If the network device determines to respond to the IP address request message, the network device may execute the above 303. If the network device determines not to respond to the IP address request message, the network device may also determine whether to discard the IP address request message to be sent to other devices based on its own configuration information, thereby ensuring normal communication of the terminal device.
[0094] In some implementations, if the network device determines not to respond to the IP address request packet, the network device executes 404 .
[0095] 404. Process the IP address request message based on the identity of the network device in the wireless mesh network.
[0096] In some embodiments, when determining not to respond to the IP address request message, the network device discards the IP address request message to be sent to other devices based on the network device serving as a master node of the mesh network; or,
[0097] In the case of determining not to respond to the IP address request message, the network device forwards the IP address request message based on the network device as a child node of the mesh network and based on the target address information carried in the IP address request message.
[0098] The master node of the mesh network is used to manage the IP addresses of devices in the LAN. The child nodes of the mesh network are devices in the LAN except the master device.
[0099] For example, a network device can determine its identity in a mesh network based on configuration information. If the configuration information indicates that the network device is used to manage the IP addresses of devices in the LAN, the network device serves as a master node in the mesh network. If the configuration information indicates that the network device is not used to manage the IP addresses of devices in the LAN, the network device serves as a child node in the mesh network.
[0100] It's important to note that when a network device acts as the master node of a mesh network, the IP addresses of devices within the local area network (LAN) should be managed and maintained by the network device. If a terminal device still requests an IP address from other devices, this can negatively impact the LAN, causing network conflicts and network security risks. Therefore, the network device can still prevent the terminal device's IP request from impacting the LAN by discarding the IP address request message being sent to other devices.
[0101] A network device acting as a child node of a mesh network indicates that the IP address of the device in the current LAN is managed and maintained by other devices. In this case, the network device can normally forward the IP address request message of the terminal device, thereby ensuring the normal communication of the terminal device.
[0102] Furthermore, after powering on a network device, it initializes its various functional modules (for example, the module that determines whether to respond to an IP address request message). During this initialization process, the network device cannot process received messages. These messages are then transparently transmitted to other devices on the LAN, potentially causing them to assign an IP address to the terminal device.
[0103] In this regard, the present disclosure proposes an implementation method. In combination with FIG3 , as shown in FIG5 , the method further includes 501 .
[0104] 501. After the network device is initialized, a reset operation is performed on the network card in the network device.
[0105] The reset operation is used to trigger the terminal device to re-establish the communication connection with the network device.
[0106] After a network device resets its network card, the communication connection between the network device and its directly connected device (e.g., a terminal device) is disconnected and needs to be re-established. The terminal device then needs to obtain an IP address to communicate with the network. Therefore, after re-establishing the communication connection with the network device, the terminal device will resend an IP address request message.
[0107] In some embodiments, before the network device performs a reset operation on the network card in the network device, the terminal device sends an IP address request message. The network device forwards the IP address request message to another device through transparent transmission. After the network device performs a reset operation on the network card in the network device, the network device re-establishes a communication connection with the terminal device, and the terminal device re-sends the IP address request message.
[0108] For example, in conjunction with FIG5 , if the terminal device has sent an IP address request message before 301 , then in 301 , the IP address request message received by the network device is the IP address request message resent by the terminal device after the network card of the network device is reset.
[0109] In some embodiments, the terminal device does not send an IP address request message before the network device performs a reset operation on the network card in the network device. After the network device performs a reset operation on the network card in the network device, the network device re-establishes a communication connection with the terminal device, and the terminal device sends an IP address request message.
[0110] For example, in conjunction with FIG5 , if the terminal device has not sent an IP address request message before 301 , then in 301 , the IP address request message received by the network device is the IP address request message sent by the terminal device for the first time after the network card of the network device is reset.
[0111] Based on the above technical solution, even if the terminal device is assigned an incorrect IP address by other devices during the initialization of the network device, the network device can reallocate the IP address of the terminal device by resetting the network card after the initialization is completed. At this time, since the network device has been initialized, the network device can normally determine whether to respond to the IP address request message and subsequent operations, thereby ensuring that only the network device is responsible for the IP address allocation of the terminal device in the current local area network, avoiding the problem of IP address allocation errors caused by allocating IP addresses to multiple devices.
[0112] It is understandable that, in order to implement the above functions, the network device includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the algorithm steps of each example described in the embodiments of the present disclosure, the present disclosure can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in a hardware or computer software-driven hardware manner depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present disclosure.
[0113] The embodiments of the present disclosure can divide the network device into functional modules according to the above-mentioned method embodiments. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one functional module. The above-mentioned integrated modules can be implemented in the form of hardware or software. It should be noted that the division of modules in the embodiments of the present disclosure is schematic and is only a logical functional division. In actual implementation, there may be other division methods. The following is an example of dividing each functional module corresponding to each function.
[0114] FIG6 is a schematic diagram of the structure of a network device provided by an embodiment of the present disclosure, which can execute the IP address allocation method provided by the above method embodiment. As shown in FIG6 , the network device 60 includes: a processing unit 601 and a communication unit 602 .
[0115] The communication unit 602 is used to receive an IP address request message sent by a terminal device connected to the network device; the IP address request message is used to request allocation of an IP address.
[0116] The processing unit 601 is used to allocate an IP address to the terminal device based on the IP address request message when determining to respond to the IP address request message according to the destination address information carried in the IP address request message, and discard the IP address request message to be sent to other devices.
[0117] In some embodiments, the processing unit 601 is used to: determine the sending mode of the IP address request message according to the destination address information carried in the IP address request message; and determine a response to the IP address request message when the sending mode is broadcast.
[0118] In some embodiments, the processing unit 601 is used to: determine the sending method of the IP address request message based on the destination address information carried in the IP address request message; when the sending method is unicast, determine whether the destination address information is the same as the address information of the network device; when the destination address information is the same as the address information of the network device, determine to respond to the IP address request message; or, when the destination address information is not the same as the address information of the network device, determine not to respond to the IP address request message.
[0119] In some embodiments, the processing unit 601 is configured to process the IP address request message based on the identity of the network device in the mesh network when determining not to respond to the IP address request message.
[0120] In some embodiments, the processing unit 601 is used to: when it is determined that there is no response to the IP address request message, based on the network device acting as the main node of the mesh network, discard the IP address request message to be sent to other devices; or, when it is determined that there is no response to the IP address request message, based on the network device acting as a child node of the mesh network, forward the IP address request message based on the target address information carried in the IP address request message.
[0121] In some embodiments, the processing unit 601 is used to perform a reset operation on the network card in the network device after the network device is initialized; the reset operation is used to trigger the terminal device to re-establish a communication connection with the network device.
[0122] In some embodiments, the communication unit 602 is used to receive a message sent by a terminal device; the processing unit 601 is used to determine that the message is an IP address request message when the port information carried in the message is preset port information.
[0123] In some embodiments, the network device is connected to the terminal device through a wired link or a wireless link; the network device is connected to other devices through a wired link or a wireless link.
[0124] In the case of implementing the functions of the above-mentioned integrated modules in the form of hardware, the embodiment of the present disclosure provides another structure of the network device involved in the above-mentioned embodiment. As shown in Figure 7, the network device 70 includes: a memory 701, a processor 702, a communication interface 703, and a bus 704.
[0125] The memory 701 may be a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (RAM) or other type of dynamic storage device that can store dynamic information and instructions, an electrically erasable programmable read-only memory (EEPROM), a disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto.
[0126] The processor 702 may be a logic block, module, and circuit that implements or executes the various exemplary methods described in conjunction with the embodiments of the present disclosure. The processor 702 may be a central processing unit, a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array, or other programmable logic device, a transistor logic device, a hardware component, or any combination thereof. The processor 702 may also implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the embodiments of the present disclosure. The processor 702 may also be a combination that implements computing functions, for example, a combination of one or more microprocessors, a combination of a DSP (digital signal processor) and a microprocessor, and the like.
[0127] The communication interface 703 is used to connect to other devices via a communication network, such as Ethernet, wireless access network, or wireless local area network (WLAN).
[0128] In some implementations, the memory 701 may exist independently of the processor 702. The memory 701 may be connected to the processor 702 via a bus 704 and used to store instructions or program codes. When the processor 702 calls and executes the instructions or program codes stored in the memory 701, the method described in any of the embodiments of the present disclosure can be implemented.
[0129] In some implementations, the memory 701 may also be integrated with the processor 702 .
[0130] Bus 704 can be an Extended Industry Standard Architecture (EISA) bus, for example. Bus 704 can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, FIG7 shows bus 704 with only one thick line, but this does not mean that there is only one bus or only one type of bus.
[0131] Some embodiments of the present disclosure provide a computer-readable storage medium (e.g., a non-transitory computer-readable storage medium), which stores computer program instructions. When the computer program instructions are executed on a computer, the computer executes the method described in any of the above embodiments.
[0132] Exemplarily, the above-mentioned computer-readable storage media may include, but are not limited to: magnetic storage devices (e.g., hard disks, floppy disks, or magnetic tapes), optical disks (e.g., compact disks (CDs), digital versatile disks (DVDs), etc.), smart cards, and flash memory devices (e.g., erasable programmable read-only memories (EPROMs), cards, sticks, or key drives, etc.). The various computer-readable storage media described in the present disclosure may represent one or more devices and / or other machine-readable storage media for storing information. The term "machine-readable storage medium" may include, but is not limited to, wireless channels and various other media capable of storing, containing, and / or carrying instructions and / or data.
[0133] An embodiment of the present disclosure provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the method described in any one of the above embodiments.
[0134] The above is only a specific embodiment of the present disclosure, but the scope of protection of the present disclosure is not limited thereto. Any changes or replacements within the technical scope disclosed in the present disclosure should be included in the scope of protection of the present disclosure. Therefore, the scope of protection of the present disclosure should be based on the scope of protection of the claims.
Claims
1. A method for allocating Internet Protocol (IP) addresses, applied to network equipment, wherein: The method comprises: receiving an IP address request message sent by a terminal device connected to the network device, wherein the IP address request message is used to request allocation of an IP address; and In response to determining to respond to the IP address request message based on the destination address information carried in the IP address request message, an IP address is allocated to the terminal device based on the IP address request message, and the IP address request message to be sent to other devices is discarded.
2. The method according to claim 1, further comprising: Determining a sending mode of the IP address request message according to the destination address information carried in the IP address request message; In response to the sending mode being broadcast, it is determined to respond to the IP address request message.
3. The method according to claim 1, further comprising: Determining a sending mode of the IP address request message according to the destination address information carried in the IP address request message; In response to the sending mode being unicast, determining whether the destination address information is the same as the address information of the network device; In response to the destination address information being identical to the address information of the network device, determining to respond to the IP address request message; or, In response to the destination address information being different from the address information of the network device, it is determined not to respond to the IP address request message.
4. The method according to claim 3, further comprising: In response to determining not to respond to the IP address request message, the IP address request message is processed based on the identity of the network device in the wireless mesh network.
5. The method according to claim 4, wherein In response to determining not to respond to the IP address request message, processing the IP address request message based on the identity of the network device in the mesh network includes: In response to determining not to respond to the IP address request message, based on the network device serving as a master node of the mesh network, discarding the IP address request message to be sent to other devices; or, In response to determining not to respond to the IP address request message, based on the network device serving as a child node of the mesh network, the IP address request message is forwarded based on the target address information carried in the IP address request message.
6. The method according to claim 1, wherein Before receiving the IP address request message sent by the terminal device connected to the network device, the method further includes: After the network device is initialized, a reset operation is performed on the network card in the network device, wherein the reset operation is used to trigger the terminal device to re-establish a communication connection with the network device.
7. The method according to claim 1, wherein The receiving an IP address request message sent by a terminal device connected to the network device includes: receiving a message sent by the terminal device; In response to the port information carried by the message being the preset port information, the message is determined to be the IP address request message.
8. The method according to claim 1, wherein The network device is connected to the terminal device via a wired link or a wireless link; the network device is connected to other devices via a wired link or a wireless link.
9. A network device, wherein: The network device is connected to a terminal device, and the network device includes: a memory and a processor; the memory and the processor are coupled; the memory is used to store instructions executable by the processor; and the processor executes the method according to any one of claims 1 to 8 when executing the instructions.
10. A computer-readable storage medium, wherein: The computer-readable storage medium stores computer instructions, which, when executed on a computer, enable the computer to perform the method according to any one of claims 1 to 8.