Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is different of NSD and WifiP2pManager?

There are several choice for making a WiFi program in android, most common methods are using NSD and WifiP2pManager.

What is different between these 2 choice?

like image 411
hamedata Avatar asked Feb 17 '15 09:02

hamedata


People also ask

What is WifiP2pManager?

android.net.wifi.p2p.WifiP2pManager. This class provides the API for managing Wi-Fi peer-to-peer connectivity. This lets an application discover available peers, setup connection to peers and query for the list of peers.

What is Wi-Fi discovery?

Wi-Fi CERTIFIED Wi-Fi Aware™extends Wi-Fi® capability with quick discovery, connection, and data exchange with other Wi-Fi devices—without the need for a traditional network infrastructure, internet connection, or GPS signal.

What is LG P2P service?

What Is a Peer-to-Peer (P2P) Service? A peer-to-peer (P2P) service is a decentralized platform whereby two individuals interact directly with each other, without intermediation by a third party. Instead, the buyer and the seller transact directly with each other via the P2P service.

How does P2P WiFi work?

Wi-Fi Direct (also known as peer-to-peer or P2P) allows your application to quickly find and interact with nearby devices, at a range beyond the capabilities of Bluetooth. The Wi-Fi Direct (P2P) APIs allow applications to connect to nearby devices without needing to connect to a network or hotspot.


1 Answers

Firstly, these are not two entities to be differentiated. Even if you use Wi-Fi P2p for NSD, you should use WifiP2pManager for connection initiation and negotiation. NSD is to be used for Discovery phase

I assume your question to be difference between Using Wi-Fi P2p Service Discovery(NSD) and Not using it (using normal scan WifiP2pManager.discoverPeers() ).

The answer is explicitly provided here under three sub-topics. However

The difference is actually in the initial phase: The peer discovery phase

  • When you don't use the Wi-Fi P2p Service discovery, you scan for all devices that are active with WiFi direct. The scan result list may contain peers that are not of your interest. You can't help it, as you do not have a filter.
  • In the case where you need to discover only peers that are of your interest, then Wi-Fi P2p Service discovery should be used. Here, the filter condition is set in the name of Service.

    For ex: your app "XYZ" needs to form groups ONLY with other devices that also use the same app "XYZ", then you can create a service and name it, say service_xyz, and this service info will be broadcast along with the Wi-Fi Direct device details. On the receiver end, you implement a service listener that listens for the service "service_xyz". By doing so, only devices with the desired service name are discovered and listed. Useful for gaming apps, social networking apps.

However, after this phase, in both the methods, from the discovered list a particular device is selected and connect request is initiated. From here on, the following phases are the same - connection request, negotiation, group formation...

hope this helped you.

like image 126
Hariharan Gandhi Avatar answered Sep 19 '22 08:09

Hariharan Gandhi