latest 6G technology news

WiFi distribution network and status quo of IoT devices

WiFi distribution network and status quo of IoT devices

Smart products in the Internet of Things (IoT/IoE) generally use WiFi to connect with routers.

I. Introduction
At present, smart products in the Internet of Things (IoT/IoE) generally use WiFi to complete the connection with the router, and then perform data interaction through the mobile phone and the cloud. The topology is as follows:
As can be seen from the figure above, there is no direct interaction between APP and smart products, but a “cloud” terminal (of course, we can also directly use the local area network).
Here comes the problem: smart hardware such as smart sockets, smart air conditioners, smart air purifiers, etc., do not have a human-computer interaction interface, so they cannot search, select a specified AP, and enter a connection password like a computer.iot board - WiFi distribution network and status quo of IoT devices

iot board – WiFi distribution network and status quo of IoT devices


WiFi distribution network is used to solve the networking needs of smart devices. Further speaking, it is to inform the WiFi module in the smart device of the name (SSID) and password (PWD) of the AP in some way, and then the smart device connects to the designated AP according to the received SSID and password.

2. Mainstream network distribution methods
Currently popular WiFi configuration modes generally have the following two types:
1. SoftAP distribution network: The WiFi module of the smart device is switched to AP mode, and the mobile phone acts as a STA to connect to the AP of the smart device. After that, the two parties establish a Socket connection to exchange data (the two parties agreed on the port before).
2. Quick connection/one-key configuration mode: the mobile APP packs the corresponding information into a specific area of the 802.11 data packet and sends it to the surrounding environment; the WiFi module of the smart device is in the promiscuous mode (Promiscuous Model), and monitors all reports in the network. text until the required information is parsed (the data format has been agreed upon by both parties before).

It can be seen that both need the support of WiFi hardware. The SoftAP method requires hardware to support AP mode, and the quick connection/one-key configuration method requires hardware to support promiscuous mode (some WiFi chip manufacturers have turned off promiscuous mode to save power).

3. SoftAP distribution network
Take the Linux terminal as an example: First, switch to AP mode, script example:

killall -q wpa_supplicant
killall -q udhcpc
killall -q udhcpd
killall -q hostapd

# above: clear the current network related process
echo “start switch to AP mode…”

mkdir -p /var/lib/misc
touch /var/lib/misc/udhcpd.leases
ifconfig wlan0 down
ifconfig wlan0 up
# above: the current network card IP is

hostapd -B /etc/wifi/hostapd.conf
# Above: Enter AP mode. Different drivers enter AP mode in different ways
udhcpd /etc/wifi/udhcpd.conf
# above: start udhcpd, assign IP for devices connected to AP

Example of /etc/wifi/hostapd.conf configuration file:

# hostapd service configuration file
rsn_pairwise=CCMP TKIP

/etc/wifi/udhcpd.conf configuration file example:

# udhcpd service configuration file
interface wlan0
opt dns
opt router
option subnet
option domain localhost
option lease 864000

Secondly, the smart device opens a socket and waits for the device to connect itself, and then the two parties communicate through the socket. The smart device receives the WiFi information and saves it to the /etc/wifi/wpa_supplicant.conf file

Finally, the smart device exits the AP mode and connects to the designated router. Script example:


ifconfig wlan0 down
killall -q wpa_supplicant
killall -q udhcpd
killall -q udhcpc
killall -q hostapd
ifconfig wlan0 up
# above: clear the current network related process

wpa_supplicant -B -Dnl80211 -iwlan0 -c /etc/wifi/wpa_supplicant.conf
# above: connect to the router

udhcpc -R -i wlan0
# Above: request IP and other information from the router

4. Quick connection/one-key configuration
4.1 Working mode of wireless network card

A wireless network card is a terminal that uses wireless signals for data transmission. Wireless network cards usually include 4 modes, namely broadcast mode, multicast mode, direct mode and promiscuous mode. If users want to monitor all signals in the network, they need to set the network card to monitor mode.latest 6G technology news

latest 6G technology news


The monitoring mode refers to the promiscuous mode. The following will introduce several working modes of the network card in detail. As described below:
(1) Broadcast mode (BroadCast Model): the frame whose physical address (Mac) is 0XFFFFFF is a broadcast frame, and the network card working in broadcast mode receives broadcast frames.
(2) Multicast transmission (MultiCast Model): The frame with the multicast transmission address as the destination physical address can be received by other hosts in the group at the same time, but the hosts outside the group cannot receive it. However, if the network card is set to multicast transmission mode, it can receive all multicast transmission frames, regardless of whether it is a member of the group.
(3) Direct Mode (Direct Model): A network card working in direct mode only receives frames whose destination address is its own Mac address.
(4) Promiscuous Mode (Promiscuous Model): The network card working in promiscuous mode receives all the frames flowing through the network card, and the communication packet capture program runs in this mode.


