我正在运行以下测试脚本,尝试从下载的示例文件.pcap
中读取数据包。好像跑不了。我有所有的模块,但似乎没有运行的例子。
import socket
import dpkt
import sys
pcapReader = dpkt.pcap.Reader(file("test1.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)
出于某种原因,这一点没有得到正确的解释。当运行它时,我得到
KeyError: 138
module body in test.py at line 4
function __init__ in pcap.py at line 105
Program exited.
这是为什么?怎么了?我的安装有问题吗?我在mac上使用Python2.6
目前没有回答
相关问题 更多 >
编程相关推荐