is p2p0 a wireless interface for WIFI DIRECT in an

2019-03-30 14:08发布

问题:

when i print all interfaces in my android device:

03-10 19:50:15.484: I/System.out(22415): lo
03-10 19:50:15.494: I/System.out(22415): upnlink0
03-10 19:50:15.504: I/System.out(22415): svnet0
03-10 19:50:15.504: I/System.out(22415): rmnet0
03-10 19:50:15.514: I/System.out(22415): rmnet1
03-10 19:50:15.524: I/System.out(22415): rmnet2
03-10 19:50:15.534: I/System.out(22415): sit0
03-10 19:50:15.544: I/System.out(22415): ip6tnl0
03-10 19:50:15.554: I/System.out(22415): p2p0
03-10 19:50:15.564: I/System.out(22415): wlan0

i wounder if p2p0 is the actual interface for WIFI DIRECT? also how to print just the currently used INTERFACES ??

回答1:

Yes, p2p0 is a kind of virtual interface to be used for Wi-Fi Direct. It is (or appears to be to me) mutually exclusively with using wlan0 to connect to an Access Point. In other words, it's using the same hardware as wlan0, so you can either be using wlan0 to connect to an AP or you can be using p2p0 for a peer-to-peer connection.

As to your other question, if you've got a terminal open on your phone or (more likely) you've got an adb (Android Debug Bridge) shell open, you can issue the following command to list the status of all your network interfaces which are UP (connected):

$ ip link | grep "state UP"