def simpleTest(): info('*** Create and test a simple network ***\n') topo = TopoTest() info('*** Create the controller ***\n') c0 = RemoteController('c0', port=6653) info(c0) net = Mininet(topo=topo, link=TCLink, build=False) num_ini = 1 num_end = 1 # Asignando una MAC determinada a las interfaces de los switches for s in net.switches: for i in s.intfs.values()[1:]: print i s.intf(str(i)).setMAC( str(num_ini) + "0:00:00:00:00:0" + str(num_end)) num_end += 1 num_end = 1 num_ini += 1 net.addController(c0) info('*** Build the network\n') net.build() info('*** Starting network\n') net.start() info('*** Running CLI\n') CLI(net) info('*** Stopping network') net.stop()
def test(): op = OptionParser() op.add_option('--cli', action="store_true", dest="cli") op.add_option('--ports', action="store", dest="ports") op.set_defaults(cli=False, ports=2) options, args = op.parse_args() topo = SingleSwitchTopo(int(options.ports)) NetASMSwitch.CTL_ADDRESS = "127.0.0.1" NetASMSwitch.CTL_PORT = 7791 net = Mininet(topo, switch=NetASMSwitch, autoSetMacs=True, controller=lambda name: RemoteController(name)) NetASMSwitch.start_datapath(net.switches, address="127.0.0.1", port=6633) net.start() if options.cli: CLI(net) else: net.pingAll() net.stop() NetASMSwitch.stop_datapath()
def main(): "Create and run the Wordcount mapreduce program in Mininet topology" # parse the command line parsed_args = parseCmdLineArgs() # instantiate our topology print("Instantiate topology") topo = MR_Topo(Racks=parsed_args.racks, M=parsed_args.map, R=parsed_args.reduce) # create the network print("Instantiate network") net = Mininet(topo, link=TCLink) # activate the network print("Activate network") net.start() # debugging purposes print("Dumping host connections") dumpNodeConnections(net.hosts) # For large networks, this takes too much time so we # are skipping this. But it works. # # debugging purposes #print "Testing network connectivity" #net.pingAll () #print "Running wordcount apparatus" # Unfortunately, I cannot get this to work :-( #runMapReduceWordCount (net.hosts, parsed_args) print("Generating commands file to be sourced") genCommandsFile(net.hosts, parsed_args) # run the cli CLI(net) # @NOTE@ # You should run the generated commands by going to the # Mininet prompt on the CLI and typing: # source commands.txt # Then, keep checking if all python jobs (except one) are completed # You can look at the *.out files which have all the debugging data # If there are errors in running the python code, these will also # show up in the *.out files. # cleanup net.stop()
def topology(): print('Creating Mininet Topology...\n') net = Mininet(host=RemoteHost, link=RemoteLink, switch=RemoteOVSSwitch) print( 'Creating hosts h1 (20.0.0.1) and h2 (20.0.0.2)...\nObs.: h1 is in node1 and h2 is in node2\n' ) h1 = net.addHost('h1', ip='20.0.0.1') h2 = net.addHost('h2', ip='20.0.0.2', server='node2') print('Creating a link between h1 and h2...\n') net.addLink(h1, h2) print('\n----------------------------------------------\n\n') print( 'Creating hosts h3, h4, h5 and h6\nObs.: h3 and h4 is in node1. h5 and h6 is in node2\n' ) h3 = net.addHost('h3', ip='20.0.0.3') h4 = net.addHost('h4', ip='20.0.0.4') h5 = net.addHost('h5', ip='20.0.0.5', server='node2') h6 = net.addHost('h6', ip='20.0.0.6', server='node2') print( 'Creating OVS switches s0, s1 and s2.\nObs.: s0 and s1 is in node1. s2 is in node2\n' ) s0 = net.addSwitch('s0') s1 = net.addSwitch('s1') s2 = net.addSwitch('s2', server='node2') print( 'Creating links between:\n . s0 - s1\n . . s1 - h3\n . . s1 - h4\n . s0 - s2\n . . s2 - h5\n . . s2 - h6\n' ) net.addLink(s0, s1) net.addLink(s0, s2) net.addLink(h3, s1) net.addLink(h4, s1) net.addLink(h5, s2) net.addLink(h6, s2) #print('Adding permit all rule in s0, s1 and s2') #os.system('sh ovs-ofctl add-flow s0 action=normal') #os.system('sh ovs-ofctl add-flow s1 action=normal') #os.system('sh ovs-ofctl add-flow s2 action=normal') net.start() CLI(net) net.stop()
def main(): "Create and run the Wordcount mapreduce program in Mininet topology" # parse the command line parsed_args = parseCmdLineArgs() # instantiate our topology print "Instantiate topology" topo = JF_Topo(number_of_servers=parsed_args.nServers, switch_graph_degree=parsed_args.nSwitches, number_of_links=parsed_args.nPorts) # create the network print "Instantiate network" #net = Mininet (topo, link=TCLink) net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink, controller=JELLYPOX, autoSetMacs=True) # activate the network print "Activate network" net.start() # debugging purposes print "Dumping host connections" dumpNodeConnections(net.hosts) #print "Generating commands file to be sourced" #genCommandsFile (net.hosts, parsed_args) # run the cli CLI(net) # @NOTE@ # You should run the generated commands by going to the # Mininet prompt on the CLI and typing: # source commands.txt # Then, keep checking if all python jobs (except one) are completed # You can look at the *.out files which have all the debugging data # If there are errors in running the python code, these will also # show up in the *.out files. # cleanup net.stop()
def main(): "Create and run the Wordcount mapreduce program in Mininet topology" # instantiate our topology print "Instantiate topology" topo = Fattree(4) # k = 4 in this case #topo.createTopo() # #topo.createLink() # create link between hosts and switches net = Mininet(topo, link=TCLink) #net.addController('Controller', port=5557) net.start() # debugging purposes print "Dumping host connections" dumpNodeConnections(net.hosts) topo.set_ovs_protocol_13() #genCommandsFile (net.hosts, parsed_args) # run the cli #print "Testing network connectivity" CLI(net) # @NOTE@ # You should run the generated commands by going to the # Mininet prompt on the CLI and typing: # source commands.txt # Then, keep checking if all python jobs (except one) are completed # You can look at the *.out files which have all the debugging data # If there are errors in running the python code, these will also # show up in the *.out files. # cleanup #net.pingAll() net.stop()
# Add switches info('*** Adding switches\n') s1 = net.addSwitch('s1', protocols='OpenFlow13') #... s2 = net.addSwitch('s2', protocols='OpenFlow13') #... # Add links info('*** Creating links\n') for i in range(num_machines // 2): links.append(net.addLink(hosts[i], s1, bw=10)) for i in range(num_machines // 2, num_machines): links.append(net.addLink(hosts[i], s2, bw=10)) links.append(net.addLink(s1, s2, bw=1000)) links.append(net.addLink(c_h100, s1)) links.append(net.addLink(s_h200, s2)) net.addController(c0) # Build the network info('*** Build the network\n') net.build() info('*** Starting network\n') net.start() info('*** Running CLI\n') CLI(net) info('*** Stopping network') net.stop()
def test(): topo = MyTopo() net = Mininet(topo=topo, link=TCLink) net.start() CLI(net) net.stop()
self.addLink(host4, switch2) self.addLink(host5, switch2) self.addLink(host3, switch3) self.addLink(host6, switch4) self.addLink(switch1, switch5) self.addLink(switch2, switch5) self.addLink(switch3, switch5) self.addLink(switch4, switch5) if __name__ == '__main__': PARSER = argparse.ArgumentParser() PARSER.add_argument('--ip', dest='ip', help='ONOS Network Controller IP Address', default='127.0.0.1', type=str) CLI_ARGS = PARSER.parse_args() setLogLevel('info') SWITCH = partial(OVSSwitch, protocols='OpenFlow13') NET = Mininet(topo=SampleTopology(), controller=RemoteController('ONOS', ip=CLI_ARGS.ip, port=6633), switch=SWITCH) NET.start() CLI(NET) NET.stop()
def _CLI(self): CLI(self.net)