LoneWolf
LoneWolf

Reputation: 581

Error while using dpkt in python

I'm writing some code to parse a pcap file in python as follows:

#!/usr/bin/env python
import socket
import dpkt
import sys
import pcap
pcapReader = dpkt.pcap.Reader(file("clients.pcap", "rb"))
for ts, data in pcapReader:
    ether = dpkt.ethernet.Ethernet(data)
    if ether.type != dpkt.ethernet.ETH_TYPE_IP: raise
    ip = ether.data
    src = socket.inet_ntoa(ip.src)
    dst = socket.inet_ntoa(ip.dst)
    print "%s -> %s" % (src, dst)

While compiling, I’m getting the following error message::

Traceback (most recent call last):
  File "test.py", line 3, in <module>
    import dpkt
ImportError: No module named dpkt

Any help is appreciated.

Upvotes: 2

Views: 7116

Answers (1)

Felipe Volpato
Felipe Volpato

Reputation: 401

On Ubuntu, just type:

sudo apt-get install python-dpkt

Upvotes: 4

Related Questions