Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用scapy查找tcp流_Python_Tcp_Scapy - Fatal编程技术网

Python 使用scapy查找tcp流

Python 使用scapy查找tcp流,python,tcp,scapy,Python,Tcp,Scapy,我正在使用scapys sniff函数捕获tcp和udp数据包。我想知道tcp流以及流存在的时间。在wireshark中,我们有wireshark内部的会话id。我想知道流存在的时间,用于使用scapy嗅探数据包。 是tcp或udp数据包中的任何字段或计算流存在时间的任何方法。我正在谷歌搜索解决方案,但没有找到答案。 我们在wireshark中还有一个图形可以看到流箭头。我们可以使用python实现同样的功能吗。每个数据包都有一个与之相关的时间戳,您可以通过以下方式轻松检索: >>&

我正在使用scapys sniff函数捕获tcp和udp数据包。我想知道tcp流以及流存在的时间。在wireshark中,我们有wireshark内部的会话id。我想知道流存在的时间,用于使用scapy嗅探数据包。 是tcp或udp数据包中的任何字段或计算流存在时间的任何方法。我正在谷歌搜索解决方案,但没有找到答案。
我们在wireshark中还有一个图形可以看到流箭头。我们可以使用python实现同样的功能吗。

每个数据包都有一个与之相关的时间戳,您可以通过以下方式轻松检索:

>>> pkt = Ether() / IP() / UDP()
>>> pkt.time
1411350054.376391
>>> 

因此,只需找到会话中的第一个TCP数据包和最后一个TCP数据包来计算持续时间。

非常感谢您的回复。我的捕获中有许多数据包,比如500个数据包。我需要在捕获中计算TCP流。默认情况下,我们在scapy中没有任何计算内容。非常感谢您的回答。谢谢