Sniffer Descriptors¶
SNAP descriptors are objects that are passed to local and remote sniffer callbacks. These descriptors represent packets that are received and transmitted by a SNAPconnect instance. This section lists the supported descriptors, their meanings, and their attributes.
The descriptors passed to sniffer functions are NOT over-the-air packets. These descriptors only represent packets that are received and transmitted over SNAPconnect serial and TCP connections.
For more about sniffer operations, refer to the accept_sniffer()
, connect_tcp()
, and
start_sniffer()
functions.
Tip
Because not every descriptor type supports every attribute, you will want to use the Python builtin function
isinstance(descriptor, descriptor_type)
to verify the descriptor type prior to accessing its attributes.
Common Attributes¶
- All packet descriptors share several attributes in common:
raw
: A string of decrypted bytes representing the undecoded packet.rx
: True if the packet was received by the SNAPconnect instance running the sniffer.tx
: True if the packet was transmitted by the SNAPconnect instance running the sniffer.
Data Mode Packets¶
-
snap.
DataModeDescriptor
¶
DataModeDescriptor
represents received and transmitted (originated or forwarded) data mode packets.
Attributes
data
: The data being carried by the packet.dstAddr
: A three-byte string representing the address of the immediate destination of the packet (subject to mesh routing) or a two-byte multicast group (for a multicast data mode packet).final_dst_addr
: A three-byte string representing the address of the final destination of the packet (unicast only).isMulticast
: True if the packet is multicast or False if it is unicast.seq
: The sequence number of the packet.srcAddr
: A three-byte string representing the SNAP address of the original source of the packet.ttl
: The number of hops remaining for this packet (multicast only).
See also
hooks.HOOK_STDIN
for how data mode packets are normally received.data_mode()
mcast_data_mode()
Mesh Routing Packets¶
-
snap.
MeshDescriptor
¶
MeshDescriptor
represents received and transmitted mesh routing packets.
Attributes
additionalAddresses
: An optional list of additional discovered/errored addresses.hopLimit
: The number of hops remaining for this packet.msgId
: A single character representing the type of mesh packet.Q
is used for route requests,P
is used for route replies, andE
is used for route errors.source
: A three-byte string representing the address of the immediate source of the packet.originator
: A three-byte string representing the address of the node that created the packet.originatorDistance
: The number of hops traveled from the originator.target
: A three-byte string representing the address of the target for the routing packet.targetDistance
: The number of hops until the target is reached.
Undecoded Packets¶
-
snap.
RawDescriptor
¶
RawDescriptor
may show up in cases where a packet could not be decoded and broken into the correct components. A
raw descriptor contains no additional information outside of the attributes common to all descriptors.
RPC Packets¶
-
snap.
RpcDescriptor
¶
RpcDescriptor
represents received and transmitted RPC packets.
Attributes
args
: A tuple of arguments to be passed to the RPC function.dstAddr
: A three-byte string representing the address of the immediate destination of the packet (subject to mesh routing) or a two-byte multicast group (for a multicast packet).final_dst_addr
: A three-byte string representing the address of the final destination of the packet (unicast only).funcName
: Name of the RPC function to be called.isMulticast
: True if the packet is multicast or False if it is unicast.last_hop_addr
: A three-byte string representing the address of the immediate source of the packet.seq
: The sequence number of the packet.srcAddr
: A three-byte string representing the address of the original source of the packet.ttl
: The number of hops remaining for this packet (multicast only).
See also
Traceroute Packets¶
TraceRouteDescriptor
represents received and transmitted traceroute packets.
Attributes
dstAddr
: A three-byte string representing the address of the immediate destination of the packet.elapsed
: The elapsed time, in milliseconds, to reach the target node. (This time does not include the first hop in the path, which will typically be trivial for serial connections but can be significant when SNAPconnect performs a traceroute over a TCP bridge.)final_dst_addr
: A three-byte string representing the address of the final destination of the packet.isMulticast
: True if the packet is multicast or False if it is unicast.msgId
: A single character representing the type of traceroute packet.Q
is used for traceroute queries andP
is used for traceroute replies.orig_src_addr
: A three-byte string representing the address of the original source of the packet.records
: A list of traceroute records with ‘address’ and ‘linkQuality’ attributes.srcAddr
: A three-byte string representing the address of the immediate source of the packet.
See also
traceroute()
hooks.HOOK_TRACEROUTE
for information on how traceroute packets are received.