Wi-Fi Direct
Wi-Fi Direct is a Wi-Fi standard that allows devices to connect with each other without requiring a Wi-Fi access point. Wi-Fi Direct negotiates the link with a Wi-Fi Protected Setup (WPS) system that assigns each device a limited wireless access point.
Establishing a peer-to-peer (P2P) link has the following phases:
-
P2P discovery, which allows to search for P2P devices in the vicinity
-
P2P group formation, a P2P group is formed with the identification of one of the devices as group owner. A device can either become group owner (GO) autonomously if configured to do so or it can be negotiated between devices with the exchange of GO intents.
-
P2P provisioning, which authenticates the link by using either Push Button Configuration (PBC) or PIN authentication.
-
P2P connection, when the connection between a Group Owner (GO) and a Group Client (GC) is actually established.
P2P interfaces
The Wi-Fi driver on load creates a wfd0
interface that is used by the wpa_supplicant for P2P group formation.
Once a group is formed, virtual p2p-wfd0-N interfaces are created, where N is an index starting at 0.
These virtual interfaces are then used for provisioning.
-
Group additions, find, and connect operations happen on the
wfd0
interface. -
Provisioning occurs on the virtual p2p-wfd0-N interfaces.
Enable P2P on the driver
The wfd0
interface is disabled by default to improve the performance of the wlan0
interface in client infrastructure mode.
To customize the default driver interfaces, edit the file /etc/udev/scripts/load_iw612.sh
and specify the driver mode.
# head -n 8 /etc/udev/scripts/load_iw612.sh
#!/bin/sh
# The bit settings of drv_mode are:
# Bit 0 : STA
# Bit 1 : uAP
# Bit 2 : WIFIDIRECT
# eg, for STA + uAP + WIFIDIRECT, set 7 (b'111)
DRIVER_MODE=1 # Only STA
To configure STA + AP + P2P mode, set DRIVER_MODE
to 7 (b'111) and reboot your device.
The MAC addresses assigned to the additional interfaces are composed by swapping some bytes of the main MAC address. If you require unique MAC addresses for additional interfaces, you can set them with a standard Linux command:
|
Automatic P2P connection setup
This topic explains how to do an automatic P2P connection with negotiated GO and PBC join, where any of the peers can adopt the GO role.
-
Find the MAC address of the remote peer you want to connect to, which you can get using
iw dev
command under thewfd0
interface:# iw dev phy#0 Interface wfd0 ifindex 7 wdev 0x2 addr 02:04:f3:8d:40:03 type managed txpower 0.00 dBm Interface wlan0 ifindex 6 wdev 0x1 addr 00:04:f3:8d:40:03 type managed txpower 0.00 dBm
-
Edit the file
/etc/network/interfaces
and add the remote peer MAC address using the parameterp2p-peer-mac
at thewfd0
interface entry:/etc/network/interfaces# WiFi P2P interface #auto wfd0 iface wfd0 inet static address 192.168.45.30 netmask 255.255.255.0 wpa-driver nl80211 wpa-conf /etc/wpa_supplicant_p2p.conf p2p-peer-mac 02:04:f3:8d:40:03
Other optional configurable parameters of the P2P connection include:
-
p2p-discover-window
: Duration in seconds on the peer discovery operation (default of 120 seconds). -
p2p-freq
: Frequency for the channel used in the P2P connection (negotiated by default). Digi recommends you select a fixed frequency because it improves resiliency. -
p2p-local-address
: The local IP address assigned to the P2P interface (no default IP assigned). -
p2p-local-netmask
: The network mask assigned to the P2P interface (no default mask assigned).
-
-
Repeat the previous step (this time with your device’s MAC) on the peer device.
-
Reboot the devices with the following command:
# reboot
-
Bring up the
wfd0
interface simultaneously at both ends:# ifup wfd0
This creates a Wi-Fi direct connection using negotiated GO and PBC join.
For details on this automatic P2P connection, see the script /etc/network/if-up.d/p2plink
.
Manual P2P connection setup
The following examples will use two ConnectCore 91 devices to establish P2P connections.
Before running any of the examples, bring up the wfd0
interface on both peers with:
# ifup wfd0
The examples below use wpa-supplicant P2P-specific commands.
For more information about these commands, see the wpa_supplicant and Wi-Fi P2P README.
|
Autonomous GO creation
Create Autonomous Group Owner (GO) and join using PBC method
Peer (GO) ---- PBC --- Peer (GC)
Step | Peer CC911 | Peer CC912 |
---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
Ctrl+C to exit |
Ctrl+C to exit |
6 |
|
|
7 |
|
|
8 |
|
|
Create Autonomous GO and join using PIN from GO
Peer (GO) ---- PIN --- Peer (GC)
Step | Peer CC911 | Peer CC912 |
---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
Ctrl+C to exit |
|
5 |
(shows <pin>) |
|
6 |
|
|
7 |
Ctrl+C to exit |
|
8 |
|
|
9 |
|
|
Create Autonomous GO and join using PIN from GC
Peer (GO) ---- PIN --- Peer (GC)
Step | Peer CC911 | Peer CC912 |
---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
(shows <pin>) |
|
5 |
Ctrl+C to exit |
Ctrl+C to exit |
6 |
|
|
7 |
|
|
8 |
|
|
Create Autonomous GO and invite GC using PBC
Peer (GO) ---- PBC --- Peer (GC)
Step | Peer CC911 | Peer CC912 |
---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
Ctrl+C to exit |
Ctrl+C to exit |
7 |
|
|
8 |
|
|
9 |
|
|
For any of these methods, if you want to use the 5GHz frequency,
issue p2p_group_add freq=5180 in step two.
|
Negotiated GO
Negotiate GO and join using PIN
Peer (GO | GC) ---- PIN --- Peer (GO | GC)
Step | Peer CC911 | Peer CC912 |
---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
Ctrl+C to exit |
Ctrl+C to exit |
7 |
|
|
8 |
|
|
Negotiate GO and join using PBC
Peer (GO | GC) ---- PBC --- Peer (GO | GC)
Step | Peer CC911 | Peer CC912 |
---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
Ctrl+C to exit |
Ctrl+C to exit |
7 |
|
|
8 |
|
|