Monitor your Browsing/Downloading data via Python

Download-Monitor

So here’s a small script which will monitor the amount of your browsing/downloading data.
I have used pypcap and dpkt library. dpkt is a library which provides packets creation/ parsing capabilities with an object oriented interface. The project is hosted at http://code.google.com/p/dpkt/ .

#!/usr/bin/python2.7
import pcap, dpkt, socket

pc = pcap.pcap()
ports = (80, 8080, 443, 888) # for HTPP and HTPPS

pc is now my pcap.pcap object. pcap objects are their own iterator returning the timestamp and
the packet as a 2-tuple.

def process():
  mem = sport = dport = 0
  try:
    for ts, pkt in pc:
      eth = dpkt.ethernet.Ethernet(pkt)
      ip = eth.data

Continue reading