Wi-Fi Direct (P2P)
Supported ICs[ RTL8730E ][ RTL8721Dx ][ RTL8721F ]
Note
Realtek Wi-Fi P2P only supports Linux hosts with wpa_supplicant, including Fat Host in Wi-Fi Card mode (WHC Wi-Fi Configuration Options and Operating Modes) and RTL8730E Linux architecture.
Wi-Fi P2P Introduction
Wi-Fi Direct, also known as Wi-Fi P2P (Wi-Fi Peer-to-Peer), is a wireless communication technology released by the Wi-Fi Alliance. It aims to simplify the connection process between devices and achieve fast and convenient wireless communication. This technology enables Wi-Fi Direct connections between devices, bypassing traditional access points (APs) for direct peer-to-peer communication. This means users on the go can wirelessly print documents, share screens, share data, sync files, and display information from devices like notebooks, smartphones, and tablets.
P2P architecture
In P2P architecture, three core components are defined:
P2P Device:
Supports the Wi-Fi P2P protocol, such as smartphones, tablets, and laptops.
Capable of discovering other devices, negotiating connections, and joining or creating a P2P group.
P2P Group Owner(GO):
The role of “controller” in a P2P network, similar to an access point (AP) in a traditional Wi-Fi network.
GO is responsible for managing device connections, resource allocation, and data forwarding within the group.
There can only be one GO in a P2P group.
P2P Group Client(GC):
Devices connected to the Group Owner (GO), similar to terminal devices (STA) in a traditional Wi-Fi network.
Can exchange data with GO and communicate with other clients through the GO’s forwarding.
A P2P group can have multiple clients, forming a 1-to-n topology.
P2P topology
Before forming a P2P Group (i.e. P2P Network), each terminal exists as a P2P Device.
After completing P2P negotiation among these P2P devices, one of them will assume the role of GO while others act as GC.
Since the Group Owner (GO) functions similarly to an Access Point (AP), legacy STAs (Stations) without P2P capability can discover and associate with the GO. These conventional devices are termed Legacy Clients.
The final P2P group topology is structured as follows:
P2P Group topology
P2P concurrent operation
A P2P Device can operate concurrently with a WLAN. Such a device is considered a P2P Concurrent Device. The figure below shows a P2P Concurrent Device that has one MAC entity operating as a WLAN-STA and the second MAC entity operating as a P2P Device.
P2P Group topology
P2P implementation process
The implementation process of P2P mainly includes Device Discovery, Service Discovery, Group Formation, Connection Establishment and Data Transmission:
Device Discovery:
Devices discover each other by sending and listening to Probe Request and Probe Response on social channels such as 1, 6, and 11.
Service Discovery:
Optional stage, used to query whether the other devices supports specific services.
Group Formation:
GO Negotiation: through the GO Negotiation protocol, two devices negotiate to determine which one will become the Group Owner.
Provisioning: negotiate the connection method and complete security authentication to ensure encrypted communication.
Connection Establishment and Data Transmission:
Once the connection is successfully established, the Group Owner (GO) assigns IP addresses and the client joins the network. Devices can then exchange data using the TCP/IP protocol.
Wi-Fi P2P Supported Features
Realtek devices provide the following support for the Wi-Fi P2P protocol:
Core Functional Support
Support GO.
Support GC.
Support GO + STA.
P2P Security Support
Before the connection is established, authentication is performed using the WPS protocol (either PIN or Push Button method).
After the connection is established, WPA2 encryption is used to secure communication data.
Wi-Fi P2P Porting Guide
Realtek Wi-Fi P2P supports Linux Host, Wi-Fi Card mode S2H (WHC Wi-Fi Configuration Options and Operating Modes), or RTL8730E Linux.
For device driver porting, refer to Wi-Fi Card mode Configuration Options and Operating Modes. For host driver porting, refer to the Linux tab in Wi-Fi Card mode Driver Porting.
For device driver porting, refer to Wi-Fi Card mode Configuration Options and Operating Modes. For host driver porting, refer to the Linux tab in Wi-Fi Card mode Driver Porting.
In the directory
{SDK}
, execute sourceenvsetup.sh
to set up the compilation environment.Select the target machine and target distro for compilation, such as rtl8730elh-va7 full.
You're building on Linux Lunch menu... pick a combo: 1. rtl8730elh-va7-full 2. rtl8730elh-va7-generic 3. rtl8730elh-va8-full 4. rtl8730elh-va8-generic Which would you like?
After entering the build directory, execute
mfw menuconfig
.Find
and select .(Top) -> CONFIG WIFI ----Configuration---- (X)ENABLE WIFI ---> CONFIG WIFI MODE ---> ( ) ENABLE NAN (X) ENABLE P2P
Open
{SDK}/sources/firmware/component/wifi/whc/whc_host_linux/Makefile
, enable the P2P compilation option.export CONFIG_NAN = n export CONFIG_P2P = y export CONFIG_MCC = n export CONFIG_BT_INIC = n export CONFIG_FULLMAC_HCI_IPC = y
Open
{SDK}/sources/yocto/meta-realtek/meta-realtek-bsp/recipes-connectivity/wpa-supplicant/wpa-supplicant/defconfig
, enable the wpa supplicant P2P related features.# P2P (Wi-Fi Direct) # This can be used to enable P2P support in wpa_supplicant. See README-P2P for # more information on P2P operations. CONFIG_P2P=y # AP mode operations with wpa_supplicant # This can be used for controlling AP mode operations with wpa_supplicant. It # should be noted that this is mainly aimed at simple cases like # WPA2-Personal while more complex configurations like WPA2-Enterprise with an # external RADIUS server can be supported with hostapd. CONFIG_AP=y # Wi-Fi Protected Setup (WPS) CONFIG_WPS=y
Execute
m
andmfw
to generate firmwares, location:{SDK}/images
.Use the image tool to download firmwares to the development board.
Wi-Fi P2P Usage Guide
P2P testing uses standard wpa_cli commands
Below is a basic example of establishing a P2P connection through network negotiation (tested with two RTL8730E devices):
DUT |
SUT |
NOTE |
---|---|---|
wpa_supplicant -i wlan0 -c {path}/wpa_supplicant.conf -B |
Path can be any directory. The content edited in wpa_supplicant.conf is as follows: ctrl_interface=/var/run/wap_supplicant update_config=1 device_name=P2P_Device_1 manufacturer=Realtek model_name=RTW_STA model_number=WLAN_CU serial_number=12345 device_type=1-0050F204-1 os_version=01020300 config_methods=virtual_display virtual_push_button keypad display push_button |
|
wpa_supplicant -i wlan0 -c {path}/wpa_supplicant.conf -B |
The content is consistent with the above, except for device_name: device_name=P2P_Device_2 |
|
wpa_cli -i wlan0 |
wpa_cli -i wlan0 |
|
p2p_find |
||
p2p_find |
||
p2p_peers |
The “p2p_peers” command can print out all the scanned P2P devices, include mac address |
|
p2p_peers |
||
p2p_connect 00:e0:4c:00:06:fb pbc go_intent=15 |
Specify the other party’s MAC address for connection After successful connection, DUT acts as GO and SUT acts as GC |
|
p2p_connect 00:e0:4c:00:06:f9 pbc go_intent=0 |
||
q |
Execute ifconfig, a new interface named p2p-wlan0-0 can be found on the GO side |
|
ifconfig |
||
ifconfig p2p-wlan0-0 192.168.43.1 |
Set up a DHCP server and modify the interface in udhcpd.conf to ‘p2p-wlan0-0’ |
|
udhcpd -S /etc/udhcpd.conf |
||
q |
Execute ifconfig, a new interface named p2p-wlan0-0 can be found on the GC side |
|
ifconfig |
||
dhcpcd p2p-wlan0-0 |
DUT obtains an IP address and do ping test |
|
ping 192.168.43.1 -c 10 |