Python 3.x 如何使用Pyshark将流索引作为显示筛选器来筛选PCAP文件?

Python 3.x 如何使用Pyshark将流索引作为显示筛选器来筛选PCAP文件?,python-3.x,filter,wireshark,display,pyshark,Python 3.x,Filter,Wireshark,Display,Pyshark,我有一个PCAP文件,其流索引范围为0-30。我试图只提取与任意流索引(即2)关联的数据包 我的程序使用以下方法正确输出流索引: stream_index = packet.tcp.stream print(stream_index) 流索引返回2 filter = '(tcp.stream == ' + stream_index + ')' output_name = 'PCAPFile.pcap' capture = pyshark.FileCapture(filename, displ

我有一个PCAP文件,其流索引范围为0-30。我试图只提取与任意流索引(即2)关联的数据包

我的程序使用以下方法正确输出流索引:

stream_index = packet.tcp.stream
print(stream_index)
流索引返回2

filter = '(tcp.stream == ' + stream_index + ')'
output_name = 'PCAPFile.pcap'

capture = pyshark.FileCapture(filename, displayfilter = filter, output_file = output_name)
capture.load_packets()
capture.close()
它的输出返回一个pcap文件,其中包含与流索引0(而不是2)关联的几个数据包

打开Wireshark并使用
(tcp.stream==2)
作为显示过滤器,返回我正在查找的与索引流2关联的所有数据包


任何帮助都将不胜感激。

我刚刚用您的代码运行了一个测试,我得到了正确的数据包,但我的PCAP流索引已重置为0。