7 from mininet.net
import Mininet
8 from mininet.node
import OVSSwitch, Controller, RemoteController
9 from mininet.log
import setLogLevel, info
10 from mininet.cli
import CLI
11 from mininet.clean
import cleanup
12 from mininet.util
import errRun
23 "Add the OpenFlow13 Protocol" 25 params[
'protocols'] =
'OpenFlow13' 26 OVSSwitch.__init__(self, name, **params)
31 Mininet looks for this during stop(). It exists in OVSSwitch. Kilda, at the moment, 32 doesn't like this batch operation (and it shouldn't be done in batch) 34 info (
"\nIGNORE batchStartup()\n")
35 for switch
in switches:
37 info (
"\n .... BATCH = TRUE !!!!!!\n")
43 Mininet looks for this during stop(). It exists in OVSSwitch. Kilda, at the moment, 44 doesn't like this batch operation (and it shouldn't be done in batch) 46 info (
"\nIGNORE batchShutdown()\n")
47 for switch
in switches:
49 info (
"\n .... BATCH = TRUE !!!!!!\n")
56 netstat = subprocess.check_output([
'netstat',
'-rn']).split(
'\n')
58 if line.startswith(
'0.0.0.0'):
59 gateway = re.split(
'\s+', line)[1]
65 subprocess.Popen([
"ovs-ofctl",
"-O",
"OpenFlow13",
"add-flow",
"s1",
66 "idle_timeout=0,priority=1000,in_port=1,actions=output:2"],
67 stdout=subprocess.PIPE).wait()
68 subprocess.Popen([
"ovs-ofctl",
"-O",
"OpenFlow13",
"add-flow",
"s1",
69 "idle_timeout=0,priority=1000,in_port=2,actions=output:1"],
70 stdout=subprocess.PIPE).wait()
74 global net, hosts1, hosts2
75 net = Mininet( controller=RemoteController, switch=KildaSwitch, build=
False )
78 info(
"*** Creating (Remote) controllers\n" )
79 c0 = net.addController(
'c0', ip=gateway, port=6653)
81 info(
"*** Creating switches\n" )
82 s1 = net.addSwitch(
's1' )
83 s2 = net.addSwitch(
's2' )
85 info(
"*** Creating hosts\n" )
86 hosts1 = [ net.addHost(
'h%ds1' % n )
for n
in ( 1, 2 ) ]
87 hosts2 = [ net.addHost(
'h%ds2' % n )
for n
in ( 1, 2 ) ]
89 info(
"*** Creating links\n" )
96 info(
"*** Starting network\n" )
103 result = host1.cmd(
'ping -c1 -w1 %s' % (host2.IP()) )
104 lines = result.split(
"\n")
105 if "1 packets received" in lines[3]:
106 print "CONNECTION BETWEEN ", host1.IP(),
"and", host2.IP()
108 print "NO CONNECTION BETWEEN ", host1.IP(),
"and", host2.IP()
112 global hosts1, hosts2, net
117 setLogLevel(
'warning' )
119 setLogLevel(
'info' )
123 setLogLevel(
'info' )
126 for i
in range(count):
127 info(
"*** Running Loop #{} of {}".
format(i+1, count) )
129 ping(hosts1[0], hosts1[1])
130 ping(hosts1[0], hosts2[0])
131 info (
"--> Cleanup\n")
def batchStartup(cls, switches, run=errRun)
def batchShutdown(cls, switches, run=errRun)
def __init__(self, name, params)