安装必要软件:
iwwpa-supplicant
查看无线网卡是否支持WIFI Direct
$ sudo iw list
GREP查看, 如果有以下的模式:
?* IBSS
?* managed
?* monitor
?* AP
?* P2P-GO
?* P2P-Client
如果看到 P2P-GO(Group Owner) 和 P2P-Client,
你的无线网卡是支持 Wi-Fi Direct 的了.
$ sudo wpa_cli
一些P2P 的终端命令
1.p2p_find
2.p2p_stop_find
3.p2p_connect
4.p2p_invite
5.p2p_group_add
6.p2p_remove_group
7.terminate
8.status
Wi-Fi Direct 的连接方法:
1.PBC – Push Button Control method
2.PIN – Secret PIN number method
3.Invite – Invitation Method
1.PBC – Push Button Control method
2.PIN – Secret PIN number method
3.Invite – Invitation Method
wpa_supplicant.conf – P2P 方面的配置:
ctrl_interface=/var/run/wpa_supplicant
# For Android Terminals un-comment below line & comment above Line
#ctrl_interface=DIR=/data/system/wpa_supplicant GROUP=wifi
ap_scan=1
device_name=Terminal-1
device_type=1-0050F204-1
driver_param=use_p2p_group_interface=1
# If you need to modify the group owner intent, 0-15, the higher
# number indicates preference to become the GO. You can also set
# this on p2p_connect commands.
#p2p_go_intent=15
# optional, can be useful for monitoring, forces
# wpa_supplicant to use only channel 1 rather than
# 1, 6 and 11:
#p2p_listen_reg_class=81
#p2p_listen_channel=1
#p2p_oper_reg_class=81
#p2p_oper_channel=1
Terminal-1: (一号终端机, 可能是一个LINUX PC,或 一个 ANDROID 设备)
$ sudo vi /etc/wpa_supplicant-t1.conf
ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
device_name=Terminal-1
device_type=1-0050F204-1
driver_param=use_p2p_group_interface=1
Terminal-2: (二号终端机, 可能是一个LINUX PC,或 一个 ANDROID 设备)
$ sudo vi /etc/wpa_supplicant-t2.conf
ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
device_name=Terminal-2
device_type=1-0050F204-1
driver_param=use_p2p_group_interface=1
Terminal-1: run wpa_supplicant as daemon
sudo ./wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant-t1.conf -Bd
Terminal-2: run wpa_supplicant as daemon
$ sudo ./wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant-t2.conf -Bd
Terminal-1: wpa_cli – client
$ sudo ./wpa_cli -i wlan0
Terminal-2: wpa_cli – client
$ sudo ./wpa_cli -i wlan0
Wi-Fi Direct 的连接PBC Method方法
Terminal-1:
> p2p_find
Terminal-2:
>p2p_find
>p2p_peers
<Terminal-1 Mac Address>
Terminal-1:
> p2p_peers
<Terminal-2 MAC Address>
Terminal-2:
> p2p_find
> p2p_peers
<Terminal-1 MAC Address>
Terminal-1:
> p2p_connect pbc auth go_intent=7 freq=2412 #channel-1
?Here GO_INTENT value is very important. Because it decides P2P-GO negotiation.
?Who is having higher GO_INTENT will be come P2P-GO, the lowest one will become P2P-Client.
?GO_INTENT values ranges from 0 to 15
?You can choose any channel by changing the frequency to 2.4GHz/5GHz bands..
?Who is having higher GO_INTENT will be come P2P-GO, the lowest one will become P2P-Client.
?GO_INTENT values ranges from 0 to 15
?You can choose any channel by changing the frequency to 2.4GHz/5GHz bands..
Terminal-2:
> p2p_connect <Terminal-1 MAC Address> pbc freq=2412 go_intent=7
> status # This will print the connection status
?Here tie-breaker bit will be set, since the GO_INTENT values are same. Either Terminal-1 or Terminal-2 will become P2P-GO(SoftAP), other terminal will act as P2P-Client.
?New P2P interface will be created, you can check using ifconfig. i.e. p2p-wlan0
?New P2P interface will be created, you can check using ifconfig. i.e. p2p-wlan0
Terminal-1:
$ sudo ifconfig p2p-wlan0 192.168.2.1 up #P2P-GO
$ sudo iw dev wlan0
$ sudo iw dev p2p-wlan0
Terminal-2:
$ sudo ifconfig p2p-wlan0 192.168.2.2 up #P2P-Client
$ sudo iw dev wlan0
$ sudo iw dev p2p-wlan0 link #p2p-wlan0 will keep changing.
Ping Test
Terminal-1:
$ ping 192.168.2.2
Terminal-2:
$ ping 192.168.2.1
本文转载至:http://blog.csdn.net/myxmu/article/details/12249751
本文描述了用iperf测试wifi direct的传输速度的方法。
1.推送iperf文件到待测试的两个手机
adb remount
adb push iperf /system/bin
adb shell
cd /system/bin/
chmod 777 iperf
2.两手机进行wifi direct连接
首先,对所有已保存的ap进行取消保存的操作。
然后wifi direct连接。
3.获取手机的ip地址
adb shellifconfig p2p0
4.在一个手机上启iperf的server
cd /system/bin/iperf -s
5.在另一个手机上启iperf的client端
cd /system/bin/iperf -c [另一手机的ip地址] -i 3 -t 180
这样就可以了。
-i 3表示每隔3s报告一次传输速度。
-t 180 表示总共处理180s。