Making New Objects

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
      ip6 =
      ... # Process the encapsulated IPv6 packet

Class Methods
ip(object or byte array) -> anIP

Makes a new IP (IPv4) object
ip6bject or byte array) -> anIP6

Makes a new IP6 (IPv6) object
tcp(object or byte array) -> aTCP

Makes a new TCP object
udp(object or byte array) -> aUDPP

Makes a new UDP object
icmp(object or byte array) -> anICMP

Makes a new ICMP object
icmp6(object or byte array) -> anICMP

Makes a new ICMPv6 object

Nevil Brownlee
Mon, 27 Jan 14 (NZDT)