def initWithParams(numberOfSpines, numberOfLeafs): topo = clos(numberOfSpines, numberOfLeafs) net = Mininet(topo=topo, controller=OVSController, switch=STPSwitch) net.start() dumpNodeConnections(net.values()) CLI(net) net.stop()
def main(): behavioral_model = os.path.join(sys.path[0], '../targets/switch/behavioral-model') topo = SingleSwitchTopo(behavioral_model) net = Mininet(topo=topo, host=P4Host, switch=OpenflowEnabledP4Switch, controller=None) net.start() h1 = net.get('h1') h1.setARP("10.0.0.1", "00:aa:bb:00:00:00") h1.setDefaultRoute("dev eth0 via 10.0.0.1") h1.describe() h2 = net.get('h2') h2.setARP("10.0.1.1", "00:aa:bb:00:00:01") h2.setDefaultRoute("dev eth0 via 10.0.1.1") h2.describe() configure_switch() time.sleep(1) print "Ready !" result = 0 if parser_args.cli: CLI(net) else: time.sleep(3) node_values = net.values() print node_values hosts = net.hosts print hosts # ping hosts print "PING BETWEEN THE HOSTS" result = net.ping(hosts, 30) # print host arp table & routes for host in hosts: print "ARP ENTRIES ON HOST" print host.cmd('arp -n') print "HOST ROUTES" print host.cmd('route') print "HOST INTERFACE LIST" intfList = host.intfNames() print intfList if result != 0: print "PING FAILED BETWEEN HOSTS %s" % (hosts) else: print "PING SUCCESSFUL!!!" net.stop() return result
def main(): behavioral_model = os.path.join(sys.path[0], '../targets/switch/behavioral-model') topo = SingleSwitchTopo(behavioral_model) net = Mininet(topo=topo, host=P4Host, switch=OpenflowEnabledP4Switch, controller=None ) net.start() h1 = net.get('h1') h1.setARP("10.0.0.1", "00:aa:bb:00:00:00") h1.setDefaultRoute("dev eth0 via 10.0.0.1") h1.describe() h2 = net.get('h2') h2.setARP("10.0.1.1", "00:aa:bb:00:00:01") h2.setDefaultRoute("dev eth0 via 10.0.1.1") h2.describe() configure_switch() time.sleep(1) print "Ready !" result = 0 if parser_args.cli: CLI( net ) else: time.sleep(3) node_values = net.values() print node_values hosts = net.hosts print hosts # ping hosts print "PING BETWEEN THE HOSTS" result = net.ping(hosts,30) # print host arp table & routes for host in hosts: print "ARP ENTRIES ON HOST" print host.cmd('arp -n') print "HOST ROUTES" print host.cmd('route') print "HOST INTERFACE LIST" intfList = host.intfNames() print intfList if result != 0: print "PING FAILED BETWEEN HOSTS %s" % (hosts) else: print "PING SUCCESSFUL!!!" net.stop() return result
def main(): lg.setLogLevel('debug') context = Context() if not get_cmd_line_args(context): return print 'Starting with [%s] switches' % context.switch_number # Create the topology with the context args taken from the cmd-line myTopo = create_topology(context) # The network myNet = Mininet(myTopo, switch=MultiSwitch) # The SDN-remote_controller connection mySDNController = myNet.addController( context.remote_controller_name, customClass({'remote': RemoteController}, context.remote_controller_args)) myLocalController = myNet.addController('c1', controller=OVSController) # myLocalController.start() dump_hosts(myNet) # This will output the nodes port connections to MININET_NET_FILE dumpNodeConnections(myNet.values()) # This will output the nodes port connections to MININET_DUMP_FILE dumpNodes(myNet.values()) # start_gateways(myNet) #start_switches(context, myNet, mySDNController, myLocalController) myNet.start() # Insert ovs-ofctl rules print 'Inserting flows into the switches...' init_flows(context) # Start the command line CLI(myNet) cleanup()
def main(): lg.setLogLevel('info') context = Context() if not get_cmd_line_args(context): return print 'Starting with [%s] switches' % context.switch_number # Create the topology with the context args taken from the cmd-line myTopo = create_topology(context) # The network myNet = Mininet(myTopo) # The SDN-remote_controller connection mySDNController = myNet.addController( context.remote_controller_name, customConstructor({'remote': RemoteController}, context.remote_controller_args)) myLocalController = myNet.addController('c1', controller=OVSController) myLocalController.start() dump_hosts(myNet) # This will output the nodes port connections to MININET_NET_FILE dumpNodeConnections(myNet.values()) # This will output the nodes port connections to MININET_DUMP_FILE dumpNodes(myNet.values()) # start_gateways(myNet) start_switches(context, myNet, mySDNController, myLocalController) # Insert ovs-ofctl rules print 'Inserting flows into the switches...' init_flows(context) # Start the command line CLI(myNet) cleanup()
def main(): net = Mininet(controller=None) sw1 = net.addSwitch('sw1', cls=P4DockerSwitch, target_name="p4openflowswitch", start_program="/bin/bash") h1 = net.addHost('h1', ip='10.0.0.1', mac='00:04:00:00:00:02') h2 = net.addHost('h2', ip='10.0.0.2', mac='00:05:00:00:00:02') # add links if StrictVersion(VERSION) <= StrictVersion('2.2.0'): net.addLink(sw1, h1, port1=1) net.addLink(sw1, h2, port1=2) else: net.addLink(sw1, h1, port1=1, fast=False) net.addLink(sw1, h2, port1=2, fast=False) sw1.execProgram("/switch/docker/startup.sh", args="--of-ip %s" % parser_args.controller_ip) time.sleep(1) net.start() print "Ready !" result = 0 time.sleep(3) if parser_args.cli: CLI(net) else: node_values = net.values() print node_values hosts = net.hosts print hosts # ping hosts print "PING BETWEEN THE HOSTS" result = net.ping(hosts, 30) if result != 0: print "PING FAILED BETWEEN HOSTS %s" % (hosts) else: print "PING SUCCESSFUL!!!" net.stop() return result
def main(): net = Mininet( controller=None ) sw1 = net.addSwitch( 'sw1', cls=P4DockerSwitch, target_name="p4openflowswitch", start_program="/bin/bash") h1 = net.addHost( 'h1', ip = '10.0.0.1', mac = '00:04:00:00:00:02' ) h2 = net.addHost( 'h2', ip = '10.0.0.2', mac = '00:05:00:00:00:02' ) # add links if StrictVersion(VERSION) <= StrictVersion('2.2.0') : net.addLink( sw1, h1, port1 = 1 ) net.addLink( sw1, h2, port1 = 2 ) else: net.addLink( sw1, h1, port1 = 1, fast=False ) net.addLink( sw1, h2, port1 = 2, fast=False ) sw1.execProgram("/switch/docker/startup.sh", args="--of-ip %s" % parser_args.controller_ip) time.sleep(1) net.start() print "Ready !" result = 0 time.sleep(3) if parser_args.cli: CLI(net) else: node_values = net.values() print node_values hosts = net.hosts print hosts # ping hosts print "PING BETWEEN THE HOSTS" result = net.ping(hosts,30) if result != 0: print "PING FAILED BETWEEN HOSTS %s" % (hosts) else: print "PING SUCCESSFUL!!!" net.stop() return result
def test_verifying_mininet_hosts_in_onos_controller(self,switches=4): try: topo = LinearTopo(switches) net = Mininet( topo=topo) net.start() ctrl = net.addController( 'onos', controller=RemoteController, ip=self.controller, port=6653) for switch in net.switches: switch.start( [ctrl] ) log.info('mininet all the devices IDs %s'%net.keys()) log.info('mininet all the devices details %s'%net.values()) log.info('mininet all the devices information %s'%net.items()) response = net.pingAll() log.info('pingAll response is %s'%response) assert_equal(response, 0.0) self.cliEnter() hosts = json.loads(self.cli.hosts(jsonFormat = True)) log.info('Discovered hosts: %s' %hosts) assert_equal(len(hosts),switches) self.cliExit() except Exception as Error: log.info('Got unexpected error %s while creating topology'%Error) Cleanup.cleanup() raise Cleanup.cleanup()
def main(cli=0): net = Mininet( controller = None ) # add hosts h1 = net.addHost( 'h1', ip = '172.16.101.5/24', mac = '00:04:00:00:00:02' ) h2 = net.addHost( 'h2', ip = '172.16.102.5/24', mac = '00:05:00:00:00:02' ) # add switch 1 sw1 = net.addSwitch( 'sw1', target_name = "p4dockerswitch", cls = P4DockerSwitch, config_fs = 'configs/sw1/l3_bgp', pcap_dump = True ) # add switch 2 sw2 = net.addSwitch( 'sw2', target_name = "p4dockerswitch", cls = P4DockerSwitch, config_fs = 'configs/sw2/l3_bgp', pcap_dump = True ) # add links if StrictVersion(VERSION) <= StrictVersion('2.2.0') : net.addLink( sw1, h1, port1 = 1 ) net.addLink( sw1, sw2, port1 = 2, port2 = 2 ) net.addLink( sw2, h2, port1 = 1 ) else: net.addLink( sw1, h1, port1 = 1, fast=False ) net.addLink( sw1, sw2, port1 = 2, port2 = 2, fast=False ) net.addLink( sw2, h2, port1 = 1, fast=False ) net.start() # configure hosts h1.setDefaultRoute( 'via 172.16.101.1' ) h2.setDefaultRoute( 'via 172.16.102.1' ) sw1.cmd( 'service quagga start') sw2.cmd( 'service quagga start') result = 0 if cli: CLI( net ) else: sleep(30) node_values = net.values() print node_values hosts = net.hosts print hosts # ping hosts print "PING BETWEEN THE HOSTS" result = net.ping(hosts,30) # print host arp table & routes for host in hosts: print "ARP ENTRIES ON HOST" print host.cmd('arp -n') print "HOST ROUTES" print host.cmd('route') print "HOST INTERFACE LIST" intfList = host.intfNames() print intfList if result != 0: print "PING FAILED BETWEEN HOSTS %s" % (hosts) else: print "PING SUCCESSFUL!!!" net.stop() return result
cmd = "ethtool -K {} tx off sg off tso off" cmd = cmd.format(intf.name) intf.node.cmd(cmd) ## configure interfaces if args.one_direction: dynamic_interfaces = (links[1].intf1, links[4].intf1) else: dynamic_interfaces = (links[1].intf1, links[1].intf2, links[4].intf1, links[4].intf2) static_interfaces = (links[0].intf1, links[0].intf2, links[5].intf1, links[5].intf2) for node in net.values(): if isinstance(node, OVSController): print("Not configuring interfaces of controller") continue for intf in node.intfList(): if intf in dynamic_interfaces: print("Configuring dynamic intf {} from {}".format(intf, node)) intf.config(**dynamic_intfops) elif intf in static_interfaces: print("Configuring static intf {} from {}".format(intf, node)) intf.config(**static_intfops) else: print("Not configuring intf {} from {}".format(intf, node))
def main(cli=0): net = Mininet(controller=None) # add hosts h1 = net.addHost('h1', ip='172.16.10.1/24') h2 = net.addHost('h2', ip='172.16.10.2/24') # add switch 1 sw1 = net.addSwitch('sw1', target_name="p4dockerswitch", cls=P4DockerSwitch, config_fs='configs/sw1/l2', pcap_dump=True) # add switch 2 sw2 = net.addSwitch('sw2', target_name="p4dockerswitch", cls=P4DockerSwitch, config_fs='configs/sw2/l2', pcap_dump=True) # add links if StrictVersion(VERSION) <= StrictVersion('2.2.0'): net.addLink(sw1, h1, port1=1) net.addLink(sw1, sw2, port1=2, port2=2) net.addLink(sw2, h2, port1=1) else: net.addLink(sw1, h1, port1=1, fast=False) net.addLink(sw1, sw2, port1=2, port2=2, fast=False) net.addLink(sw2, h2, port1=1, fast=False) net.start() result = 0 if cli: CLI(net) else: sleep(3) node_values = net.values() print node_values hosts = net.hosts print hosts # ping hosts print "PING BETWEEN THE HOSTS" result = net.ping(hosts, 30) # print host arp table & routes for host in hosts: print "ARP ENTRIES ON HOST" print host.cmd('arp -n') print "HOST ROUTES" print host.cmd('route') print "HOST INTERFACE LIST" intfList = host.intfNames() print intfList if result != 0: print "PING FAILED BETWEEN HOSTS %s" % (hosts) else: print "PING SUCCESSFUL!!!" net.stop() return result
def main(cli=0): net = Mininet( controller = None ) # add hosts h1 = net.addHost( 'h1', ip = '172.16.101.5/24', mac = '00:04:00:00:00:02' ) h2 = net.addHost( 'h2', ip = '172.18.101.5/24', mac = '00:04:00:00:00:03' ) h3 = net.addHost( 'h3', ip = '172.16.102.5/24', mac = '00:05:00:00:00:02' ) h4 = net.addHost( 'h4', ip = '172.18.102.5/24', mac = '00:05:00:00:00:03' ) # add switch 1 - spine 1 sw1 = net.addSwitch( 'sw1', target_name = "p4sonicswitch", cls = P4DockerSwitch, config_fs = 'configs/sw1/l3_bgp', pcap_dump = True, start_program='/bin/bash') # add switch 2 - spine 2 sw2 = net.addSwitch( 'sw2', target_name = "p4sonicswitch", cls = P4DockerSwitch, config_fs = 'configs/sw2/l3_bgp', pcap_dump = True, start_program='/bin/bash') # add switch 3 - leaf 1 sw3 = net.addSwitch( 'sw3', target_name = "p4sonicswitch", cls = P4DockerSwitch, config_fs = 'configs/sw3/l3_bgp', pcap_dump = True, start_program='/bin/bash') # add switch 4 - leaf 2 sw4 = net.addSwitch( 'sw4', target_name = "p4sonicswitch", cls = P4DockerSwitch, config_fs = 'configs/sw4/l3_bgp', pcap_dump = True, start_program='/bin/bash') # add links if StrictVersion(VERSION) <= StrictVersion('2.2.0') : net.addLink( sw3, h1, port1 = 1 ) net.addLink( sw3, h2, port1 = 2 ) net.addLink( sw1, sw3, port1 = 1, port2 = 3 ) net.addLink( sw2, sw3, port1 = 1, port2 = 4 ) net.addLink( sw4, h3, port1 = 1 ) net.addLink( sw4, h4, port1 = 2 ) net.addLink( sw1, sw4, port1 = 2, port2 = 3 ) net.addLink( sw2, sw4, port1 = 2, port2 = 4 ) else: net.addLink( sw3, h1, port1 = 1 , fast=False ) net.addLink( sw3, h2, port1 = 2 , fast=False ) net.addLink( sw1, sw3, port1 = 1, port2 = 3 , fast=False ) net.addLink( sw2, sw3, port1 = 1, port2 = 4 , fast=False ) net.addLink( sw4, h3, port1 = 1 , fast=False ) net.addLink( sw4, h4, port1 = 2 , fast=False ) net.addLink( sw1, sw4, port1 = 2, port2 = 3 , fast=False ) net.addLink( sw2, sw4, port1 = 2, port2 = 4 , fast=False ) sw1.cpFile('run_bm_sw1.sh', '/sonic-swss/bmv2/run_bm.sh') sw1.execProgram('/scripts/startup.sh', args='-m 00:00:01:00:00:01') sw1.execProgram("/configs/startup_config.sh") sw2.cpFile('run_bm_sw2.sh', '/sonic-swss/bmv2/run_bm.sh') sw2.execProgram('/scripts/startup.sh', args='-m 00:00:01:00:00:02') sw2.execProgram("/configs/startup_config.sh") sw3.cpFile('run_bm_sw3.sh', '/sonic-swss/bmv2/run_bm.sh') sw3.execProgram('/scripts/startup.sh', args='-m 00:00:01:00:00:03') sw3.execProgram("/configs/startup_config.sh") sw4.cpFile('run_bm_sw4.sh', '/sonic-swss/bmv2/run_bm.sh') sw4.execProgram('/scripts/startup.sh', args='-m 00:00:01:00:00:04') sw4.execProgram("/configs/startup_config.sh") net.start() # hosts configuration - ipv4 h1.setDefaultRoute( 'via 172.16.101.1' ) h2.setDefaultRoute( 'via 172.18.101.1' ) h3.setDefaultRoute( 'via 172.16.102.1' ) h4.setDefaultRoute( 'via 172.18.102.1' ) sw1.cmd( 'service quagga start') sw2.cmd( 'service quagga start') sw3.cmd( 'service quagga start') sw4.cmd( 'service quagga start') result = 0 if cli: CLI(net) else: sleep(90) node_values = net.values() print node_values hosts = net.hosts print hosts # ping hosts print "PING BETWEEN THE HOSTS" result = net.ping(hosts,30) if result != 0: print "PING FAILED BETWEEN HOSTS %s" % (hosts) else: print "PING SUCCESSFUL!!!" # print host arp table & routes for host in hosts: print "ARP ENTRIES ON HOST" print host.cmd('arp -n') print "HOST ROUTES" print host.cmd('route') print "HOST INTERFACE LIST" intfList = host.intfNames() print intfList net.stop() return result
def main(cli=0, ipv6=0): net = Mininet( controller = None ) # add hosts h1 = net.addHost( 'h1', ip = '172.16.101.5/24', mac = '00:04:00:00:00:02' ) h2 = net.addHost( 'h2', ip = '172.16.102.5/24', mac = '00:05:00:00:00:02' ) # add switch 1 sw1 = net.addSwitch( 'sw1', target_name = "p4dockerswitch", cls = P4DockerSwitch, config_fs = 'configs/sw1/l3_ospf', pcap_dump = True ) # add switch 2 sw2 = net.addSwitch( 'sw2', target_name = "p4dockerswitch", cls = P4DockerSwitch, config_fs = 'configs/sw2/l3_ospf', pcap_dump = True ) # add links if StrictVersion(VERSION) <= StrictVersion('2.2.0') : net.addLink( sw1, h1, port1 = 1 ) net.addLink( sw1, sw2, port1 = 2, port2 = 2 ) net.addLink( sw2, h2, port1 = 1 ) else: net.addLink( sw1, h1, port1 = 1, fast=False ) net.addLink( sw1, sw2, port1 = 2, port2 = 2, fast=False ) net.addLink( sw2, h2, port1 = 1, fast=False ) net.start() # hosts configuration - ipv4 h1.setDefaultRoute( 'via 172.16.101.1' ) h2.setDefaultRoute( 'via 172.16.102.1' ) if ipv6: # hosts configuration - ipv6 h1.setIP6( '2ffe:0101::5', 64, 'h1-eth0' ) h2.setIP6( '2ffe:0102::5', 64, 'h2-eth0' ) h1.setDefaultRoute( 'via 2ffe:0101::1', True ) h2.setDefaultRoute( 'via 2ffe:0102::1', True ) sw1.cmd( 'service quagga start') sw2.cmd( 'service quagga start') result = 0 if cli: CLI( net ) else: sleep(60) node_values = net.values() print node_values hosts = net.hosts print hosts # ping hosts print "PING BETWEEN THE HOSTS" result = net.ping(hosts,30) if result != 0: print "PING FAILED BETWEEN HOSTS %s" % (hosts) else: print "PING SUCCESSFUL!!!" if ipv6: print "PING6 BETWEEN THE HOSTS" result = net.ping6(hosts, 30) if result != 0: print "PING6 FAILED BETWEEN HOSTS %s" % (hosts) else: print "PING6 SUCCESSFUL!!!" # print host arp table & routes for host in hosts: print "ARP ENTRIES ON HOST" print host.cmd('arp -n') print "HOST ROUTES" print host.cmd('route') print "HOST INTERFACE LIST" intfList = host.intfNames() print intfList net.stop() return result
def main(cli=0): net = Mininet( controller = None ) # add hosts h1 = net.addHost( 'h1', ip = '172.16.10.1/24' ) h2 = net.addHost( 'h2', ip = '172.16.10.2/24' ) # add switch 1 sw1 = net.addSwitch( 'sw1', target_name = "p4dockerswitch", cls = P4DockerSwitch, config_fs = 'configs/sw1/stp', pcap_dump = True ) # add switch 2 sw2 = net.addSwitch( 'sw2', target_name = "p4dockerswitch", cls = P4DockerSwitch, config_fs = 'configs/sw2/stp', pcap_dump = True ) # add switch 3 sw3 = net.addSwitch( 'sw3', target_name = "p4dockerswitch", cls = P4DockerSwitch, config_fs = 'configs/sw3/stp', pcap_dump = True ) # add switch 4 sw4 = net.addSwitch( 'sw4', target_name = "p4dockerswitch", cls = P4DockerSwitch, config_fs = 'configs/sw4/stp', pcap_dump = True ) # add links if StrictVersion(VERSION) <= StrictVersion('2.2.0') : net.addLink( sw1, h1, port1 = 1 ) net.addLink( sw2, h2, port1 = 1 ) net.addLink( sw1, sw3, port1 = 2, port2 = 1 ) net.addLink( sw1, sw4, port1 = 3, port2 = 1 ) net.addLink( sw2, sw3, port1 = 2, port2 = 2 ) net.addLink( sw2, sw4, port1 = 3, port2 = 2 ) net.addLink( sw3, sw4, port1 = 3, port2 = 3 ) else: net.addLink( sw1, h1, port1 = 1, fast = False ) net.addLink( sw2, h2, port1 = 1, fast = False ) net.addLink( sw1, sw3, port1 = 2, port2 = 1, fast = False ) net.addLink( sw1, sw4, port1 = 3, port2 = 1, fast = False ) net.addLink( sw2, sw3, port1 = 2, port2 = 2, fast = False ) net.addLink( sw2, sw4, port1 = 3, port2 = 2, fast = False ) net.addLink( sw3, sw4, port1 = 3, port2 = 3, fast = False ) net.start() result = 0 if cli: CLI( net ) else: sleep(30) node_values = net.values() print node_values hosts = net.hosts print hosts print "PING BETWEEN THE HOSTS" result = net.ping(hosts, 30) # print host arp table & routes for host in hosts: print "ARP ENTRIES ON HOST" print host.cmd('arp -n') print "HOST ROUTES" print host.cmd('route') print "HOST INTERFACE LIST" intfList = host.intfNames() print intfList if result != 0: print "PING FAILED BETWEEN HOSTS %s" % (hosts) else: print "PING SUCCESSFUL!!!" net.stop() return result