首页 > 解决方案 > 防止 tcpreplay 阻塞 Mininet Python API cmds

问题描述

我需要执行多个不同的命令来将 pcaps 重播到我的网络中。

第一个 pcap 超过 100 秒,我需要播放它,然后立即播放其他 pcap。

我的问题是,当我在我的 python 代码中执行这一行时:

h2.cmd('tcpreplay --intf1=h2-eth0 BenignTest.pcap 10.0.0.1')

程序在继续之前等待这 100 秒的 pcap 完成。我需要程序在发送该命令后立即继续。

有没有办法让 tcpreplay 像这样非阻塞?

标签: pythonmininettcpreplay

解决方案


原来它就像添加&到命令的末尾一样简单。

h2.cmd('tcpreplay --intf1=h2-eth0 BenignTest.pcap 10.0.0.1 &')

&将命令发送到后台并释放正在使用的终端。

https://bashitout.com/2013/05/18/Ampersands-on-the-command-line.html


推荐阅读