Exemplo n.º 1
0
 def __init__( self, net, *args, **kwargs ):
     self.iperfs = {}
     self.bw = '12k'
     self.mn = net
     self.lastbw = {}  # last bandwidth reports
     self.start()
     quietRun( 'rm /tmp/*.iperf /tmp/*.client' )
     CLI.__init__( self, net, *args, **kwargs )
Exemplo n.º 2
0
def testNetwork():
    net = Mininet( topo=None, build=False, ipBase='10.0.0.0/8')

    info( '*** Adding controller\n' )
    c0=net.addController(name='c0', controller=RemoteController, ip='127.0.0.1', port=6633)

    info( '*** Add switches\n')
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch)
    s2 = net.addSwitch('s2', cls=OVSKernelSwitch)
    s3 = net.addSwitch('s3', cls=OVSKernelSwitch)
    s4 = net.addSwitch('s4', cls=OVSKernelSwitch)
    s5 = net.addSwitch('s5', cls=OVSKernelSwitch)
    s6 = net.addSwitch('s6', cls=OVSKernelSwitch)
    s7 = net.addSwitch('s7', cls=OVSKernelSwitch)

    info( '*** Add hosts\n')
    h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)
    h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None)
    h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None)
    h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None)
    h5 = net.addHost('h5', cls=Host, ip='10.0.0.5', defaultRoute=None)
    h6 = net.addHost('h6', cls=Host, ip='10.0.0.6', defaultRoute=None)
    h7 = net.addHost('h7', cls=Host, ip='10.0.0.7', defaultRoute=None)
    h8 = net.addHost('h8', cls=Host, ip='10.0.0.8', defaultRoute=None)

    info( '*** Add links\n')
    net.addLink(s2, s1)
    net.addLink(s3, s1)
    net.addLink(s4, s2)
    net.addLink(s4, s3)
    net.addLink(s5, s2)
    net.addLink(s5, s3)
    net.addLink(s6, s2)
    net.addLink(s6, s3)
    net.addLink(s7, s2)
    net.addLink(s7, s3)
    net.addLink(h1, s4)
    net.addLink(h2, s4)
    net.addLink(h3, s5)
    net.addLink(h4, s5)
    net.addLink(h5, s6)
    net.addLink(h6, s6)
    net.addLink(h7, s7)
    net.addLink(h8, s7)

    info( '*** Starting network\n')
    net.build()
    info( '*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info( '*** Starting switches\n')
    net.get('s1').start([c0])
    net.get('s2').start([c0])
    net.get('s3').start([c0])
    net.get('s4').start([c0])
    net.get('s5').start([c0])
    net.get('s6').start([c0])
    net.get('s7').start([c0])

    info( '*** Post configure switches and hosts\n')

    CLI(net)
    net.stop()
Exemplo n.º 3
0
 def __init__ (self, net):
     """Init method for our custom CLI."""
     self.net = net
     CLI.__init__(self, net)
Exemplo n.º 4
0
                            num_servers, RX_bandwidth, measuringtime)  # t1
            generatetraffic(hosts[6], hosts[8], hosts[2], hosts[4],
                            num_servers, RX_bandwidth, measuringtime)  # t2
            generatetraffic(hosts[9], hosts[11], hosts[5], hosts[7],
                            num_servers, RX_bandwidth, measuringtime)  # t3
            generatetraffic(hosts[14], hosts[16], hosts[10], hosts[12],
                            num_servers, RX_bandwidth, measuringtime)  #t4

            print
            "Sending traffic..."
            time.sleep(measuringtime + writingtime)
            print
            "done"
            continue

        elif tenant_id == 'c':
            CLI(net)
            continue

        elif tenant_id == 'q':
            print
            "quit experiment"
            break

        else:
            continue

    CLI(net)

    net.stop()
Exemplo n.º 5
0
 def __init__(self, mn_wifi, stdin=sys.stdin, script=None):
     CLI.__init__(self, mn_wifi, stdin=sys.stdin, script=None)
Exemplo n.º 6
0
 def do_help(self, line):
     " "
     CLI.do_help(self, line)
     output(self.dynHelpStr)
Exemplo n.º 7
0
 def __init__( self, *args, **kwargs ):
     "cnet: second network"
     self.cnet = kwargs.pop( 'cnet' )
     CLI.__init__( self, *args, **kwargs )
Exemplo n.º 8
0
def run_cli():
    net = SimpleTopology.create_net()
    net.start()
    CLI(net)
    net.stop()
Exemplo n.º 9
0
def createNetwork():
    #send rate at each link in Mbps
    bwg = 1  #in Mbps
    bwbn = 1  #in Mbps
    mqs = 100  #max queue size of interfaces
    dly = '2.5ms'
    apps = 4  #number of other UDP applications = number of DRR classes - 1

    #create empty network
    net = Mininet(intf=TCIntf)

    info('\n*** Adding controller\n')
    net.addController('c0')  #is it ok ?

    #add host to topology
    ht = net.addHost('ht', ip='10.10.0.1/24')
    hu = net.addHost('hu', ip='10.10.0.2/24')
    it = net.addHost('it', ip='10.20.0.1/24')
    iu = net.addHost('iu', ip='10.20.0.2/24')

    rh = net.addHost('rh', ip='10.10.0.10/24')
    ri = net.addHost('ri', ip='10.20.0.20/24')

    info('\n** Adding Switches\n')
    # Adding 2 switches to the network
    sw1 = net.addSwitch('sw1')
    sw2 = net.addSwitch('sw2')

    info('\n** Creating Links \n')
    #create link beetween the network
    link_ht_sw1 = net.addLink(ht, sw1)
    link_hu_sw1 = net.addLink(hu, sw1, intfName1='hu-eth0')
    link_rh_sw1 = net.addLink(rh, sw1, intfName1='rh-eth0')

    link_it_sw2 = net.addLink(it, sw2)
    link_iu_sw2 = net.addLink(iu, sw2)
    link_ri_sw2 = net.addLink(ri, sw2, intfName1='ri-eth0')

    link_rh_ri = net.addLink(rh, ri, intfName1='rh-eth1', intfName2='ri-eth1')

    #set bandwith
    link_ht_sw1.intf1.config(bw=bwbn, max_queue_size=mqs)
    link_hu_sw1.intf1.config(bw=bwbn, max_queue_size=mqs)
    link_rh_sw1.intf1.config(
        bw=bwbn, max_queue_size=mqs
    )  #max_queue_size is hardcoded low to prevent bufferbloat, too high queuing delays

    link_it_sw2.intf1.config(bw=bwg, max_queue_size=mqs)
    link_iu_sw2.intf1.config(bw=bwg, max_queue_size=mqs)
    link_ri_sw2.intf1.config(bw=bwg, max_queue_size=mqs,
                             delay=dly)  #delay is set at ri on both interfaces

    link_rh_ri.intf1.config(
        bw=bwg,
        max_queue_size=mqs)  #loss is set at rh on its interface to ri only

    link_ht_sw1.intf2.config(bw=bwbn, max_queue_size=mqs)
    link_hu_sw1.intf2.config(bw=bwbn, max_queue_size=mqs)
    link_rh_sw1.intf2.config(bw=bwbn, max_queue_size=mqs)

    link_it_sw2.intf2.config(bw=bwg, max_queue_size=mqs)
    link_iu_sw2.intf2.config(bw=bwg, max_queue_size=mqs)
    link_ri_sw2.intf2.config(bw=bwg, max_queue_size=mqs)

    link_rh_ri.intf2.config(bw=bwg, max_queue_size=mqs,
                            delay=dly)  #delay is set at ri on both interfaces

    net.start()

    info('\n*** Configuring hosts\n')

    rh.cmd(
        'ifconfig rh-eth1 10.12.0.10 netmask 255.255.255.0'
    )  #reconfiguring mutiples intefaces host to prevent mininet strange initialisation behaviors
    rh.cmd('ifconfig rh-eth0 10.10.0.10 netmask 255.255.255.0')
    rh.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward'
           )  #enable forwarding at routers

    ri.cmd(
        'ifconfig ri-eth1 10.12.0.20 netmask 255.255.255.0'
    )  #reconfiguring mutiples intefaces host to prvent mininet strange initialisation behaviors
    ri.cmd('ifconfig ri-eth0 10.20.0.20 netmask 255.255.255.0')
    ri.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward'
           )  #enable forwarding at routers

    #configure host default gateways
    ht.cmd('ip route add default via 10.10.0.10')
    hu.cmd('ip route add default via 10.10.0.10')
    it.cmd('ip route add default via 10.20.0.20')
    iu.cmd('ip route add default via 10.20.0.20')

    #configure router routing tables
    rh.cmd('ip route add default via 10.12.0.20')
    ri.cmd('ip route add default via 10.12.0.10')

    # weiyu:
    iu.cmd('touch server.pcap')
    hu.cmd('touch client.pcap')

    rh.cmd('tc qdisc del dev rh-eth1 root')

    start_nodes(rh, ri, iu, hu, mqs, it, ht, apps)  #experiment actions

    it.cmd(
        'ethtool -K it-eth0 tx off sg off tso off'
    )  #disable TSO on TCP on defaul TCP sender need to be done on other host if sending large TCP file from other nodes

    time.sleep(1)

    # Enable the mininet> prompt if uncommented
    info('\n*** Running CLI\n')
    CLI(net)

    # stops the simulation
    net.stop()
