Tuesday, 24 April 2018

802.11w Protected Management Frames

Protected Management Frames is a feature to protect some types of management frames like
deauthorization, disassociation and action frames. This feature prevents attackers from sending
plain deauthorization/disassociation frames to disrupt or tear down a connection/association. PMF
is a Wi-Fi Alliance specification based on IEEE 802.11w

The AP is configured with SSID, encryption type, authentication type, and PMF capability bit in
the RSN IE capability field. Based on those settings, STAs associating with this AP will perform
PMF association and get unicast/broadcast/IGTK (Integrated Group Temporal Key) keys. IGTK is
used for broadcast, deauthorization, and disassociation frames.
Most of the PMF functionality is handled in hostapd. As part of PMF, new key management
algorithms (SHA-256 and SHA-256-PSK) are introduced.

hostapd is configured with PMF settings through the pmf.conf file. After successfully parsing
pmf.conf, hostapd sends config ioctls down to WLAN driver. The Linux shim processes the config
ioctls from hostapd and starts the AP with PMF settings in beacons. PMF STA associate with the
AP and both AP and STA derive necessary keys.
The key used for protecting unicast frames is used for protection of management frames as well.

Embedded

http://www.plantation-productions.com/Webster/www.artofasm.com/Linux/HTML/MemoryArchitecturea2.html

Direct cache mapping - One memory block can be mapped to only one of the cache block and it is possible that more than one memory block mapped to the same cache block. It is very inefficient because same cache mapped memory block will evict another memory block,
Not more than one same cache mapped memory block can be in cache memory.

2 way associative  - 2 cache lines(blocks) per set. One memory block is cached to any one set of the cache. Within that that set it can be mapped to any of the cache block.
2 memory blocks mapped to the same set, need not have to evict each other. They can exist in cache at the same time.

4 way associative - 4 cache lines(blocks) per set.


Programme Address Space:

Mainly

stack - Stores local variables of the functions, functional parameters and return pointer.
heap - dynamically allocated memory
bss - Uninitialised static and global variables, filled with zeroes
data - initialised static and global vaiables
text - programme code and initialised strings variable or constants

https://manybutfinite.com/post/anatomy-of-a-program-in-memory/


Questions:
1) 96 interuupts are available in the system. Storethe IRQ number in bit mask
2) Write programm to return highest available interrupt while allocating the interrupt.

Monday, 23 April 2018

Wifi Data TX path

Wifi TX for AP mode :

Linux stack passes ethernet packet.

1. xmit( netdev, skb) --- This is call back api of the wifi driver .
   - Linux stack calls this callback api to send packet through wifi driver
   - Extract the driver specific pointer from netdev.

2. Check that is skb has clones and remove any clones to it
    skb = skb_unshare(skb);

3. Check available header length, driver needs to add its header needed for host to target packet tradnfer
    skb_headroom()  --- return the available headroom
    skb = skb_realloc_headroom(skb, head_length_needed)
 

4. Check is the frame multicast packet
        - struct eth_head *eth = (struct eth_head *)skb->data;
          eth->destination[0] = 0x01 --- > it is multicast packet

5. It it is not multicast packet, find the STA node that is associated with dest mac address.
  -     AP maintains node table of all the connected STA devices.
  -     If STA node is not found, then dest mac address is unknown mac and packet is discarded, Who fress the SKB here ??

STA devices connect and disconnect at random interval of time, access to node table needs to be protected. In tx path, node table is accessed only for read the table. rw_lock can be used to protect it here.

Read_Write lock: It allows multiple readers at the same but only one writer. Example, if reader has taken the lock, another reader can also take the lock, second reader will not get blocked till first reader unlocks it. Both can access the critical section the same time.
 read_lock(rw_lock)  ;

If writer tries to take the lock and if there are no readers at the same time, it will get the lock. In case there are any readers holding the lock, writer has to wait till all reader unlock the lock.
Wait operation is similer to spin_lock().

write_lock(rw_lock);
   
6. Classify the packet
 - Different types of packet are sent over ehternet,
   - IPv4
   - IPv6
   - EAPOL
   - ARP

   From  the ethernet header extract the type.
   For IPV4 packet types need to extract the "Type of Service" DSCP value from IP headet of  the packet.
  - struct ipheader *iph = (uint8 *)skb->data + sizeof(ether_header);
     iph->tos  - is the tid of the packet.
 Each tid falls into to any one of the below ACs
 Access Catogaries - Back Ground ----- lowest priority
                                 Best Effort
                                  Video
                                  Voice --- highetst priority

  Each SKB has some space left for control buffer(cb portion) of 48 bytes. This space can be used by each layer to set status of the packet and to set flags that describe the packet.

Tid of the packet is set in cb portion of the skb



7. DHCP packet - Check UDP source port as 63 or 64

Extended Access Point: Provide connectivity to remote access Point