【问题标题】:Confusion with POpen/stdin/scapy/tcpreplay与 POpen/stdin/scapy/tcpreplay 混淆
【发布时间】:2017-12-22 13:03:08
【问题描述】:

我正在尝试在此处模拟代码: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 scapy tcpreplay


    【解决方案1】:

    让它工作......使用这个标题而不是引用答案中的标题:

    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。

    为了澄清我上面的问题...我试图发送 1 个数据包,更新数据包的 IP,然后循环发送更新的数据包。

    将数据包列表写入标准输入,然后使用 sendpfast 并不比将数据包列表写入临时文件,然后在临时文件上使用 sendpfast 快。 Sendpfast 似乎只适用于从磁盘上已经存在的 pcap 文件中发送一堆数据包。

    此链接 (https://byt3bl33d3r.github.io/mad-max-scapy-improving-scapys-packet-sending-performance.html) 为我的问题提供了最佳解决方案。它允许我打开一个套接字,在该套接字上发送一个数据包,更新数据包,然后通过同一个套接字发送。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-09
      • 1970-01-01
      • 2016-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多