Networking

wpa_supplicant/WiFi Direct:wpa_cli 命令 p2p_find 返回 FAIL

  • June 1, 2017

我正在嘗試在我的 Arch linux 機器上執行 WiFi Direct 以連接到 Android 智能手機。但是,當嘗試查找 WiFi Direct 對等方時,FAIL返回的消息沒有其他錯誤消息。我怎樣才能找出問題所在?

根據wpa_supplicant 的 P2P README這篇博文,我從 git 編譯了 wpa_supplicant(repo git://w1.fi/srv/git/hostap.git、commit 2d18ab40826ecaec26bfd82d42dcb08f2715e362、master 截至 2017 年 5 月 31 日,建構配置見下文)。

我開始wpa_supplicant並習慣wpa_cli發出命令p2p_find,但是,這會返回消息,在輸出、輸出或系統日誌 ( )中FAIL都沒有其他資訊wpa_cli``wpa_supplicant``journalctl -f

如何wpa_supplicant顯示有用的錯誤消息?


建構和執行wpa_supplicant

git clone git://w1.fi/srv/git/hostap.git
cd hostapd/wpa_supplicant
cp defconf .config
# Edit .config to uncomment:
#  * CONFIG_AP=y
#  * CONFIG_P2P=y
#  * CONFIG_wps=y
#  * (CONFIG_DRIVER_NL80211=y) enabled by default
#  * (CONFIG_CTRL_IFACE=y)     enabled by default
# 
#  * CONFIG_LIBNL32=y (Arch Linux uses libnl 3.2)
# 
make

# Run wpa_supplicant. See below for config files
sudo ./wpa_supplicant -c/etc/wpa_supplicant/p2p.conf -iwlan0 -dd -Dnl80211

wpa_supplicant 點對點配置

/etc/wpa_supplicant/p2p.conf:

ctrl_interface=DIR=/var/run/wpa_supplicant 
update_config=1
device_name=My Arch Machine
device_type=1-0050F204-1
driver_param=use_p2p_group_interface=1

日誌文件

wpa_cli會話(使用者輸入之後>

> wpa_cli
wpa_cli v2.6
[...]
Selected interface 'wlan0'

Interactive mode

> p2p_find
FAIL

wpa_supplicant標準輸出。p2p_find從內部呼叫的點wpa_cli標有# < ------ p2p_find ------ >

/etc/wpa_supplicant/p2p.conf' driver 'nl80211' ctrl_interface 'N/A' bridge 'N/A'
Configuration file '/etc/wpa_supplicant/p2p.conf' -> '/etc/wpa_supplicant/p2p.conf'
Reading configuration file '/etc/wpa_supplicant/p2p.conf'
ctrl_interface='DIR=/var/run/wpa_supplicant'
update_config=1
device_name='My Arch Machine'
driver_param='use_p2p_group_interface=1'
nl80211: Supported cipher 00-0f-ac:1
nl80211: Supported cipher 00-0f-ac:5
nl80211: Supported cipher 00-0f-ac:2
nl80211: Supported cipher 00-0f-ac:4
nl80211: Supported cipher 00-0f-ac:10
nl80211: Supported cipher 00-0f-ac:8
nl80211: Supported cipher 00-0f-ac:9
nl80211: Using driver-based off-channel TX
nl80211: Driver-advertised extended capabilities (default) - hexdump(len=8): 00 00 00 00 00 00 00 40
nl80211: Driver-advertised extended capabilities mask (default) - hexdump(len=8): 00 00 00 00 00 00 00 40
nl80211: interface wlan0 in phy phy0
nl80211: Set mode ifindex 3 iftype 2 (STATION)
nl80211: Subscribe to mgmt frames with non-AP handle 0xa6c350
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xa6c350 match=040a
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xa6c350 match=040b
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xa6c350 match=040c
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xa6c350 match=040d
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xa6c350 match=090a
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xa6c350 match=090b
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xa6c350 match=090c
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xa6c350 match=090d
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xa6c350 match=0409506f9a09
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xa6c350 match=7f506f9a09
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xa6c350 match=06
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xa6c350 match=0a07
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xa6c350 match=0a11
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xa6c350 match=1101
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xa6c350 match=1102
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xa6c350 match=0505
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xa6c350 match=0500
rfkill: initial event: idx=1 type=1 op=0 soft=0 hard=0
netlink: Operstate: ifindex=3 linkmode=1 (userspace-control), operstate=5 (IF_OPER_DORMANT)
nl80211: driver param='use_p2p_group_interface=1'
nl80211: Use separate P2P group interface
Add interface wlan0 to a new radio phy0
nl80211: Regulatory information - country=00
nl80211: 2402-2472 @ 40 MHz 20 mBm
nl80211: 2457-2482 @ 20 MHz 20 mBm (no IR)
nl80211: 2474-2494 @ 20 MHz 20 mBm (no OFDM) (no IR)
nl80211: 5170-5250 @ 80 MHz 20 mBm (no IR)
nl80211: 5250-5330 @ 80 MHz 20 mBm (DFS) (no IR)
nl80211: 5490-5730 @ 160 MHz 20 mBm (DFS) (no IR)
nl80211: 5735-5835 @ 80 MHz 20 mBm (no IR)
nl80211: 57240-63720 @ 2160 MHz 0 mBm
nl80211: Added 802.11b mode based on 802.11g information
wlan0: Own MAC address: 00:26:82:b0:3a:0a
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=0 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=1 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=2 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=3 set_tx=0 seq_len=0 key_len=0
wlan0: RSN: flushing PMKID list in the driver
nl80211: Flush PMKIDs
wlan0: State: DISCONNECTED -> INACTIVE
wlan0: WPS: UUID based on MAC address: cfafece3-a583-5946-bcde-95bd75350713
ENGINE: Loading dynamic engine
ENGINE: Loading dynamic engine
EAPOL: SUPP_PAE entering state DISCONNECTED
EAPOL: Supplicant port status: Unauthorized
nl80211: Skip set_supp_port(unauthorized) while not associated
EAPOL: KEY_RX entering state NO_KEY_RECEIVE
EAPOL: SUPP_BE entering state INITIALIZE
EAP: EAP entering state DISABLED
wlan0: Added interface wlan0
wlan0: State: INACTIVE -> DISCONNECTED
nl80211: Set wlan0 operstate 0->0 (DORMANT)
netlink: Operstate: ifindex=3 linkmode=-1 (no change), operstate=5 (IF_OPER_DORMANT)
random: Got 20/20 bytes from /dev/random
RTM_NEWLINK: ifi_index=3 ifname=wlan0 operstate=2 linkmode=0 ifi_family=0 ifi_flags=0x1003 ([UP])
RTM_NEWLINK: ifi_index=3 ifname=wlan0 operstate=2 linkmode=1 ifi_family=0 ifi_flags=0x1003 ([UP])
EAPOL: disable timer tick
CTRL_IFACE monitor attached /tmp/wpa_ctrl_14358-125\x00
CTRL-DEBUG: ctrl_sock-sendto: sock=12 sndbuf=212992 outq=0 send_len=3
# < ------ p2p_find ------ >
wlan0: Control interface command 'P2P_FIND'
CTRL-DEBUG: ctrl_sock-sendto: sock=12 sndbuf=212992 outq=0 send_len=5
^Cwlan0: Removing interface wlan0
wlan0: Request to deauthenticate - bssid=00:00:00:00:00:00 pending_bssid=00:00:00:00:00:00 reason=3 state=DISCONNECTED
wlan0: State: DISCONNECTED -> DISCONNECTED
nl80211: Set wlan0 operstate 0->0 (DORMANT)
netlink: Operstate: ifindex=3 linkmode=-1 (no change), operstate=5 (IF_OPER_DORMANT)
EAPOL: External notification - portEnabled=0
EAPOL: External notification - portValid=0
wlan0: WPA: Clear old PMK and PTK
wlan0: Cancelling scan request
wlan0: Cancelling authentication timeout
Off-channel: Clear pending Action frame TX (pending_action_tx=(nil)
Remove interface wlan0 from radio phy0
Remove radio phy0
nl80211: deinit ifname=wlan0 disabled_11b_rates=0
nl80211: Remove monitor interface: refcount=0
netlink: Operstate: ifindex=3 linkmode=0 (kernel-control), operstate=6 (IF_OPER_UP)
nl80211: Set mode ifindex 3 iftype 2 (STATION)
nl80211: Unsubscribe mgmt frames handle 0x88888888882e4bd9 (mode change)
wlan0: CTRL-EVENT-TERMINATING 
CTRL-DEBUG: ctrl_sock-sendmsg: sock=12 sndbuf=212992 outq=0 send_len=23
CTRL_IFACE monitor sent successfully to /tmp/wpa_ctrl_14358-125\x00
CTRL_IFACE wait for attached monitors to receive messages

journalctl -f:

Mai 31 09:40:17 arch sudo[31534]: user : TTY=pts/3 ; PWD=/home/user/Computer/Network/wifi-direct/hostap/wpa_supplicant ; USER=root ; COMMAND=./wpa_supplicant -c/etc/wpa_supplicant/p2p.conf -iwlan0 -dd -Dnl80211
Mai 31 09:40:17 arch sudo[31534]: pam_unix(sudo:session): session opened for user root by user(uid=0)
Mai 31 09:40:17 arch kernel: brcmsmac bcma0:1: brcms_ops_bss_info_changed: qos enabled: false (implement)
Mai 31 09:40:17 arch kernel: brcmsmac bcma0:1: brcms_ops_config: change power-save mode: false (implement)
Mai 31 09:40:17 arch kernel: IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
# < ------ p2p_find ------ >
Mai 31 09:40:35 arch sudo[31534]: pam_unix(sudo:session): session closed for user root

系統資訊

uname -a
## Linux arch 4.11.2-1-ARCH #1 SMP PREEMPT Mon May 22 06:53:49 CEST 2017 x86_64 GNU/Linux

lspci -k
## 05:00.0 Network controller: Broadcom Limited BCM43225 802.11b/g/n (rev 01)
##         Subsystem: Broadcom Limited Device 04da
##         Kernel driver in use: bcma-pci-bridge
##         Kernel modules: bcma

WLAN 卡功能

**iw list**輸出:能力P2P-clientP2P-GO並且P2P-device 在那裡。

Wiphy phy0
   max # scan SSIDs: 4
   max scan IEs length: 2257 bytes
   max # sched scan SSIDs: 0
   max # match sets: 0
   max # scan plans: 1
   max scan plan interval: -1
   max scan plan iterations: 0
   Retry short limit: 7
   Retry long limit: 4
   Coverage class: 0 (up to 0m)
   Device supports RSN-IBSS.
   Supported Ciphers:
           * WEP40 (00-0f-ac:1)
           * WEP104 (00-0f-ac:5)
           * TKIP (00-0f-ac:2)
           * CCMP-128 (00-0f-ac:4)
           * CCMP-256 (00-0f-ac:10)
           * GCMP-128 (00-0f-ac:8)
           * GCMP-256 (00-0f-ac:9)
   Available Antennas: TX 0 RX 0
   Supported interface modes:
            * IBSS
            * managed
            * AP
            * AP/VLAN
            * monitor
   Band 1:
           Capabilities: 0x7c
                   HT20
                   SM Power Save disabled
                   RX Greenfield
                   RX HT20 SGI
                   RX HT40 SGI
                   No RX STBC
                   Max AMSDU length: 3839 bytes
                   No DSSS/CCK HT40
           Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
           Minimum RX AMPDU time spacing: 8 usec (0x06)
           HT Max RX data rate: 500 Mbps
           HT TX/RX MCS rate indexes supported: 0-15
           Bitrates (non-HT):
                   * 1.0 Mbps
                   * 2.0 Mbps (short preamble supported)
                   * 5.5 Mbps (short preamble supported)
                   * 11.0 Mbps (short preamble supported)
                   * 6.0 Mbps
                   * 9.0 Mbps
                   * 12.0 Mbps
                   * 18.0 Mbps
                   * 24.0 Mbps
                   * 36.0 Mbps
                   * 48.0 Mbps
                   * 54.0 Mbps
           Frequencies:
                   * 2412 MHz [1] (19.0 dBm)
                   * 2417 MHz [2] (19.0 dBm)
                   * 2422 MHz [3] (19.0 dBm)
                   * 2427 MHz [4] (19.0 dBm)
                   * 2432 MHz [5] (19.0 dBm)
                   * 2437 MHz [6] (19.0 dBm)
                   * 2442 MHz [7] (19.0 dBm)
                   * 2447 MHz [8] (19.0 dBm)
                   * 2452 MHz [9] (19.0 dBm)
                   * 2457 MHz [10] (19.0 dBm)
                   * 2462 MHz [11] (19.0 dBm)
                   * 2467 MHz [12] (19.0 dBm)
                   * 2472 MHz [13] (19.0 dBm)
                   * 2484 MHz [14] (disabled)
   Supported commands:
            * new_interface
            * set_interface
            * new_key
            * start_ap
            * new_station
            * new_mpath
            * set_mesh_config
            * set_bss
            * authenticate
            * associate
            * deauthenticate
            * disassociate
            * join_ibss
            * join_mesh
            * set_tx_bitrate_mask
            * frame
            * frame_wait_cancel
            * set_wiphy_netns
            * set_channel
            * set_wds_peer
            * probe_client
            * set_noack_map
            * register_beacons
            * start_p2p_device
            * set_mcast_rate
            * connect
            * disconnect
            * set_qos_map
            * Unknown command (121)
   Supported TX frame types:
            * IBSS: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
            * managed: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
            * AP: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
            * AP/VLAN: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
            * mesh point: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
            * P2P-client: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
            * P2P-GO: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
            * P2P-device: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
   Supported RX frame types:
            * IBSS: 0x40 0xb0 0xc0 0xd0
            * managed: 0x40 0xd0
            * AP: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
            * AP/VLAN: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
            * mesh point: 0xb0 0xc0 0xd0
            * P2P-client: 0x40 0xd0
            * P2P-GO: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
            * P2P-device: 0x40 0xd0
   software interface modes (can always be added):
            * AP/VLAN
            * monitor
   interface combinations are not supported
   HT Capability overrides:
            * MCS: ff ff ff ff ff ff ff ff ff ff
            * maximum A-MSDU length
            * supported channel width
            * short GI for 40 MHz
            * max A-MPDU length exponent
            * min MPDU start spacing
   Device supports TX status socket option.
   Device supports HT-IBSS.
   Device supports SAE with AUTHENTICATE command
   Device supports low priority scan.
   Device supports scan flush.
   Device supports AP scan.
   Device supports per-vif TX power setting
   Driver supports full state transitions for AP/GO clients
   Driver supports a userspace MPM
   Device supports configuring vdev MAC-addr on create.

iw list輸出:開源驅動程序brcmfmac不支持 P2P 模式。

支持的模式:

Supported interface modes:
        * IBSS
        * managed
        * AP
        * AP/VLAN
        * monitor

P2P 支持unknownwikidev上標記為

Supported modes

STA (Station) mode: supported
IBSS (Ad-Hoc) mode: supported
AP (Master) mode: unsupported
Mesh (802.11s) mode: unsupported
P2P mode: unknown
Monitor mode: supported
Packet injection: unknown

引用自:https://unix.stackexchange.com/questions/368260