我有个问题。
如何通过使用dpkt库和来自pcap文件的每个主机名的ts来获得get和HTTP/1.0 200OK之间的响应时间差(我是指web服务器的时间延迟)?
我的初步代码:
#!/usr/bin/env python
import dpkt
f = open('mycapture.cap')
pcap = dpkt.pcap.Reader(f)
for ts, buf in pcap:
eth = dpkt.ethernet.Ethernet(buf)
ip = eth.data
tcp = ip.data
if tcp.dport == 80 and len(tcp.data) > 0:
http = dpkt.http.Request(tcp.data)
print ts, http.headers['host']
f.close()但它仍然是输出时间戳,只有GET请求。
它看起来会像这样:
tcpdump -i eth0 -w pcapfile; python (command).py pcapfile
google.com 0.488183
facebook.com 0.045466
quora.com 0.032777发布于 2013-01-24 16:03:44
看起来您已经成功获取了第一个请求数据包,现在您需要获取响应的第一个数据包……类似于:
if tcp.sport == 80 and len(tcp.data) > 0:
# Here you can save the timestamp of the response and calculate the difference祝好运
https://stackoverflow.com/questions/13122758
复制相似问题