Wednesday, 18 December 2013

WiFi Direct

Wi-Fi Direct builds upon the successful IEEE802.11 infrastructure mode and lets devices negotiate who will take over the AP-like functionalities. Thus, legacy Wi-Fi devices may seamlessly connect to Wi-Fi Direct devices . By taking this decision, Wi-Fi Direct immediately inherits all the enhanced QoS, power saving, and security mechanisms.

Here's a quick guide on setting up WPS.
http://kb.linksys.com/Linksys/GetArticle.aspx?docid=e48d3bae2e7442feb53b412234d3d41f_17336.xml

In a typical Wi-Fi network, clients discover and associate to WLANs, which are created and announced by Access Points (APs). In this way, a device unambiguously behaves either as an AP or as a client, each of these roles involving a different set of functionality. A major novelty of Wi-Fi Direct is that these roles are specified as dynamic, and hence a Wi-Fi Direct device has to implement both the role of a client and the role of an AP.

The device implementing AP-like functionality in the P2P Group is referred to as the P2P Group Owner (P2P GO), and devices acting as clients are known as P2P Clients.Legacy clients can also communicate with the P2P GO, as long as they are not 802.11b-only devices and support the required security mechanisms.

For example, consider a laptop accessing the Internet through a legacy infrastructure AP while at the same time streaming content to a TV set by establishing a P2P Group, where the laptop acts as P2P GO.


If the P2P GO leaves the P2P Group then the group is torn down, and has to be re-established using some of the specified procedures.


 Wi-Fi Direct devices usually start by performing a traditional Wi-Fi scan (active or passive), by means of which they can discover existent P2P Groups3 and Wi-Fi networks.

After this scan, a new Discovery algorithm is executed, which we describe next. First, a P2P Device selects one of the so-called Social channels, namely channels 1, 6 or 11 in the 2.4 Ghz band, as its Listen channel.

Then, it alternates between two states: a search state, in which the device performs active scanning by sending Probe Requests in each of the social channels; and a listen state, in which the device listens for Probe Requests
in its listen channel to respond with Probe Responses. The amount of time that a P2P Device spends on each state is randomly distributed, typically between 100 ms and 300 ms.

EAP based setup based on external registrar

Station willing to connect to AP, sends out a probe request with WPS IE, request type set to enrollee.

AP sends a Wi-Fi Simple Configuration probe response to the Registrar with
Response Type set to AP.


After this M1 to M8 exchange occurs. Enrollee (the station) may decide to associate to a WSC-enabled AP and initiate the registration protocol by sending message M1 to the Registrar; assuming that
the Registrar is not yet prepared to enroll the candidate enrollee it will respond with message M2D.

M2D – this message indicates that the Registrar is unable to authenticate with the Enrollee, but it is willing to provide descriptive information about the Registrar to the Enrollee.

Phase 1:
1. The Enrollee sends its Discovery message using an 802.11 probe request. The
Discovery message is broadcast by the AP to all external Registrars.
2. The AP responds to the probe request with its own Discovery data.
3. The Enrollee connects to the AP and initiates 802.1X.
4. The Enrollee‟s M1 message is proxied to all External Registrars as UPnP events.
Each active Registrar (Internal Registrar, if enabled, and all the External
Registrars that have subscribed to receive UPnP events from the AP) should
send M2 or M2D.
5. The two external Registrars send M2D messages to the AP. The AP queues
these up for delivery to the Enrollee.
6.The AP sequentially delivers the M2D messages to the Enrollee, which responds
with ACK messages to each one. After the last M2D has been delivered without
a WSC_MSG response, the AP sends EAP-Failure to terminate the 802.1X
connection.


