How to run ping when STP is ready in a mininet topology

If you have a topology like a mesh or any other with redundant links, you must use Spanning tree protocol (STP) to avoid a while.
To run STP, you can use a controller app or setup your virtual switches to be compatible with STP.

To run as controller:

Run a STP controller app. In my case I use Ryu:
ryu-manager --ofp-tcp-listen-port=6633 ryu.app.simple_switch_stp_13

To run as virtual switch (OVSSwitch):

You can modify your switch from your terminal (outside mininet) as follows:

ovs-vsctl set bridge s1 stp-enable=true

You can use the same sentence inside a python script like follows:

s1.cmd('ovs-vsctl set bridge s1 stp-enable=true')

Now, to avoid execute ping before STP is ready, you need to see the status port of your switch. You can use the following code to insert in your python script.

while(s1.cmdPrint('ovs-ofctl show s1 | grep -o FORWARD | head -n1') != "FORWARD\r\n"):
    time.sleep(3)
# Avoid initial too long delaytime.sleep(2)
info("Running ping\n")
ping=h2.cmdPrint('ping -c3 ' + h1.IP())
print(ping)

When the switch port changes it status to FORWARDS, means that STP finished. You can check the status every one second (or 3 in my case to avoid an overload).
After that, you can execute ping without dropped packets.
Enjoy it!

Comments

Popular posts from this blog

Exception: Could not find a default OpenFlow controller in Mininet

How to fix Android when developer options are not available for this user

Webcam streaming throught VLC with YUY2 compatibility