Skip to content

andyhao567/py-pcap

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

== Python pcap file library ==

This is a pcap file reader and writer which doesn't need libpcap.  The
read interface is similar to that of pcapy, but you can do things like
read packets from a StringIO or gzip object.  It handles
different-endian files transparently.

This can also write pcap files, because hey, why not.

To use it:

    >>> import pcap
    >>> p = pcap.open('test.pcap', 'w')     # Create a new file
    >>> p.write(((0, 0, 3), 'foo'))         # Add a packet
    >>> p.write(((0, 0, 3), 'bar'))
    >>> del p
    >>> p = pcap.open(file('test.pcap'))    # Also takes file objects
    >>> (p.version, p.thiszone, p.sigfigs, p.snaplen, p.linktype)
    ((2, 4), 0, 0, 65535, 1)
    >>> [i for i in p]                      # Iterable
    [((0, 0, 3), 'foo'), ((0, 0, 3), 'bar')]
    >>> 

Enjoy.

Version 1.1 is available at
<http://dirtbags.net/py-pcap/py-pcap-1.1.tar.gz>

Neale Pickett <neale@dirtbags.net>

About

Python “pcap” file reader and writer

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 74.4%
  • Python 25.6%