Phase 2:
1. Enter PIN in ER.
2. Registrar notifies the AP when it becomes active by setting the Selected Registrar attribute to TRUE
3. After the AP receives a SetSelectedRegistrar UPnP action with Selected Registrar TRUE, AP incorporates Selected Registrar flag set to TRUE in its Beacons and Probe Responses
4. Enrollee reconnects and restarts the 802.1X authentication. This time, Registrar sends an M2 message rather than an M2D message.
5. The Enrollee and Registrar engage in the complete Registration Protocol until the
Enrollee is provisioned with its Credential.

Monday, 16 December 2013

Out-of-Band setup

In out-of-band methods there is a transfer of information by a channel other than the Wi-Fi channel itself.

  1. Near-Field-Communication Method, in which the user simply has to bring the new client close to the access point to allow a near field communication between the devices. NFC Forum compliant RFID tags can also be used. Support of this mode is optional.
  2. USB Method, in which the user uses a USB flash drive to transfer data between the new client device and the access point of the network. Support of this mode is optional, but deprecated.

The USB method has been deprecated and is not part of the Alliance's certification testing.

Thursday, 7 November 2013

Hostapd - user space daemon for AP and authentication server

To make hotspot on a laptop, Check if iwlist to check if it has AP capability as shown below.


Download hostpad source code from http://hostap.epitest.fi/hostapd/. Read http://wireless.kernel.org/en/users/Documentation/hostapd for further details.
root@ramapriya:/home/ramapriya/hostapd-2.4/hostapd#cp defconfig .config
root@ramapriya:/home/ramapriya/hostapd-2.4/hostapd#make
You get two binaries after successful make: hostapd and hostapd_cli.

Once set up is ready, change hostapd.conf file in hostapd folder.
A sample configuration is given below:


interface=wlan0
ctrl_interface=/var/run/hostapd
ssid=Shim_te_ccmp
hw_mode=g
wpa_passphrase=123456789012
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
ht_capab=[SHORT-GI-20][TX-STBC][HT40-][RX-STBC1]
channel=1
rts_threshold=2346
fragm_threshold=2346
beacon_int=100
wpa=2
ieee80211n=1
wmm_enabled=1
wpa_group_rekey=0
wps_state=1

2. Start hostapd.
./hostapd  hostapd.conf

3. Start the AP using the configuration in hostapd.conf file.
./hostapd_cli

Possible errors:
fatal error: netlink/genl/genl.h: No such file or directory
Solution:
sudo apt-get install libnl-dev



Thursday, 12 September 2013

Useful links

http://www.wildpackets.com/resources/compendium/wireless_lan/802_11n
http://www.my80211.com/home/2009/12/5/80211-null-data-frames.html
http://www.digitalthreat.net/2012/01/bypassing-wps-router-security/
4way handshake:
http://etutorials.org/Networking/802.11+security.+wi-fi+protected+access+and+802.11i/Part+II+The+Design+of+Wi-Fi+Security/Chapter+10.+WPA+and+RSN+Key+Hierarchy/Details+of+Key+Derivation+for+WPA/

Aggregation:
https://en.wikipedia.org/wiki/Frame_aggregation
Block ACK:
http://wiki.deliberant.com/faq/autoba-auto-block-ack/

EAP-PEAP:
https://supportforums.cisco.com/blog/154046
802.11e:
http://www.eetimes.com/document.asp?doc_id=1271987
802.11r:
http://www.codealias.info/technotes/the_ieee_802.11r_standard_for_fast_wireless_handoffs
http://www.cisco.com/c/en/us/support/docs/wireless-mobility/wireless-lan-wlan/116493-technote-technology-00.html

Legacy power save:
http://processors.wiki.ti.com/index.php/OMAP_Wireless_Connectivity_Power_Save

