How to connect 2 different WIFI direct  Group Owner (GO)

How to connect 2 different WIFI direct Group Owner (GO)

Problem statement: Design a dedicated and scalable content-centric routing for data transfers among Android Smatphones.

Here I will discuss how I solve the problem by using Android default Wi-Fi direct (P2P) support.

Wi-Fi direct(p2p) Technology

Wi-Fi Direct is a recent protocol standardized by the WiFi Alliance, intending to enable Device to Device (D2D) communications between nodes, referred to as peers. Communication among peers in Wi-Fi Direct occurs within a single group. One peer in the group acts as Group Owner (GO) and the other devices, called clients, associate with it. In order to establish wireless connections between devices, Wi-Fi Direct specifies the so-called P2P Discovery, which consists of three procedures: Device Discovery, Group Formation, and Service Discovery.

The GO periodically transmits a beacon to advertise the group so as to enable disconnected devices to discover and, possibly, join the group. Each client is either a P2P client or a legacy client. P2P clients and legacy clients coexist seamlessly in the same group. It is important to note that Wi-Fi Direct has been designed to support D2D communications within a group, however, its protocol does not prevent communication between different groups.

Among the android dev portal ref P2P client forms through wifip2pgroup formation and Legacy client forms through wifip2pservice discovery.

Existing pitfall

In Android devices, once a Wi-Fi Direct connection is established, the GO automatically runs the DHCP to assign IP addresses to itself (192.168.49.1/24) as well as to the P2P clients or legacy clients in its own group (192.168.49.x/24 where x is a random number ∈ [2, 254] to minimize the chance of address conflicts). So, two neighbors' GOs cannot communicate directly, because of the IP address conflict. Consider the case with 2 GO named GO1 and GO2.

  • Any pair of devices (GO, P2P clients, and legacy clients) can exchange data at the IP layer.
  • Now let's say GO2 is a legacy client of GO1. When GO2 wishes to transmit an IP packet to GO1, the destination is set to 192.168.49.1 and the packet is thus sent to its local loop and not to the Wi-Fi interface.
  • Also, when GO1 sends an IP packet to GO2, GO2 discards it since its IP layer detects that the packet source address matches its own (192.168.49.1).
  • So, neither bidirectional unicast data transfer between GO and its clients nor direct data transfer between GOs is allowed.
Casetti's solution

I found the research paper Data Connectivity and Smart Group Formation in Wi-Fi Direct Multi-group Networks where they make a solution with inter Group communication.

In Wi-Fi Direct, the communication between a P2P client and a legacy client that is also the GO of a different group is allowed in both directions.

To send data from GO1 to its neighboring group (GO2), they leverage a P2P client of GO1 to relay the traffic toward GO2 as Legacy Client.





Mike Dawson

I engineer open-source technology to enable teaching, learning, and sharing : online or offline | CEO and Co-Founder at Ustad Mobile

1y

As Riccardo mentioned: one way around this problem is to use the IPv6 link local address. I was able to use this in our mesh network library : https://github.com/UstadMobile/Meshrabiya . We have built socket factories that can then take care of routing multihop traffic, which allows using OKHTTP etc over the mesh. The other work around is that on Android 12+ some devices support concurrent Access Point and Station mode. This allows you to use Local Only Hotspot, which uses a randomized IP address range, so it is very unlikely that two neighbor nodes will have an IP conflict.

Like
Reply

this is our similar implementation, we use ipv6 to resolve the ip address problem https://github.com/giangiu25307/Connection

To view or add a comment, sign in

Insights from the community

Others also viewed

Explore topics