Detailed Description
In order to make the objects, technical solutions and advantages of the present disclosure more apparent, the technical solutions of the present disclosure will be clearly and completely described below with reference to the specific embodiments of the present disclosure and the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments obtained by a person skilled in the art without making any inventive step based on the embodiments in the description belong to the protection scope of the present application.
The technical solutions provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.
Fig. 1 is a schematic diagram of a process for acquiring a MAC address according to an embodiment of the present application, which may specifically include the following steps:
s100: and receiving each management frame propagated in a broadcasting mode, and respectively determining the MAC address carried in each management frame.
In the prior art, the function of the early WiFi probe to acquire the MAC address is integrated on the AP device, that is, the AP device provides network service for the accessed terminal, and also receives signals broadcast by peripheral terminals that are not accessed, and determines the MAC address from the received signals. However, when the AP device acquires the MAC address, the AP device may interfere with the quality of the network service provided by the AP device, and the efficiency of the AP device acquiring the MAC address is low, so that the AP device does not integrate the function of acquiring the MAC address any more but uses an independent device to realize the function of acquiring the MAC address. That is, the WiFi probe of the prior art is a stand-alone device, which no longer provides network service for the mobile terminal, but is only used for acquiring the MAC address of the mobile terminal for performing subsequent services.
Similarly, in one or more embodiments of the present application, the process of acquiring the MAC address may also be performed by a WiFi probe, which is a standalone device and does not include a function of providing a network service for the mobile terminal. Then, the WiFi probe may acquire, via the antenna, the management frame broadcast by the devices with WLAN connectivity. Wherein, the management frame conforms to IEEE802.11 standard, and the management frame may also carry MAC address.
Specifically, how the WiFi probe acquires the broadcasted management frame is a mature method in the prior art, and the content of the process is not repeated in this application.
It should be noted that, in this embodiment of the present application, the device having a function of connecting to a WLAN specifically may include: a mobile terminal (e.g., a mobile phone, a tablet computer, etc.) and an AP device. Therefore, the WiFi probe can acquire the management frame broadcasted by the mobile terminal and can also receive the management frame broadcasted by the AP equipment. In addition, the management frame in the present application may include at least: the management Frame broadcast by the AP device is generally a Beacon Frame (Beacon Frame), because the mobile terminal is generally a party needing to access the WLAN, and the AP device is a party providing WLAN access.
In addition, when the device broadcasts the management frame, the content of the management frame needs to conform to the IEEE802.11 standard, and therefore the management frame carries the MAC address. Then, the WiFi terminal may also determine the MAC address carried in each received management frame. Of course, the MAC address may be a legitimate MAC address of the device (i.e., the real address of the device that is provided when connecting to the network), or the MAC address may be a MAC address that is randomly generated by the device.
S102: and determining the address type of the MAC address and the equipment type corresponding to the MAC address aiming at each determined MAC address.
S104: and sequentially storing each MAC address of the determined equipment type as the AP equipment.
In one or more embodiments of the present application, since the device sending the MAC is the device, and whether the MAC address is a real address or not is correspondingly specified in the IEEE802.11 standard, after the WiFi probe determines the MAC address carried in the management frame, it may also determine, for each MAC address, an address type of the MAC address and a device type corresponding to the MAC address. Wherein the address types include: a legal MAC address and a random MAC address, the device type at least comprising: an AP device.
Specifically, the WiFi probe may determine the type of the MAC address first, and for each determined MAC address, determine whether a value of b1 bits (bit) in a first byte of the MAC address is 0, if so, determine that the address type of the MAC address is a valid MAC address and store the valid MAC address, and if not, determine that the address type of the MAC address is a random address and do not store the random address. For the determined legal MAC address, the WiFi probe can be provided for a background server so that the background server can execute services (such as services of passenger flow statistics and analysis, accurate marketing, public safety and the like) according to needs.
Certainly, in the embodiment of the application, the WiFi probe may also store the determined legal MAC addresses locally, and send the determined legal MAC addresses to the background server when the number of the stored legal MAC addresses reaches a preset value, or send the stored legal MAC addresses to the background server according to a preset time interval.
In addition, as described in step S100, since the management frame received by the WiFi probe may be a probe request frame broadcast by the mobile terminal or a beacon frame broadcast by the AP device, and the MAC address of the AP device is not generally used for subsequent backend servers to perform services, in this embodiment of the present application, the WiFi probe may further determine and store the MAC address of the AP device as the device type from the determined MAC addresses, but may not send the MAC address to the backend servers to reduce communication pressure.
Further, since the MAC address of the AP device is used for the mobile terminal to establish a communication connection with the AP device, the MAC address carried in the beacon frame broadcasted by the AP device is a valid MAC address. Therefore, in the embodiment of the application, after determining each legal MAC address, the WiFi probe may determine whether the device type corresponding to the legal MAC address is an AP device, if so, store the MAC address in a linked list in sequence, and if not, directly store the MAC address so as to send the MAC address to the background server.
Furthermore, when the WiFi probe stores the determined MAC address of the AP device in the linked list, the WiFi probe may store the MAC address in the time sequence of receiving the management frame carrying the MAC address. And the number of the MAC addresses stored in the linked list can be set as required, and then after the linked list is full of storage, when the newly determined MAC address of the AP equipment needs to be stored, the WiFi probe can delete the MAC address stored earliest in the linked list and then determine the MAC address of the AP equipment. For example, assuming that the capacity of the linked list of the WiFi probe is 5, five MAC addresses a 1-a 5 are stored in chronological order, and after determining a new MAC address a6 that needs to be stored in the linked list, the MAC address a1 may be deleted, and five MAC addresses a 2-a 6 may be stored.
In addition, since the position of the WiFi probe is generally fixed, and the AP devices around the WiFi probe are also generally fixed, the WiFi probe may further perform a re-processing after determining each MAC address, and for each determined MAC address, when the MAC address matches any one of the MAC addresses that have already been stored, the WiFi probe does not perform a processing on the MAC address.
S106: and when the address type of any MAC address is determined to be a random MAC address, sequentially generating and broadcasting a beacon frame according to each MAC address of which the stored equipment type is the AP equipment.
In one or more embodiments of the present application, when it is determined that an address type of any MAC address is a random MAC address, it may be determined that the MAC address cannot be used for a subsequent background server to perform a service, and therefore the WiFi probe may further generate and broadcast a beacon frame in sequence according to each MAC address of which the device type is stored as an AP device. And when the terminal broadcasting the management frame carrying the random MAC address receives the beacon true frame broadcast by the WiFi probe and if the beacon frame is determined to be reliable, returning the management frame carrying the legal MAC address to the WiFi probe. The WiFi probe may determine and store the legitimate MAC address through steps S100 and S102.
Specifically, as illustrated in step S100, in one or more embodiments of the present application, the WiFi probe does not have a function of providing a network service, and is a device that passively receives a broadcasted management frame. Therefore, in order to implement the function of broadcasting the beacon frame, in step S106, a main program executable by a Central Processing Unit (CPU) of the WiFi probe calls an AT command stored in a non-volatile memory (e.g., ROM) according to service logic, configures parameters to be used when an antenna of the WiFi probe broadcasts a signal, and sequentially generates beacon frames according to MAC addresses of AP devices of the stored device types, and sequentially broadcasts the sequentially generated beacon frames through the antenna in the generation order.
That is, the WiFi probe configures itself as a device capable of broadcasting signals according to the AT commands configured in advance and the service logic of the main program, and broadcasts the generated beacon frame. Wherein the AT commands can be pre-configured as needed in the ROM of the WiFi probe. And the WiFi probe is configured through the AT instruction, so that the existing WiFi probe without the network service function can realize the beacon frame broadcasting on the basis of not changing a hardware structure, and the upgrading cost of the WiFi probe is reduced. Meanwhile, the WiFi probe does not have a network service function, the function of the WiFi probe can be intensively used for acquiring the MAC address, and the efficiency is higher than that of AP equipment integrating the function of acquiring the MAC address in the prior art.
In addition, since the WiFi probe stores the determined MAC addresses of the AP devices in a chain manner in step S104, the WiFi probe may sequentially generate and broadcast a beacon frame including the MAC address from the MAC address for each stored MAC address of the AP devices. Therefore, the WiFi probe can complete the broadcast of the beacon frame while not interfering with the acquisition management frame.
Further, as for a received beacon frame, the terminal usually identifies the network identifier of the beacon frame first and determines whether the beacon frame is a reliable beacon frame, in step S104 in this embodiment of the present application, the WiFi probe may further determine, for each MAC address of the AP device, a network identifier in a management frame carrying each MAC address, and establish and store a corresponding relationship between the MAC address and the determined network identifier. Then, in step S106, when the WiFi probe generates a beacon frame, sequentially determining, for each called MAC address, a network identifier corresponding to the MAC address according to a stored correspondence between each MAC address and each network identifier, and then generating a beacon frame carrying the MAC address and the network identifier according to the MAC address and the network identifier corresponding to the MAC address. The network identifier may be a Service Set Identifier (SSID).
It should be noted that, when determining whether the beacon frame is trusted, the terminal may determine whether the MAC address corresponding to the beacon frame is connected according to the history of WLAN connection, and if so, determine that the beacon frame is trusted, and if not, determine that the beacon frame is not trusted. Or, the terminal may also determine whether the beacon frame is trusted according to a pre-acquired white list and/or black list of the MAC address, and the specific determination manner of the terminal is not limited in the present application. However, as long as the terminal determines that the beacon frame broadcasted by the WiFi probe is trustworthy and provides a management frame carrying a legal MAC address, the WiFi probe may perform step S100 to determine the legal MAC address through the management frame and continue to perform the subsequent steps.
Through the method for acquiring the MAC address shown in fig. 1, the WiFi probe may sequentially store the acquired MAC addresses of the surrounding AP devices, and when receiving a management frame carrying a random MAC address, may generate and broadcast a beacon frame through the stored MAC addresses of the AP devices, so that a terminal broadcasting the management frame carrying the random MAC address returns a management frame carrying a legal MAC address to the WiFi probe when receiving a reliable beacon frame broadcasted by the WiFi probe. The defects of the WiFi probe in obtaining the legal MAC address in the prior art are overcome.
In addition, in the embodiment of the present application, since the validity of the MAC address of the AP device, which is the device type acquired by the WiFi probe, generally decreases with time, the WiFi probe may further determine, for the stored MAC address of each AP device, whether the MAC address is overtime, if yes, delete the MAC address, and if not, do not perform the processing.
Further, when the WiFi probe broadcasts the beacon frame in sequence in step S106, since there is interference between the broadcast beacon frame and the reception management frame, the WiFi probe may also broadcast the generated beacon frame in sequence according to the preset time interval. Wherein the time interval can be set as required (e.g., 5 seconds), which is not limited in this application.
Further, in the embodiment of the present application, in order to reduce the resource consumed by the WiFi probe, the WiFi probe may not perform step S106 when the number of management frames acquired in step S100 is less than the preset number. That is, when the number of surrounding terminals is small, even when a management frame carrying a random MAC address is received, a beacon frame is not generated to broadcast but the random MAC address is ignored in order to concentrate the resources of the WiFi probe on determining the MAC address. The preset number may be set as needed, for example, the number of WiFi probes set in a place with a large flow of people may be higher (e.g., 10), the number of WiFi probes set in a place with a small flow of people may be lower (e.g., 1), and the like, which is not limited in the present application.
Based on the method for acquiring the MAC address provided in fig. 1, the present application also correspondingly provides a device for acquiring the MAC address, as shown in fig. 2.
Fig. 2 is a schematic structural diagram of an apparatus for acquiring a MAC address according to an embodiment of the present application, including:
a receiving determination module 200, configured to receive each management frame transmitted in a broadcast manner, and determine an MAC address carried in each management frame;
a classification module 202, configured to determine, for each determined MAC address, an address type of the MAC address and a device type corresponding to the MAC address, where the address types at least include: a legal MAC address and a random MAC address, the device type at least comprising: the access point comprises common equipment and wireless access point AP equipment;
the storage module 204 is used for sequentially storing each MAC address of the determined device type as the AP device;
the broadcast module 206, when determining that the address type of any MAC address is a random MAC address, sequentially generates and broadcasts a beacon frame according to each MAC address whose device type is stored as an AP device, so that a terminal that broadcasts a management frame carrying a random MAC address returns a management frame carrying a valid MAC address when receiving a trusted beacon frame.
The storage module 204 sequentially stores each MAC address with the device type being the AP device in a linked list according to the time sequence determined by each MAC address with the device type being the AP device.
The broadcast module 206 sequentially calls each MAC address of the AP device as the device type according to the stored linked list, generates a beacon frame, and broadcasts the beacon frame.
The classification module 202 determines, for each MAC address whose device type is an AP device, a network identifier in a management frame carrying each MAC address; the storage module 204 is configured to establish and store a corresponding relationship between the MAC address and the determined network identifier; the broadcast module 206 determines, for each called MAC address, a network identifier corresponding to the MAC address according to a stored correspondence between each MAC address and each network identifier, and generates a beacon frame according to the MAC address and the network identifier corresponding to the MAC address.
The broadcast module 206, when determining that the address type of any MAC address is a random MAC address, invokes and executes AT least one AT instruction stored in advance, configures parameters of an antenna broadcast signal, sequentially generates beacon frames for each MAC address of the AP device according to the stored device type, and sequentially broadcasts the beacon frames through the antenna according to the generation sequence according to the configured parameters of the broadcast signal.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.