Parsing WiFi Packets (libpcap) Parsing WiFi Packets (libpcap) c c

Parsing WiFi Packets (libpcap)


A Google search for "802.11 frame format" provides some promising links I believe. Here's a high-level overview that lays out the packet: http://www.technologyuk.net/telecommunications/networks/wireless_networks.shtml.


If you are using pylibpcap, then you can grab the RSSI this way. This is crude and makes assumptions about the flags in the 802.11 frame (ie the flags must be 0x0000482F), but it worked for me. This is a python hack and I didn't want to go down the route of installing extra modules (dpkt and scapy have features to do this, but not well documented) when the hack is just one call to struct.unpack.

(len,data,timestamp) = p.get_next()if data[0:8] =='\x00\x00\x22\x00\x2F\x48\x00\x00' and len(data) >= 50:  type_subtype = ord(data[34])  dest_mac     = data[38:38+6]  src_mac      = data[44:44+6]  rssi,        = struct.unpack("b",data[22])

If your flags aren't as above, then look at radiotap-parser.c in the OP's question, and figure out how to calculate the offset to the RSSI field (22 in this example). Each flag bit changes the offset by 1,2,4 or 8 bytes.


I know this post is old but I came across it trying to do wifi parsing with no luck so Im hoping I might be able to help someone else!

There is a relatively new library but Its amazing for all levels of the stack. Its called libTins and will parse out packets at every layer of the stack for you. Its BSD licensed (as of 2015) and is super easy to do sniffing. Its built on top of lib pcap but will accept byte arrays if you want to do the sniffing yourself.