Search code examples
pythonmininettcpreplay

Prevent tcpreplay blocking Mininet Python API cmds


I need to execute multiple different commands to replay pcaps into my network.

The first pcap is over 100 seconds, I need to play it and then immediately play other pcaps.

My problem is, when I execute this line in my python code:

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

The program waits for this 100 second pcap to finish before continuing. I need the program to continue as soon as it sends that command.

Is there a way to make tcpreplay non-blocking like this?


Solution

  • Turns out it is as simple as adding & to the end of the command.

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

    & sends the command to the background and frees up the terminal being used.

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