我正在尝试模拟这里的代码:Scapy and tcpreplay: bypass temporary file for performance
当我尝试运行该代码时,以下行显示Python错误:
f = subprocess.Popen(argv, stdin=subprocess.PIPE)错误显示
Failed: Error opening pcap file: truncated dump file; tried to read 4 file header bytes, only got 0我想我得到了这个错误,因为子进程试图在将任何内容写入stdin之前从stdin读取数据。
有什么建议吗?
发布于 2017-07-20 03:49:32
开始工作了..。在引用的答案中使用此标头而不是标头:
header = b'\xd4\xc3\xb2\xa1\x02\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x7f\x00\x00\x01\x00\x00\x00'我没有在我的代码中使用sendpfast。
为了澄清我上面的问题...我尝试发送一个数据包,更新数据包的IP,然后循环发送更新后的数据包。
将数据包列表写入stdin,然后使用sendpfast并不比将数据包列表写入临时文件,然后对临时文件使用sendpfast更快。Sendpfast似乎只适用于从磁盘上已有的pcap文件发送一大堆数据包。
这个链接(https://byt3bl33d3r.github.io/mad-max-scapy-improving-scapys-packet-sending-performance.html)为我的问题提供了最好的解决方案。它允许我打开一个套接字,在该套接字上发送单个数据包,更新数据包,然后通过相同的套接字发送。
https://stackoverflow.com/questions/45153604
复制相似问题