Wifi direct wpa supplicant

wpa_supplicant wifi-direct connection between Linux and Android

I’m trying to make wifi-direct connection between Android and Linux. I’m using rtl8188au. I found some tips about wifi direct by using wpa_supplicant, so I get wpa_supplicant v2.0. and this is what I did for wifi-direct.

1.Compiled rtl8288au driver, activated nl80211. 2.Compiled wpa_supplicant and wpa_cli for nl80211. 3.Run wpa_supplicant on linux, with option -Dnl80211. success. 4.Set ip address for wlan0. 5.Run wpa_cli, and try to connect to android device. 

The connection can made success at once, but disconnected soon. Here is wpa_cli logs. wpa_cli -p /var/run/wpa_supplicant

> p2p_find OK P2P-DEVICE-FOUND e6:fa:ed:8a:5e:e8 p2p_dev_addr=e6:fa:ed:8a:5e:e8 pri_dev_type=10-0050F204-5 name='[Phone] Kulong' config_methods=0x188 dev_capab=0x25 group_capab=0x0 > > > p2p_connect e6:fa:ed:8a:5e:e8 pbc OK P2P-FIND-STOPPED P2P-DEVICE-FOUND e6:fa:ed:8a:5e:e8 p2p_dev_addr=e6:fa:ed:8a:5e:e8 pri_dev_type=10-0050F204-5 name='[Phone] Kulong' config_methods=0x80 dev_capab=0x25 group_capab=0x8 P2P-GO-NEG-SUCCESS CTRL-EVENT-STATE-CHANGE state=3 BSSID=00:00:00:00:00:00 SSID= CTRL-EVENT-CONNECTED - Connection to 38:1d:d9:d4:db:70 completed (auth) [id=0 id_str=] CTRL-EVENT-STATE-CHANGE state=9 BSSID=38:1d:d9:d4:db:70 SSID=DIRECT-4J CTRL-EVENT-EAP-STARTED e6:fa:ed:8a:de:e8 CTRL-EVENT-EAP-PROPOSED-METHOD vendor=0 method=1 CTRL-EVENT-EAP-PROPOSED-METHOD vendor=14122 method=254 WPS-REG-SUCCESS e6:fa:ed:8a:de:e8 2d96823c-8a30-5dd0-a267-e3adae8b1564 P2P-GROUP-FORMATION-SUCCESS P2P-GROUP-STARTED wlan0 GO ssid="DIRECT-4J" freq=2412 passphrase="xZbKV6sF" go_dev_addr=38:1d:d9:d4:db:70 WPS-SUCCESS CTRL-EVENT-EAP-FAILURE e6:fa:ed:8a:de:e8 AP-STA-CONNECTED e6:fa:ed:8a:de:e8 p2p_dev_addr=e6:fa:ed:8a:5e:e8 AP-STA-DISCONNECTED e6:fa:ed:8a:de:e8 p2p_dev_addr=e6:fa:ed:8a:5e:e8 P2P-DEVICE-LOST p2p_dev_addr=e6:fa:ed:8a:5e:e8 

Источник

How to set up a Wifi-Direct connection between Android and Linux

I want to connect two devices using Wifi-Direct. One is a pc with Linux (during my test I’m using Linux Mint 17.2), the other is an Android smartphone (Samsung Galaxy S3 with Android 4.3. Not rooted and don’t want to root). Reading a number of guides on the internet, I decided to use wpa_supplicant in Linux and to create an app for Android. This is one of the best guides I found for wpa_supplicant: https://web.archive.org/web/20210114180304/https://processors.wiki.ti.com/index.php/OMAP_Wireless_Connectivity_NLCP_WiFi_Direct_Configuration_Scripts When I run iw list I see that the «Supported interface modes:» allows P2P_client and P2P_GO. My wpa_supplicant.conf contains:

ctrl_interface=/var/run/wpa_supplicant update_config=1 ap_scan=1 device_name=My-pc device_type=1-0050F204-1 driver_param=use_p2p_group_interface=1 p2p_go_intent=15 p2p_go_ht40=1 

The app is very similar to this example (it’s from a book) https://github.com/retomeier/Wrox-ProfessionalAndroid-4E/blob/9741a8b62005d49519b1decfea21e7213fdd94a3/Snippets_ch18/app/src/main/java/com/professionalandroid/apps/myapplication/WiFiDirectActivity.java It works as expected. When I try it with two Android devices, they can see each other and connect (it appear the Wifi-Direct icon). Now I am trying to connect Android and Linux, but I guess I don’t really understand how wpa_supplicant works. I also saw this question that is very similar to what I asked, but it doesn’t really answer my doubts. Direct Wifi Communication between android smartphone and other devices My problem is that I can’t understand how to do the handshake between the two devices and how to set up the network. Wpa_supplicant is my problem. I run:

sudo wpa_supplicant -wlan0 -Dnl80211 -c/etc/wpa_supplicant.conf sudo wpa_cli 
  • The device_name (and other parameters) weren’t set as I specifiend in the .conf file
  • wpa_supplicant continues to try to connect to all the networks
  • p2p_find was really slow.
Читайте также:  Линукс точка доступа wifi

so I went into /usr/share/dbus-1/system-services and moved away the two files

