An Example of Python and libpcap (pcapy)

26 Oct

Long long ago, I wrote this piece of code, with Python and pcapy, for my project. Today I put it on my blog, partly for recording, and partly for memento.

This program read the data in libpcap file format, filter some useless records, and write the filtered records to a new file. Majorly, the work was done with pcapy, a wrapper for libpcap packet capture library.

This code is somehow bad, abuse of “import *”, import never-used library, insufficient comments, and so on. But I want to post the original copy, except one comment line. The bad of the post code could be a good teacher of future good ones.

Nowadays, the team is already the thing of the past. But I could never forget it, my first team to involve and lead.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please put your code into a <pre>YOUR CODE</pre> section. Thanks and Happy Coding!