https://notepad.link/LU61E
Tuesday, 3 October 2023
Saturday, 23 September 2023
TE files
Files that end with *.te are SELinux policy source files, which define domains and their labels. You may need to create new policy files in /device/manufacturer/device-name/sepolicy, but you should try to update existing files where possible.
require Statement at the start of the list.
If SELinux policy rule does not exist to allow access, such as for a process opening a file, access is denied
We use “optional_policy” statement to declare a rule which could be invalid if an appropriate module (module containing a declaration of an interface) is disabled/removed or is not declared. Probably the following example is better than my definition.
optional_policy(`
corosync_exec(fenced_t)
‘)
Sunday, 23 July 2023
Sunday, 2 July 2023
ML Basics
- Calculus: Limits, continuity and differentiability. Maxima and minima. Mean value theorem. Integration.
- Linear Algebra: Matrices, determinants, system of linear equations, eigenvalues and eigenvectors, LU decomposition
- Probability: Random variables. Uniform, normal, exponential, Poisson and binomial distributions. Mean, median, mode and standard deviation. Conditional probability and Bayes theorem.
https://iisc.talentsprint.com/cds/main.html#curriculum
fit function trains the model, taking features (aka columns) and part of the data which is intended to be trained.
https://www.sharpsightlabs.com/blog/sklearn-fit/
“house price” is the column we’ve to predict so we take that column as y and the rest of the columns as our X variable. test_size = 0.05 specifies only 5% of the whole data is taken as our test set, and 95% as our train set.
https://www.geeksforgeeks.org/how-to-split-a-dataset-into-train-and-test-sets-using-python/
Friday, 27 February 2015
Nice to know
ping -b 255.255.255.255
AP will respond back.
WARNING: pinging broadcast address
PING 255.255.255.255 (255.255.255.255) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_req=2 ttl=255 time=0.402 ms
64 bytes from 192.168.1.1: icmp_req=3 ttl=255 time=0.444 ms
64 bytes from 192.168.1.1: icmp_req=4 ttl=255 time=0.382 ms
DHCP setup sequence in Cisco AP:
To open command line interface: telnet <AP's IP address> 9000
ap> en
password: (generally Cisco)
ap#conf t
ap(config)#service dhcp
ap(config)#ip dhcp pool meghna
ap(dhcp-config)#network 192.168.1.0 255.255.255.0
ap(dhcp-config)#lease infinite
How to unpatch a .patch file?
patch -p1 < hostapd_2.0_xxx.patch
modprobe wil6210 rx_ring_order=8
This can be verified in /sys/module/wil6210/parameters/rx_ring_order
4 way handshake:----------------
How to configure PTK and GTK rekeying? For 30 mins timeout, in WLC configure the “Enable Session Timeout” in 1800
(or)
In hostpad.conf,
wpa_group_rekey=600 (in seconds)
wpa_ptk_rekey=600
> show pmk-cache all shows lifetime of the timers.
while running hostapd, if you get the error : nl80211: Could not configure driver mode
sudo nmcli nm wifi off
sudo rfkill unblock wlan
Installing toolchain--------------------
Download tool chain
https://launchpad.net/gcc-arm-embedded/+download
Install:
cd /dir/in/which/tar/file/is/saved && tar xjf gcc-arm-none-eabi-*-yyyymmdd-mac.tar.bz2
which arm-none-eabi-gcc
should show something like:
/home/user/Desktop/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-gcc
Friday, 23 January 2015
P2P Provisioning
Purpose of provisioning is to get user credential (WPS PIN or PBC) for WPS procedure. P2P GO shall use the operating channel as indicated during GO negotiation.
When a P2P Device joins an existing P2P Group that it has not stored a credential for, it shall send a Provision Discovery Request frame with a single method set in the Config Methods attribute to indicate the desire to enroll in the network.
The Provision Discovery Request frame shall be sent to the P2P Device Address of the P2P Group Owner and on the operating channel of the P2P Group.
The P2P Group Owner may use this frame as a trigger that a device wants to enroll (maybe an indication can be shown to the user). A P2P Group Owner shall respond to a received Provision Discovery Request frame with a Provision Discovery Response frame.
Provision discovery request will have a single method set in the config methods attribute to indicate the desire to enroll in the network.
Provision discovery response MAY have same method as in provision discovery request to indicate SUCCESS or shall be NULL to indicate failure.
Group formation bit in the P2P capability bitmap of the P2P capability attribute shall be set to 1 until provisioning succeeds.
On successful completion of provisioning P2P Group Owner shall set group formation bit is set to 0.
Thursday, 22 January 2015
Opportunistic power save in P2P
P2P Power Management protocol defines an availability period, called the CTWindow(Client Traffic Window), during which a P2P Group Owner is present. P2P Clients are allowed to transmit during CTWindow period. If at the end of the CTWindow all associated P2P Clients are sleeping, the P2P
Group Owner is allowed to sleep until the next Beacon time. However, if any P2P Client stays in active mode at the end of the CTWindow the P2P Group Owner is forced to remain awake
until the next Beacon time.
The P2P Group Owner is responsible for selecting an appropriate value for
CTWindow. The CTWindow shall be an integral number of TU and shall always
be less than the beacon interval. For a P2P Group Owner that desires to be
discoverable, the CTWindow should be at least 10 TU. A CTWindow shall start
at each TBTT and extend for the chosen duration.
Opportunistic power save:
The P2P Group Owner shall indicate that Opportunistic Power Save is enabled by setting the OppPS bit to 1 in the CTWindow and OppPS Parameters field of the Notice of Absence attribute in beacon.
With OppPS set to 1:
If at the end of the CTWindow all associated P2P Clients are sleeping, the P2PGroup Owner is allowed to sleep until the next Beacon time. Here's a Null function set with
power management bit set to 1 to indicate that STA is going to sleep.
However, if any P2P Client stays in active mode at the end of the CTWindow the P2P Group Owner is forced to remain awake until the next Beacon time.
Wednesday, 18 December 2013
WiFi Direct
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
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
- 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.
- 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.
Thursday, 7 November 2013
Hostapd - user space daemon for AP and authentication server
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-devThursday, 12 September 2013
Useful links
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:
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
https://community.arubanetworks.com/t5/Technology-Blog/802-11-TIM-and-DTIM-Information-Elements/ba-p/256997
https://alethea.in/legacy-power-save-mode/
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/
Top half and Bottom halves:
---------------------------------
https://www.quora.com/What-is-the-advantage-of-new-request_threaded_irq-over-request_irq
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
https://support.ssl.com/Knowledgebase/Article/View/19/0/der-vs-crt-vs-cer-vs-pem-certificates-and-how-to-convert-them
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
How to send SMS from ADB
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
PCI BAR essentials
--------------------
https://docs.oracle.com/cd/E19455-01/805-7378/hwovr-28/index.html
https://github.com/billfarrow/pcimem
11AC resources
==========
STBC
------
http://www.radio-electronics.com/info/antennas/mimo/precoding-codes-alamouti-diversity-space-time.php
MIMO GI
----------
http://rfmw.em.keysight.com/wireless/helpfiles/89600b/webhelp/subsystems/wlan-mimo/Content/mimo_fmt_grdintparams.htm
Where is hard link used?
https://www.lifewire.com/what-are-hard-links-2190041
----------------
https://docs.aws.amazon.com/dlami/latest/devguide/tutorial-conda.html
Thursday, 8 August 2013
U-APSD
Unscheduled Automatic Power Save Delivery (U-APSD)
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)
- U-APSD(UN-scheduled) or
- Scheduled power save mode
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.
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
To get the current rfkill status, use rfkill list:
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:
GO negotiation response from device 2:
attribute. For example for devices using pushbutton authentication,
information it shall use to execute Provisioning.
P2P GO Negotiation confirmation from device 1:
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.
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:
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.
aCWMin is PHY dependent. For example, for OFDM PHY, aCWmin = 15.
So, CWmin = 3 and CWmax = 7.
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
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
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.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.
Max discoverable Interval value > T > Min discoverable Interval value
Following is a P2P IE in probe request frame:
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.- Beacon
- Probe Response
- Association Response
- Reassociation Response
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.
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
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:








































