Android 上 Wifi 感知和 Wifi P2P 之间的区别?

Difference between Wifi aware and Wifi P2P on Android?

WiFi 感知和 WiFi P2P 技术之间的主要区别是什么?

使用 WiFi P2P,您可以在两个或多个附近的设备之间建立连接,而无需公共网络。但是 android 文档规范还指出

Wi-Fi Aware capabilities enable devices running Android 8.0 (API level 26) and higher to discover and connect directly to each other without any other type of connectivity between them.

它们有什么区别?

根据 Android 文档,使用 Wi-Fi Aware,您可以在服务发现阶段设备之间发送数据(仅限轻量级!最多 255 字节) 并且在需要时,您可以打开设备之间的连接以发送更大的数据。使用 Wi-Fi 点对点,您必须先执行某种身份验证,然后打开一个套接字,然后才能在设备之间发送数据。

以下是 Wi-Fi aware overview 中我获得这些信息的部分:

The Wi-Fi Aware APIs let apps perform the following operations:

  • Discover other devices: [...] After the subscriber discovers a publisher, the subscriber can either send a short message or establish a network connection with the discovered device.
  • Create a network connection: After two devices have discovered each other [...] they can create a bi-directional Wi-Fi Aware network connection without an access point.

Note: Messages are generally used for lightweight messaging, as they might not be delivered (or be delivered out-of-order or more than once) and are limited to about 255 bytes in length.

此外,借助 Wi-Fi Aware,开发人员可以在 DiscoverySession class 的方法 createNetworkSpecifierOpen()createNetworkSpecifierPassphrase() 之间进行选择,以打开未加密或加密的连接,分别在设备之间。

对于 Wi-Fi 点对点,开发人员除了 WifiP2PManager.connect() 方法外别无选择。调用它会在正在连接的设备上触发一个对话框(按钮配置),并且该对话框只会在两个设备首次相互连接时出现。

顺便说一句...修改WifiP2pConfigWpsInfo是没有用的;它将始终使用按钮配置选项。我在我拥有的设备(Asus ZC520TL-Nougat、Asus ZE551ML-Marshmallow、Huawei Y5-Marshmallow 和 Huawei T1-KitKat)上对其进行了测试。即使 wifip2pconfig.wps.setup 不等于 WpsInfo.PBC,也会出现 PBC 对话框。如果不是所有设备都如此,请随时纠正我,因为它可能只是 OEM 问题。

有关详细信息,请访问 Wi-Fi peer-to-peer overview

WiFi Aware 建立连接的速度明显加快。

发现阶段更加灵活:您可以将自己的信息(255 字节)添加到您的服务公告中,并与其他点交换短消息(255 字节),而无需建立连接。

但是,WiFi Aware 中的所有连接都是一对一的。一个设备只能有非常有限的同时连接数(对于 Pixel 2 来说是两个)。

相比之下,WiFi P2P 的工作方式更类似于一个自动热点:设备之间协商哪些设备将创建一个 WiFi 网络,然后其他设备可以加入。如果您设法获得 WiFi SSID/password, 可以手动加入网络。

我的理解是WiFi P2P在电池方面的性能较差(至少在中心节点的情况下)。

来自https://www.wi-fi.org/knowledge-center/faq/what-is-the-relationship-between-wi-fi-aware-and-wi-fi-direct

Wi-Fi Aware 是一种与 Wi-Fi Direct 类似的 peer-to-peer 连接技术。然而,虽然 Wi-Fi Direct 需要一个集中的协调器,称为组所有者,但 Wi-Fi Aware 创建分散的动态 peer-to-peer 连接。许多应用程序,例如 Miracast 和直接打印机连接,都可以与 Wi-Fi Direct 配合使用。 Wi-Fi Aware 的定位是在高度移动的环境中提供 peer-to-peer 连接,在这种环境中,设备以不太确定的方式加入或离开。无论是专业人士在拥挤的会议中寻找彼此,还是地铁上的陌生人临时加入 multi-player 游戏,Wi-Fi Aware connections 可以无缝适应不断变化的环境和使用条件。