Skip to content

Instantly share code, notes, and snippets.

@hwchiu
Last active August 29, 2015 14:02
Show Gist options
  • Save hwchiu/e0cabf76019f1df4bb77 to your computer and use it in GitHub Desktop.
Save hwchiu/e0cabf76019f1df4bb77 to your computer and use it in GitHub Desktop.
  1. mininet: mn --controller=remote,ip=127.0.0.1 --topo topo --custom topo.py
  2. h1 ping h4
  3. open other terminal
  4. type "ovs-ofctl dump-flows s2" to make sure the flow is pass through s2.
  5. type "ifocnfig s1-eth1" to shutdown the link between s1 and s2
  6. The result in the mininet promt:
64 bytes from 10.0.0.4: icmp_req=71 ttl=64 time=0.028 ms
64 bytes from 10.0.0.4: icmp_req=72 ttl=64 time=195 ms
64 bytes from 10.0.0.4: icmp_req=73 ttl=64 time=0.157 ms
64 bytes from 10.0.0.4: icmp_req=74 ttl=64 time=0.023 ms
64 bytes from 10.0.0.4: icmp_req=75 ttl=64 time=0.025 ms
64 bytes from 10.0.0.4: icmp_req=76 ttl=64 time=0.023 ms
64 bytes from 10.0.0.4: icmp_req=77 ttl=64 time=0.041 ms
64 bytes from 10.0.0.4: icmp_req=78 ttl=64 time=10.2 ms
64 bytes from 10.0.0.4: icmp_req=79 ttl=64 time=0.320 ms
64 bytes from 10.0.0.4: icmp_req=84 ttl=64 time=118 ms
64 bytes from 10.0.0.4: icmp_req=85 ttl=64 time=0.290 ms
64 bytes from 10.0.0.4: icmp_req=86 ttl=64 time=0.038 ms
64 bytes from 10.0.0.4: icmp_req=87 ttl=64 time=0.031 ms
64 bytes from 10.0.0.4: icmp_req=88 ttl=64 time=0.032 ms
64 bytes from 10.0.0.4: icmp_req=89 ttl=64 time=0.033 ms

According to the above result, you can see i shutdown the interface on icmp_req=79, and the ping will work again after icmp_req=85. 7. type "ovs-ofctl dump-flows s3" to make sure the flow is pass through s3 now.

from mininet.topo import Topo
class MininetTopo(Topo):
def __init__(self,**opts):
Topo.__init__(self, **opts)
host1 = self.addHost('h1')
host2 = self.addHost('h2')
host3 = self.addHost('h3')
host4 = self.addHost('h4')
self.switch = {}
for s in range(1,5):
self.switch[s-1] = self.addSwitch('s%s' %(s))
self.addLink(self.switch[0], self.switch[1])
self.addLink(self.switch[0], self.switch[2])
self.addLink(self.switch[1], self.switch[2])
self.addLink(self.switch[1], self.switch[3])
self.addLink(self.switch[2], self.switch[3])
self.addLink(self.switch[0], host1)
self.addLink(self.switch[1], host2)
self.addLink(self.switch[3], host3)
self.addLink(self.switch[3], host4)
topos = {'topo':(lambda:MininetTopo())}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment