wltrace.dot11 module¶
IEEE802.11 protocol definitions and utilities.
-
exception
wltrace.dot11.
Dot11Exception
[source]¶ Bases:
exceptions.Exception
-
class
wltrace.dot11.
Dot11Packet
(fh=None, phy=None, counter=1, *args, **kwargs)[source]¶ Bases:
wltrace.common.GenericHeader
IEEE802.11 packet.
This class parse as much as possible depending on the packet type and subtype.
Parameters: - fh (file object) – the file’s read pointer points to the beginning of a 802.11 packet.
- phy (
pyparser.capture.common.PhyInfo
) – PHY information. - counter (int) – packet index in trace file, starting from 1.
-
FIELDS
= ['fc', 'duration', 'addr1']¶
-
PACK_PATTERN
= '<HH6s'¶
-
crc_ok
¶
-
dest
¶ Shortcut to
pkt.addr1
.
-
end_epoch_ts
¶
-
end_ts
¶
-
epoch_ts
¶
-
hash
¶
-
src
¶ Shortcut to
pkt.addr2
.
-
ts
¶ Shortcut to
pkt.phy.timestamp
.
-
wltrace.dot11.
MAX_ACK_LATENCY_US
= 100¶ Maximum allowed gap between a packet and its ack in the packet trace.
-
wltrace.dot11.
is_ack
(pkt)[source]¶ Whether or not the packet is an ack packet.
Parameters: pkt ( wltrace.dot11.Dot11Packet
) – the packet.Returns: True
if it is an ack packet, otherwiseFalse
.Return type: bool
-
wltrace.dot11.
is_broadcast
(mac)[source]¶ Whether or not a mac is broadcast MAC address.
Parameters: mac (str) – MAC address in string format ( xx:xx:xx:xx:xx:xx
). Case insensitive.Returns: bool.
-
wltrace.dot11.
is_highest_rate
(rate)[source]¶ Whether or not the rate is the highest rate (single spatial stream) in rate table.
Parameters: rate (int) – rate in Mbps. Can be 802.11g/n rate. Returns: True
if the rate is highest, otherwiseFalse
. Note that ifrate
is not valid, this function returnsFalse
, instead of raising an exception.Return type: bool
-
wltrace.dot11.
is_lowest_rate
(rate)[source]¶ Whether or not the rate is the lowest rate in rate table.
Parameters: rate (int) – rate in Mbps . Can be 802.11g/n rate. Returns: True
if the rate is lowest, otherwiseFalse
. Note that ifrate
is not valid, this function returnsFalse
, instead of raising an exception.Return type: bool
-
wltrace.dot11.
is_multicast
(mac)[source]¶ Whether a MAC address is IPV4/V6 multicast address.
See https://en.wikipedia.org/wiki/Multicast_address#Ethernet
Parameters: mac (str) – MAC address Returns: bool >>> is_multicast('01:80:C2:00:00:08') True
-
wltrace.dot11.
mcs_to_rate
(mcs, bw=20, long_gi=True)[source]¶ Convert MCS index to rate in Mbps.
Parameters: Returns: rate – bitrate in Mbps
Return type: >>> mcs_to_rate(5, bw=20, long_gi=False) 57.8
>>> mcs_to_rate(4, bw=40, long_gi=True) 81
>>> mcs_to_rate(3, bw=80, long_gi=False) 130
>>> mcs_to_rate(13, bw=160, long_gi=True) 936
-
wltrace.dot11.
next_seq
(seq)[source]¶ Next sequence number.
Parameters: seq (int) – current sequence number Returns: next sequence number, may wrap around Return type: int >>> next_seq(3) 4
>>> next_seq(4095) 0