P2P Discovery enables two devices to find each other quickly and form a P2P Group. P2P group discovery procedure consists of the following components.
- P2P Device Discovery: Two P2P Devices will find each other, once they arrive in a common channel. P2P Device Discovery happens in channels 1,6,11 as per the Specification.
- Service Discovery: This is an optional mechanism used in the discovery procedure. This service discovery mechanism will make use of GAS frame exchanges. Devices will exchange ANQP request/ ANQP response in the service discovery. We will see the ANQP frame exchanges mostly in HS2.0 protocol.
- Group Formation: Devices will form a P2P Group, one device will become a GO and there will be mostly one GC or multiple GCs connected to the GO. And there are multiple Group formation methods used as per the Specification. They are
- Negotiation Method (standard method) [ GO or GC will be decided based on Intent values]
- Autonomous Method (One Device declares as a GO)
- Persistent Method (Invoking previously connected devices, we can invoke the group from either GO or GC)
- P2P Invitation: We will use the P2P invitation frame exchange to invoke a persistent P2P group or to invite a P2P device to join the group. In Persistent Method there will be less frames exchanging during the group formation hand shake to reduce the time it takes to form a group, but it the devices should be connected earlier to invoke the persistent group.
P2P Device Discovery Procedures
Basic Mechanism : P2P Devices use active scanning method to discover each other , devices use probe request and probe response frames to discover each other. Once the Group is formed GO will transmit the Beacon , so that the discovery may happen through the beacon as well.
P2P device shall not respond to probe request unless it is:
- P2P Group Owner
- Listen State
P2P device shall not transmit a beacon unless it is a P2P GO.
Observe the below to check how the discovery procedure happens
Scan phase: The Scan Phase uses the scanning process defined in IEEE Std 802.11-2012 . It may be used by a P2P Device to find P2P Devices or P2P Groups and to locate the best potential Operating Channel to establish a P2P Group. In the Scan Phase, devices collect information about surrounding devices or networks by scanning all supported channels. The P2P Device in the Scan Phase shall not reply to Probe Request frames.
Listen State : A P2P Device that is not in a P2P Group may use the Listen State to become discoverable. In the Listen State a P2P Device dwells on a given channel, termed the Listen Channel. This is a channel chosen from the list of Social Channels. Channels 1, 6, and 11 in the 2.4 GHz band shall be used as the Social Channels.
The Listen Channel shall be chosen at the beginning of the Device Discovery and shall remain the same until P2P Discovery completes.
A P2P Device in the Listen State shall only reply to Probe Request frames that contain the P2P IE, the P2P Wildcard SSID element, a Wildcard BSSID, and a Destination Address that is either the broadcast address or its P2P Device Address.
Check the P2P probe request wild card SSID from the below capture.
Check the listen channel in the below capture.
Observe that each device will select a random number in between 1 to 3 to select how long they stay in the listen state. If any device selects the number 1 then that device stays on the listen channel for 100TU. And the device selects the number as 3 , then the device stays on the listen channel for 3*100TU. They select the randomness to avoid the case where p2p devices will never discover each other.
P2P device should be available in a Listen state for at least 500ms for every 5Sec to get discovered
In the above Figure 1 : Discovery Procedure observe that device1 selected random number as 1, and device2 selected random as 3 to listen in the listen state.
Search State: In the search state devices will be searching for the P2P devices and the devices will be sending the probe request to discover the other devices, in the above Figure 1 : Discovery Procedure observe that device1 in the search state sent the probe request to the device2 in channel 6, and the device2 in the listen state at channel 6 has replied with the probe response frame. So the device discovery has happened when both the devices arrive on a common channel.
Once the devices are discovered then we see the device as FOUND. See the below supplicant logs when the devices is discovered, “p2p_find” is used to discover the devices, we can trigger the command in the device if we have the access to the wlan supplicant interactive shell.
> p2p_find OK <2>P2P-DEVICE-FOUND 02:f0:bc:44:87:62 p2p_dev_addr=02:f0:bc:44:87:62
Devices will be alternatively changing their states from listen and search to discover the devices.
Observe the P2P Probe request and response frames in the below captures.
P2P Probe Request frame
P2P Probe Response frame
In the next post, we will learn about the service discovery in the P2P protocol.