Many of python-libtrace's classes have a new-instance function, so you can create a new object; this is most useful for handling encapsulated packets. These methods take a single argument, which may be an existing object or a byte array. In most cases the argument will be something you have unpacked from an incoming package. This allows you to work on encapsulated packets, e.g.
for pkt in trace:
trans = pkt.transport
if trans.proto != 41: # IPv6 over IPv4
continue
ip6 = ip6.new(trans)
... # Process the encapsulated IPv6 packet
| Class Methods | |
| ip() |
ip(object or byte array) -> anIP |
| Makes a new IP (IPv4) object | |
| ip6() |
ip6bject or byte array) -> anIP6 |
| Makes a new IP6 (IPv6) object | |
| tcp() |
tcp(object or byte array) -> aTCP |
| Makes a new TCP object | |
| udp() |
udp(object or byte array) -> aUDPP |
| Makes a new UDP object | |
| icmp() |
icmp(object or byte array) -> anICMP |
| Makes a new ICMP object | |
| icmp6() |
icmp6(object or byte array) -> anICMP |
| Makes a new ICMPv6 object | |