4.2 Overview of quick connection/one-key configuration

One-click configuration transmits data through specific regions of 802.11 packets. 802.11 is a wireless local area network protocol formulated by IEEE. It uses 802.2 logical link control encapsulation to carry IP packets, so it can receive wireless network data in 802.2 SNAP format. If you turn on the promiscuous mode of the wifi chip to monitor the wireless signal in the space, you will get the data packet as shown in the figure below:

From the perspective of the wireless signal monitor, the Length, Destination, BSSID, Source, Seq, and FCS fields are always exposed regardless of whether the wireless channel is encrypted. Therefore, it is possible to obtain information from these fields in the practical signal monitoring method. But from the perspective of the sender, due to the limitation of the operating system (such as ISO or Android), the control of fields such as BSSID, Source, Seq, and FCS requires high control authority, which is generally difficult for the sender to obtain. Based on these objective conditions, there are currently two means of one-key configuration and contract delivery, multicast and broadcast, to complete information transmission.


4.3 Quick connection/one key configuration data encoding

The application layer mainly encodes the SSID and password information related to one-key configuration through certain rules and then transmits them. The one-click configuration application layer data encoding is as follows:


4.4 Multicast one-key configuration components

Since 802.11 has the characteristic that the last three bytes of the Destination are the same as the last three bytes of the destination multicast address when processing multicast, in actual use, the change of the multicast address can be used to transmit information. The MAC address is a 48bit (6-byte hexadecimal number) address used by the Ethernet layer 2 to identify the location of the device. The MAC address is divided into two parts, the first 24 bits are Organizationally unique identifier (OUI, Organizationally unique identifier), and the last 24 bits are assigned by the manufacturer. MAC addresses are divided into unicast, multicast, and broadcast. Unicast address (unicast address) means a single device, node, multicast address or multicast address (multicast address, group address) means a group of devices, nodes, broadcast address (broadcast address) is a special case of multicast, means all addresses, Express it with all Fs: FF-FF-FF-FF-FF-FF. Of course, the three-layer IP address also has unicast, multicast, and broadcast points. The structure of MAC is as follows:

When using multicast to complete one-key configuration, the content of the Organization Assigned Portion in the Destination field of the 802.11 packet is the last 23 bits of the multicast address filled by the sender. Each contract sending process can transmit 23Bit, and the entire contract sending process sends Version data first, and then sends Data data. Send continuously in a loop, the interval of each packet of data is 10ms, until the device gets all the information and passes the verification, and then notifies the sender through the Socket.

In order to improve reliability, the two phases of the process of sending multicast packets must be encoded and verified according to certain rules.


4.5 Broadcast one-key configuration components

One-key configuration can also transmit information based on the Length field, and the sender can control it conveniently by changing the length of the data packet it needs to send. Therefore, as long as a set of communication protocols using length encoding is developed, the Length field in the 802.2 SNAP data packet can be used for information transmission.

In practical applications, we use UDP broadcast packets as the carrier of information. The information sender sends a series of UDP broadcast packets in the space, and the length of each packet (that is, the Length field) is encoded according to certain specifications. The layer intercepts the 802.2 SNAP format data packet, and then the encoded Length field can be obtained, and then the required information can be parsed out according to the protocol for convenience of reception. The entire broadcast packet sending process is divided into synchronization phase, version phase, and data phase. In the synchronization phase, the data packet sending interval is 5ms, the Verson and data packet sending interval is 10ms, and the pause is 50ms after each round. The synchronization phase needs to be sent continuously for 2 seconds, the Version and data phases need to be sent continuously 20 times as one round, and then the synchronization phase and data phase are sent repeatedly, as shown in the figure:

5. Status quo of WiFi distribution network application
Problems exposed by quick connection/one-key configuration:
(1) At present, the wireless network modes of routers for home use include 802.11b only, 802.11g only, 802.11n only, 802.11bg mixed, and 802.11bgn mixed. In routing mode, the rate of UDP broadcast/multicast packets sent by the mobile phone itself is also fast, and the WiFi module of the smart device may not be able to capture complete information in terms of processing speed due to performance limitations, resulting in the failure of quick connection/one-key configuration.

(2) If there are multiple devices of the same type in the quick connection/one-key configuration in the distribution network environment, there may be multiple devices connected to the router.

(3) During the network distribution process, there is interference from similar wireless signals of the same frequency, which may also lead to failure.

To sum up, under the background of the current popularization of “high-performance mobile phone + high-speed routing”, “quick connection/one-key configuration and distribution network” is increasingly showing its incompetent dilemma in the all-encompassing consumer LAN environment. At present, the distribution network of mainstream manufacturers has canceled the “Quick Connection/One-key Configuration” earlier, and mainly promotes “SoftAP” or Bluetooth direct connection based on the “Bluetooth+WiFi” module and other distribution network methods.

Leave a Reply

Your email address will not be published. Required fields are marked *