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:

../../../_images/p2p_topology.svg

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.

../../../_images/p2p_concurrent_device.svg

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.

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