topo = FatTree(4, 10, 0.1) mapping = { "h1": 0, "h2": 0, "h3": 1, "h4": 1, "s1": 0, "s2": 0, "s3": 1, "s4": 1, "s5": 0, "s6": 1, "s7": 1 } cluster = maxinet_main.Cluster(minWorkers=2, maxWorkers=2) exp = maxinet_main.Experiment(cluster, topo, nodemapping=mapping) exp.setup() print exp.get_node("h1").cmd("ifconfig") # call mininet cmd function of h1 print exp.get_node("h4").cmd("ifconfig") print "waiting 5 seconds for routing algorithms on the controller to converge" time.sleep(5) print exp.get_node("h1").cmd("ping -c 5 10.0.0.4") exp.stop()
#!/usr/bin/python2 # # Minimal example showing how to use MaxiNet with OpenFlow 1.3. # Make sure your controller is able to handle OpenFlow 1.3. # from src.mininet.node import OVSSwitch from src.maxinet.Frontend import maxinet_main from src.maxinet.tools import FatTree topo = FatTree(4, 10, 0.1) cluster = maxinet_main.Cluster() exp = maxinet_main.Experiment(cluster, topo, switch=OVSSwitch) exp.setup() #Enable OpenFlow 1.3 on all switches for switch in exp.switches: exp.get_worker( switch).run_cmd('ovs-vsctl -- set Bridge %s ' % switch.name + 'protocols=OpenFlow10,OpenFlow12,OpenFlow13') #Create some Flows print exp.get_node("h1").cmd("ping -c 5 10.0.0.4") #Dump Flows with OpenFlow 1.3 Command print exp.get("s1").dpctl("-O OpenFlow13 dump-flows") exp.stop()
# operation was successful. # import subprocess import time from src.maxinet.Frontend import maxinet_main from src.maxinet.tools import FatTree topo = FatTree(4, 10, 0.1) # start maxinet cluster cluster = maxinet_main.Cluster() # create experiment on cluster with FatTree topology exp = maxinet_main.Experiment(cluster, topo) exp.setup() time.sleep(2) h3 = exp.get_node("h3") # get node object "h3" w3 = exp.get_worker("h3") # get worker-machine running node "h3" # create file on worker machine w3.run_cmd("dd if=/dev/urandom of=/tmp/testfile1 bs=1024 count=1024") # get_file transfers a file from the file system of a worker to the file # system of the frontend w3.get_file("/tmp/testfile1", "/tmp/") # put_file transfers a file from file system of the frontend to the file # system of the worker w3.put_file("/tmp/testfile1", "/tmp/testfile2") print w3.run_cmd("md5sum /tmp/testfile1").strip()