def main(args): if not args.onos_ip: controller = ONOSCluster('c0', 3) onosIp = controller.nodes()[0].IP() else: controller = RemoteController('c0', ip=args.onos_ip) onosIp = args.onos_ip topo = ClosTopo(args) net = Mininet(topo=topo, build=False, controller=[controller]) net.build() collectorIntf = Intf('veth_1', node=net.nameToNode["s12"]) net.start() print "Network started" # Always generate background pings. sleep(3) for (h1, h2) in combinations(net.hosts, 2): h1.startPingBg(h2) h2.startPingBg(h1) print "Background ping started" # Increase the MTU size for INT operation if args.pipeconf_id.endswith("int") or args.pipeconf_id.endswith("full"): setMTU(net, JUMBO_MTU) for h in net.hosts: h.startIperfServer() print "Iperf servers started" if args.bg_traffic: sleep(4) print "Starting iperf clients..." net.hosts[0].startIperfClient(net.hosts[-1], flowBw="400k", numFlows=50, duration=10) generateNetcfg(onosIp, net, args) if args.netcfg_sleep > 0: print "Waiting %d seconds before pushing config to ONOS..." \ % args.netcfg_sleep sleep(args.netcfg_sleep) print "Pushing config to ONOS..." call(("%s/onos-netcfg" % RUN_PACK_PATH, onosIp, TEMP_NETCFG_FILE)) if not args.onos_ip: ONOSCLI(net) else: CLI(net) net.stop() call(("rm", "-f", TEMP_NETCFG_FILE))
def main(args): if not args.onos_ip: controller = ONOSCluster('c0', 3) onosIp = controller.nodes()[0].IP() else: controller = RemoteController('c0', ip=args.onos_ip) onosIp = args.onos_ip topo = ClosTopo(args) net = Mininet(topo=topo, build=False, controller=[controller]) net.build() # Add an interface that the collector is connected to collectorIntf1 = Intf('veth_11', node=net.nameToNode["s11"]) collectorIntf2 = Intf('veth_21', node=net.nameToNode["s12"]) net.start() print "Network started" # Always generate background pings. sleep(3) for (h1, h2) in combinations(net.hosts, 2): h1.startPingBg(h2) h2.startPingBg(h1) print "Background ping started" for h in net.hosts: h.startIperfServer() print "Iperf servers started" if args.bg_traffic: sleep(4) print "Starting iperf clients..." for (h1, h2) in combinations(net.hosts, 2): h1.startIperfClient(h2, flowBw="10k", numFlows=10, duration=999999) h2.startIperfClient(h1, flowBw="10k", numFlows=10, duration=999999) generateNetcfg(onosIp, net, args) if args.netcfg_sleep > 0: print "Waiting %d seconds before pushing config to ONOS..." \ % args.netcfg_sleep sleep(args.netcfg_sleep) print "Pushing config to ONOS..." call(("%s/onos-netcfg" % RUN_PACK_PATH, onosIp, TEMP_NETCFG_FILE)) if not args.onos_ip: ONOSCLI(net) else: CLI(net) net.stop() call(("rm", "-f", TEMP_NETCFG_FILE))
def main(args): topo = ClosTopo() if not args.onos_ip: controller = ONOSCluster('c0', 3) onosIp = controller.nodes()[0].IP() else: controller = RemoteController('c0', ip=args.onos_ip, port=args.onos_port) onosIp = args.onos_ip net = Mininet(topo=topo, build=False, controller=[controller]) print net.switches net.build() switch = net.switches[0] Intf( 'eth0', node=switch ) print net.switches net.start() print "Network started" ''' # Generate background traffic. sleep(3) for (h1, h2) in combinations(net.hosts, 2): h1.startPingBg(h2) h2.startPingBg(h1) print "Background ping started" ''' for h in net.hosts: h.startIperfServer() print "Iperf servers started" # sleep(4) # print "Starting traffic from h1 to h3..." # net.hosts[0].startIperfClient(net.hosts[-1], flowBw="200k", numFlows=100, duration=10) print "Setting netcfg..." call(("onos-netcfg", onosIp, "%s/tools/test/topos/simple-cfg.json" % ONOS_ROOT)) if not args.onos_ip: ONOSCLI(net) else: CLI(net) net.stop()
def main(args): if not args.onos_ip: controller = ONOSCluster('c0', 3) onosIp = controller.nodes()[0].IP() else: controller = RemoteController('c0', ip=args.onos_ip) onosIp = args.onos_ip topo = ClosTopo(args) net = Mininet(topo=topo, build=False, controller=[controller]) net.build() net.start() print "Network started" # Generate background traffic. sleep(3) for (h1, h2) in combinations(net.hosts, 2): h1.startPingBg(h2) h2.startPingBg(h1) print "Background ping started" for h in net.hosts: h.startIperfServer() print "Iperf servers started" # sleep(4) # print "Starting traffic from h1 to h3..." # net.hosts[0].startIperfClient(net.hosts[-1], flowBw="200k", numFlows=100, duration=10) generateNetcfg(onosIp, net, args) if args.netcfg_sleep > 0: print "Waiting %d seconds before pushing config to ONOS..." % args.netcfg_sleep sleep(args.netcfg_sleep) print "Pushing config to ONOS..." call(("%s/onos-netcfg" % RUN_PACK_PATH, onosIp, TEMP_NETCFG_FILE)) if not args.onos_ip: ONOSCLI(net) else: CLI(net) net.stop() call(("rm", "-f", TEMP_NETCFG_FILE))
def run(topo, controllers=None, link=TCLink, autoSetMacs=True): if not topo: print 'Need to provide a topology' exit(1) args = parse_args() if not controllers and len(args.ipAddrs) > 0: controllers = args.ipAddrs if not controllers and args.clusterSize < 1: print 'Need to provide a list of controller IPs, or define a cluster size.' exit(1) setLogLevel('info') if args.clusterSize > 0: if 'ONOS_ROOT' not in os.environ: print "Environment var $ONOS_ROOT not set (needed to import onos.py)" exit(1) sys.path.append(os.environ["ONOS_ROOT"] + "/tools/dev/mininet") from onos import ONOSCluster, ONOSOVSSwitch, ONOSCLI controller = ONOSCluster('c0', args.clusterSize) onosAddr = controller.nodes()[0].IP() net = ONOSMininet(topo=topo, controller=controller, switch=ONOSOVSSwitch, link=link, autoSetMacs=autoSetMacs) cli = ONOSCLI else: onosAddr = controllers[0] net = ONOSMininet(topo=topo, controllers=controllers, link=link, autoSetMacs=autoSetMacs) cli = CLI net.start() if len(args.netcfgJson) > 0: if not os.path.isfile(args.netcfgJson): error('*** WARNING no such netcfg file: %s\n' % args.netcfgJson) else: info('*** Setting netcfg: %s\n' % args.netcfgJson) call(("onos-netcfg", onosAddr, args.netcfgJson)) cli(net) net.stop()
def main(args): topo = ClosTopo() if not args.onos_ip: controller = ONOSCluster('c0', 3) onosIp = controller.nodes()[0].IP() else: controller = RemoteController('c0', ip=args.onos_ip, port=args.onos_port) onosIp = args.onos_ip net = Mininet(topo=topo, build=False, controller=[controller]) net.build() net.start() print "Network started" # Generate background traffic. sleep(3) for (h1, h2) in combinations(net.hosts, 2): h1.startPingBg(h2) h2.startPingBg(h1) print "Background ping started" for h in net.hosts: h.startIperfServer() print "Iperf servers started" # sleep(4) # print "Starting traffic from h1 to h3..." # net.hosts[0].startIperfClient(net.hosts[-1], flowBw="200k", numFlows=100, duration=10) print "Setting netcfg..." call(("onos-netcfg", onosIp, "%s/tools/test/topos/bmv2-demo-cfg.json" % ONOS_ROOT)) if not args.onos_ip: ONOSCLI(net) else: CLI(net) net.stop()
def run(): "Test a multiple ONOS cluster network" setLogLevel('info') # East and west control network topologies (using RenamedTopo) # We specify switch and host prefixes to avoid name collisions # East control switch prefix: 'east_cs', ONOS node prefix: 'east_onos' # Each network is a renamed SingleSwitchTopo of size clusterSize # It's also possible to specify your own control network topology clusterSize = 1 etopo = RenamedTopo(SingleSwitchTopo, clusterSize, snew='east_cs', hnew='east_onos') wtopo = RenamedTopo(SingleSwitchTopo, clusterSize, snew='west_cs', hnew='west_onos') # east and west ONOS clusters # Note that we specify the NAT node names to avoid name collisions east = ONOSCluster('east', topo=etopo, ipBase='192.168.123.0/24', nat='enat0') west = ONOSCluster('west', topo=wtopo, ipBase='192.168.124.0/24', nat='wnat0') # Data network topology topo = LinearTopo(10) # Create network net = Mininet(topo=topo, switch=MultiSwitch, controller=[east, west]) # Assign switches to controllers count = len(net.switches) for i, switch in enumerate(net.switches): switch.controller = east if i < count / 2 else west # Start up network net.start() ONOSCLI(net) # run our special unified Mininet/ONOS CLI net.stop()
def run(): "Test a multiple ONOS cluster network" #setLogLevel( 'error' ) cprint(figlet_format('TENNISON', font='slant'), 'red') setLogLevel('info') loading_bar_thread = threading.Thread(name='loading_bar', target=loading_bar) #loading_bar_thread.start() #progress(10, 100, status='Processing topology') # East and west control network topologies (using RenamedTopo) # We specify switch and host prefixes to avoid name collisions # East control switch prefix: 'east_cs', ONOS node prefix: 'east_onos' # Each network is a renamed SingleSwitchTopo of size clusterSize # It's also possible to specify your own control network topology clusterSize = 1 update_loading_bar(5, 'Transforiming cluster toplogies') etopo = RenamedTopo(SingleSwitchTopo, clusterSize, snew='a_cs', hnew='alpha_c') wtopo = RenamedTopo(SingleSwitchTopo, clusterSize, snew='b_cs', hnew='beta_c') # east and west ONOS clusters # Note that we specify the NAT node names to avoid name collisions #progress(20, 100, status='Launching ONOS cluster alpha') update_loading_bar(10, 'Creating alpha cluster') alpha_cluster = ONOSCluster('alpha', topo=etopo, ipBase='192.168.123.0/24', nat='alpha_nat') update_loading_bar(10, 'Creating beta cluster') #progress(50, 100, status='Launching ONOS cluster beta') beta_cluster = ONOSCluster('beta', topo=wtopo, ipBase='192.168.124.0/24', nat='beta_nat', portOffset=100) # Data network topology. TODO Add link delays and change topo. #progress(70, 100, status='Initialising topology') update_loading_bar(10, 'Creating topology') topo = LinearTopo(10) #topo = TreeTopo(2) #progress(80, 100, status='Creating network') # Create network update_loading_bar(5, 'Compiling topologies') net = Mininet(topo=topo, switch=MultiSwitch, controller=[alpha_cluster, beta_cluster]) #progress(85, 100, status='Launching TENNISON instance alpha') update_loading_bar(5, 'Adding tennison alpha') tennison_alpha = net.addHost('alpha_t', cls=TENNISONNode, ipBase='192.168.123.1/24', ip='192.168.123.100', gw='192.168.123.2') net.addLink(tennison_alpha, alpha_cluster.net.get('a_cs1')) #progress(90, 100, status='Launching TENNISON instance beta') update_loading_bar(5, 'Adding tennison beta') tennison_beta = net.addHost('beta_t', cls=TENNISONNode, portOffset=100, ipBase='192.168.124.1/24', ip='192.168.124.100', gw='192.168.124.2') net.addLink(tennison_beta, beta_cluster.net.get('b_cs1')) # Assign switches to controllers count = len(net.switches) #TODO this will have to change depending on the topology for i, switch in enumerate(net.switches): #progress(90+i, 100, status='Connecting switches to ONOS') switch.controller = alpha_cluster if i < count / 2 else beta_cluster #TODO Need to add TENNISON here. Connect TENNISON to controller switches #TENNISON is a mininet Node with a direct connect to ONOS (preferably not over loopback) # Start up network #progress(99, 100, status='Loading network, please wait') update_loading_bar(5, 'Launching network, please wait') net.start() #tennison_alpha.setIP('192.168.123.2') #progress(100, 100, status='Complete') # This code should be placed in the Tennison class update_loading_bar(5, 'Starting tennison alpha') output = tennison_alpha.cmd('ifconfig alpha_t-eth0 192.168.123.100') output = tennison_alpha.cmd('route add default gw 192.168.123.2') output = tennison_alpha.cmd('ifconfig lo up') #info('Setting tennison alpha ip ' + output) tennison_alpha.start() update_loading_bar(5, 'Starting tennison beta') output = tennison_beta.cmd('ifconfig beta_t-eth0 192.168.124.100') output = tennison_beta.cmd('route add default gw 192.168.124.2') output = tennison_beta.cmd('ifconfig lo up') ##info('Setting tennison beta ip ' + output) tennison_beta.start() fixIPTables() #Install onos apps alpha_cluster.net.get('alpha_c1').cmd('/opt/onos/tools/dev/bash_profile') alpha_cluster.net.get('alpha_c1').cmd( '/opt/onos-tennison-apps/install_apps_remote > onos-apps.log') beta_cluster.net.get('beta_c1').cmd('/opt/onos/tools/dev/bash_profile') beta_cluster.net.get('beta_c1').cmd( '/opt/onos-tennison-apps/install_apps_remote > onos-apps.log') update_loading_bar(100, 'Loading complete') time.sleep(1) setLogLevel('info') info('\n') global Loading Loading = False ONOSCLI(net) # run our special unified Mininet/ONOS CLI tennison_alpha.stop() tennison_beta.stop() net.stop()
default='simple_switch') parser.add_argument('--onos_ip', help='ONOS-BMv2 controller IP address', type=str, action="store", required=False) return parser.parse_args() if __name__ == '__main__': # from mininet.log import setLogLevel # setLogLevel("info") args = get_args() if not args.onos_ip: controller = ONOSCluster('c0', 3) onosIp = controller.nodes()[0].IP() else: controller = RemoteController('c0', ip=args.onos_ip) onosIp = args.onos_ip exercise = ExerciseRunner(args.topo, args.log_dir, args.pcap_dir, args.switch_json, args.behavioral_exe, args.onos_ip, args.quiet) print "Pushing config to ONOS..." call(("%s/onos-netcfg" % RUN_PACK_PATH, onosIp, TEMP_NETCFG_FILE)) exercise.run_exercise()
def run(topo, controllers=None, link=TCLink, autoSetMacs=True): if not topo: print 'Need to provide a topology' exit(1) parser = ArgumentParser(description='ONOS Mininet ' + type(topo).__name__) parser.add_argument( '--cluster-size', help='Starts an ONOS cluster with the given number of instances', type=int, action='store', dest='clusterSize', required=False, default=0) parser.add_argument( '--netcfg', help='Relative path of the JSON file to be used with netcfg', type=str, action='store', dest='netcfgJson', required=False, default='') parser.add_argument('ipAddrs', metavar='IP', type=str, nargs='*', help='List of controller IP addresses', default=[]) args = parser.parse_args() if not controllers and len(args.ipAddrs) > 0: controllers = args.ipAddrs if not controllers and args.clusterSize < 1: print 'Need to provide a list of controller IPs, or define a cluster size.' exit(1) setLogLevel('info') if args.clusterSize > 0: if 'ONOS_ROOT' not in os.environ: print "Environment var $ONOS_ROOT not set (needed to import onos.py)" exit(1) sys.path.append(os.environ["ONOS_ROOT"] + "/tools/dev/mininet") from onos import ONOSCluster, ONOSOVSSwitch, ONOSCLI controller = ONOSCluster('c0', args.clusterSize) onosAddr = controller.nodes()[0].IP() net = ONOSMininet(topo=topo, controller=controller, switch=ONOSOVSSwitch, link=link, autoSetMacs=autoSetMacs) cli = ONOSCLI else: onosAddr = controllers[0] net = ONOSMininet(topo=topo, controllers=controllers, link=link, autoSetMacs=autoSetMacs) cli = CLI net.start() if len(args.netcfgJson) > 0: if not os.path.isfile(args.netcfgJson): error('*** WARNING no such netcfg file: %s\n' % args.netcfgJson) else: info('*** Setting netcfg: %s\n' % args.netcfgJson) call(("onos-netcfg", onosAddr, args.netcfgJson)) cli(net) net.stop()
def run(): "Test a multiple ONOS cluster network" #setLogLevel( 'error' ) cprint(figlet_format('TENNISON', font='slant'), 'red') progress(10, 100, status='Processing topology') # East and west control network topologies (using RenamedTopo) # We specify switch and host prefixes to avoid name collisions # East control switch prefix: 'east_cs', ONOS node prefix: 'east_onos' # Each network is a renamed SingleSwitchTopo of size clusterSize # It's also possible to specify your own control network topology clusterSize = 1 etopo = RenamedTopo( SingleSwitchTopo, clusterSize, snew='a_cs', hnew='alpha_c' ) wtopo = RenamedTopo( SingleSwitchTopo, clusterSize, snew='b_cs', hnew='beta_c' ) # east and west ONOS clusters # Note that we specify the NAT node names to avoid name collisions progress(20, 100, status='Launching ONOS cluster alpha') alpha = ONOSCluster( 'alpha', topo=etopo, ipBase='192.168.123.0/24', nat='alpha_nat' ) progress(50, 100, status='Launching ONOS cluster beta') beta = ONOSCluster( 'beta', topo=wtopo, ipBase='192.168.124.0/24', nat='beta_nat', portOffset=100 ) # Data network topology. TODO Add link delays and change topo. progress(70, 100, status='Initialising topology') topo = LinearTopo( 10 ) progress(80, 100, status='Creating network') # Create network net = Mininet( topo=topo, switch=MultiSwitch, controller=[ alpha, beta ] ) progress(85, 100, status='Launching TENNISON instance alpha') tennison_alpha = net.addHost('alpha_t', cls=TENNISONNode) net.addLink(tennison_alpha, alpha.net.get('a_cs1')) error(type(tennison_alpha)) progress(90, 100, status='Launching TENNISON instance beta') tennison_beta = net.addHost('beta_t', cls=TENNISONNode) # Assign switches to controllers count = len( net.switches ) #TODO this will have to change depending on the topology for i, switch in enumerate( net.switches ): progress(90+i, 100, status='Connecting switches to ONOS') switch.controller = alpha if i < count/2 else beta #TODO Need to add TENNISON here. Connect TENNISON to controller switches #TENNISON is a mininet Node with a direct connect to ONOS (preferably not over loopback) # Start up network progress(99, 100, status='Loading network, please wait') net.start() #tennison_alpha.setIP('192.168.123.2') progress(100, 100, status='Complete') setLogLevel( 'info' ) # This code should be placed in the Tennison class output = tennison_alpha.cmd('ifconfig alpha_t-eth0 192.168.123.2') info('Setting tennison ip ' + output) tennison_alpha.start() ONOSCLI( net ) # run our special unified Mininet/ONOS CLI tennison_alpha.stop() tennison_beta.stop() net.stop()