Exemplo n.º 10
0
def run():
    "Create and test a simple network"
    net = Mininet()

    info("*** Creating Switches\n")
    s1 = net.addSwitch('s1')

    info("*** Creating hosts on s1\n")
    for h in range(1, 11):
        host = net.addHost('h%s' % h)
        net.addLink(host, s1)

    info("*** Creating Faucet and Gauge controllers\n")
    MININET_HOST_IP = "143.117.69.165"
    net.addController('c1',
                      controller=RemoteController,
                      ip=MININET_HOST_IP,
                      port=6653)
    net.addController('c2',
                      controller=RemoteController,
                      ip=MININET_HOST_IP,
                      port=6654)
    net.start()

    # info( "*** Running tests\n" )
    # print "Dumping host connections"
    # dumpNodeConnections(net.hosts)
    # print "Testing network connectivity"
    # net.pingAll()

    info("*** Launching slave hosts\n")
    # host 1 ping host 2
    h1 = net.get('h1')
    h1.cmd('ping h2 &')
    info("Host 1 slave task running on PID:" + str(h1.cmd('echo $!')))

    # host 2 become an iperf server
    h2 = net.get('h2')
    h2.cmd('iperf -s &')
    info("Host 2 slave task running on PID:" + str(h2.cmd('echo $!')))

    # host 3 iperf host 2 iperf server
    h3 = net.get('h3')
    h3.cmd('iperf -c ' + net.get('h2').IP() + ' -t 100 &')
    info("Host 3 slave task running on PID:" + str(h3.cmd('echo $!')))

    # host 4
    h4 = net.get('h4')
    h4.cmd(
        'tcpreplay --loop=1000 --intf1=h4-eth0 /traffic/TenMinutesWebBrowsing.pcap &'
    )
    info("Host 4 slave task running on PID:" + str(h4.cmd('echo $!')))

    # host 5
    h5 = net.get('h5')
    h5.cmd('tcpreplay --loop=1000 --intf1=h5-eth0 /traffic/16-09-28.pcap &')
    info("Host 5 slave task running on PID:" + str(h5.cmd('echo $!')))

    # host 6
    h6 = net.get('h6')
    h6.cmd('tcpreplay --loop=1000 --intf1=h6-eth0 /traffic/161012.pcap &')
    info("Host 6 slave task running on PID:" + str(h6.cmd('echo $!')))

    # host 7
    h7 = net.get('h7')
    h7.cmd(
        'tcpreplay --loop=1000 --intf1=h7-eth0 /traffic/JAN15-2016-EXT.pcap &')
    info("Host 7 slave task running on PID:" + str(h7.cmd('echo $!')))

    # host 8
    h8 = net.get('h8')
    h8.cmd('tcpreplay --loop=1000 --intf1=h8-eth0 /traffic/IOT3-test.pcap &')
    info("Host 8 slave task running on PID:" + str(h8.cmd('echo $!')))

    # host 9
    h9 = net.get('h9')
    h9.cmd(
        'tcpreplay --loop=1000 --intf1=h9-eth0 /traffic/SynFlood-test.pcap &')
    info("Host 9 slave task running on PID:" + str(h9.cmd('echo $!')))

    CLI(net)
    net.stop()
Exemplo n.º 11
0
def singleController(reqs):

    net = Mininet(controller=Controller, switch=OVSSwitch, link=TCLink)

    print "*** Creating the controller***"

    c0 = net.addController('c0', port=6633)

    print "*** Creating switch"
    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2')
    print "*** Creating the hosts"
    hosts1 = [net.addHost('h%d' % n) for n in 1, 2, 3, 4]
    hosts2 = [net.addHost('h%d' % n) for n in 5, 6, 7, 8]

    print "** creating links"
    for h in hosts1:
        net.addLink(s1, h)

    for h in hosts2:
        net.addLink(s2, h)

    links1 = dict(bw=10, delay='15ms', loss=5, use_htb=True)
    net.addLink(s1, s2, **links1)
    net.build()
    s1.start([c0])
    s2.start([c0])

    net.start()

    ############## multi poll integration starts #######################

    hosts = net.hosts  #this creates an array which has list of all the host h1 to h8

    server = hosts[0]  #get the value of first host h1

    outfiles, errfiles = {}, {
    }  #creates two array to store the out files(to show ping outputs)  and err files(to show errprs encountered)

    h1 = net.get('h1')

    file = open(
        '/home/mininet/result.txt', 'w'
    )  #here I am creating one more file to write the request time inn between hosts and cost of streaming

    #### Here I am running loop to get each host from hosts array and I am pinging each host from h1 and storing the output in .out file #######
    for h in hosts:
        outfiles[h] = '/home/mininet/%s.out' % h.name
        errfiles[h] = '/home/mininet/%s.out' % h.name

        ping_op = h1.cmd(
            'ping -c1', h.IP()
        )  #pinging each host from h1 just for 1 time to get the time value and storing the o/p to ping_op #####
        match = re.search(
            'ttl=(\d+) time=([\d.]+)', ping_op
        )  #extracting time value from output of ping command  #########
        ttl = match.group(1)
        rtt = match.group(2)  #rtt shows the time in string
        rtt = float(rtt)  #converting string to float
        reqs = float(reqs)
        cost = rtt * reqs  # calculating cost where cost is time* no of reqests. By default I have taken no of req as 10

        #outputting request time and cost in result.txt
        file.write("Request time in between h1 and ")
        file.write(h.name)
        file.write(" is ")
        file.write(str(rtt))
        file.write("------ and cost of streaming data is ")
        file.write(str(cost))
        file.write("\n")

        #generating traffic by pinging each host from h1 10 times and saving the output to hostname.out file so for h1 the file name will be h1.out
        h.cmdPrint('ping -c10', server.IP(), '>', outfiles[h], '2>',
                   errfiles[h], '&')
    #### For loop Ends ######################################################################

    file.close()  #closing result.txt file

    print "Monitoring output for", 5, "seconds"

    #for loop for calling monitorFiles fnction
    for h, line in monitorFiles(outfiles, 5, timeoutms=500):
        if h:
            print '%s: %s' % (h.name, line)
    for h in hosts:
        h.cmd('kill %ping')

    ################multi[poll ntegration ends ##############################################################i#

    print "dumping host connections"

    dumpNodeConnections(net.hosts)
    #net.pingAll()
    rootnode = connectToInternet(net)
    CLI(net)
    net.stop()
