Gives you access to fieds within (the captured part of) a packet. You will normally work on Packets returned from Trace.read_packet() or a Trace iterator (see Trace Handling), but you can create a new packet instance with packet() (see below).
Note that the Layer and Decode methods return None if their requested object was not present in the packet, or was not completely captured.
Class Methods | |
packet() |
Packet() -> aPacket |
Makes a new Python Packet. A
python-libtrace packet maintains a set of pointers into a libtrace
packet or a python-libtrace data object. In a newly-created
Packet, all such pointers are NULL. |
Instance Methods | |
layer2 | pkt.layer2 -> aLayer2 |
Gets a Layer2 object from the packet; see Layers page | |
layer3 | pkt.layer3 -> aLayer3 |
Gets a Layer3 object from the packet; see Layers page |
|
transport | pkt.transport -> aTransport |
Gets a Transport object from the packet; see Layers page |
|
ip | pkt.ip -> anIP |
Gets an IPv4 header from the packet | |
ip6 | pkt.ip6 -> anIP6 |
Gets an IPv6 header from the packet | |
tcp | pkt.tcp-> aTCP |
Gets a TCP header from the packet | |
tcp_payload | pkt.tcp_payload -> aData |
Gets a TCP payload from the packet, or None if it wasn't TCP. tcp_payload.data returns a ByteArray of the data |
|
udp | pkt.udp -> aUDP |
Gets a UDP header from the packet | |
udp_payload | pkt.udp_payload -> aData |
Gets a UDP payload from the packet, or None if it wasn't UDP. udp_payload.data returns a ByteArray of the data |
|
icmp | pkt.icmp -> anICMP |
Gets an ICMP header from the packet | |
icmp6 | pkt.icmp -> anICMP |
Gets an ICMP v6header from the packet | |
apply_filter() | pkt.apply_filter(aFilter) -> result |
Tests whether the current contents of the packet
match aFilter.
Result is True if the filter matches, False if it doesn't, or None if the filter was invalid |
Instance Variables | |
data | pkt.data -> aByteArray |
Byte array containing object's header and its following bytes. May be used for any python-libtrace object |
|
time | pkt.time -> aTimeval |
Packet Arrival Time as a Python Time | |
seconds | pkt.seconds -> aFloat |
Packet Arrival Time in Unix seconds (double) | |
ts_sec |
pkt.ts_sec -> anInteger |
Packet Arrival Time in Unix seconds (integer) | |
erf_time | pkt.erf_time -> anInteger |
Packet Arrival Time as a DAG ERF time (64-bit) | |
wire_len | pkt.wire_len -> anInteger |
Original size of packet on the wire | |
capture_len | pkt.capture_len -> anInteger |
Number of bytes captured; may be less than wire_len | |
ethertype | internet.ethertype -> anInteger |
Ethertype for the packet that contained this object | |
linktype |
pkt.linktype -> anInteger |
Packet's link type; see Layer2 on Layers page for linktype values | |
vlan_id |
pkt.vlan_id -> anInteger |
VLAN ID for packets with an 802.1Q VLAN tag, zero otherwise | |
direction |
pkt.direction -> anInteger |
'Direction' of packet, for traces from interfaces that support this, e.g. ERF traces. Direction values are: TRACE_DIR_INCOMING, TRACE_DIR_INCOMING and TRACE_DIR_OTHER |
Class Set Method | |
data= | Packet.data = aByteArray |
Overwrites the data bytes in a Data object with bytes from a byte array. The byte array may not be longer than the original data from the packet. |
Nevil Brownlee
Mon, 13 Apr 15 (NZST)