A method and apparatus for a wireless device to obtain an IP address for a wireless connection terminal
By utilizing the interactive communication protocol between the wireless AP device and the AC controller, the AC controller obtains the IP address of the wireless connected terminal, thus solving the problem that the wireless AP device cannot obtain an IP address when the DHCP server is turned off, and achieving accurate IP address acquisition.
Patent Information
- Application Number
- CN202310288591.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-23
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-03-23
AI Technical Summary
When the DHCP server is turned off in AC controller mode, the wireless AP device cannot obtain the IP address of the wireless connection terminal, resulting in the inability to report a valid device IP.
By establishing an interactive communication protocol between the wireless AP device and the AC controller, the AC controller is used to obtain the IP address of the wireless connected terminal, including receiving and forwarding Discovery, Offer, Request and ACK messages. The libcpap and iwinfoathxassoclist are used to capture and parse message information, and the /tmp/apdhcp.lease file is constructed to query the IP address.
When the DHCP server is turned off on the wireless AP device, the IP address of the wireless connected terminal can be accurately obtained, avoiding the problem of inaccurate IP address reported by the wireless AP device and realizing the acquisition of IP address of the wireless connected terminal.
Smart Images

Figure CN116389422B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of network communication, and in particular to a method and apparatus for a wireless device to obtain the IP address of a wireless connection terminal. Background Technology
[0002] When a wireless AP device is operating in AC controller mode, its DHCP server is turned off. When a wireless terminal connects, it usually obtains its IP address through the AC controller. In this case, the wireless AP device cannot obtain the IP address of the wireless terminal, and it will be unable to report a valid device IP address when reporting wireless terminal information.
[0003] Chinese patent CN109088959A, entitled "An Address Allocation Method, Apparatus, and System," discloses an address allocation method, apparatus, and system. When a wireless access point (AP) device successfully connects to an AC controller, it receives an IP address range and DHCP parameters assigned to the AP device by the AC controller. Based on these parameters, the AP device configures itself as the AC controller, reducing the operational burden on both the AP and AC devices and eliminating the need for additional equipment for testing, maintenance, or network redeployment. However, when a wireless terminal connects and obtains its IP address from the AC controller, the AP device's DHCP server is already closed, preventing the AP from acquiring the terminal's IP address and thus hindering its ability to report a valid device IP. Summary of the Invention
[0004] In view of this, the present invention proposes a method and apparatus for a wireless device to obtain the IP address of a wireless connection terminal, which is used to solve the problem that a wireless AP device cannot obtain the IP address of the access wireless device after the DHCP server is turned off.
[0005] The technical solution of this invention is implemented as follows: On one hand, this invention provides a method for a wireless device to obtain the IP address of a wireless connection terminal. The wireless device includes at least one wireless access point (AP) device and an AC controller wired to the wireless AP device. The wireless AP device and the AC controller are configured with an interactive communication protocol. When the wireless AP device is wired to the AC controller and the DHCP server of the wireless AP device is turned off, the method includes:
[0006] S1, the wireless AP device receives the Discovery message sent by the wireless connection terminal and forwards it to the AC controller. The Discovery message includes a matching request.
[0007] S2, the wireless AP device receives the Offer message sent by the AC controller and forwards it to the wireless connection terminal. The Offer message includes the IP address that the AC controller can provide.
[0008] S3, the wireless AP device receives a Request message sent by the wireless connection terminal and forwards it to the AC controller. The Request message includes the IP address that is desired.
[0009] S4, the wireless AP device receives the ACK message sent by the AC controller and forwards it to the wireless connection terminal to obtain the IP address. The ACK message includes the MAC address and the IP address.
[0010] Preferably, step S2 further includes:
[0011] The wireless AP device captures the Offer message through libcpap, saves the requestIP, MAC address, and hostname to the configuration file, and sets the flag to 0x0.
[0012] Preferably, step S3 further includes:
[0013] The wireless AP device runs IP detection, periodically checking whether the IP address in the configuration file has been assigned; if it has been assigned, the flag is configured as 0x0.
[0014] Preferably, step S4 further includes:
[0015] If the MAC address and IP address in the ACK packet exist in the configuration file, configure the flag to 0x1.
[0016] Preferably, step S4 further includes:
[0017] The wireless AP device obtains the MAC address of the currently connected wireless terminal through iwinfoathxassoclist, and then obtains the corresponding IP address from the configuration file using the MAC address.
[0018] Preferably, step S1 further includes:
[0019] The wireless connection terminal broadcasts Discovery messages within the local network. The wireless AP device receives the Discovery message wirelessly and forwards it to the AC controller. After receiving the Discovery message, the AC controller constructs an Offer message and sends it to the wireless AP device and forwards it to the wireless connection terminal to inform it of the available IP address.
[0020] Preferably, step S2 further includes:
[0021] After receiving the Offer message, the wireless connection terminal sends a Request message to the wireless AP device and forwards it to the AC controller to inform the AC controller of the IP address that needs to be assigned.
[0022] On the other hand, the present invention also provides an apparatus for a wireless device to obtain the IP address of a wireless connection terminal. The wireless device includes at least one wireless access point (AP) device and an AC controller wiredly connected to the wireless AP device. The wireless AP device and the AC controller are configured with an interactive communication protocol. When the wireless AP device is wiredly connected to the AC controller and the DHCP server of the wireless AP device is turned off, the apparatus includes:
[0023] The matching message module is used for the wireless AP device to receive Discover messages sent by the wireless connection terminal and forward them to the AC controller. The Discover message includes a matching request.
[0024] A message module is provided for wireless AP devices to receive Offer messages sent by AC controllers and forward them to wireless connection terminals. The Offer message includes an IP address that can be provided by the AC controller.
[0025] The request message module is used by the wireless AP device to receive the Request message sent by the wireless connection terminal and forward it to the AC controller. The Request message includes the IP address that is desired to be obtained.
[0026] The response message module allows the wireless AP device to receive and forward ACK messages sent by the AC controller to the wireless connection terminal to obtain the IP address. The ACK message includes the MAC address and the IP address.
[0027] On the other hand, embodiments of the present invention also provide an apparatus including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of a method for the wireless device to obtain the IP address of a wireless connection terminal.
[0028] On the other hand, embodiments of the present invention also provide a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, it implements the steps of a method for the wireless device to obtain the IP address of a wireless connection terminal.
[0029] The method and apparatus for a wireless device to obtain the IP address of a wireless connection terminal according to the present invention have the following advantages over the prior art:
[0030] (1) When the wireless AP device is connected to the AC controller and enters the AC controller mode, and its own DHCP server is turned off, the AC controller with the DHCP server turned on and the wireless AP device work in a dual-thread manner to construct a / tmp / apdhcp.lease file of the wireless AP device. The IP address of the wireless connection terminal can be directly queried in the / tmp / apdhcp.lease file by MAC address.
[0031] (2) When the DHCP server of the wireless AP device is turned off and the wireless AP device cannot obtain the IP address requested by the wireless connection terminal through DHCP in a timely manner, the external AC controller will receive and send messages to inform the wireless connection terminal of the IP address, so as to avoid the inaccurate IP reported by the wireless AP device. Attached Figure Description
[0032] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0033] Figure 1 This is a flowchart of a method for a wireless device to obtain the IP address of a wireless connection terminal according to the present invention;
[0034] Figure 2 This is a schematic diagram illustrating the working principle of a method for a wireless device to obtain the IP address of a wireless connection terminal according to the present invention.
[0035] Figure 3 This is a structural diagram of a device for obtaining the IP address of a wireless connection terminal according to the present invention. Detailed Implementation
[0036] The technical solutions of the present invention will be clearly and completely described below with reference to the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0037] Example
[0038] A method is provided for a wireless device to obtain an IP address of a wireless connection terminal. The wireless device includes at least one wireless access point (AP) device and an AC controller wiredly connected to the wireless AP device. The wireless AP device and the AC controller are configured with an interactive communication protocol. When the wireless AP device is wiredly connected to the AC controller and the DHCP server of the wireless AP device is disabled, the method includes:
[0039] S1, the wireless AP device receives the Discovery message sent by the wireless connection terminal and forwards it to the AC controller. The Discovery message includes a matching request.
[0040] S2, the wireless AP device receives the Offer message sent by the AC controller and forwards it to the wireless connection terminal. The Offer message includes the IP address that the AC controller can provide.
[0041] S3, the wireless AP device receives a Request message sent by the wireless connection terminal and forwards it to the AC controller. The Request message includes the IP address that is desired.
[0042] S4, the wireless AP device receives the ACK message sent by the AC controller and forwards it to the wireless connection terminal to obtain the IP address. The ACK message includes the MAC address and the IP address.
[0043] To address the issue that wireless terminals connected to a wireless access point (AP) device (thin AP mode) cannot directly obtain IP addresses from the AP device after the DHCP server is disabled, this application proposes a method that utilizes other AC controllers to obtain the IP addresses of wireless terminals.
[0044] Step S2 also includes:
[0045] The wireless AP device captures the Offer message through libcpap, saves the requestIP, MAC address, and hostname to the configuration file, and sets the flag to 0x0.
[0046] Step S3 also includes:
[0047] The wireless AP device runs an IP detection function, periodically checking whether the IP address in the configuration file is reachable; if it is not reachable, the flag is configured as 0x0.
[0048] Step S4 also includes:
[0049] If the MAC address and IP address in the ACK packet exist in the configuration file, configure the flag to 0x1.
[0050] Step S4 also includes:
[0051] The wireless AP device obtains the MAC address of the currently connected wireless terminal through iwinfoathxassoclist, and then obtains the corresponding IP address from the configuration file using the MAC address.
[0052] Step S1 also includes:
[0053] The wireless connection terminal broadcasts Discovery messages within the local network. The wireless AP device receives the Discovery message wirelessly and forwards it to the AC controller. After receiving the Discovery message, the AC controller constructs an Offer message and sends it to the wireless AP device and forwards it to the wireless connection terminal to inform it of the available IP address.
[0054] Step S2 also includes:
[0055] After receiving the Offer message, the wireless connection terminal sends a Request message to the wireless AP device and forwards it to the AC controller to inform the AC controller of the IP address that needs to be assigned.
[0056] Wireless terminals primarily obtain IP addresses via DHCP. However, when the DHCP server is disabled on the wireless AP device, the wireless terminal does not know the location of the DHCP server when requesting an IP address. Therefore, the wireless terminal will broadcast a Discovery message within the local network. After receiving the Discovery message, the AC controller's DHCP server will construct an Offer message and send it to the wireless terminal, informing the terminal that the AC controller's DHCP server can provide it with an IP address. Upon receiving the Offer message, the wireless terminal will send a broadcast Request message to the AC controller's DHCP server, telling the server that it wants to obtain the assigned IP address. At this time, the wireless AP device captures the Offer message through libcpap, saves the requestIP, MAC address, and hostname to / tmp / apdhcp.lease, and configures the flag to 0x0. After receiving the Request message, the AC controller's DHCP server sends an ACK message, notifying the wireless connected terminal that it can use the assigned IP address. The wireless AP device uses the libcpap capture program to capture the ACK message sent by the AC controller's DHCP server. If the MAC address and IP address in the ACK message exist in / tmp / apdhcp.lease, then the flag is configured to 0x1. This step constructs the terminal IP information belonging to the wireless AP device by capturing the ACK message sent by the DHCP server, which is used by the wireless AP device to obtain the IP address of the wireless connected terminal.
[0057] The wireless AP device runs an IP detection program that periodically checks whether the IP address in / tmp / apdhcp.lease is reachable. If it is not reachable, the flag is configured to 0x0. This step is used to clean up offline devices.
[0058] The wireless AP device obtains the MAC address of the currently connected wireless terminal through methods such as iwinfoathxassoclist, and then obtains the corresponding IP address in / tmp / apdhcp.lease through the MAC address.
[0059] like Figure 2 The diagram shown illustrates the working principle of this method:
[0060] Add a new apDhcpMonitor program to the wireless AP device, create a main thread to detect whether the IP address in / tmp / apdhcp.lease is online (step S3), create another thread to capture DHCP server messages (step S4), construct a dhcp.lease file for the wireless AP device through apDhcpMonitor, and when the wireless AP device reports information about the access device, query the device's IP address in the dhcp.lease file by MAC address.
[0061] To implement the above method for obtaining the IP address of the wireless connection terminal Figure 3 This invention provides a structural diagram of a device for obtaining the IP address of a wireless connection terminal. The wireless device includes at least one wireless access point (AP) device and an AC controller wired to the wireless AP device. The wireless AP device and the AC controller are configured with an interactive communication protocol. When the wireless AP device is wired to the AC controller and the DHCP server of the wireless AP device is disabled, the device includes:
[0062] The matching message module is used for the wireless AP device to receive Discover messages sent by the wireless connection terminal and forward them to the AC controller. The Discover message includes a matching request.
[0063] A message module is provided for wireless AP devices to receive Offer messages sent by AC controllers and forward them to wireless connection terminals. The Offer message includes an IP address that can be provided by the AC controller.
[0064] The request message module is used by the wireless AP device to receive the Request message sent by the wireless connection terminal and forward it to the AC controller. The Request message includes the IP address that is desired to be obtained.
[0065] The response message module allows the wireless AP device to receive and forward ACK messages from the AC controller to the wireless connection terminal, thereby obtaining the IP address. The ACK message includes both the MAC address and the IP address.
[0066] On the other hand, embodiments of the present invention also provide an apparatus including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of a method for the wireless device to obtain the IP address of a wireless connection terminal.
[0067] On the other hand, embodiments of the present invention also provide a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, it implements the steps of a method for the wireless device to obtain the IP address of a wireless connection terminal.
[0068] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0069] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, embodiments of the present invention can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0070] Embodiments of the present invention are described with reference to flowchart illustrations and / or block diagrams of methods, wireless connectivity terminals (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing wireless connectivity terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing wireless connectivity terminal, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0071] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing wireless connection terminal to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including an instruction means, the instruction means being implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0072] These computer program instructions can also be loaded onto a computer or other programmable data processing wireless connection terminal, causing a series of operational steps to be executed on the computer or other programmable wireless connection terminal to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable wireless connection terminal for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0073] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present invention.
[0074] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or wireless connection terminal 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 wireless connection terminal. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or wireless connection terminal that includes said element.
[0075] The present invention has provided a detailed description of a method and apparatus for a wireless device to obtain the IP address of a wireless connection terminal. Specific examples have been used to illustrate the principle and implementation of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core idea of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation and application scope based on the idea of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method for a wireless device to obtain the IP address of a wireless connection terminal, characterized in that, The wireless device includes at least one wireless access point (AP) device and an AC controller wired to the wireless AP device. The wireless AP device and the AC controller are configured with an interactive communication protocol. When the wireless AP device is wired to the AC controller, the DHCP server of the wireless AP device is disabled, and the AC controller assigns IP addresses to wireless connection terminals, the wireless AP device runs a DHCP monitoring program. The DHCP monitoring program includes a capture thread and a main thread. The method includes: S1, the wireless AP device receives the Discovery message sent by the wireless connection terminal and forwards it to the AC controller. The Discovery message includes a matching request. S2, the wireless AP device receives the Offer message sent by the AC controller and forwards it to the wireless connection terminal. The Offer message includes the IP address that the AC controller can provide. The capture thread captures the Offer message, writes the requestIP, MAC address, and hostname in the Offer message into the local terminal lease configuration file of the wireless AP device, and configures the corresponding flag to 0x0 to complete the pre-registration of the terminal IP. S3, the wireless AP device receives a Request message sent by the wireless connection terminal and forwards it to the AC controller. The Request message includes the IP address that is desired. The main thread periodically checks whether the IP address in the terminal lease configuration file is reachable; if it is not reachable, the corresponding flag is configured to 0x0 to clear offline devices. S4, the wireless AP device receives the ACK message sent by the AC controller and forwards it to the wireless connection terminal to obtain the IP address. The ACK message includes the MAC address and the IP address. The capture thread captures the ACK packet and parses the MAC address and IP address in the ACK packet; when the MAC address and IP address already exist in the terminal lease configuration file, the corresponding flag is configured to 0x1 to confirm that the terminal IP is valid; S5, the wireless AP device obtains the MAC address of the currently accessing wireless connection terminal, queries the corresponding IP address in the terminal lease configuration file based on the MAC address, and uses the queried IP address when reporting the wireless connection terminal information.
2. The method for a wireless device to obtain the IP address of a wireless connection terminal as described in claim 1, characterized in that, The DHCP monitoring program is apDhcpMonitor.
3. The method for a wireless device to obtain the IP address of a wireless connection terminal as described in claim 1, characterized in that, The terminal lease configuration file is / tmp / apdhcp.lease.
4. The method for a wireless device to obtain the IP address of a wireless connection terminal as described in claim 1, characterized in that, The capture thread captures the Offer message and / or the ACK message using the libcpap or libpcap message capture program.
5. The method for a wireless device to obtain the IP address of a wireless connection terminal as described in claim 1, characterized in that, In step S5, the wireless AP device obtains the MAC address of the currently connected wireless terminal through iwinfo athx assoclist.
6. The method for a wireless device to obtain the IP address of a wireless connection terminal as described in claim 1, characterized in that, Step S1 further includes: The wireless connection terminal broadcasts Discovery messages within the local network. The wireless AP device receives the Discovery message wirelessly and forwards it to the AC controller. After receiving the Discovery message, the AC controller constructs an Offer message and sends it to the wireless AP device and forwards it to the wireless connection terminal to inform it of the available IP address.
7. The method for a wireless device to obtain the IP address of a wireless connection terminal as described in claim 1, characterized in that, Following step S2, the following is also included: After receiving the Offer message, the wireless connection terminal sends a Request message to the wireless AP device and forwards it to the AC controller to inform the AC controller of the IP address that needs to be assigned.
8. A device for a wireless device to obtain the IP address of a wireless connection terminal, characterized in that, The wireless device includes at least one wireless access point (AP) device and an AC controller wired to the wireless AP device. The wireless AP device and the AC controller are configured with an interactive communication protocol. When the wireless AP device is wired to the AC controller, the DHCP server of the wireless AP device is disabled, and the AC controller assigns IP addresses to wireless connection terminals, the wireless AP device runs a DHCP monitoring program. The DHCP monitoring program includes a capture thread and a main thread. The device includes: The matching message module is used for the wireless AP device to receive Discover messages sent by the wireless connection terminal and forward them to the AC controller. The Discover message includes a matching request. A message module is provided for wireless AP devices to receive Offer messages sent by AC controllers and forward them to wireless connection terminals. The Offer message includes an IP address that can be provided by the AC controller. The capture thread captures the Offer message, writes the requestIP, MAC address, and hostname in the Offer message into the local terminal lease configuration file of the wireless AP device, and configures the corresponding flag to 0x0 to complete the pre-registration of the terminal IP. The request message module is used by the wireless AP device to receive Request messages sent by the wireless connection terminal and forward them to the AC controller. The Request message includes the IP address that is desired to be obtained. The main thread periodically checks whether the IP address in the terminal lease configuration file is reachable; if it is not reachable, the corresponding flag is configured to 0x0 to clear offline devices. The response message module allows the wireless AP device to receive and forward ACK messages sent by the AC controller to the wireless connection terminal and obtain the IP address. The ACK message includes the MAC address and the IP address. The capture thread captures the ACK packet and parses the MAC address and IP address in the ACK packet; when the MAC address and IP address already exist in the terminal lease configuration file, the corresponding flag is configured to 0x1 to confirm that the terminal IP is valid; The wireless AP device obtains the MAC address of the currently connected wireless terminal, queries the corresponding IP address in the terminal lease configuration file based on the MAC address, and uses the queried IP address when reporting the wireless connection terminal information.
9. An electronic device, characterized in that, The electronic device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the method as claimed in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the steps of the method as described in any one of claims 1-7.
Citation Information
Patent Citations
Address allocation method, device and system
CN109088959A
User information management method based on thin AP
CN101835145A