For beginners in C:
http://www.thegeekstuff.com/2010/03/debug-c-program-using-gdb/
(note: info args to know the arguments passed to the function and 
     info locals to print local variables (in the current stack frame)
http://www.geeksforgeeks.org/memory-layout-of-c-program/

Linux
Download kernel source code:
http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.3.3-wily/

Compiling kernel module:
http://www.thegeekstuff.com/2013/06/compile-linux-kernel/

followed by update-grub

To invoke a utility or shell script with a particular priority
http://en.wikipedia.org/wiki/Nice_(Unix)

Useful utilities:
gnome-system-monitor
gnome-www-browser

http://cciew.blogspot.in/2011/02/short-slot-time.html

Beamforming:
http://ruwanindikaprasanna.blogspot.in/2016/01/is-my-80211ac-wifi-ap-beamforming.html

Spatial multiplexing:
https://wifijedi.com/2009/02/01/how-stuff-works-spatial-multiplexing/

Certified Wireless Analysis Professional notes:
http://mrncciew.com/2014/10/04/my-cwap-study-notes/

Linux network drivers:
http://linuxgazette.net/156/jangir.html

Kernel crash:
http://www.dedoimedo.com/computers/crash-analyze.html#mozTocId782257
http://blog.csdn.net/u011839461/article/details/12001437

Spin lock internals- Very nice article:
http://www.linuxinternals.org/blog/2014/05/07/spinlock-implementation-in-linux-kernel/

Tasklets:
https://www.ibm.com/developerworks/library/l-tasklets/

DMA
https://www.kernel.org/doc/Documentation/DMA-API-HOWTO.txt

Cryptography
http://crypto.stackexchange.com/questions/27131/differences-between-the-terms-pre-master-secret-master-secret-private-key

Setting ASUS as AP:
http://askubuntu.com/questions/404881/how-do-i-install-an-asus-usb-ac56-wifi-adapter
http://w1.fi/hostapd/
http://freeradius.org/download.html
SIM800 user manual
https://cdn-shop.adafruit.com/product-files/2637/SIM800+Series_AT+Command+Manual_V1.09.pdf


Code composer studio setup:
http://software-dl.ti.com/ccs/esd/CCSv7/CCS_7_1_0/exports/ccs_setup_7.1.0.00014.exe
[‎3/‎3/‎2017 2:26 PM] Janaki Vallabha Eranna:
http://software-dl.ti.com/ccs/esd/CCSv7/CCS_7_1_0/exports/ccs_setup_7.1.0.00014.exe

How to send SMS from ADB
http://stackoverflow.com/questions/4043490/how-do-i-send-an-sms-from-a-shell

To build web demo for sensortag
-------------------------------------
http://processors.wiki.ti.com/index.php/Contiki_setting_up_sw

Main page:
----------
http://processors.wiki.ti.com/index.php/Contiki-6LOWPAN

Download and setup contiki
--------------------------
http://www.contiki-os.org/start.html

Setup tool chain
-----------------
http://processors.wiki.ti.com/index.php/Contiki_setting_up_sw

Setting up edge router
----------------------
http://processors.wiki.ti.com/index.php/Cc26xx_sw_examples

Source code:
------------
https://github.com/contiki-os/contiki

sniffer:
--------
http://processors.wiki.ti.com/index.php/Contiki_sniffer

6lowpan coding documentation
----------------------------
https://github.com/contiki-os/contiki/blob/master/doc/sicslowpan-doc.txt


/home/user/Documents/src/contiki-master/examples/cc26xx

Thursday, 8 August 2013

U-APSD

Unscheduled Automatic Power Save Delivery (U-APSD)

The uplink data frames sent by stations (STA → AP) are used as indications (triggers) to AP that the power saving stations are awake. Here is a nice article on NULL frame which is being sent from STA to AP to inform that it is planning to switch to power save mode: http://www.my80211.com/home/2009/12/5/80211-null-data-frames.html.

AP then sends the buffered data frames (buffered when the stations where in doze mode).

In APSD a station is awake during a Service Period (SP). An unscheduled SP begins when the AP receives a trigger frame from a station and ends when the station receives a QoS Data or QoS Null frame indicating the end of the service period (EOSP).

QOS Info Field when sent from AP(beacon)


AP needs inform to stations whether it supports the 

  1.  U-APSD(UN-scheduled) or 
  2. Scheduled power save mode 
by setting and resetting U-APSD flag bit in QoS info field. If U-APSD bit is 1, then it supports U-APSD and if U-APSD =0 then it does not supports U-APSD



QOS Info Field when sent from STA ((re)association request frame)



Max SP length (2 bit field) indicates max number of total buffered MSDUs and MMPDUs the WMM AP may deliver to WMM STA during the service period triggered by WMM STA.

  Max SP length

Setting 0 in AC (BE, BK, VI and VO) indicate that the corresponding AC is neither trigger-enabled nor delivery-enabled.

 TIM in the Beacon might not indicate whether frames are buffered at the AP, it requires to periodically send QoS Null frames if no other triggers are sent in order to learn the actual buffer status of the AP.


If U-APSD is configured through ADDTSs each time a new application starts which requires its usage, then the stations can rely on the TIM information of the Beacons to be informed about new traffic at the AP, enter into U-APSD mode through ADDTS when a communication starts and revert back to legacy
power save mode when it ends.

Wednesday, 7 August 2013

rfkill

Some devices come with a hard switch that lets you kill different types of RF radios: 802.11 / Bluetooth. Some times these buttons may kill more than one RF type. The Linux kernel rfkill subsystem exposes these hardware buttons and lets userspace query its status and set its status through a /dev/rfkill.

 To get the current rfkill status, use rfkill list:


Note that an index (3) is assigned  for wireless LAN interface.
To turn off the interface, use the command rfkill block <index> and to turn on the interface again, use rfkill unblock <index>



Monday, 5 August 2013

Part 3: P2P Group Owner Negotiation


Once the two P2P Devices have found each other, they start the Group Owner(GO) Negotiation phase. This is implemented using a three-way handshake, namely GO negotiation.Request/Response/Confirmation,  whereby the two devices agree on which device will act as P2P GO and on the channel where the group will operate, which can be in the 2.4 Ghz or 5 Ghz bands.

In order to agree on the device that will act as P2P GO, P2P devices send a numerical parameter, the GO Intent value, within the three-way hand-shake, and the device declaring the highest value becomes the P2P GO. To prevent conflicts when two devices declare the same GO Intent, a tie-breaker bit is included in the GO Negotiation Request, which is randomly set every time a GO Negotiation Request is sent.


P2P GO Negotiation Request from device 1:



If operating channel is not available, it will use another channel from the Channel List.Configuration time is Time needed by the device to get configured an function as a GO in units of 10 milliseconds.

 WPS IE in GO negotiation request:

GO negotiation response from device 2:



WPS IE in GO negotiation response:

                

When using PIN based WSC, the selected PIN (from the display of either the
P2P Client or P2P Group Owner) is indicated using Device Password ID
attribute. For example for devices using pushbutton authentication,


A P2P Device may decline Group Owner Negotiation if the Device Password ID
in the GO Negotiation Response is incompatible with the Provisioning
information it shall use to execute Provisioning.

P2P GO Negotiation confirmation from device 1:


Group Owner determination is depicted below.


Once the devices have discovered each other and agreed on the respective roles, the next phase is the establishment of a secure communication using Wi-Fi Protected Setup.

Friday, 26 July 2013

QoS packets

WiFi MultiMedia (WMM)

Wireless Multimedia Extensions (WME), also known as Wi-Fi Multimedia (WMM), is a Wi-Fi Allianceinteroperability certification, based on the IEEE 802.11e standard. WMM not only prioritize traffic on the basis of the type of traffic (voice, video, best effort data, or background data) , but also taking into account network load and channel conditions.

With WMM-Admission Control, the access point (AP) in a Wi-Fi network admits only the traffic streams it can support based on the available network resources.  Users can confidently use voice applications knowing the quality of traffic stream will be consistently high and will provide the reliability needed to host real-time applications in Wi-Fi networks.

 When the network resources are not sufficient to provide this level of performance, the new traffic stream is not admitted, allowing the client device to seek association with an alternative AP that has sufficient network resources to support the traffic stream, and preserving the quality of already admitted traffic streams.


WMM replaces the traditional Wi-Fi DCF distributed coordination function for traditional CSMA/CA wireless frame transmission with EDCF.

QoS:

QoS modifies the media access rule such that Data having a higher priority is given preferential access to the medium. EDCA contention access is an extension of the legacy CSMA/CA DCF mechanism to include priorities. 

The contention window and backoff times are adjusted to change the probability of gaining medium access to favor higher priority classes. A total of eight user priority levels are available. Each priority is mapped to an Access Category (AC), which corresponds to one of four transmit queue.



A station that wins an EDCA contention is granted a TXOP—the right to use the medium for a period of time. The duration of this TXOP is specified per access category, and is contained in the TXOP limit field of the access category (AC) parameter record in the EDCA parameter set(e.g. in beacon frame as shown below). A QoS STA can use a TXOP to transmit multiple frames within an access category.

WMM/WME IE in beacon




 AC parameters format:

AP advertises ACM bit in Beacon to indicate if admission control
is mandatory for any Access Category.

Case 1: ACM bit not set



AC Index (ACI)is chosen as per the following table.

The AIFSN (arbitration interframe space number) subfield indicates the number of slots after a SIFS duration a non-AP STA should defer before either invoking a backoff or starting a transmission. The minimum value for the AIFSN subfield is 2.



ECWmin/ ECWmax is the minimum/maximum value of contention window which is expressed in exponent.
As in 802.11-2007 spec, table 7.37, CWmin = (aCWmin+1)/4 – 1 and CWmax = (aCWmin+1)/2 – 1

aCWMin is PHY dependent. For example, for OFDM PHY, aCWmin = 15.
So, CWmin = 3 and CWmax = 7.
ECWmin = 2
ECWmax = 3

The Queue Size subfield is an 8-bit field that indicates the amount of buffered traffic for a given TC or TS at the non-AP STA sending this frame.

TXOP grants a particular STA the right to use the medium at a defined point in time, for a defined maximum duration. The allowed duration of TXOPs are communicated globally in the beacon for stations using EDCA.Non-AP STAs should make sure that TXOPs should not exceed TXOP limit. 

Case 2: ACM bit is set

When ACM bit is set, STA sends ADDTS Request Action Frame to AP that includes a TSPEC. Before a client can send traffic of a certain priority type, it must have requested to do so via the TSpec mechanism. For example, a WLAN client device wanting to use the voice AC must first make a request for use of that AC.

Add Traffic Stream

The Add Traffic Stream (ADDTS) function is how a WLAN client performs an admissions request to an AP.

Association and re-association message


The association message might contain one or more TSpecs and one TSRS IE if the STA wants to establish the traffic stream as part of the association. The re-association message might contain one or more TSPECs and one TSRS IE if an STA roams to another AP. 


The ADDTS contains the TSpec element that describes the traffic request. See figure 1 and figure 2 for examples of an ADDTS request and response. Apart from key data describing the traffic requirements, such as data rates and frame sizes, the TSpec element also tells the AP the minimum physical rate that the client device will use. This allows the calculation of how much time that station can potentially consume in sending and receiving in this TSpec, and therefore allowing the AP to calculate whether it has the resources to meet the TSpec. 

TSpec admission control is used by the WLAN client (target clients are VoIP handsets) when a call is initiated and during a roam request. During a roam, the TSpec request is appended to the re-association request. 

Note that action code is 0 for ADDTS request.


                                             figure-1

Action code is 1 for ADDTS response. Status code 0 specifies that admission is accepted.



                                            figure -2



Following is the sample data packets for voice(with UP = 7) and best effort (UP = 0).

Data frame (voice):




Thursday, 25 July 2013

Part 2: P2P states

Run wpa_supplicant and wpa_cli in STA1 in another terminal.Similarly run wpa_supplicant and wpa_cli in STA2 also. (please refer to this link )

To discover other P2P devices, use p2p_find command.


Now, state machine enters scan and find phase. (find phase alternates between listen and search state.)




Scan phase

In scan phase all supported channels are scanned. It can either be an active scan or a passive scan. It sends probe requests in channel 1 to 11 or listens to beacon from channel 1 to 11.

video

Find phase:

1. Listen state

A P2P device that is not in a P2P group may use listen state to become discoverable.

  • In listen state P2P device dwells on listen channel (configured in p2p.conf => p2p_listen_channel=1 to configure listen channel as 1) for at least a contiguous period of 500ms every 5 seconds.
  •  Listens for probe requests and shall only respond to probe requests that contain P2P IE.
  • If probe request contains WPS IE with device type attribute, it  shall only respond if device type is same as it's primary and secondary device type.
Duration of each listen state shall be a random number 'T' such that,
Max discoverable Interval value > T > Min discoverable Interval value

Following is a P2P IE in probe request frame:


Group Limit field is 0 indicates that additional P2P connections are supported.
1 indicates that no further connections are allowed.

WPS IE in the same probe request:


2. Search State:

Alternates between channels 1,6 and 11. Sends probe request in one channel and listens for probe response from the same channel.

Find state is a combination of listen and search states.






Supported rates

Supported Rates Element

This element is included in the following frames sent from AP.
  1. Beacon
  2. Probe Response
  3. Association Response
  4. Reassociation Response 
AP mandates that stations joining the BSS support certain rates.  The rates required by the AP are called basic rates. In other words, basic rate contains the rates that all devices in the cell must support.  All management frames, multicast, and broadcast packets are  transmitted using one of the Basic Rates.

The Supported Rates element specifies up to eight rates. The information field is encoded as 1 to 8 octets, where each octet describes a single Supported Rate.



    IEEE 802.11 specification provides mapping value for each data rate. For example,

    value for few of the rates: 
    02 = 1 Mb/s
       03 = 1.5 Mb/s
    04 = 2 Mb/s
       05 = 2.5 Mb/s
     06 = 3 Mb/s
        09 = 4.5 Mb/s
       11 = 5.5 Mb/s
                                Figure 1: BSSBasicRateSet parameter encoding

    For the basic rate an encoding is used, which sets bit 7 to 1. Following is a part of beacon frame. As per figure 1, value for 1 Mb/s is 02 (0000 0010) . Notice the hex value highlighted in the following packet. it is 82 (1000 0010) for 1 Mb/s.




    This is applicable only for the basic rates (rates marked with (B)). You can notice that the other values after 11(B) which is 0x96 begin with 0.Remaining values are supported rates. (Support for these rates is not required to join a BSS, but a station may choose to transmit at any supported rate that the receiving station supports.)

    Extended Supported Rates element


    For STAs supporting eight or fewer data rates, this element is optional for
    inclusion. For STAs supporting more than eight data rates, this element shall
    be included in all of the frame types that include the supported rates element.

    The information field is encoded as 1 to 255 octets where each octet describes a single supported rate.


    From beacon frame:



     

    Wednesday, 24 July 2013

    Part 1: P2P aka WiFi Direct - Introduction and Configuration of wpa_supplicant in Linux kernel version 3.8.3

    What is P2P?

    P2P alias Wi-Fi Direct builds upon the successful IEEE802.11 infrastructure mode and lets devices negotiate who will take over the AP-like functionalities. Thus, legacy Wi-Fi devices may seamlessly connect to Wi-Fi Direct devices . By taking this decision, Wi-Fi Direct immediately inherits all the enhanced QoS, power saving, and security mechanisms.


    In a typical Wi-Fi network, clients discover and associate to WLANs, which are created and announced by Access Points (APs). In this way, a device unambiguously behaves either as an AP or as a client, each of these roles involving a different set of functionality. A major novelty of Wi-Fi Direct is that these roles are specified as dynamic, and hence a Wi-Fi Direct device has to implement both the role of a client and the role of an AP.


    The device implementing AP-like functionality in the P2P Group is referred to as the P2P Group Owner (P2P GO), and devices acting as clients are known as P2P
    Clients.Legacy clients can also communicate with the P2P GO, as long as they are not 802.11b-only devices and support the required security mechanisms.

    For example, consider a laptop accessing the Internet through a legacy infrastructure AP while at the same time streaming content to a TV set by establishing a P2P Group, where the laptop acts as P2P GO.If the P2P GO leaves the P2P Group then the group is torn down, and has to be re-established using some of the specified procedures.

    Wi-Fi Direct devices usually start by performing a traditional Wi-Fi scan (active or passive), by means of which they can discover existent P2P Groups and Wi-Fi networks.

    After this scan, a new Discovery algorithm is executed, which we describe next. First, a P2P Device selects one of the so-called Social channels, namely channels 1, 6 or 11 in the 2.4 Ghz band, as its Listen channel.

    Then, it alternates between two states: a search state, in which the device performs active scanning by sending Probe Requests in each of the social channels; and a listen state, in which the device listens for Probe Requests in its listen channel to respond with Probe Responses. The amount of time that a P2P Device spends on each state is randomly distributed, typically between 100 ms and 300 ms.


    How to know if your device supports p2p? Use iw list command in terminal and look for the following field. If it contains p2p-client and p2p-GO, you can be assured that your device supports P2P.



    Just like a client and server model, you need to run supplicant and p2p client.
    Supplicant is a daemon running in the user space to provide authentication.

    mac80211 and cfg80211 does not implement WPA feature. So you need a seperate program which provides supplicant functionality in Linux which is
    wpa_supplicant.Install latest release of wpa_supplicant from http://hostap.epitest.fi/releases

    I downloaded: wpa_supplicant-2.0.tar.gz


    First thing you need to do is to create the .config file in the folder wpa_supplicant-2.0/wpa_supplicant from defconfig file.


    Enable following options in defconfig file (uncommenting is removing # in defconfig file)

    
    
    CONFIG_CTRL_IFACE=y
    CONFIG_DRIVER_NL80211=y 
    CONFIG_WPS=y
    CONFIG_WPS2=y
    CONFIG_P2P=y
    CONFIG_AP=y
    
    
    Give cp defconfig .config command and then make command in wpa_supplicant 
    folder. Now there are two binaries created wpa_supplicant and wpa_cli. In order to run wpa_supplicant we need a config file. Traditionally it is created in /etc folder. Here is a sample config file for p2p. (/etc/p2p.conf)
    ctrl_interface=/var/run/wpa_supplicant
    update_config=1
    device_name=PRIYA-P2P
    device_type=2-0050F204-1
    p2p_listen_reg_class=81
    p2p_listen_channel=1
    p2p_oper_reg_class=81
    p2p_oper_channel=1
    p2p_go_intent=1
    p2p_no_group_iface=1



    Find out the wireless interface using iwconfig command and then give the following command in wpa_supplicant

    ./wpa_supplicant -i wlan2 -c /etc/p2p.conf -Dnl80211

    You will see a msg "Successfully initialized wpa_supplicant" which means that supplicant has started running.In another window run the wpa client using ./wpa_cli

    This opens an interactive mode in which commands can be given.
    Interactive mode
    >


    (Tip: Use killall wpa_supplicant if you get error message like: 

    ctrl_iface exists and seems to be in use - cannot override it Delete '/var/run/wpa_supplicant/wlan2' manually if it is not used anymore Failed to initialize control interface '/var/run/wpa_supplicant'. You may have another wpa_supplicant process already running or the file was left by an unclean termination of wpa_supplicant in which case you will need to manually remove this file before starting wpa_supplicant again.  )