Skip to content

dirtbags/py-pcap

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
title
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')]
>>> 

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published