mininet files for dev VMs
diff --git a/test-network/mininet/dev_network.py b/test-network/mininet/dev_network.py
new file mode 100755
index 0000000..0eb519a
--- /dev/null
+++ b/test-network/mininet/dev_network.py
@@ -0,0 +1,175 @@
+#!/usr/bin/python
+
+"""
+Start up a Simple topology
+"""
+from mininet.net import Mininet
+from mininet.node import Controller, RemoteController
+from mininet.log import setLogLevel, info, error, warn, debug
+from mininet.cli import CLI
+from mininet.topo import Topo
+from mininet.util import quietRun
+from mininet.moduledeps import pathCheck
+from mininet.link import Link, TCLink
+
+from sys import exit
+import os.path
+from subprocess import Popen, STDOUT, PIPE
+
+import sys
+
+NR_NODES=10 #; Switches per rigonal networks
+
+class MyController( Controller ):
+ def __init__( self, name, ip='127.0.0.1', port=6633, **kwargs):
+ """Init.
+ name: name to give controller
+ ip: the IP address where the remote controller is
+ listening
+ port: the port where the remote controller is listening"""
+ Controller.__init__( self, name, ip=ip, port=port, **kwargs )
+
+ def start( self ):
+ "Overridden to do nothing."
+ return
+
+ def stop( self ):
+ "Overridden to do nothing."
+ return
+
+ def checkListening( self ):
+ "Warn if remote controller is not accessible"
+ listening = self.cmd( "echo A | telnet -e A %s %d" %
+ ( self.ip, self.port ) )
+ if 'Unable' in listening:
+ warn( "Unable to contact the remote controller"
+ " at %s:%d\n" % ( self.ip, self.port ) )
+
+class SDNTopo( Topo ):
+ "SDN Topology"
+
+ def __init__( self, *args, **kwargs ):
+ Topo.__init__( self, *args, **kwargs )
+ sw1 = self.addSwitch('sw1', dpid='0000000000000101')
+ sw2 = self.addSwitch('sw2', dpid='0000000000000102')
+ sw3 = self.addSwitch('sw3', dpid='0000000000000103')
+ sw4 = self.addSwitch('sw4', dpid='0000000000000104')
+ sw5 = self.addSwitch('sw5', dpid='0000000000000105')
+ sw6 = self.addSwitch('sw6', dpid='0000000000000106')
+
+ self.addLink( sw1, sw2 )
+ self.addLink( sw1, sw6 )
+ self.addLink( sw2, sw3 )
+ self.addLink( sw3, sw4 )
+ self.addLink( sw3, sw6 )
+ self.addLink( sw4, sw5 )
+ self.addLink( sw5, sw6 )
+ self.addLink( sw4, sw6 )
+
+ switches=[]
+ for n in range(2, 9):
+ NWID=n
+ switch = []
+ host = []
+ for i in range (NR_NODES):
+ name_suffix = '%02d' % NWID + "." + '%02d' % (int(i)+1)
+ dpid_suffix = '%02x' % NWID + '%02x' % (int(i)+1)
+ dpid = '0000' + '0000' + '0000' + dpid_suffix
+ sw = self.addSwitch('sw'+name_suffix, dpid=dpid)
+ switch.append(sw)
+
+ for i in range (NR_NODES):
+ host.append(self.addHost( 'host%d.%d' % (n,int(i)+1) ))
+
+ for i in range (NR_NODES):
+ self.addLink(host[i], switch[i])
+
+ for i in range (1, NR_NODES):
+ self.addLink(switch[0], switch[i])
+
+ switches.append(switch)
+
+ self.addLink(switches[8-2][0],sw1)
+ self.addLink(switches[2-2][0],sw2)
+ self.addLink(switches[3-2][0],sw3)
+ self.addLink(switches[4-2][0],sw4)
+ self.addLink(switches[5-2][0],sw4)
+ self.addLink(switches[6-2][0],sw5)
+ self.addLink(switches[7-2][0],sw6)
+
+
+def startsshd( host ):
+ "Start sshd on host"
+ info( '*** Starting sshd\n' )
+ name, intf, ip = host.name, host.defaultIntf(), host.IP()
+ banner = '/tmp/%s.banner' % name
+ host.cmd( 'echo "Welcome to %s at %s" > %s' % ( name, ip, banner ) )
+ host.cmd( '/usr/sbin/sshd -o "Banner %s"' % banner, '-o "UseDNS no"' )
+ info( '***', host.name, 'is running sshd on', intf, 'at', ip, '\n' )
+
+def startsshds ( hosts ):
+ for h in hosts:
+ startsshd( h )
+
+def stopsshd( ):
+ "Stop *all* sshd processes with a custom banner"
+ info( '*** Shutting down stale sshd/Banner processes ',
+ quietRun( "pkill -9 -f Banner" ), '\n' )
+
+def sdnnet(opt):
+# os.system('/home/ubuntu/openflow/controller/controller ptcp: &')
+# os.system('/home/ubuntu/openflow/controller/controller ptcp:7000 &')
+
+ topo = SDNTopo()
+ info( '*** Creating network\n' )
+# net = Mininet( topo=topo, controller=RemoteController )
+ net = Mininet( topo=topo, controller=MyController, link=TCLink)
+# dc = DebugController('c3', ip='127.0.0.1', port=7000)
+# net.addController(dc)
+# net.addController(controller=RemoteController)
+# host1, host2, host3, host4, host5, host6 = net.get( 'host1', 'host2', 'host3', 'host4', 'host5', 'host6')
+
+ ## Adding 2nd, 3rd and 4th interface to host1 connected to sw1 (for another BGP peering)
+ sw1 = net.get('sw1')
+ sw2 = net.get('sw2')
+ sw3 = net.get('sw3')
+ sw4 = net.get('sw4')
+ sw5 = net.get('sw5')
+ sw6 = net.get('sw6')
+
+ hosts = []
+ for n in range(2, 9):
+ host = []
+ for i in range (NR_NODES):
+ host.append(net.get( 'host%d.%d' % (n, int(i)+1) ))
+ hosts.append(host)
+
+ net.start()
+
+ for n in range(2, 9):
+ for i in range (NR_NODES):
+ hosts[n-2][i].defaultIntf().setIP('192.168.%d.%d/16' % (n,(int(i)+1)))
+ hosts[n-2][i].defaultIntf().setMAC('00:00:%02x:%02x:%02x:%02x' % (192,168,n,(int(i)+1)))
+
+ for i in range (NR_NODES):
+ for k in range (2,9):
+ for h in range (NR_NODES):
+ hosts[n-2][i].setARP('192.168.%d.%d' % (k, (int(h)+1)), '00:00:%02x:%02x:%02x:%02x' % (192,168,k,(int(h)+1)))
+
+ stopsshd ()
+ for n in range(2, 9):
+ startsshds ( hosts[n-2] )
+
+ if opt=="cli":
+ CLI(net)
+ stopsshd()
+ net.stop()
+
+if __name__ == '__main__':
+ setLogLevel( 'info' )
+ if len(sys.argv) == 1:
+ sdnnet("cli")
+ elif len(sys.argv) == 2 and sys.argv[1] == "-n":
+ sdnnet("nocli")
+ else:
+ print "%s [-n]" % sys.argv[0]
diff --git a/test-network/mininet/dev_network_core.py b/test-network/mininet/dev_network_core.py
new file mode 100755
index 0000000..a0e184e
--- /dev/null
+++ b/test-network/mininet/dev_network_core.py
@@ -0,0 +1,157 @@
+#!/usr/bin/python
+
+"""
+Start up a Simple topology
+"""
+from mininet.net import Mininet
+from mininet.node import Controller, RemoteController
+from mininet.log import setLogLevel, info, error, warn, debug
+from mininet.cli import CLI
+from mininet.topo import Topo
+from mininet.util import quietRun
+from mininet.moduledeps import pathCheck
+from mininet.link import Link, TCLink
+
+from sys import exit
+import os.path
+from subprocess import Popen, STDOUT, PIPE
+
+import sys
+
+
+#import argparse
+
+class MyController( Controller ):
+ def __init__( self, name, ip='127.0.0.1', port=6633, **kwargs):
+ """Init.
+ name: name to give controller
+ ip: the IP address where the remote controller is
+ listening
+ port: the port where the remote controller is listening"""
+ Controller.__init__( self, name, ip=ip, port=port, **kwargs )
+
+ def start( self ):
+ "Overridden to do nothing."
+ return
+
+ def stop( self ):
+ "Overridden to do nothing."
+ return
+
+ def checkListening( self ):
+ "Warn if remote controller is not accessible"
+ listening = self.cmd( "echo A | telnet -e A %s %d" %
+ ( self.ip, self.port ) )
+ if 'Unable' in listening:
+ warn( "Unable to contact the remote controller"
+ " at %s:%d\n" % ( self.ip, self.port ) )
+
+class SDNTopo( Topo ):
+ "SDN Topology"
+
+ def __init__( self, *args, **kwargs ):
+ Topo.__init__( self, *args, **kwargs )
+ sw1 = self.addSwitch('sw1', dpid='0000000000000101')
+ sw2 = self.addSwitch('sw2', dpid='0000000000000102')
+ sw3 = self.addSwitch('sw3', dpid='0000000000000103')
+ sw4 = self.addSwitch('sw4', dpid='0000000000000104')
+ sw5 = self.addSwitch('sw5', dpid='0000000000000105')
+ sw6 = self.addSwitch('sw6', dpid='0000000000000106')
+
+ host1 = self.addHost( 'host1' )
+ host2 = self.addHost( 'host2' )
+ host3 = self.addHost( 'host3' )
+ host4 = self.addHost( 'host4' )
+ host5 = self.addHost( 'host5' )
+ host6 = self.addHost( 'host6' )
+
+ self.addLink( host1, sw1 )
+ self.addLink( host2, sw2 )
+ self.addLink( host3, sw3 )
+ self.addLink( host4, sw4 )
+ self.addLink( host5, sw5 )
+ self.addLink( host6, sw6 )
+
+ self.addLink( sw1, sw2 )
+ self.addLink( sw1, sw6 )
+ self.addLink( sw2, sw3 )
+ self.addLink( sw3, sw4 )
+ self.addLink( sw3, sw6 )
+ self.addLink( sw4, sw5 )
+ self.addLink( sw5, sw6 )
+ self.addLink( sw4, sw6 )
+
+def startsshd( host ):
+ "Start sshd on host"
+ info( '*** Starting sshd\n' )
+ name, intf, ip = host.name, host.defaultIntf(), host.IP()
+ banner = '/tmp/%s.banner' % name
+ host.cmd( 'echo "Welcome to %s at %s" > %s' % ( name, ip, banner ) )
+ host.cmd( '/usr/sbin/sshd -o "Banner %s"' % banner, '-o "UseDNS no"' )
+ info( '***', host.name, 'is running sshd on', intf, 'at', ip, '\n' )
+
+def startsshds ( hosts ):
+ for h in hosts:
+ startsshd( h )
+
+def stopsshd( ):
+ "Stop *all* sshd processes with a custom banner"
+ info( '*** Shutting down stale sshd/Banner processes ',
+ quietRun( "pkill -9 -f Banner" ), '\n' )
+
+def sdnnet(opt):
+# os.system('/home/ubuntu/openflow/controller/controller ptcp: &')
+# os.system('/home/ubuntu/openflow/controller/controller ptcp:7000 &')
+
+ topo = SDNTopo()
+ info( '*** Creating network\n' )
+# net = Mininet( topo=topo, controller=RemoteController )
+ net = Mininet( topo=topo, controller=MyController, link=TCLink)
+# dc = DebugController('c3', ip='127.0.0.1', port=7000)
+# net.addController(dc)
+# net.addController(controller=RemoteController)
+
+ host1, host2, host3, host4, host5, host6 = net.get( 'host1', 'host2', 'host3', 'host4', 'host5', 'host6')
+
+ ## Adding 2nd, 3rd and 4th interface to host1 connected to sw1 (for another BGP peering)
+ sw1 = net.get('sw1')
+ sw2 = net.get('sw2')
+ sw3 = net.get('sw3')
+ sw4 = net.get('sw4')
+ sw5 = net.get('sw5')
+ sw6 = net.get('sw6')
+
+ net.start()
+
+ sw2.attach('tap01_2')
+ sw3.attach('tap01_3')
+ sw4.attach('tap01_4')
+ sw4.attach('tap01_5')
+ sw5.attach('tap01_6')
+ sw6.attach('tap01_7')
+ sw1.attach('tap01_8')
+
+ host1.defaultIntf().setIP('192.168.100.141/16')
+ host2.defaultIntf().setIP('192.168.100.142/16')
+ host3.defaultIntf().setIP('192.168.100.143/16')
+ host4.defaultIntf().setIP('192.168.100.144/16')
+ host5.defaultIntf().setIP('192.168.100.145/16')
+ host6.defaultIntf().setIP('192.168.100.146/16')
+
+ hosts = [ host1, host2, host3, host4, host5, host6 ]
+ stopsshd ()
+ startsshds ( hosts )
+
+ if opt=="cli":
+ CLI(net)
+ stopsshd()
+ net.stop()
+
+if __name__ == '__main__':
+ setLogLevel( 'info' )
+ if len(sys.argv) == 1:
+ sdnnet("cli")
+ elif len(sys.argv) == 2 and sys.argv[1] == "-n":
+ sdnnet("nocli")
+ else:
+ print "%s [-n]" % sys.argv[0]
diff --git a/test-network/mininet/dev_network_core_1.py b/test-network/mininet/dev_network_core_1.py
new file mode 100755
index 0000000..a0e184e
--- /dev/null
+++ b/test-network/mininet/dev_network_core_1.py
@@ -0,0 +1,157 @@
+#!/usr/bin/python
+
+"""
+Start up a Simple topology
+"""
+from mininet.net import Mininet
+from mininet.node import Controller, RemoteController
+from mininet.log import setLogLevel, info, error, warn, debug
+from mininet.cli import CLI
+from mininet.topo import Topo
+from mininet.util import quietRun
+from mininet.moduledeps import pathCheck
+from mininet.link import Link, TCLink
+
+from sys import exit
+import os.path
+from subprocess import Popen, STDOUT, PIPE
+
+import sys
+
+
+#import argparse
+
+class MyController( Controller ):
+ def __init__( self, name, ip='127.0.0.1', port=6633, **kwargs):
+ """Init.
+ name: name to give controller
+ ip: the IP address where the remote controller is
+ listening
+ port: the port where the remote controller is listening"""
+ Controller.__init__( self, name, ip=ip, port=port, **kwargs )
+
+ def start( self ):
+ "Overridden to do nothing."
+ return
+
+ def stop( self ):
+ "Overridden to do nothing."
+ return
+
+ def checkListening( self ):
+ "Warn if remote controller is not accessible"
+ listening = self.cmd( "echo A | telnet -e A %s %d" %
+ ( self.ip, self.port ) )
+ if 'Unable' in listening:
+ warn( "Unable to contact the remote controller"
+ " at %s:%d\n" % ( self.ip, self.port ) )
+
+class SDNTopo( Topo ):
+ "SDN Topology"
+
+ def __init__( self, *args, **kwargs ):
+ Topo.__init__( self, *args, **kwargs )
+ sw1 = self.addSwitch('sw1', dpid='0000000000000101')
+ sw2 = self.addSwitch('sw2', dpid='0000000000000102')
+ sw3 = self.addSwitch('sw3', dpid='0000000000000103')
+ sw4 = self.addSwitch('sw4', dpid='0000000000000104')
+ sw5 = self.addSwitch('sw5', dpid='0000000000000105')
+ sw6 = self.addSwitch('sw6', dpid='0000000000000106')
+
+ host1 = self.addHost( 'host1' )
+ host2 = self.addHost( 'host2' )
+ host3 = self.addHost( 'host3' )
+ host4 = self.addHost( 'host4' )
+ host5 = self.addHost( 'host5' )
+ host6 = self.addHost( 'host6' )
+
+ self.addLink( host1, sw1 )
+ self.addLink( host2, sw2 )
+ self.addLink( host3, sw3 )
+ self.addLink( host4, sw4 )
+ self.addLink( host5, sw5 )
+ self.addLink( host6, sw6 )
+
+ self.addLink( sw1, sw2 )
+ self.addLink( sw1, sw6 )
+ self.addLink( sw2, sw3 )
+ self.addLink( sw3, sw4 )
+ self.addLink( sw3, sw6 )
+ self.addLink( sw4, sw5 )
+ self.addLink( sw5, sw6 )
+ self.addLink( sw4, sw6 )
+
+def startsshd( host ):
+ "Start sshd on host"
+ info( '*** Starting sshd\n' )
+ name, intf, ip = host.name, host.defaultIntf(), host.IP()
+ banner = '/tmp/%s.banner' % name
+ host.cmd( 'echo "Welcome to %s at %s" > %s' % ( name, ip, banner ) )
+ host.cmd( '/usr/sbin/sshd -o "Banner %s"' % banner, '-o "UseDNS no"' )
+ info( '***', host.name, 'is running sshd on', intf, 'at', ip, '\n' )
+
+def startsshds ( hosts ):
+ for h in hosts:
+ startsshd( h )
+
+def stopsshd( ):
+ "Stop *all* sshd processes with a custom banner"
+ info( '*** Shutting down stale sshd/Banner processes ',
+ quietRun( "pkill -9 -f Banner" ), '\n' )
+
+def sdnnet(opt):
+# os.system('/home/ubuntu/openflow/controller/controller ptcp: &')
+# os.system('/home/ubuntu/openflow/controller/controller ptcp:7000 &')
+
+ topo = SDNTopo()
+ info( '*** Creating network\n' )
+# net = Mininet( topo=topo, controller=RemoteController )
+ net = Mininet( topo=topo, controller=MyController, link=TCLink)
+# dc = DebugController('c3', ip='127.0.0.1', port=7000)
+# net.addController(dc)
+# net.addController(controller=RemoteController)
+
+ host1, host2, host3, host4, host5, host6 = net.get( 'host1', 'host2', 'host3', 'host4', 'host5', 'host6')
+
+ ## Adding 2nd, 3rd and 4th interface to host1 connected to sw1 (for another BGP peering)
+ sw1 = net.get('sw1')
+ sw2 = net.get('sw2')
+ sw3 = net.get('sw3')
+ sw4 = net.get('sw4')
+ sw5 = net.get('sw5')
+ sw6 = net.get('sw6')
+
+ net.start()
+
+ sw2.attach('tap01_2')
+ sw3.attach('tap01_3')
+ sw4.attach('tap01_4')
+ sw4.attach('tap01_5')
+ sw5.attach('tap01_6')
+ sw6.attach('tap01_7')
+ sw1.attach('tap01_8')
+
+ host1.defaultIntf().setIP('192.168.100.141/16')
+ host2.defaultIntf().setIP('192.168.100.142/16')
+ host3.defaultIntf().setIP('192.168.100.143/16')
+ host4.defaultIntf().setIP('192.168.100.144/16')
+ host5.defaultIntf().setIP('192.168.100.145/16')
+ host6.defaultIntf().setIP('192.168.100.146/16')
+
+ hosts = [ host1, host2, host3, host4, host5, host6 ]
+ stopsshd ()
+ startsshds ( hosts )
+
+ if opt=="cli":
+ CLI(net)
+ stopsshd()
+ net.stop()
+
+if __name__ == '__main__':
+ setLogLevel( 'info' )
+ if len(sys.argv) == 1:
+ sdnnet("cli")
+ elif len(sys.argv) == 2 and sys.argv[1] == "-n":
+ sdnnet("nocli")
+ else:
+ print "%s [-n]" % sys.argv[0]
diff --git a/test-network/mininet/dev_network_edge.py b/test-network/mininet/dev_network_edge.py
new file mode 100755
index 0000000..29be6ad
--- /dev/null
+++ b/test-network/mininet/dev_network_edge.py
@@ -0,0 +1,155 @@
+#!/usr/bin/python
+import sys
+
+Controllers=[{"ip":"127.0.0.1", "port":6633}]
+
+"""
+Start up a Simple topology
+"""
+from mininet.net import Mininet
+from mininet.node import Controller, RemoteController
+from mininet.log import setLogLevel, info, error, warn, debug
+from mininet.cli import CLI
+from mininet.topo import Topo
+from mininet.util import quietRun
+from mininet.moduledeps import pathCheck
+from mininet.link import Link, TCLink
+
+from sys import exit
+import os.path
+from subprocess import Popen, STDOUT, PIPE
+
+import sys
+
+#import argparse
+
+class MyController( Controller ):
+ def __init__( self, name, ip='127.0.0.1', port=6633, **kwargs):
+ """Init.
+ name: name to give controller
+ ip: the IP address where the remote controller is
+ listening
+ port: the port where the remote controller is listening"""
+ Controller.__init__( self, name, ip=ip, port=port, **kwargs )
+
+ def start( self ):
+ "Overridden to do nothing."
+ return
+
+ def stop( self ):
+ "Overridden to do nothing."
+ return
+
+ def checkListening( self ):
+ "Warn if remote controller is not accessible"
+ listening = self.cmd( "echo A | telnet -e A %s %d" %
+ ( self.ip, self.port ) )
+ if 'Unable' in listening:
+ warn( "Unable to contact the remote controller"
+ " at %s:%d\n" % ( self.ip, self.port ) )
+
+class SDNTopo( Topo ):
+ "SDN Topology"
+
+ def __init__( self, *args, **kwargs ):
+ Topo.__init__( self, *args, **kwargs )
+
+ switch = []
+ host = []
+
+ for i in range (NR_NODES):
+ name_suffix = '%02d' % NWID + "." + '%02d' % (int(i)+1)
+ dpid_suffix = '%02x' % NWID + '%02x' % (int(i)+1)
+ dpid = '0000' + '0000' + '0000' + dpid_suffix
+ sw = self.addSwitch('sw'+name_suffix, dpid=dpid)
+ switch.append(sw)
+
+ for i in range (NR_NODES):
+ host.append(self.addHost( 'host%d.%d' % (NWID,int(i)+1) ))
+
+ for i in range (NR_NODES):
+ self.addLink(host[i], switch[i])
+
+ for i in range (1, NR_NODES):
+ self.addLink(switch[0], switch[i])
+
+def startsshd( host ):
+ "Start sshd on host"
+ info( '*** Starting sshd\n' )
+ name, intf, ip = host.name, host.defaultIntf(), host.IP()
+ banner = '/tmp/%s.banner' % name
+ host.cmd( 'echo "Welcome to %s at %s" > %s' % ( name, ip, banner ) )
+ host.cmd( '/usr/sbin/sshd -o "Banner %s"' % banner, '-o "UseDNS no"' )
+ info( '***', host.name, 'is running sshd on', intf, 'at', ip, '\n' )
+
+def startsshds ( hosts ):
+ for h in hosts:
+ startsshd( h )
+
+def startiperf( host ):
+ host.cmd( '/usr/bin/iperf', '-s &' )
+
+def startiperfs ( hosts ):
+ for h in hosts:
+ startiperf( h )
+
+def stopiperf( ):
+ quietRun( "pkill -9 iperf" )
+
+def stopsshd( ):
+ "Stop *all* sshd processes with a custom banner"
+ info( '*** Shutting down stale sshd/Banner processes ',
+ quietRun( "pkill -9 -f Banner" ), '\n' )
+
+def sdnnet(opt):
+ topo = SDNTopo()
+ info( '*** Creating network\n' )
+ net = Mininet( topo=topo, controller=MyController, link=TCLink)
+ #net = Mininet( topo=topo, link=TCLink, build=False)
+ #controllers=[]
+ #for c in Controllers:
+ # rc = RemoteController('c%d' % Controllers.index(c), ip=c['ip'],port=c['port'])
+ # print "controller ip %s port %s" % (c['ip'], c['port'])
+ # controllers.append(rc)
+
+ #net.controllers=controllers
+ net.build()
+
+ host = []
+ for i in range (NR_NODES):
+ host.append(net.get( 'host%d.%d' % (NWID,int(i)+1) ))
+
+ net.start()
+
+ sw=net.get('sw%02x.%02x' % (NWID,1))
+ print "center sw", sw
+ sw.attach('tap%02x_1' % NWID)
+
+ for i in range (NR_NODES):
+ host[i].defaultIntf().setIP('192.168.%d.%d/16' % (NWID,(int(i)+1)))
+ host[i].defaultIntf().setMAC('00:00:%02x:%02x:%02x:%02x' % (192,168,NWID,(int(i)+1)))
+
+ for i in range (NR_NODES):
+ for n in range (2,9):
+ for h in range (NR_NODES):
+ host[i].setARP('192.168.%d.%d' % (n, (int(h)+1)), '00:00:%02x:%02x:%02x:%02x' % (192,168,n,(int(h)+1)))
+
+ stopsshd ()
+# stopiperf ()
+ startsshds ( host )
+# startiperfs ( host )
+
+ if opt=="cli":
+ CLI(net)
+ stopsshd()
+ net.stop()
+
+if __name__ == '__main__':
+ setLogLevel( 'info' )
+ if len(sys.argv) == 3:
+ NWID=int(sys.argv[1])
+ NR_NODES=int(sys.argv[2])
+ sdnnet("nocli")
+ else:
+ print "%s <NWID> <NR_NODES>" % sys.argv[0]
+ sys.exit(1)
diff --git a/test-network/mininet/dev_network_edge_2.py b/test-network/mininet/dev_network_edge_2.py
new file mode 100755
index 0000000..50dc00c
--- /dev/null
+++ b/test-network/mininet/dev_network_edge_2.py
@@ -0,0 +1,156 @@
+#!/usr/bin/python
+import sys
+
+Controllers=[{"ip":"127.0.0.1", "port":6633}]
+
+"""
+Start up a Simple topology
+"""
+from mininet.net import Mininet
+from mininet.node import Controller, RemoteController
+from mininet.log import setLogLevel, info, error, warn, debug
+from mininet.cli import CLI
+from mininet.topo import Topo
+from mininet.util import quietRun
+from mininet.moduledeps import pathCheck
+from mininet.link import Link, TCLink
+
+from sys import exit
+import os.path
+from subprocess import Popen, STDOUT, PIPE
+
+import sys
+
+#import argparse
+
+class MyController( Controller ):
+ def __init__( self, name, ip='127.0.0.1', port=6633, **kwargs):
+ """Init.
+ name: name to give controller
+ ip: the IP address where the remote controller is
+ listening
+ port: the port where the remote controller is listening"""
+ Controller.__init__( self, name, ip=ip, port=port, **kwargs )
+
+ def start( self ):
+ "Overridden to do nothing."
+ return
+
+ def stop( self ):
+ "Overridden to do nothing."
+ return
+
+ def checkListening( self ):
+ "Warn if remote controller is not accessible"
+ listening = self.cmd( "echo A | telnet -e A %s %d" %
+ ( self.ip, self.port ) )
+ if 'Unable' in listening:
+ warn( "Unable to contact the remote controller"
+ " at %s:%d\n" % ( self.ip, self.port ) )
+
+class SDNTopo( Topo ):
+ "SDN Topology"
+
+ def __init__( self, *args, **kwargs ):
+ Topo.__init__( self, *args, **kwargs )
+
+ switch = []
+ host = []
+
+ for i in range (NR_NODES):
+ name_suffix = '%02d' % NWID + "." + '%02d' % (int(i)+1)
+ dpid_suffix = '%02x' % NWID + '%02x' % (int(i)+1)
+ dpid = '0000' + '0000' + '0000' + dpid_suffix
+ sw = self.addSwitch('sw'+name_suffix, dpid=dpid)
+ switch.append(sw)
+
+ for i in range (NR_NODES):
+ host.append(self.addHost( 'host%d.%d' % (NWID,int(i)+1) ))
+
+ for i in range (NR_NODES):
+ self.addLink(host[i], switch[i])
+
+ for i in range (1, NR_NODES):
+ self.addLink(switch[0], switch[i])
+
+def startsshd( host ):
+ "Start sshd on host"
+ info( '*** Starting sshd\n' )
+ name, intf, ip = host.name, host.defaultIntf(), host.IP()
+ banner = '/tmp/%s.banner' % name
+ host.cmd( 'echo "Welcome to %s at %s" > %s' % ( name, ip, banner ) )
+ host.cmd( '/usr/sbin/sshd -o "Banner %s"' % banner, '-o "UseDNS no"' )
+ info( '***', host.name, 'is running sshd on', intf, 'at', ip, '\n' )
+
+def startsshds ( hosts ):
+ for h in hosts:
+ startsshd( h )
+
+def startiperf( host ):
+ host.cmd( '/usr/bin/iperf', '-s &' )
+
+def startiperfs ( hosts ):
+ for h in hosts:
+ startiperf( h )
+
+def stopiperf( ):
+ quietRun( "pkill -9 iperf" )
+
+def stopsshd( ):
+ "Stop *all* sshd processes with a custom banner"
+ info( '*** Shutting down stale sshd/Banner processes ',
+ quietRun( "pkill -9 -f Banner" ), '\n' )
+
+def sdnnet(opt):
+ topo = SDNTopo()
+ info( '*** Creating network\n' )
+ net = Mininet( topo=topo, controller=MyController, link=TCLink)
+ #net = Mininet( topo=topo, link=TCLink, build=False)
+ #controllers=[]
+ #for c in Controllers:
+ # rc = RemoteController('c%d' % Controllers.index(c), ip=c['ip'],port=c['port'])
+ # print "controller ip %s port %s" % (c['ip'], c['port'])
+ # controllers.append(rc)
+
+ #net.controllers=controllers
+ net.build()
+
+ host = []
+ for i in range (NR_NODES):
+ host.append(net.get( 'host%d.%d' % (NWID,int(i)+1) ))
+
+ net.start()
+
+ sw=net.get('sw%02x.%02x' % (NWID,1))
+ print "center sw", sw
+ sw.attach('tap%02x_1' % NWID)
+ sw.attach('tap%02x_2' % NWID)
+
+ for i in range (NR_NODES):
+ host[i].defaultIntf().setIP('192.168.%d.%d/16' % (NWID,(int(i)+1)))
+ host[i].defaultIntf().setMAC('00:00:%02x:%02x:%02x:%02x' % (192,168,NWID,(int(i)+1)))
+
+ for i in range (NR_NODES):
+ for n in range (2,9):
+ for h in range (NR_NODES):
+ host[i].setARP('192.168.%d.%d' % (n, (int(h)+1)), '00:00:%02x:%02x:%02x:%02x' % (192,168,n,(int(h)+1)))
+
+ stopsshd ()
+# stopiperf ()
+ startsshds ( host )
+# startiperfs ( host )
+
+ if opt=="cli":
+ CLI(net)
+ stopsshd()
+ net.stop()
+
+if __name__ == '__main__':
+ setLogLevel( 'info' )
+ if len(sys.argv) == 3:
+ NWID=int(sys.argv[1])
+ NR_NODES=int(sys.argv[2])
+ sdnnet("nocli")
+ else:
+ print "%s <NWID> <NR_NODES>" % sys.argv[0]
+ sys.exit(1)
diff --git a/test-network/mininet/dev_network_single.py b/test-network/mininet/dev_network_single.py
new file mode 100755
index 0000000..0eb519a
--- /dev/null
+++ b/test-network/mininet/dev_network_single.py
@@ -0,0 +1,175 @@
+#!/usr/bin/python
+
+"""
+Start up a Simple topology
+"""
+from mininet.net import Mininet
+from mininet.node import Controller, RemoteController
+from mininet.log import setLogLevel, info, error, warn, debug
+from mininet.cli import CLI
+from mininet.topo import Topo
+from mininet.util import quietRun
+from mininet.moduledeps import pathCheck
+from mininet.link import Link, TCLink
+
+from sys import exit
+import os.path
+from subprocess import Popen, STDOUT, PIPE
+
+import sys
+
+NR_NODES=10 #; Switches per rigonal networks
+
+class MyController( Controller ):
+ def __init__( self, name, ip='127.0.0.1', port=6633, **kwargs):
+ """Init.
+ name: name to give controller
+ ip: the IP address where the remote controller is
+ listening
+ port: the port where the remote controller is listening"""
+ Controller.__init__( self, name, ip=ip, port=port, **kwargs )
+
+ def start( self ):
+ "Overridden to do nothing."
+ return
+
+ def stop( self ):
+ "Overridden to do nothing."
+ return
+
+ def checkListening( self ):
+ "Warn if remote controller is not accessible"
+ listening = self.cmd( "echo A | telnet -e A %s %d" %
+ ( self.ip, self.port ) )
+ if 'Unable' in listening:
+ warn( "Unable to contact the remote controller"
+ " at %s:%d\n" % ( self.ip, self.port ) )
+
+class SDNTopo( Topo ):
+ "SDN Topology"
+
+ def __init__( self, *args, **kwargs ):
+ Topo.__init__( self, *args, **kwargs )
+ sw1 = self.addSwitch('sw1', dpid='0000000000000101')
+ sw2 = self.addSwitch('sw2', dpid='0000000000000102')
+ sw3 = self.addSwitch('sw3', dpid='0000000000000103')
+ sw4 = self.addSwitch('sw4', dpid='0000000000000104')
+ sw5 = self.addSwitch('sw5', dpid='0000000000000105')
+ sw6 = self.addSwitch('sw6', dpid='0000000000000106')
+
+ self.addLink( sw1, sw2 )
+ self.addLink( sw1, sw6 )
+ self.addLink( sw2, sw3 )
+ self.addLink( sw3, sw4 )
+ self.addLink( sw3, sw6 )
+ self.addLink( sw4, sw5 )
+ self.addLink( sw5, sw6 )
+ self.addLink( sw4, sw6 )
+
+ switches=[]
+ for n in range(2, 9):
+ NWID=n
+ switch = []
+ host = []
+ for i in range (NR_NODES):
+ name_suffix = '%02d' % NWID + "." + '%02d' % (int(i)+1)
+ dpid_suffix = '%02x' % NWID + '%02x' % (int(i)+1)
+ dpid = '0000' + '0000' + '0000' + dpid_suffix
+ sw = self.addSwitch('sw'+name_suffix, dpid=dpid)
+ switch.append(sw)
+
+ for i in range (NR_NODES):
+ host.append(self.addHost( 'host%d.%d' % (n,int(i)+1) ))
+
+ for i in range (NR_NODES):
+ self.addLink(host[i], switch[i])
+
+ for i in range (1, NR_NODES):
+ self.addLink(switch[0], switch[i])
+
+ switches.append(switch)
+
+ self.addLink(switches[8-2][0],sw1)
+ self.addLink(switches[2-2][0],sw2)
+ self.addLink(switches[3-2][0],sw3)
+ self.addLink(switches[4-2][0],sw4)
+ self.addLink(switches[5-2][0],sw4)
+ self.addLink(switches[6-2][0],sw5)
+ self.addLink(switches[7-2][0],sw6)
+
+
+def startsshd( host ):
+ "Start sshd on host"
+ info( '*** Starting sshd\n' )
+ name, intf, ip = host.name, host.defaultIntf(), host.IP()
+ banner = '/tmp/%s.banner' % name
+ host.cmd( 'echo "Welcome to %s at %s" > %s' % ( name, ip, banner ) )
+ host.cmd( '/usr/sbin/sshd -o "Banner %s"' % banner, '-o "UseDNS no"' )
+ info( '***', host.name, 'is running sshd on', intf, 'at', ip, '\n' )
+
+def startsshds ( hosts ):
+ for h in hosts:
+ startsshd( h )
+
+def stopsshd( ):
+ "Stop *all* sshd processes with a custom banner"
+ info( '*** Shutting down stale sshd/Banner processes ',
+ quietRun( "pkill -9 -f Banner" ), '\n' )
+
+def sdnnet(opt):
+# os.system('/home/ubuntu/openflow/controller/controller ptcp: &')
+# os.system('/home/ubuntu/openflow/controller/controller ptcp:7000 &')
+
+ topo = SDNTopo()
+ info( '*** Creating network\n' )
+# net = Mininet( topo=topo, controller=RemoteController )
+ net = Mininet( topo=topo, controller=MyController, link=TCLink)
+# dc = DebugController('c3', ip='127.0.0.1', port=7000)
+# net.addController(dc)
+# net.addController(controller=RemoteController)
+# host1, host2, host3, host4, host5, host6 = net.get( 'host1', 'host2', 'host3', 'host4', 'host5', 'host6')
+
+ ## Adding 2nd, 3rd and 4th interface to host1 connected to sw1 (for another BGP peering)
+ sw1 = net.get('sw1')
+ sw2 = net.get('sw2')
+ sw3 = net.get('sw3')
+ sw4 = net.get('sw4')
+ sw5 = net.get('sw5')
+ sw6 = net.get('sw6')
+
+ hosts = []
+ for n in range(2, 9):
+ host = []
+ for i in range (NR_NODES):
+ host.append(net.get( 'host%d.%d' % (n, int(i)+1) ))
+ hosts.append(host)
+
+ net.start()
+
+ for n in range(2, 9):
+ for i in range (NR_NODES):
+ hosts[n-2][i].defaultIntf().setIP('192.168.%d.%d/16' % (n,(int(i)+1)))
+ hosts[n-2][i].defaultIntf().setMAC('00:00:%02x:%02x:%02x:%02x' % (192,168,n,(int(i)+1)))
+
+ for i in range (NR_NODES):
+ for k in range (2,9):
+ for h in range (NR_NODES):
+ hosts[n-2][i].setARP('192.168.%d.%d' % (k, (int(h)+1)), '00:00:%02x:%02x:%02x:%02x' % (192,168,k,(int(h)+1)))
+
+ stopsshd ()
+ for n in range(2, 9):
+ startsshds ( hosts[n-2] )
+
+ if opt=="cli":
+ CLI(net)
+ stopsshd()
+ net.stop()
+
+if __name__ == '__main__':
+ setLogLevel( 'info' )
+ if len(sys.argv) == 1:
+ sdnnet("cli")
+ elif len(sys.argv) == 2 and sys.argv[1] == "-n":
+ sdnnet("nocli")
+ else:
+ print "%s [-n]" % sys.argv[0]
diff --git a/test-network/mininet/dev_network_tunnel_1.sh b/test-network/mininet/dev_network_tunnel_1.sh
new file mode 100755
index 0000000..4f9767f
--- /dev/null
+++ b/test-network/mininet/dev_network_tunnel_1.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+onosdev1=192.168.56.11
+onosdev2=192.168.56.12
+onosdev3=192.168.56.13
+onosdev4=192.168.56.14
+
+dir=`dirname $0`
+TUNNEL=("2 2 onosdev2" "3 3 onosdev3" "4 4 onosdev4" "5 5 onosdev2")
+NW_ID=01
+
+start () {
+ ## Modify ##
+ ulimit -c
+ for (( i = 0; i< ${#TUNNEL[@]}; i ++)); do
+ t=`echo ${TUNNEL[$i]}`
+ ifnr=`echo $t | awk '{print $1}'`
+ tun_tag=`echo $t | awk '{print $2}'`
+ tun_end_=`echo $t | awk '{print $3}'`
+ tun_end=`eval echo '$'$tun_end_`
+ echo "ifconfig tap${NW_ID}_${ifnr}"
+ ifconfig tap${NW_ID}_${ifnr}
+ if [ $? -ne 0 ]; then
+ echo "creating tap${NW_ID}_${ifnr}"
+ sudo tunctl -t tap${NW_ID}_${ifnr}
+ fi
+ echo "$dir/capsulator -v -d -t eth1 -f ${tun_end} -vb tap${NW_ID}_${ifnr}#${tun_tag}"
+ sudo ifconfig tap${NW_ID}_${ifnr} 0.0.0.0 up > /dev/null 2>&1
+ sudo $dir/capsulator -v -d -t eth1 -f ${tun_end} -vb tap${NW_ID}_${ifnr}#${tun_tag} > /dev/null 2>&1 &
+ done
+}
+
+stop () {
+ sudo pkill capsulator
+}
+
+case "$1" in
+ start | restart)
+ stop
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ status)
+ nr=`pgrep capsulator | wc -l`
+ if [ $nr -gt 0 ]; then
+ echo "$nr tunnel(s) is running"
+ else
+ echo "tunnel is not running"
+ fi
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|status}" >&2
+ exit 1
+ ;;
+esac
diff --git a/test-network/mininet/dev_network_tunnel_2.sh b/test-network/mininet/dev_network_tunnel_2.sh
new file mode 100755
index 0000000..d183d88
--- /dev/null
+++ b/test-network/mininet/dev_network_tunnel_2.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+onosdev1=192.168.56.11
+onosdev2=192.168.56.12
+onosdev3=192.168.56.13
+onosdev4=192.168.56.14
+
+dir=`dirname $0`
+
+TUNNEL=("1 2 onosdev1" "2 5 onosdev1")
+NW_ID=02
+
+start () {
+ ## Modify ##
+ ulimit -c
+ for (( i = 0; i< ${#TUNNEL[@]}; i ++)); do
+ t=`echo ${TUNNEL[$i]}`
+ ifnr=`echo $t | awk '{print $1}'`
+ tun_tag=`echo $t | awk '{print $2}'`
+ tun_end_=`echo $t | awk '{print $3}'`
+ tun_end=`eval echo '$'$tun_end_`
+ echo "ifconfig tap${NW_ID}_${ifnr}"
+ ifconfig tap${NW_ID}_${ifnr}
+ if [ $? -ne 0 ]; then
+ echo "creating tap${NW_ID}_${ifnr}"
+ sudo tunctl -t tap${NW_ID}_${ifnr}
+ fi
+ echo "$dir/capsulator -v -d -t eth1 -f ${tun_end} -vb tap${NW_ID}_${ifnr}#${tun_tag}"
+ sudo ifconfig tap${NW_ID}_${ifnr} 0.0.0.0 up > /dev/null 2>&1
+ sudo $dir/capsulator -v -d -t eth1 -f ${tun_end} -vb tap${NW_ID}_${ifnr}#${tun_tag} > /dev/null 2>&1 &
+ done
+}
+
+stop () {
+ sudo pkill capsulator
+}
+
+case "$1" in
+ start | restart)
+ stop
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ status)
+ nr=`pgrep capsulator | wc -l`
+ if [ $nr -gt 0 ]; then
+ echo "$nr tunnel(s) is running"
+ else
+ echo "tunnel is not running"
+ fi
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|status}" >&2
+ exit 1
+ ;;
+esac
diff --git a/test-network/mininet/dev_network_tunnel_3.sh b/test-network/mininet/dev_network_tunnel_3.sh
new file mode 100755
index 0000000..a74a53b
--- /dev/null
+++ b/test-network/mininet/dev_network_tunnel_3.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+onosdev1=192.168.56.11
+onosdev2=192.168.56.12
+onosdev3=192.168.56.13
+onosdev4=192.168.56.14
+
+dir=`dirname $0`
+
+TUNNEL=("1 3 onosdev1")
+NW_ID=03
+
+start () {
+ ## Modify ##
+ ulimit -c
+ for (( i = 0; i< ${#TUNNEL[@]}; i ++)); do
+ t=`echo ${TUNNEL[$i]}`
+ ifnr=`echo $t | awk '{print $1}'`
+ tun_tag=`echo $t | awk '{print $2}'`
+ tun_end_=`echo $t | awk '{print $3}'`
+ tun_end=`eval echo '$'$tun_end_`
+ echo "ifconfig tap${NW_ID}_${ifnr}"
+ ifconfig tap${NW_ID}_${ifnr}
+ if [ $? -ne 0 ]; then
+ echo "creating tap${NW_ID}_${ifnr}"
+ sudo tunctl -t tap${NW_ID}_${ifnr}
+ fi
+ echo "$dir/capsulator -v -d -t eth1 -f ${tun_end} -vb tap${NW_ID}_${ifnr}#${tun_tag}"
+ sudo ifconfig tap${NW_ID}_${ifnr} 0.0.0.0 up > /dev/null 2>&1
+ sudo $dir/capsulator -v -d -t eth1 -f ${tun_end} -vb tap${NW_ID}_${ifnr}#${tun_tag} > /dev/null 2>&1 &
+ done
+}
+
+stop () {
+ sudo pkill capsulator
+}
+
+case "$1" in
+ start | restart)
+ stop
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ status)
+ nr=`pgrep capsulator | wc -l`
+ if [ $nr -gt 0 ]; then
+ echo "$nr tunnel(s) is running"
+ else
+ echo "tunnel is not running"
+ fi
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|status}" >&2
+ exit 1
+ ;;
+esac
diff --git a/test-network/mininet/dev_network_tunnel_4.sh b/test-network/mininet/dev_network_tunnel_4.sh
new file mode 100755
index 0000000..1367b75
--- /dev/null
+++ b/test-network/mininet/dev_network_tunnel_4.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+onosdev1=192.168.56.11
+onosdev2=192.168.56.12
+onosdev3=192.168.56.13
+onosdev4=192.168.56.14
+
+dir=`dirname $0`
+
+TUNNEL=("1 4 onosdev1")
+NW_ID=04
+
+start () {
+ ## Modify ##
+ ulimit -c
+ for (( i = 0; i< ${#TUNNEL[@]}; i ++)); do
+ t=`echo ${TUNNEL[$i]}`
+ ifnr=`echo $t | awk '{print $1}'`
+ tun_tag=`echo $t | awk '{print $2}'`
+ tun_end_=`echo $t | awk '{print $3}'`
+ tun_end=`eval echo '$'$tun_end_`
+ echo "ifconfig tap${NW_ID}_${ifnr}"
+ ifconfig tap${NW_ID}_${ifnr}
+ if [ $? -ne 0 ]; then
+ echo "creating tap${NW_ID}_${ifnr}"
+ sudo tunctl -t tap${NW_ID}_${ifnr}
+ fi
+ echo "$dir/capsulator -v -d -t eth1 -f ${tun_end} -vb tap${NW_ID}_${ifnr}#${tun_tag}"
+ sudo ifconfig tap${NW_ID}_${ifnr} 0.0.0.0 up > /dev/null 2>&1
+ sudo $dir/capsulator -v -d -t eth1 -f ${tun_end} -vb tap${NW_ID}_${ifnr}#${tun_tag} > /dev/null 2>&1 &
+ done
+}
+
+stop () {
+ sudo pkill capsulator
+}
+
+case "$1" in
+ start | restart)
+ stop
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ status)
+ nr=`pgrep capsulator | wc -l`
+ if [ $nr -gt 0 ]; then
+ echo "$nr tunnel(s) is running"
+ else
+ echo "tunnel is not running"
+ fi
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|status}" >&2
+ exit 1
+ ;;
+esac