wltrace.utils module¶
Various utilitis for packet trace parsing.
-
wltrace.utils.
align_up
(offset, align)[source]¶ Align
offset
up toalign
boundary.Parameters: Returns: aligned offset.
Return type: >>> align_up(3, 2) 4
>>> align_up(3, 1) 3
-
wltrace.utils.
bin_to_mac
(bin, size=6)[source]¶ Convert 6 bytes into a MAC string.
Parameters: bin (str) – hex string of lenth 6. Returns: String representation of the MAC address in lower case. Return type: str Raises: Exception
– iflen(bin)
is not 6.
-
wltrace.utils.
calc_padding
(fmt, align)[source]¶ Calculate how many padding bytes needed for
fmt
to be aligned toalign
.Parameters: Returns: padding format (e.g., various number of ‘x’).
Return type: >>> calc_padding('b', 2) 'x'
>>> calc_padding('b', 3) 'xx'
-
wltrace.utils.
win_ts
(high, low)[source]¶ Convert Windows timestamp to Unix timestamp.
Windows timestamp is a 64-bit integer, the value of which is the number of 100 ns intervals from 1/1/1601-UTC.
Parameters: Returns: Python timestamp (
datetime.datetime
object).