pcap 纳秒 Python [英] pcap nanoseconds Python

查看:79
本文介绍了pcap 纳秒 Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论如何,是否可以使用现有的 python 库从 pcap 中获得纳秒?我有一个纳秒级的 pcap 文件,它与 Wireshark 一起工作得很好,但 Python pcapy 库甚至不会导入文件.

Is there anyway to get nanoseconds out of a pcap with existing python libraries? I have a nanoseconds pcap file that works just fine with Wireshark but the Python pcapy library will not even import the file.

此功能确实存在于 c libpcap 中(请参阅:此线程)但是有人将它移植到 Python 中吗?我查看了源代码,但更改 pcapy 以允许这样做超出了我的头脑.

This functionality does exist in c libpcap (see: this thread) but has anyone ported it into Python? I took a look at the source code but it is over my head in changing pcapy to allow this.

纳秒对于我正在做的事情是必要的,微秒并没有给我必要的精度,尽管我的代码在微秒上运行得很好.

Nanoseconds are necessary for what I am doing and microseconds do not give me the necessary precision, though my code is working perfectly fine with micros.

推荐答案

在尝试了 Python 中所有现有的 pcap 模块后,我们决定在 pcapy 上编辑源代码.我们将其更改为包括pcap_open_offline_with_tstamp_precision(pathname, PCAP_TSTAMP_PRECISION_NANO, errbuf);"libpcap 中已经存在的功能,并且运行良好.现在,我们的数据包捕获分析有了纳秒级分辨率.

After trying every existing pcap module in Python, we decided to edit the source on pcapy. We changed this to include the "pcap_open_offline_with_tstamp_precision(pathname, PCAP_TSTAMP_PRECISION_NANO, errbuf);" functionality that already existed in libpcap and it worked perfectly. Now we have nanosecond resolution for our packet capture analysis.

这篇关于pcap 纳秒 Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