fi.epitest.hostap.WPASupplicant.service fi.w1.wpa_supplicant1.service 
sudo killall wpa_supplicant 

and it really dies, disconnecting me from Wifi without reconnecting the following second. Now I can launch wpa_supplicant and the three problems are resolved.

I go into wpa_cli, launch «p2p_find» and at the same time, I enable the search from within the app.

Android and Linux can now see each other.

P2P-DEVICE-FOUND 00:11:22:44:88:ff p2p_dev_addr=00:11:22:44:88:ff pri_dev_type=10-0050F204-5 name='GT-I9300' config_methods=0x188 dev_capab=0x24 group_capab=0x0 vendor_elems=1 new=0 

With «p2p_peers» I can see the cellphone MAC.

Here I can’t go ahead. I tried various possibilities, but none of them worked. My objective is to have Linux as Group Owner.

  • Question 1.1: Which is the correct way to handshake the two devices?
  • Question 1.2: When I try p2p_connect I often get «Michael MIC failure detected» between the results, what does it means in this contest?
  • Question 1.3: Android currently tries to connect with PBC. There is a way to connect with PIN?

Seeing that I couldn’t connect Android/Linux, I tried to do some practice with Linux/Linux (Linux Mint as GO, Ubuntu as Client), following examples from internet like the ones in the first link. I have a number of problems even here.

p2p_connect MAC_UBUNTU pin auth 
p2p_connect MAC_MINT PIN_GENERATED_BY_MINT 

When I write the psp_connect in Mint, it creates a new interface p2p_wlan0 _0, and it returns

P2P-DEVICE-LOST p2p_dev_addr=MAC_UBUNTU 

then the p2p_connect launched from Ubuntu fails.

  • Question 2.1 Why it switches interface when creating the group?
  • Question 2.2 What is the correct way to handle this change? After the change I can’t p2p_find Ubuntu anymore (I have to wait some time or restart everything)
  • Question 2.3 Should Ubuntu change it’s interface?
  • Question 2.3 In the new interface I should set the IP for both Ubuntu and Mint. how should I do this with static IPs?
  • Question 2.4 If I want to set up for example a DHCP server and client?
  • Question 1.4 And with Android(client) / Linux(GO)?
Читайте также:  Microsoft wi fi direct virtual adapter 2 ошибка 10

Источник

WiFi Direct in Linux

In WiFi, device to device communication is already possible with original IEEE 802.11 standard with ad-hoc mode, but this never became popular because of its lack of efficient power saving support or extended QoS capabilities. WiFi direct is built upon the successful IEEE 802.11 infrastructure mode and it lets devices to negotiate roles and decide which device plays the AP like functionality and which will take the client role. WiFi Direct support is available in Android from version 4.0. Here is an article which explains Wi-Fi Direct protocol in detail and to know more about roles in wifi direct and connection establishment methods, this article is a must read.

Rest of the post gives a brief introduction to roles and connection establishment procedure in p2p and also documents wpa_supplicant DBus APIs to help development of WiFi Direct applications in Linux.

Note: P2P i.e., peer to peer means a direct connection between two devices for data exchange with out any access point. P2P is a usage name to WiFi Direct.

Usually devices that provide the services act as P2P GO and device that scans and initiate the connection procedure are P2P client devices. Unlike 802.11 infrastructure mode, roles in WiFi direct are dynamic and decided by negotiation. Service discovery is a L2 protocol in WiFi Direct. A device can find the services provided by the other device without establishing a connection. Below are the high level procedural steps involved in p2p association and connection establishment procedure:

  1. Device discovery
  2. Role negotiation
  3. Service discovery
  4. security provisioning
  5. Power saving
Читайте также:  P5k e wifi ap характеристики

P2P using wpa_supplicant:

DBus bus name of wpa_supplicant is fi.w1.wpa_supplicant. Below are wpa_supplicant DBus interfaces for using P2P with wpa_supplicant.

  • fi.w1.wpa_supplicant1:
    • Method
      • GetInterface: returns object path of interface that wpa_supplicant already controls.
      • Debug level:
      • This interface is implemented by objects that represent p2p peer device
      • All the P2P operations can be performed using this interface.
      • Methods:
        • AddService: Method to add a service.
        • AddPersistentGroup: Method.
        • Properties
          • Members: ao – contains all the object paths that are part of this p2p group. This property only shows up on GO devices.
          • Role: “s” – Role of this device in this group. possible values “GO” or “client”
          • SSID: “ay” – SSID of this group
          • BSSID: “ay” – P2P group BSSID
          • Frequency: “q” – The frequency (in MHz) of the group operating channel.
          • Passphrase: “s” – Passphrase used in the group. This is always available on the GO.
          • WPSVendorExtensions: “aay” – WPS vendor extension attributes used on the GO. This is valid only the in the GO role. An empty array is returned in P2P Client role. At maximum, 10 separate vendor extension byte arrays can be configured. The GO device will include the configured attributes in WPS exchanges.
          • PeerJoined: “o” – A peer device has joined the group. This is indicated only on the GO device. The object_path received in this signal is of peer device. Peer is represented by fi.w1.wpa_supplicant1.Peer interface.
          • PeerRemoved: “o” – A peer device has left the group. This is indicated only on the GO device.

          Источник

Оцените статью
Adblock
detector