Exemplo n.º 12
0
def myNetwork():

    net = Mininet(topo=None, build=False, ipBase='10.0.0.0/8')

    info('*** Adding controller\n')
    controller = net.addController(
        name='controller',
        controller=RemoteController,
        #ip='127.0.0.1',
        ip='10.0.0.10',
        protocol='tcp',
        port=6633)

    info('*** Add switches\n')
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch)

    info('*** Add hosts\n')
    auth = net.addHost('auth',
                       cls=Host,
                       ip='10.0.0.1',
                       mac='00:00:00:00:00:01',
                       defaultRoute=None)
    ev = net.addHost('ev',
                     cls=Host,
                     ip='10.0.0.2',
                     mac='00:00:00:00:00:02',
                     defaultRoute=None)
    scada = net.addHost('scada',
                        cls=Host,
                        ip='10.0.0.3',
                        mac='00:00:00:00:00:03',
                        defaultRoute=None)

    info('*** Add links\n')
    net.addLink(auth, s1, 1, 1)
    net.addLink(scada, s1, 1, 3)
    net.addLink(ev, s1, 1, 2)

    info('*** Starting network\n')
    net.build()
    info('*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info('*** Starting switches\n')
    net.get('s1').start([controller])

    #info('*** Add NAT connectivity\n')
    # Add NAT connectivity
    net.addNAT().configDefault()
    #net.start()

    info('*** Post configure switches and hosts\n')

    #Adicionando os arps manualmente
    ev.cmdPrint('arp -s 10.0.0.3 00:00:00:00:00:03')

    scada.cmdPrint('arp -s 10.0.0.1 00:00:00:00:00:01')
    scada.cmdPrint('arp -s 10.0.0.2 00:00:00:00:00:02')

    auth.cmdPrint('arp -s 10.0.0.3 00:00:00:00:00:03')

    info('*** Setting routes\n')
    auth.cmd('route add default dev auth-eth1')
    ev.cmd('route add default dev ev-eth1')
    scada.cmd('route add default dev scada-eth1')
    CLI(net)
    net.stop()
Exemplo n.º 13
0
def myNetwork():

    net = Mininet(topo=None, build=False, ipBase='10.0.0.0/8')

    info("""
Creating the folow topology:
                                    +----+
                +----+           /--| h3 |         
                | c1 |       +--+   +----+  +----+
                +--:-+    /--|s2|-----------| h4 |      
                   :     /   +--+           +----+
+----+         +---:---+/        +-------+                      +----+
| h1 |----|    | swof1 |---------| swof2 |......................| c2 |
+----+  +--+   +-------+         +-------+\     +--+            +----+
        |s1|-----|  |                  |   \----|s4|   +----+
        +--+        | +--+    +----+   |        +--+---| h7 |      
+----+    |         |-|s3|----| h6 |   |          |    +----+
| h2 |----|           +--+    +----+   |          |   +----+
+----+                  |              |          |---| h8 |
                        |              |              +----+
                     +----+            |
                     | h5 |        +-------+    +--+  +----+       
                     +----+     |--| swop3 |----|s6|--| h11|
  +----+                +--+    |  +-------+    +--+  +----+ 
  | h9 |----------------|s5|----|       :         |     +----+
  +----+                +--+            :         |-----| h12|
           +----+         |             :               +----+   +----+
           | h10|---------|             :........................| c3 |
           +----+                                                +----+
------------------------------------------------------------------------
DEVICE          NAME            IP:PORT         	DESCRIPTION
------------------------------------------------------------------------
switch_OpenFlow swof1           10.255.255.1/8
switch_OpenFlow swof2           10.255.255.2/8
switch_OpenFlow swof3           10.255.255.3/8      
controller      c1              127.0.0.1:6631
controller      c2              127.0.0.2:6632
controller      c3              127.0.0.2:6633
switch legacy  	s1          	---
switch legacy  	s2          	---
switch legacy  	s3         	---
switch legacy  	h4          	---
switch legacy  	S5          	---
switch legacy  	s6          	---
h1          	h1          	10.0.0.1/8
h2          	h2          	10.0.0.2/8
h3          	h3          	10.0.0.3/8
h4          	h4          	10.0.0.4/8
h5          	h5          	10.0.0.5/8
h6          	h6          	10.0.0.6/8
h7          	h7          	10.0.0.7/8
h8          	h8          	10.0.0.8/8
h9          	h9          	10.0.0.9/8
h10         	h10         	10.0.0.10/8
h11         	h11         	10.0.0.11/8
h12         	h12         	10.0.0.12/8

------------------------------------------------------------------------
""")

    info('*** Adding controller\n')
    c1 = RemoteController('c1', ip='127.0.0.1', protocol='tcp', port=6631)
    net.addController(c1)

    c2 = RemoteController('c2', ip='127.0.0.2', protocol='tcp', port=6632)
    net.addController(c2)

    c3 = RemoteController('c3', ip='127.0.0.3', protocol='tcp', port=6633)
    net.addController(c3)

    info('*** Add switches\n')
    swof1 = net.addSwitch('swof1', cls=OVSKernelSwitch)
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch, failMode='standalone')
    s2 = net.addSwitch('s2', cls=OVSKernelSwitch, failMode='standalone')
    s3 = net.addSwitch('s3', cls=OVSKernelSwitch, failMode='standalone')

    swof2 = net.addSwitch('swof2', cls=OVSKernelSwitch)
    s4 = net.addSwitch('s4', cls=OVSKernelSwitch, failMode='standalone')

    swof3 = net.addSwitch('swof3', cls=OVSKernelSwitch)
    s5 = net.addSwitch('s5', cls=OVSKernelSwitch, failMode='standalone')
    s6 = net.addSwitch('s6', cls=OVSKernelSwitch, failMode='standalone')

    info('*** Add hosts\n')
    h1 = net.addHost('h1', cls=Host, ip='10.0.0.1/8', mac='00:00:00:00:00:01')
    h2 = net.addHost('h2', cls=Host, ip='10.0.0.2/8', mac='00:00:00:00:00:02')
    h3 = net.addHost('h3', cls=Host, ip='10.0.0.3/8', mac='00:00:00:00:00:03')
    h4 = net.addHost('h4', cls=Host, ip='10.0.0.4/8', mac='00:00:00:00:00:04')
    h5 = net.addHost('h5', cls=Host, ip='10.0.0.5/8', mac='00:00:00:00:00:05')
    h6 = net.addHost('h6', cls=Host, ip='10.0.0.6/8', mac='00:00:00:00:00:06')

    h7 = net.addHost('h7', cls=Host, ip='10.0.0.7/8', mac='00:00:00:00:00:07')
    h8 = net.addHost('h8', cls=Host, ip='10.0.0.8/8', mac='00:00:00:00:00:08')

    h9 = net.addHost('h9', cls=Host, ip='10.0.0.9/8', mac='00:00:00:00:00:09')
    h10 = net.addHost('h10',
                      cls=Host,
                      ip='10.0.0.10/8',
                      mac='00:00:00:00:00:10')
    h11 = net.addHost('h11',
                      cls=Host,
                      ip='10.0.0.11/8',
                      mac='00:00:00:00:00:11')
    h12 = net.addHost('h12',
                      cls=Host,
                      ip='10.0.0.12/8',
                      mac='00:00:00:00:00:12')

    info('*** Add links\n')
    net.addLink(s1, h1)
    net.addLink(s1, h2)
    net.addLink(s2, h3)
    net.addLink(s2, h4)
    net.addLink(s3, h5)
    net.addLink(s3, h6)

    net.addLink(s4, h7)
    net.addLink(s4, h8)

    net.addLink(s5, h9)
    net.addLink(s5, h10)
    net.addLink(s6, h11)
    net.addLink(s6, h12)

    net.addLink(swof1, s1)
    net.addLink(swof1, s2)
    net.addLink(swof1, s3)

    net.addLink(swof2, s4)

    net.addLink(swof3, s5)
    net.addLink(swof3, s6)

    net.addLink(swof2, swof1)  #2 #4
    net.addLink(swof2, swof3)  #3 #3

    info('*** Starting network\n')
    net.build()
    info('*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info('*** Starting switches\n')
    net.get('swof1').start([c1])
    net.get('s1').start([])
    net.get('s2').start([])
    net.get('s3').start([])

    net.get('swof2').start([c2])
    net.get('s4').start([])

    net.get('swof3').start([c3])
    net.get('s5').start([])
    net.get('s6').start([])

    info('*** Post configure switches\n')
    #swof1.cmd('ifconfig swof1 10.255.255.1/8')
    #swof2.cmd('ifconfig swof2 10.255.255.2/8')
    #swof3.cmd('ifconfig swof2 10.255.255.3/8')

    CLI(net)

    info('########## Stopping CLI ##########\n')
    net.stop()
def myNetwork():

    net = Mininet( topo=None,
                   build=False,
                   ipBase='10.0.0.0/8')

    info( '*** Adding controller\n' )
    c0=net.addController(name='c0',
                      controller=RemoteController,
                      ip='127.0.0.1',
                      protocol='tcp',
                      port=6633)

    info( '*** Add switches\n')
    s3 = net.addSwitch('s3', cls=OVSKernelSwitch)
    s4 = net.addSwitch('s4', cls=OVSKernelSwitch)
    s12 = net.addSwitch('s12', cls=OVSKernelSwitch)
    s11 = net.addSwitch('s11', cls=OVSKernelSwitch)
    s6 = net.addSwitch('s6', cls=OVSKernelSwitch)
    s2 = net.addSwitch('s2', cls=OVSKernelSwitch)
    s7 = net.addSwitch('s7', cls=OVSKernelSwitch)
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch)
    s8 = net.addSwitch('s8', cls=OVSKernelSwitch)
    s9 = net.addSwitch('s9', cls=OVSKernelSwitch)
    s5 = net.addSwitch('s5', cls=OVSKernelSwitch)
    s10 = net.addSwitch('s10', cls=OVSKernelSwitch)

    info( '*** Add hosts\n')
    h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)
    h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None)
    h7 = net.addHost('h7', cls=Host, ip='10.0.0.10', defaultRoute=None)
    h5 = net.addHost('h5', cls=Host, ip='10.0.0.13', defaultRoute=None)
    h9 = net.addHost('h9', cls=Host, ip='10.0.0.9', defaultRoute=None)
    h6 = net.addHost('h6', cls=Host, ip='10.0.0.11', defaultRoute=None)
    h4 = net.addHost('h4', cls=Host, ip='10.0.0.15', defaultRoute=None)
    h3 = net.addHost('h3', cls=Host, ip='10.0.0.14', defaultRoute=None)
    h8 = net.addHost('h8', cls=Host, ip='10.0.0.13', defaultRoute=None)
    h10 = net.addHost('h10', cls=Host, ip='10.0.0.12', defaultRoute=None)

    info( '*** Add links\n')
    net.addLink(h4, s5)
    net.addLink(s5, s1)
    net.addLink(s1, s6)
    net.addLink(s1, s2)
    net.addLink(s1, s7)
    net.addLink(s7, s11)
    net.addLink(s11, h8)
    net.addLink(s11, s12)
    net.addLink(s12, h1)
    net.addLink(s12, h10)
    net.addLink(s2, s3)
    net.addLink(s2, h7)
    net.addLink(s2, s4)
    net.addLink(s4, s10)
    net.addLink(s10, h6)
    net.addLink(s3, s9)
    net.addLink(s9, h5)
    net.addLink(s3, s8)
    net.addLink(s8, h2)
    net.addLink(s3, h9)
    net.addLink(h3, s6)

    info( '*** Starting network\n')
    net.build()
    info( '*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info( '*** Starting switches\n')
    net.get('s3').start([c0])
    net.get('s4').start([c0])
    net.get('s12').start([c0])
    net.get('s11').start([c0])
    net.get('s6').start([c0])
    net.get('s2').start([c0])
    net.get('s7').start([c0])
    net.get('s1').start([c0])
    net.get('s8').start([c0])
    net.get('s9').start([c0])
    net.get('s5').start([c0])
    net.get('s10').start([c0])

    info( '*** Post configure switches and hosts\n')

    CLI(net)
    net.stop()
Exemplo n.º 15
0
        #                                remoteIP=vsIP, remoteMAC=vsMAC, iperfPort = str(iperfPortBase + j))
        #            self.addLink(host, hgw_sw)
        #            self.addLink(root, host)

        vs = self.addHost('vs',
                          cls=IperfSourceHost,
                          ip='%s/24' % vsIP,
                          mac=vsMAC,
                          nHosts=nHosts)
        self.addLink(vs_sw, vs)

        self.addLink(vs_sw, hgw_sw)


#topos = {'tnonorth': MDCoCoTopoNorth,
#         'tnosouth': MDCoCoTopoSouth}

if __name__ == '__main__':
    setLogLevel('debug')
    topo = daneTopo()
    net = Mininet(topo=topo, controller=RemoteController)

    net.start()

    CLI(net)

    net.stop()

    info("done\n")

# topos = { 'cocotopo': ( lambda: CoCoTopo() ) }
Exemplo n.º 16
0
def emptyNet():

    "Create an empty network and add nodes to it."
    #host,port,action,protocol = ACL()
    x, y = ACL()
    print('Inbound access entry: ' + str(x))
    print('////////////////////////')
    print('Outbound access entry: ' + str(y))

    net = Mininet(controller=Controller)  #######
    print(net)

    info('*** Adding controller\n')
    #net.addController( 'c0' )                # Disable controller to create flows manually

    info('*** Adding hosts\n')
    h1 = net.addHost(
        'h1', ip='192.168.0.1',
        mac='00:00:00:00:00:01')  #Desktop connected to home network
    h2 = net.addHost('h2', ip='192.168.0.2', mac='00:00:00:00:00:02'
                     )  #IoT Device LED Light connected to home network
    h3 = net.addHost(
        'h3', ip=x[0],
        mac='00:00:00:00:00:03')  ####### IP address allowed for communication

    info('*** Adding switch\n')
    s3 = net.addSwitch('s3')

    info('*** Creating links\n')
    net.addLink(h1, s3)
    net.addLink(h2, s3)
    net.addLink(h3, s3)  ###############
    #net.addLink( h4, s3 )

    info('*** Starting network\n')
    net.start()

    # enter flow mod commands
    #os.system("h3 route add default gw 128.59.105.254 h3-eth0")
    #os.system("h3 arp -s 128.59.105.254 00:00:00:00:33:33")
    #os.system("h1 route add default gw 192.168.0.254 h1-eth0")
    #os.system("h1 arp -s 192.168.0.254 00:00:00:00:00:11:11")
    #os.system("h2 route add default gw 192.168.0.254 h2-eth0")
    #os.system("h2 arp -s 192.168.0.254 00:00:00:00:00:11:11")
    #os.system("h3 sudo python -m SimpleHTTPServer 80 &")

    #h1.cmdPrint('ifconfig')

    h3.cmdPrint('route add default gw 128.59.105.254 h3-eth0')
    h3.cmdPrint('arp -s 128.59.105.254 00:00:00:00:33:33')

    h1.cmdPrint('route add default gw 192.168.0.254 h1-eth0')
    h1.cmdPrint('arp -s 192.168.0.254 00:00:00:00:00:11:11')

    h2.cmdPrint('route add default gw 192.168.0.254 h2-eth0')
    h2.cmdPrint('arp -s 192.168.0.254 00:00:00:00:00:11:11')

    h3.cmdPrint('sudo python -m SimpleHTTPServer 80 &')
    #time.sleep(20)
    #h1.cmdPrint('curl', h3.IP() )
    os.system("more tables.txt")
    os.system("ovs-ofctl add-flows s3 tables.txt")

    info('*** Running CLI\n')
    CLI(net)

    info('*** Stoping network')
    net.stop()
def topology():
    "Create a network."
    net = Mininet(controller=RemoteController,
                  link=TCLink,
                  switch=OVSKernelSwitch)
    print "*** Creating Hosts"
    h1 = net.addHost('h1', mac='00:00:00:00:00:01')  # h1--10.0.0.1
    h2 = net.addHost('h2', mac='00:00:00:00:00:02')  # h2--10.0.0.2
    h3 = net.addHost('h3', mac='00:00:00:00:00:03')  # h3--10.0.0.3
    h4 = net.addHost('h4', mac='00:00:00:00:00:04')  # h4--10.0.0.4

    h5 = net.addHost('h5', mac='00:00:00:00:00:05')  # h5--10.0.0.5
    h6 = net.addHost('h6', mac='00:00:00:00:00:06')  # h6--10.0.0.6

    h7 = net.addHost('h7', mac='00:00:00:00:00:07')  # h7--10.0.0.7
    h8 = net.addHost('h8', mac='00:00:00:00:00:08')  # h8--10.0.0.8

    h9 = net.addHost('h9', mac='00:00:00:00:00:09')  # h8--10.0.0.9
    h10 = net.addHost('h10', mac='00:00:00:00:00:0A')  # h10--10.0.0.10

    h11 = net.addHost('h11', mac='00:00:00:00:00:0B')  # h11--10.0.0.11
    h12 = net.addHost('h12', mac='00:00:00:00:00:0C')  # h12--10.0.0.12

    h13 = net.addHost('h13', mac='00:00:00:00:00:0D')  # h13--10.0.0.13
    h14 = net.addHost('h14', mac='00:00:00:00:00:0E')  # h14--10.0.0.14

    h15 = net.addHost('h15', mac='00:00:00:00:00:0F')  # h15--10.0.0.15
    h16 = net.addHost('h16', mac='00:00:00:00:00:10')  # h16--10.0.0.16

    h17 = net.addHost('h17', mac='00:00:00:00:00:11')  # h17--10.0.0.17
    h18 = net.addHost('h18', mac='00:00:00:00:00:12')  # h18--10.0.0.18

    h19 = net.addHost('h19', mac='00:00:00:00:00:13')  # h19--10.0.0.19
    h20 = net.addHost('h20', mac='00:00:00:00:00:14')  # h20--10.0.0.20

    h21 = net.addHost('h21', mac='00:00:00:00:00:15')  # h21--10.0.0.21
    h22 = net.addHost('h22', mac='00:00:00:00:00:16')  # h22--10.0.0.22

    h23 = net.addHost('h23', mac='00:00:00:00:00:17')  # h23--10.0.0.23
    h24 = net.addHost('h24', mac='00:00:00:00:00:18')  # h24--10.0.0.24

    h25 = net.addHost('h25', mac='00:00:00:00:00:19')  # h25--10.0.0.25
    h26 = net.addHost('h26', mac='00:00:00:00:00:1A')  # h26--10.0.0.26

    print "*** Creating Switches & Controller"
    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2')
    s3 = net.addSwitch('s3')
    s4 = net.addSwitch('s4')

    c0 = net.addController('c0',
                           controller=RemoteController,
                           defaultIP='127.0.0.1',
                           port=6633)

    # between hosts & switches
    print "*** Creating and configuring link between Hosts & Switches"
    net.addLink(h1, s1, intfName1='h1-eth0', intfName2='s1-eth1')  # h1--s1
    net.addLink(h2, s2, intfName1='h2-eth0', intfName2='s2-eth1')  # h2--s2
    net.addLink(h3, s3, intfName1='h3-eth0', intfName2='s3-eth1')  # h3--s3
    net.addLink(h4, s4, intfName1='h4-eth0', intfName2='s4-eth1')  # h4--s4

    net.addLink(h5, s2, intfName1='h5-eth0', intfName2='s2-eth4')  # h5--s2
    net.addLink(h6, s3, intfName1='h6-eth0', intfName2='s3-eth4')  # h6--s3

    net.addLink(h7, s2, intfName1='h7-eth0', intfName2='s2-eth5')  # h7--s2
    net.addLink(h8, s3, intfName1='h8-eth0', intfName2='s3-eth5')  # h8--s3

    net.addLink(h9, s2, intfName1='h9-eth0', intfName2='s2-eth6')  # h9--s2
    net.addLink(h10, s3, intfName1='h10-eth0', intfName2='s3-eth6')  # h10--s3

    net.addLink(h11, s2, intfName1='h11-eth0', intfName2='s2-eth7')  # h11--s2
    net.addLink(h12, s3, intfName1='h12-eth0', intfName2='s3-eth7')  # h12--s3

    net.addLink(h13, s2, intfName1='h13-eth0', intfName2='s2-eth8')  # h13--s2
    net.addLink(h14, s3, intfName1='h14-eth0', intfName2='s3-eth8')  # h14--s3

    net.addLink(h15, s2, intfName1='h15-eth0', intfName2='s2-eth9')  # h15--s2
    net.addLink(h16, s3, intfName1='h16-eth0', intfName2='s3-eth9')  # h16--s3

    net.addLink(h17, s2, intfName1='h17-eth0', intfName2='s2-eth10')  # h17--s2
    net.addLink(h18, s3, intfName1='h18-eth0', intfName2='s3-eth10')  # h18--s3

    net.addLink(h19, s2, intfName1='h19-eth0', intfName2='s2-eth11')  # h19--s2
    net.addLink(h20, s3, intfName1='h20-eth0', intfName2='s3-eth11')  # h20--s3

    net.addLink(h21, s2, intfName1='h21-eth0', intfName2='s2-eth12')  # h21--s2
    net.addLink(h22, s3, intfName1='h22-eth0', intfName2='s3-eth12')  # h22--s3

    net.addLink(h23, s2, intfName1='h23-eth0', intfName2='s2-eth13')  # h23--s2
    net.addLink(h24, s3, intfName1='h24-eth0', intfName2='s3-eth13')  # h24--s3

    net.addLink(h25, s2, intfName1='h25-eth0', intfName2='s2-eth14')  # h25--s2
    net.addLink(h26, s3, intfName1='h26-eth0', intfName2='s3-eth14')  # h26--s3

    net.addLink(s1, s2, intfName1='s1-eth2', intfName2='s2-eth2')  # s1--s2
    net.addLink(s2,
                s3,
                intfName1='s2-eth3',
                intfName2='s3-eth2',
                bw=20,
                delay='30ms',
                max_queue_size=100)  # s2--s3
    net.addLink(s3, s4, intfName1='s3-eth3', intfName2='s4-eth2')  # s3--s4

    print "\n*** Starting controller"
    net.build()
    c0.start

    print "*** Starting 4 switches"
    s1.start([c0])
    s1.cmd('switch s1 start')
    s2.start([c0])
    s2.cmd('switch s2 start')
    s3.start([c0])
    s3.cmd('switch s3 start')
    s4.start([c0])
    s4.cmd('switch s4 start')

    s1.cmd('bash forwarding_table_normal.sh'
           )  # setting up switches forwarding table

    time.sleep(5)

    # to set tcp segmentation tso, gro, gso offloading disabled
    print "\n*** Configuring tso, gro, gso & Flowtable"
    h1.cmd('bash eth.sh')  # host1 -- gro, gso, tso off
    h4.cmd('bash eth.sh')  # host4 -- gro, gso, tso off
    h2.cmd('bash eth.sh')  # host2 -- gro, gso, tso off
    h3.cmd('bash eth.sh')  # host3 -- gro, gso, tso off
    h5.cmd('bash eth.sh')  # host5 -- gro, gso, tso off
    h6.cmd('bash eth.sh')  # host6 -- gro, gso, tso off
    h7.cmd('bash eth.sh')  # host7 -- gro, gso, tso off
    h8.cmd('bash eth.sh')  # host8 -- gro, gso, tso off
    h9.cmd('bash eth.sh')  # host9 -- gro, gso, tso off
    h10.cmd('bash eth.sh')  # host10 -- gro, gso, tso off
    h11.cmd('bash eth.sh')  # host11 -- gro, gso, tso off
    h12.cmd('bash eth.sh')  # host12 -- gro, gso, tso off
    h13.cmd('bash eth.sh')  # host13 -- gro, gso, tso off
    h14.cmd('bash eth.sh')  # host14 -- gro, gso, tso off
    h15.cmd('bash eth.sh')  # host15 -- gro, gso, tso off
    h16.cmd('bash eth.sh')  # host16 -- gro, gso, tso off
    h17.cmd('bash eth.sh')  # host17 -- gro, gso, tso off
    h18.cmd('bash eth.sh')  # host18 -- gro, gso, tso off
    h19.cmd('bash eth.sh')  # host19 -- gro, gso, tso off
    h20.cmd('bash eth.sh')  # host20 -- gro, gso, tso off
    h21.cmd('bash eth.sh')  # host21 -- gro, gso, tso off
    h22.cmd('bash eth.sh')  # host22 -- gro, gso, tso off
    h23.cmd('bash eth.sh')  # host23 -- gro, gso, tso off
    h24.cmd('bash eth.sh')  # host24 -- gro, gso, tso off
    h25.cmd('bash eth.sh')  # host25 -- gro, gso, tso off
    h26.cmd('bash eth.sh')  # host26 -- gro, gso, tso off
    time.sleep(2)
    s1.cmd('bash eth.sh')  # switch1 -- gro, gso, tso off
    s2.cmd('bash eth.sh')  # switch2 -- gro, gso, tso off
    s3.cmd('bash eth.sh')  # switch3 -- gro, gso, tso off
    s4.cmd('bash eth.sh')  # switch4 -- gro, gso, tso off
    time.sleep(2)
    s2.cmd('bash reno.sh'
           )  # setting tcp RENO, window_scalling on, maximum receiver buffer
    time.sleep(2)
    # StopWatch website to open
    # webbrowser.open('http://timer-tab.com/', new = 0)

    print "*** Dumping Host Connections"
    dumpNodeConnections(net.hosts)

    print "*** Ping : Checking connectivity"
    #net.pingAll()

    time.sleep(2)

    print "*** Start transfering data"
    h4.cmd('./h4.sh &')
    h3.cmd('./host.sh &')
    h6.cmd('./host.sh &')
    h8.cmd('./host.sh &')
    h10.cmd('./host.sh &')
    h12.cmd('./host.sh &')
    h14.cmd('./host.sh &')
    h16.cmd('./host.sh &')
    h18.cmd('./host.sh &')
    h20.cmd('./host.sh &')
    h22.cmd('./host.sh &')
    h24.cmd('./host.sh &')
    h26.cmd('./host.sh &')
    h1.cmd('./h1.sh &')
    h2.cmd('./h2.sh &')
    h5.cmd('./h5.sh &')
    h7.cmd('./h7.sh &')
    h9.cmd('./h9.sh &')
    h11.cmd('./h11.sh &')
    h13.cmd('./h13.sh &')
    h15.cmd('./h15.sh &')
    h17.cmd('./h17.sh &')
    h19.cmd('./h19.sh &')
    h21.cmd('./h21.sh &')
    h23.cmd('./h23.sh &')
    h25.cmd('./h25.sh &')
    '''
	# h1.cmd('h1 ping h2 -c 2')

	# h2.cmd('tcpdump -i h2-eth2 -w server-tcpdump')
	# h1.cmd('tcpdump -i h1-eth2 -w client-tcpdump')
	# h2.cmd('iperf -s > server_output.txt &')
	# h1.cmd('iperf -c ', h1.IP() + ' -i 1 -t 50   >  client_output.txt &')
	'''
    print "*** Running CLI"
    CLI(net)
    print "*** Stopping network"
    net.stop()
Exemplo n.º 18
0
def topology():
    "Create a network."
    net = Mininet(controller=RemoteController,
                  link=TCLink,
                  switch=OVSKernelSwitch)

    os.system('clear')
    parser = argparse.ArgumentParser(
        description='Compute Access Points over-reservation.')
    parser.add_argument("-aps",
                        metavar='APs',
                        type=int,
                        default=6,
                        help='amount of aps (default: 6)')
    parser.add_argument("-cosA",
                        metavar='MOs',
                        type=int,
                        default=0,
                        help='amount of MOs in CoS A (default: 0)')  # TBD
    parser.add_argument("-cosB",
                        metavar='MOs',
                        type=int,
                        default=0,
                        help='amount of MOs in CoS B (default: 0)')  # TBD
    parser.add_argument("-cosC",
                        metavar='MOs',
                        type=int,
                        default=0,
                        help='amount of MOs in CoS C (default: 0)')  # TBD
    args = parser.parse_args()

    print "*** Starting Simulation..."
    time.sleep(1)

    print "*** Starting Controller"
    c0 = net.addController('c0',
                           controller=RemoteController,
                           ip='127.0.0.1',
                           port=6633)  # Add Controller
    s0 = net.addSwitch('s0')  # Add Switch s0
    s11 = net.addSwitch('s11')
    s12 = net.addSwitch('s12')
    sc1 = net.addSwitch('sc1')
    sc2 = net.addSwitch('sc2')
    sc3 = net.addSwitch('sc3')
    sc4 = net.addSwitch('sc4')
    sc5 = net.addSwitch('sc5')
    sc6 = net.addSwitch('sc6')
    ap0 = net.addBaseStation('ap0', ssid="ssid_0", mode="n",
                             channel="1")  # Add ap0

    sta0 = net.addStation('sta0', ip="10.0.100.1")
    sta00 = net.addStation('sta00', ip="10.0.100.2")
    sta000 = net.addStation('sta000', ip="10.0.100.3")

    print "*** Creating PoAs"  # Cria e faz bootstrapping dos PoAs
    for i in range(1, args.aps + 1):
        print("\nCreating AP" + str(i) + "...")

        globals()['ap%s' % i] = net.addBaseStation(
            'ap' + str(i), ssid="ssid_" + str(i), mode="g",
            channel="1")  # Add AP/PoA   -> ap1 = net.addBaseStation
        globals()['ap%s' % i].start([c0])  # Start AP/PoA -> ap1.start( [c0] )
        print("Bootstrapping PoA" + str(i) + "...")
        print("Displaying PoA Pool" + "...")

    # Definicao da quantidade de MOs em cada CoS
    print "***Initializing scenario"
    cosA_MO = 14  # amount of MO in the CoSA
    cosB_MO = 6
    cosC_MO = 12
    cosX_MO = [cosC_MO, cosB_MO, cosA_MO]
    mn = 1
    sta_list = []

    # Scenario initialization - Criacao de todos os Stations (Necessario antes de addLink)
    print "*** Creating nodes"
    for mo in cosX_MO:
        for m in range(1, mo + 1):
            mo_name = 'sta' + str(mn)
            if (mn == 1):
                #				globals()['sta%s' % mn] = net.addStation( mo_name, ip="10.0.0."+str(mn), wlans=2 )
                globals()['sta%s' % mn] = net.addStation(mo_name,
                                                         ip="10.0.0." +
                                                         str(mn))
            else:
                globals()['sta%s' % mn] = net.addStation(mo_name,
                                                         ip="10.0.0." +
                                                         str(mn))
            sta_list.append("sta" + str(mn))
            mn += 1
    print sta_list

    # Initializes scenario in AP0
    mn = 1
    for mo in cosX_MO:
        for m in range(1, mo + 1):
            mo_name = 'sta' + str(mn)
            net.addLink(sta_list[mn - 1], ap0)
            #			net.addLink(sta_list[mn-1], ap0, bw=2, delay='70ms', use_htb=True)
            sta = globals()['sta%s' % mn]
            #			sta.cmdPrint("sudo python ./scripts/watch2.py -dir "+str(mn)+" &")
            sta.cmdPrint("sudo python ./scripts/server.py -ip 10.0.0." +
                         str(mn) + " -p 8088 &")
            sta.cmdPrint("sudo ./scripts/iperf_client.sh &")
            mn += 1

    print "*** Creating link between devices"
    for poa in range(1, args.aps + 1):
        net.addLink(globals()['ap%s' % poa], s0)

    print "*** Creating link between nodes"
    #	net.addLink(s11, s0)
    #	net.addLink(s12, s0)
    #	net.addLink(sc1, s11)
    #	net.addLink(sc2, s11)
    #	net.addLink(sc3, s11)
    #	net.addLink(sc4, s12)
    #	net.addLink(sc5, s12)
    #	net.addLink(sc6, s12)

    #	net.addLink(sc3, sc4)
    #	net.addLink(sc1, sc3)
    #	net.addLink(s12, sc3)
    #	net.addLink(s12, sc1)
    #	net.addLink(sc4, sc6)
    #	net.addLink(sc2, sc4)
    #	net.addLink(sc2, sc1)
    #	net.addLink(s11, sc1)
    #	net.addLink(sc2, sc5)
    #	net.addLink(s11, sc2)
    #	net.addLink(s0, sc2)
    #	net.addLink(s11, s0)

    print "*** Adding link ap0 and sta0"
    net.addLink(ap0, s0)
    net.addLink(sta0, s0)
    net.addLink(sta00, s0, bw=0.8, use_htb=True)
    net.addLink(sta000, s0)

    print "*** Starting network"
    net.build()
    c0.start()
    s0.start([c0])
    ap0.start([c0])
    #	s11.start( [c0] )
    #	s12.start( [c0] )
    #	sc1.start( [c0] )
    #	sc2.start( [c0] )
    #	sc3.start( [c0] )
    #	sc4.start( [c0] )
    #	sc5.start( [c0] )
    #	sc6.start( [c0] )

    for poa in range(1, args.aps + 1):
        globals()['ap%s' % poa].start([c0])

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
Exemplo n.º 19
0
 def __init__(self, *args, **kwargs):
     ""
     CLI.__init__( self, *args, **kwargs )
Exemplo n.º 20
0
def Mptcp():

    net = Mininet(cleanup=True)

    #add 5 hosts with mininet default IP 10.0.0.1 to 10.0.0.5 to the network topology
    h1 = net.addHost('h1')
    h2 = net.addHost('h2')
    h3 = net.addHost('h3')
    h4 = net.addHost('h4')
    h5 = net.addHost('h5')

    #add 1 switch to the topology
    s3 = net.addSwitch('s3')

    c0 = net.addController('c0')

    #connect 5 hosts through a switch
    net.addLink(h1, s3, cls=TCLink, bw=1000)
    net.addLink(h2, s3, cls=TCLink, bw=1000)
    net.addLink(h5, s3, cls=TCLink, bw=1000)
    net.addLink(h4, s3, cls=TCLink, bw=1000)
    net.addLink(h3, s3, cls=TCLink, bw=1000)
    net.addLink(h1, s3, cls=TCLink, bw=1000)
    net.addLink(h2, s3, cls=TCLink, bw=1000)
    net.addLink(h3, s3, cls=TCLink, bw=1000)
    net.addLink(h4, s3, cls=TCLink, bw=1000)
    net.addLink(h5, s3, cls=TCLink, bw=1000)

    #Assign IP,prefix and interface name to 5 hosts second interfaces
    h1.setIP('192.168.1.1', prefixLen=24, intf='h1-eth1')
    h2.setIP('192.168.1.2', prefixLen=24, intf='h2-eth1')
    h3.setIP('192.168.1.3', prefixLen=24, intf='h3-eth1')
    h4.setIP('192.168.1.4', prefixLen=24, intf='h4-eth1')
    h5.setIP('192.168.1.5', prefixLen=24, intf='h5-eth1')

    net.start()
    print "Dumping host connections"
    dumpNodeConnections(net.hosts)

    print "Testing network connectivity"
    net.pingAll()
    print "Testing bandwidth between h1 and h4"
    #CLI(net)
    time.sleep(1)  # wait for net to startup
    print "\n", " " * 5, "#" * 40, "\n", " " * 10, "STARTING\n"

    #enable mptcp on hosts
    if mptcp_enabled_test:

        set_mptcp_enabled(True)

        #test connectivity of h1(client) to the h2(server) from both the interfaces.
        h2_out = h1.cmdPrint('ping -c 1 ' + h2.IP('h2-eth0') + ' ')
        h2_out2 = h1.cmdPrint('ping -c 1 ' + h2.IP('h2-eth1') + ' ')

        print "ping test output: %s\n" % h2_out
        print "ping test output: %s\n" % h2_out2

        #give time to print ping output
        time.sleep(3)

        print 'starting iperf server at: ', h2.IP()
        h2.cmd('iperf -s >> iperf_mptcp_server_log.txt & ')
        #give time to print iperf output
        time.sleep(test_duration / 5.0)

        print 'starting iperf client at', h1.IP(), ', connect to ', h2.IP()
        h1.cmd('iperf -n 2G -c ' + h2.IP() +
               ' >> iperf_mptcp_client_log.txt &')  #client

        #give time to print iperf output
        time.sleep(test_duration / 1.2)
        print "\niperf client response:"
        print h1.cmd('cat iperf_mptcp_client_log.txt')
        h2.cmd('kill -9 %iperf')
        time.sleep(test_duration / 3.0)
        #use CLI to check any commands or outputs
        CLI(net)

    net.stop()
    os.system("sudo mn -c")
Exemplo n.º 21
0
 def cmdloop( self, *args, **kwargs ):
     "Patch to add cnet if needed"
     if 'cnet' not in self.locals:
         self.updateVars()
     CLI.cmdloop( self, *args, **kwargs )
Exemplo n.º 22
0
def sdn1net():
    topo = SDNIpModifiedTopo()
    info('*** Creating network\n')
    net = Mininet(topo=topo, controller=RemoteController)
    net = Mininet(topo=topo, controller=RemoteController)

    host1, host3, host4, host5 = net.get('host1', 'host3', 'host4', 'host5')

    #host100.setIP('1.168.30.' + str(i), 24, str(host100) + "-eth2")

    #host500.setMAC('00:00:00:00:04:%d' % (i-101), 'host%d-eth0' %(i))
    #add IP prefixes
    #for j in range(0,121):
    #host100.cmd('sudo ip addr add %s.0.40.%s/24 dev host%s-eth0' %(i,j,i))

    ## Adding 2nd, 3rd and 4th interface to host1 connected to sw1 (for another BGP peering)
    #sw1 = net.get('sw1')
    host1.setMAC('00:00:00:00:00:01', 'host1-eth0')
    host1.cmd('ip addr add 192.168.20.101/24 dev host1-eth0')
    host1.cmd('ip addr add 192.168.30.101/24 dev host1-eth0')
    #host1.cmd('ip addr add 192.168.40.101/24 dev host1-eth0')
    host1.cmd('ip addr add 192.168.60.101/24 dev host1-eth0')

    # Net has to be start after adding the above link
    net.start()

    # Set up as6sw as a learning switch as quickly as possible so it
    # hopefully doesn't connect to the actual controller
    # TODO figure out how to change controller before starting switch
    as6sw = net.get('as6sw')
    as6sw.cmd('ovs-vsctl set-controller as6sw none')
    as6sw.cmd('ovs-vsctl set-fail-mode as6sw standalone')

    sw1 = net.get('sw1')
    sw1.cmd('ovs-vsctl set-controller sw1 tcp:127.0.0.1:6633')
    #    sw2.cmd('ovs-vsctl set-controller sw2 tcp:127.0.0.1:6633')
    #    sw3.cmd('ovs-vsctl set-controller sw3 tcp:127.0.0.1:6633')
    #    sw4.cmd('ovs-vsctl set-controller sw4 tcp:127.0.0.1:6633')
    #    sw5.cmd('ovs-vsctl set-controller sw5 tcp:127.0.0.1:6633')
    #    sw6.cmd('ovs-vsctl set-controller sw6 tcp:127.0.0.1:6633')

    swTestOn = net.get('swTestOn')
    swTestOn.cmd('ovs-vsctl set-controller swTestOn none')
    swTestOn.cmd('ovs-vsctl set-fail-mode swTestOn standalone')

    host1.defaultIntf().setIP('192.168.10.101/24')
    # Run BGPd
    #host1.cmd('%s -d -f %s' % (BGPD, BGPD_CONF))
    #host1.cmd('/sbin/route add default gw 192.168.10.254 dev %s-eth0' % (host1.name))

    # Configure new host interfaces
    #host2.defaultIntf().setIP('172.16.10.2/24')
    #host2.defaultIntf().setMAC('00:00:00:00:01:02')
    #host2.cmd('/sbin/route add default gw 172.16.10.254 dev %s-eth0' % (host2.name))

    # Set up AS2
    host3.setIP('192.168.10.1', 24, 'host3-eth0')
    #host3.cmd('sudo ip addr add 172.16.20.1/24 dev host3-eth0')
    host3.setIP('192.168.20.1', 24, 'host3-eth1')
    host3.setMAC('00:00:00:00:02:01', 'host3-eth0')
    host3.setMAC('00:00:00:00:02:02', 'host3-eth1')
    #host3.setIP('172.16.20.254', 24, 'host3-eth2')
    host3.setIP('3.0.0.254', 8, 'host3-eth2')
    host3.cmd('sysctl net.ipv4.conf.all.forwarding=1')

    host3.setIP('1.168.30.2', 24, 'host3-eth3')
    host3.cmd('sysctl net.ipv4.conf.all.arp_ignore=1')
    host3.cmd('sysctl net.ipv4.conf.all.arp_announce=1')
    as2host = net.get('as2host')
    #as2host.defaultIntf().setIP('172.16.20.1/24')
    for i in range(0, 20):
        as2host.cmd('sudo ip addr add 3.0.%d.1/24 dev as2host-eth0' % i)
    as2host.setIP('1.168.30.100', 24, 'as2host-eth1')

    as2host.cmd('ip route add default via 3.0.0.254')

    # Set up AS3
    host4.setIP('192.168.30.1', 24, 'host4-eth0')
    host4.setMAC('00:00:00:00:03:01', 'host4-eth0')
    host4.setIP('4.0.0.254', 8, 'host4-eth1')
    host4.setMAC('00:00:00:00:03:99', 'host4-eth1')
    host4.cmd('sysctl net.ipv4.conf.all.forwarding=1')
    as3host = net.get('as3host')
    for i in range(0, 20):
        as3host.cmd('sudo ip addr add 4.0.%d.1/24 dev as3host-eth0' % i)
    as3host.cmd('ip route add default via 4.0.0.254')

    host4.setIP('10.0.0.4', 24, 'host4-eth2')
    host4.setMAC('00:00:00:00:03:33', 'host4-eth2')

    #root space
    host4.setIP('1.168.30.3', 24, 'host4-eth3')
    host4.setMAC('00:00:00:00:03:03', 'host4-eth3')

    # Set up AS4
    #as4host = net.get('as4host')
    #as4host.defaultIntf().setIP('172.16.40.1/24')
    #as4host.cmd('ip route add default via 172.16.40.254')

    # setup interface address for 100 quagga hosts
    #time.sleep(10)
    #for i in range(numHost101, numHost200 + 1):
    #host100 = net.get('host' + str(i))
    #host100.cmd(str(i)+'.0.1.254', 24, 'host'+str(i)+'-eth1')
    #as4host100 = net.get('as4host%s' %(i))
    #as4host100.defaultIntf().setIP(str(i) + '.0.0.1/24')
    #as4host100.cmd('ip route add default via ' + str(i) + '.0.0.254')
    #for j in range(0, 100):
    #as4host100.cmd('sudo ip addr add %d.0.%d.1/24 dev %s-eth0' %(i, j, as4host100))

    # Set up AS6 - This has a router and a route server
    as6rs, host5 = net.get('as6rs', 'host5')

    as6rs.setIP('192.168.60.1', 24, 'as6rs-eth0')
    as6rs.setMAC('00:00:00:06:06:01', 'as6rs-eth0')
    as6rs.setIP('1.168.30.6', 24, 'as6rs-eth1')
    as6rs.setMAC('00:00:00:06:06:06', 'as6rs-eth1')

    host5.setIP('192.168.60.2', 24, 'host5-eth0')
    host5.setMAC('00:00:00:00:06:02', 'host5-eth0')
    #as6router.setIP('172.16.60.254', 24, 'as6router-eth1')
    host5.setIP('5.0.0.254', 8, 'host5-eth1')
    host5.cmd('sysctl net.ipv4.conf.all.forwarding=1')
    host5.setIP('10.0.0.5', 24, 'host5-eth2')
    host5.setMAC('00:00:00:00:06:66', 'host5-eth2')
    host5.setIP('1.168.30.5', 24, 'host5-eth3')
    host5.setMAC('00:00:00:00:06:05', 'host5-eth3')

    as6host = net.get('as6host')
    #as6host.defaultIntf().setIP('5.0.0.1/24')
    for i in range(0, 10):
        as6host.cmd('sudo ip addr add 5.0.%d.1/24 dev as6host-eth0' % i)
    as6host.cmd('ip route add default via 5.0.0.254')

    # test the host in the as6
    #for i in range(1, 10):
    #    baseip = (i-1)*4
    #    host = net.get('as6host%d' % i)
    #    host.defaultIntf().setIP('172.16.70.%d/24' % (baseip+1))
    #    host.cmd('ip route add default via 172.16.70.%d' % (baseip+2))
    #   as6router.setIP('172.16.70.%d' % (baseip+2), 30, 'as6router-eth%d' % (i+1))

    # Start Quagga on border routers
    startquagga(host3, 1, QUAGGA_CONFIG_FILE_DIR + '/quagga1.conf')
    startquagga(host4, 2, QUAGGA_CONFIG_FILE_DIR + '/quagga2.conf')
    #for i in range(numHost101, numHost200 + 1):
    #host100=net.get('host%d' % (i))
    #startquaggahost5(host100, i)

    startquagga(as6rs, 4, QUAGGA_CONFIG_FILE_DIR + '/quagga-as6-rs.conf')
    startquagga(host5, 5, QUAGGA_CONFIG_FILE_DIR + '/quagga-as6.conf')

    #root1, root2, rootTestOn  = net.get( 'root1', 'root2', 'rootTestOn' )
    root1, rootTestOn = net.get('root1', 'rootTestOn')
    host1.intf('host1-eth1').setIP('1.1.1.1/24')
    root1.intf('root1-eth0').setIP('1.1.1.2/24')
    #host2.intf('host2-eth1').setIP('1.1.2.1/24')
    #root2.intf('root2-eth0').setIP('1.1.2.2/24')

    #rootTestOn.cmd('ip addr add 1.168.30.102/24 dev rootTestOn-eth0')
    rootTestOn.cmd('ip addr add 1.168.30.99/24 dev rootTestOn-eth0')

    stopsshd()

    startquagga(host1, 100,
                QUAGGA_CONFIG_FILE_DIR + '/quagga-sdn-modified.conf')
    hosts = [host1, host3, host4, host5, as2host, as6rs]
    #sshdHosts = sshdHosts + hosts
    startsshds(hosts)
    #
    onos1 = '127.0.0.1'
    forwarding1 = '%s:2000:%s:2000' % ('1.1.1.2', onos1)
    root1.cmd(
        'ssh -nNT -o "PasswordAuthentication no" -o "StrictHostKeyChecking no" -l sdn -L %s %s & '
        % (forwarding1, onos1))

    # Forward 2605 to root namespace for easier access to SDN domain BGPd
    # If root can ssh to itself without a password this should work
    root1.cmd(
        'ssh -N -o "PasswordAuthentication no" -o "StrictHostKeyChecking no" -L 2605:1.1.1.1:2605 1.1.1.1 &'
    )
    #time.sleep(3000000000)
    CLI(net)

    # Close the ssh port forwarding
    #quietRun('sudo pkill -f 1.1.1.1')

    stopsshd()
    stopquagga()
    net.stop()
 def __init__( self, mininet ):
     self.mininet = mininet
     CLI.__init__( self, mininet )
Exemplo n.º 24
0
 def interact(self):
     "Start network and run our simple CLI."
     self.start()
     result = CLI(self)
     self.stop()
     return result
Exemplo n.º 25
0
 def __init__ (self, net):
     """Init method for our custom CLI."""
     self.net = net
     CLI.__init__(self, net)
Exemplo n.º 26
0
def execute(module,
            topology_module=None,
            topology=default_topology,
            function=default_function,
            args=default_args,
            cli=default_cli,
            timeout=default_timeout,
            nodes=default_nodes,
            nox_path=default_nox_path,
            verbose=default_verbose,
            experiment_mode=default_experiment_mode):

    nodes = int(nodes)
    topology_module = module + "_topo" if topology_module is None else topology_module

    dirs = fetch_subdirs()
    setup_env(module, topology_module, function, args, topology, dirs,
              experiment_mode, nodes)
    import_directories(dirs)

    q = Queue()
    listener = Listener(signal_address)
    wait = Process(target=receive_signal, args=(listener, q))
    wait.daemon = True
    wait.start()

    # if experiment_mode:
    #     update_application = get_function_by_name(module, function)
    #     initial_topology = get_function_by_name(topology_module, topology)
    #     setup = get_function_by_name("update_lib", "setup")
    #     inst = DummyComponent(args, update_application, setup, initial_topology)
    #     os._exit(0)

    if experiment_mode:
        # yappi.start()
        nox = Process(target=run_nox)
        nox = NOX("c0", "UpdateApp")
        nox.start()
        lg.setLogLevel('output')
        output("*** Application started ***\n")
        wait.join(timeout)
        msg = ""
        status = ""
        if wait.is_alive():
            status = "killed"
            wait.terminate()
        else:
            status = "finished"
            msg = q.get()
        # yappi.stop()
        # stats = string.join([str(stat) for stat in yappi.get_stats(yappi.SORTTYPE_TTOTAL)],"\n")
        output("*** Application %s ***\n%s" % (status, msg))
        # output("*** Stats %s " % (stats))
        if verbose:
            output("\n*** Controller output: ***\n" + getControllerOutput() +
                   "\n")
        nox.stop()
        os._exit(0)
    # elif nox_only:
    #     nox_command = os.path.expanduser(nox_path)
    #     nox_dir = os.path.dirname(nox_command)
    #     os.chdir(nox_dir)
    #     if verbose:
    #         nox_command += " -v"

    #     command = "%s -i ptcp:6633 %s" % (nox_command,"UpdateApp")
    #     os.system(command)
    #     wait.join()
    #     os._exit(0)

    else:
        global mininet
        topo = get_function_by_name(topology_module,
                                    topology)(nodes).mininet_topo()
        mininet = Mininet(topo=topo,
                          switch=UserSwitch,
                          controller=lambda name: NOX(name, "UpdateApp"),
                          xterms=False,
                          autoSetMacs=True,
                          autoStaticArp=True)
        mininet.start()
        lg.setLogLevel('output')
        output("*** Mininet Up ***\n")
        output("*** Application started ***\n")
        if cli:
            CLI(mininet)
        wait.join(timeout)
        msg = ""
        status = ""
        if wait.is_alive():
            status = "killed"
            listener.close()
            wait.terminate()
        else:
            status = "finished"
            msg = q.get()
        output("*** Application %s ***\n%s" % (status, msg))
        if verbose:
            output("*** Controller output: ***\n" + getControllerOutput() +
                   "\n")
        mininet.stop()
        output("*** Mininet Down ***\n")
        os._exit(0)