Example #1
0
def main(run_tests=False):
    topo = FullTopo(nr=info.N_ROUTERS, nh=info.N_HOSTSEACH)

    net = Mininet(topo)
    net.start()

    nm = FullNM(net, info.N_ROUTERS, info.N_HOSTSEACH)

    nm.setup()

    print("{:=^80}\n".format(" Running tests "))
    if run_tests:
        for testname in tests.TESTS:
            skipped = False

            if should_skip(testname):
                skipped = True
                passed = False
            else:
                results = nm.run_test(testname)
                passed = validate_test_results(results)
            str_status = "PASSED" if passed else "FAILED"
            if skipped:
                str_status = "SKIPPED"
            print("{: >20} {:.>50} {: >8}".format(testname, "", str_status))
            time.sleep(info.TIMEOUT / 2)

    else:
        net.startTerms()
        signal.signal(signal.SIGINT, signal_handler)
        forever = threading.Event()
        forever.wait()

    net.stop()
Example #2
0
def main(run_tests=False):
    topo = SingleSwitchTopo(n=info.N_HOSTS)
    net = Mininet(topo)
    net.start()

    nm = NetworkManager(net, info.N_HOSTS)
    nm.setup()
    nm.start_router()
    time.sleep(1)

    max_points = POINTS_PER_TEST * len(tests.TESTS)
    total = 0

    print("{:=^80}\n".format(" Running tests "))
    if run_tests:
        for testname in tests.TESTS:
            results = nm.run_test(testname)
            passed = validate_test_results(results)
            crt_points = POINTS_PER_TEST if passed else 0
            total += crt_points
            str_status = "PASSED" if passed else "FAILED"
            str_points = "[{}/{}]".format(crt_points, POINTS_PER_TEST)
            print("{: >20} {:.>40} {: >8} {: >8}".format(testname, "", str_status,
                                                        str_points))
            time.sleep(info.TIMEOUT / 2)

        print("\nTOTAL: {}/{}\n".format(total, max_points))
    else:
        net.startTerms()
        signal.signal(signal.SIGINT, signal_handler)
        forever = threading.Event()
        forever.wait()

    net.stop()
Example #3
0
def perfTest():
   "Create network and run simple performance test"
   #"--- core to aggregation switches"
   linkopts1 = {'bw':50, 'delay':'5ms'}
   #"--- aggregation to edge switches"
   linkopts2 = {'bw':30, 'delay':'10ms'}
   #"--- edge switches to hosts"
   linkopts3 = {'bw':10, 'delay':'15ms'}
   topo = CustomTopo(linkopts1 , linkopts2 , linkopts3 , fanout= 2)
   #net = Mininet(topo=topo,host=CPULimitedHost, link=TCLink)
   net = Mininet(controller=None,topo=topo)
   c = net.addController('c0',controller=RemoteController,ip='127.0.0.1',port=6633)
   #net.addNAT().configDefault()
   #net.build()
   #c.start()
   net.start()
   net.startTerms()
   '''
   os.popen('ovs-vsctl add-port s1 eth0')
   for i in range(8,16):
       h = net.get('h%d'%(i))
       h.cmdPrint('dhclient '+h.defaultIntf().name)
   CLI(net)
   for i in range(8,16):
       h = net.get('h%d'%(i))
       h.cmdPrint('dhclient -r '+h.defaultIntf().name)
   net.stop()
   '''
   h = net.get('h9')
   h.cmd('ifconfig')
   CLI(net)
   net.stop()
Example #4
0
def emptyNet(nsw=1):

    net = Mininet(topo=None, build=False)

    info('*** Init Experimento 1\n\n')

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

    info('*** Adding hosts\n')
    user1 = net.addHost('user1', ip='10.0.0.2', mac='00:00:00:00:00:02')
    server1 = net.addHost('server1', ip='10.0.0.1', mac='00:00:00:00:00:01')

    info('*** Adding switch\n')
    switch1 = net.addSwitch('switch1')
    switch1.start([controller1])

    info('\n*** Creating links\n')
    net.addLink(user1, switch1)
    net.addLink(server1, switch1)

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

    info('*** Opening xterm\n')
    net.startTerms()
    info('*** Running CLI\n')
    CLI(net)

    info('*** Stopping network')
    net.stop()
Example #5
0
def myNetwork():
    CONTROLLER_IP = '10.0.2.15'

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

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

    c1 = net.addController(name='c1', controller=Controller)

    info('*** Add switches\n')
    os3 = net.addSwitch('os3')
    clu2r1 = net.addSwitch('clu2r1')

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

    clu2gre = net.addHost('clu2gre', cls=LinuxRouter, ip='30.0.0.1/16')
    or0 = net.addHost('or0',
                      cls=Host,
                      ip='30.0.0.254/16',
                      defaultRoute='via 30.0.0.1')
    http2 = net.addHost('http2',
                        cls=Host,
                        ip='192.168.0.20/24',
                        defaultRoute='via 192.168.0.254')

    info('*** Add links\n')
    net.addLink(or0, os3)
    net.addLink(os3, clu2gre, params2={'ip': '30.0.0.2/16'})

    net.addLink(clu2r1,
                clu2gre,
                intfName1=clu2r1.name + '-eth1',
                params2={'ip': '1.1.1.1/24'})
    net.addLink(os3, clu2r1, intfName2=clu2r1.name + '-eth2')

    net.addLink(http2, clu2r1, intfName2=clu2r1.name + '-eth0')

    # Routage
    print clu2gre.cmd('ip route add default via 1.1.1.254')

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

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

    info('*** Starting switches\n')
    net.get('clu2r1').start([c0])
    net.get('os3').start([c1])

    net.startTerms()
    CLI(net)
    net.stop()
Example #6
0
def main():
    topo = MyTopo(args.behavioral_exe, args.json, args.thrift_port)

    net = Mininet(topo=topo, host=P4Host, switch=P4Switch, controller=None)
    # == CPU interfaces
    # create an interface for the CPU on s11 and install it as port 11
    for s in [n for n in G.nodes() if G.node[n]["type"] == "switch"]:
        _port = _configs[s]["cpu_iface"]
        print "ADD PORT %s on %s" % (_port, s)
        cpu_intf = Intf(_port, net.get(s), 11)

    net.start()
    net.startTerms()
    # default route to gateway for each host on eth0
    # in s1 network
    for h in [net.get(n) for n in G.nodes() if G.node[n]["type"] == "host"]:
        print "CONFIG host ", h
        h.setDefaultRoute("dev eth0 via 192.0.2.1")  # set the default route
        h.cmd("../beat.sh &")  # launch heart beat on every host

    for s in [net.get(n) for n in G.nodes() if G.node[n]["type"] == "switch"]:
        cmd = "python ../lldpmain.py config/%s.json 2> log/lldp.%s.err &" % (
            str(s), str(s))
        print "LLDP on ", s, cmd
        s.cmd(cmd)  # launch LLDP

    for n in [n for n in G.nodes() if G.node[n]["type"] == "host"]:
        h = net.get(n)
        h.describe()

    sleep(1)

    # prepare switches
    for port in [
            G.node[n]["thrift_port"] for n in G.nodes()
            if G.node[n]["type"] == "switch"
    ]:
        print "CONFIG switch", port
        cmd = [args.cli, args.json, str(port)]
        with open("../commands2.txt", "r") as f:
            print " ".join(cmd)
            try:
                output = subprocess.check_output(cmd, stdin=f)
                print output
            except subprocess.CalledProcessError as e:
                print e
                print e.output
                exit(-1)

    sleep(1)

    print "LAUNCH switches slow path"
    os.system("./switches.sh")

    sleep(12)

    CLI(net)
    net.stop()
Example #7
0
def NiagaraNet():
    topo = NiagaraTopo()
    net = Mininet(
        topo=NiagaraTopo(),
        #                  host = CPULimitedHost,
        controller=lambda name: RemoteController(name, ip='127.0.0.1'))

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

    hostName = [CLIENT1, CLIENT2, SSWITCH1, SSWITCH2, SERVER1, SERVER2]
    hswitch = net.get(HSWITCH)

    # config host ip
    info('****config host ip\n')
    #    for hostname in hostName:
    #        host = net.getHost(hostname)
    for host in net.hosts:
        hostname = host.name
        host.cmdPrint("bash /home/niagara/ipHosts.sh %s" % hostname)

    # set openflow protocol
    info('****set openflow protocol\n')
    hswitch.cmdPrint("bash /home/niagara/brSwitches.sh")

    # start controller
    #    info('****start controller')
    # hswitch.cmdPrint("./startRyu.sh " + "rest_router")
    #    subprocess.call(["bash /home/niagara/startRyu.sh","rest_router"], shell=True)
    # config switch ip
    info('****config switch ip\n')
    hswitch.cmdPrint("bash /home/niagara/ipSwitches.sh")

    # config host routes
    info('****config host routes\n')
    #    for hostname in hostName:
    #        host = net.getHost(hostname)
    for host in net.hosts:
        hostname = host.name
        host.cmdPrint("bash /home/niagara/routeHosts.sh %s" % hostname)

    # set switch gw
    info('****set switch gw\n')
    hswitch.cmdPrint("bash /home/niagara/gwSwitches.sh")
    # set switch route
    info('****config switch routes\n')
    hswitch.cmdPrint("bash /home/niagara/routeSwitches.sh")

    info('****Starting terms for every node\n')
    net.startTerms()

    info('****Test connectivity\n')
    niagaraPing(net)

    info('****Runing CLI\n')
    CLI(net)
    net.stop()
Example #8
0
def myNetwork():
    CONTROLLER_IP = '10.0.2.15'
    H1_IP = '192.168.0.1'
    H2_IP = '192.168.0.2'
    H3_IP = '192.168.0.3'

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

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

    info('*** Add switches\n')
    s1 = net.addSwitch('s1',
                       cls=OVSKernelSwitch,
                       protocols='OpenFlow13',
                       dpid='1')
    s2 = net.addSwitch('s2',
                       cls=OVSKernelSwitch,
                       protocols='OpenFlow13',
                       dpid='2')
    #s3 = net.addSwitch('s3', cls=OVSKernelSwitch, protocols='OpenFlow13', dpid='3')

    info('*** Add hosts\n')
    h1 = net.addHost('h1', cls=Host, ip=H1_IP, defaultRoute=None)
    h2 = net.addHost('h2', cls=Host, ip=H2_IP, defaultRoute=None)
    h3 = net.addHost('h3', cls=Host, ip=H3_IP, defaultRoute=None)

    info('*** Add links\n')
    net.addLink(s1, h1, 1, 1)
    net.addLink(s2, h2, 2, 2)
    #net.addLink(s3, h3, 3, 3)

    net.addLink(s1, s2, 2, 1)
    #net.addLink(s1, s3, 3, 1)
    #net.addLink(s2, s3, 3, 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([c0])
    net.get('s2').start([c0])
    #net.get('s3').start([c0])

    net.startTerms()
    CLI(net)
    net.stop()
def bootMininet():
    #create mininet with the topology
    host = custom(CPULimitedHost, cpu=0.3)
    #link = custom(TCLink, bw=100, delay='5ms')
    topo = TestTopo()
    #OVSSwitch, KernelSwitch controller=  RemoteController,

    net = Mininet(topo=topo,  controller= partial( RemoteController, ip='127.0.0.1', port=6633 ), host=host, link=TCLink, build=True, autoPinCpus=True )
    net.start()
    net.startTerms()
    print("Background process!")
    CLI(net)    
    net.stop()
def main():
    topo = SingleSwitchTopo(n=info.N_HOSTS)
    net = Mininet(topo)
    net.start()

    nm = NetworkManager(net, info.N_HOSTS)
    nm.setup()
    nm.start_router()

    net.startTerms()
    try:
        while 1:
            time.sleep(500)
    except KeyboardInterrupt:
        pass

    net.stop()
from mininet.cli import CLI
from mininet.net import Mininet
from mininet.node import RemoteController

if '__main__' == __name__:
    net = Mininet(controller=RemoteController)
    c0 = net.addController('c0', port=6633)
    s1 = net.addSwitch('s1')
    h1 = net.addHost('h1')
    h2 = net.addHost('h2')

    net.addLink(s1, h1)
    net.addLink(s1, h2)

    net.build()

    c0.start()

    s1.start([c0])

    net.startTerms()
    CLI(net)
    net.stop()
Example #12
0
    c0 = net.addController('c0')

    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2')
    s3 = net.addSwitch('s3')

    h1 = net.addHost('h1')
    h2 = net.addHost('h2')
    h3 = net.addHost('h3')

    net.addLink(s1, h1)
    net.addLink(s2, h2)
    net.addLink(s3, h3)

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

    net.build()
    c0.start()
    s1.start([c0])
    s2.start([c0])
    s3.start([c0])

    net.startTerms()

    CLI(net)

    net.stop()
Example #13
0
def runExperiment(switches, publishers, consumers, protocol, delay_sw,
                  delay_sh, smpl):
    "Create	and	test	a	simple	experiment"
    #    mn --custom topology.py --topo mytopo,$delay_sw,$delay_sh  --controller=remote,port=9999 --switch=ovsk,protocols=OpenFlow14 --mac --arp --link=tc --post experiment_icn
    #    switch=OVSSwitch(protocols='OpenFlow14')

    icsdn_topo = ICNSDNTopology(delay_sw, delay_sh)
    icsdn_controller = RemoteController(name='NDSDN',
                                        ip='127.0.0.1',
                                        port=9999)
    net = Mininet(controller=icsdn_controller,
                  topo=icsdn_topo,
                  autoStaticArp=True,
                  autoSetMacs=True,
                  link=TCLink)

    net.start()
    time.sleep(50)
    exp = 'ds' + delay_sw + '_dsh' + delay_sh
    if protocol == 'icn':
        out_path = './Out/icn/' + exp + '/' + smpl + '/'

        #execute all service hosts connected to the switches
        for s in switches:
            s_num = s[2:]
            time.sleep(2)
            net.get(s).cmd('python3 ServiceHost.py -i ' + s_num +
                           ' -p icn -e ' + exp + ' -s ' + smpl + ' > ' +
                           out_path + 'SH_' + s_num + '.log &')

        #execute all the publishers. For each publisher a Service host and a producer are required to register the contents
        for p in publishers:
            p_num = p[1:]
            time.sleep(2)
            net.get(p).cmd('python3 ServiceHost.py repo -r repo -i ' + p_num +
                           ' -p icn -e ' + exp + ' -s ' + smpl + ' > ' +
                           out_path + 'SH_repo_' + p_num + '.log &')
            time.sleep(2)
            net.get(p).cmd('python3 producer.py -c content_files -r files' +
                           p_num + '   > ' + out_path + 'producer_' + p_num +
                           '.log &')

        #execute all the consumers
#        time.sleep(30)
#        for h in consumers:
#            h_num = h[1:]
#            time.sleep(2)
#            net.get(h).cmd('python3 consumer.py -i '+h_num+' -p icn -e '+exp+' -s '+smpl+' > ' + out_path + 'consumer_'+h_num+'.log &')
        net.startTerms()
    else:

        #       in the case of traditional IP routing (without ICN switches) no Service host is required.
        time.sleep(2)
        out_path = './Out/noicn/' + exp + '/' + smpl + '/'
        for p in publishers:
            p_num = p[1:]
            time.sleep(2)
            net.get(p).cmd('python3 ServiceHost.py repo -r repo -i ' + p_num +
                           ' -p noicn -e ' + exp + ' -s ' + smpl + ' > ' +
                           out_path + 'SH_repo_' + p_num + '.log &')
            time.sleep(2)
            net.get(p).cmd('python3 producer.py -c content_files -r files' +
                           p_num + '   > ' + out_path + 'producer_' + p_num +
                           '.log &')

        time.sleep(60)
        for h in consumers:
            h_num = h[1:]
            net.get(h).cmd('python3 consumer.py -i ' + h_num +
                           ' -p noicn -e ' + exp + ' -s ' + smpl + ' > ' +
                           out_path + 'consumer_' + h_num + '.log &')

# CLI(net)
    finished_num = dict()
    for c in consumers:
        finished_num[c] = 0
    e = threading.Event()
    while (True):
        e.wait(300)
        finished, finished_num = is_finished_exp(consumers, finished_num,
                                                 out_path)
        if finished:
            net.stop()
            commands.getstatusoutput('killall ryu-manager')
            commands.getstatusoutput('killall python3')
            exit(0)
Example #14
0
def main():
    nb_hosts, nb_switches, links = read_topo()

    #topo = MyTopo(args.behavioral_exe,
    #              args.json,
    #              nb_hosts, nb_switches, links)

    net = Mininet(  #topo = topo,
        host=P4Host, switch=P4Switch, controller=None)

    for i in xrange(nb_switches):
        switch = net.addSwitch('s%d' % (i + 1),
                               sw_path=args.behavioral_exe,
                               json_path=args.json,
                               thrift_port=_THRIFT_BASE_PORT + i,
                               pcap_dump=True,
                               device_id=i,
                               enable_debugger=True)

    for h in xrange(nb_hosts):
        #host = self.addHost('h%d' % (h + 1))
        host = net.addHost('h%d' % (h + 1),
                           ip='10.0.0.%d' % (h + 1),
                           mac='00:00:00:00:00:0%d' % (h + 1))

#opts = dict(bw=1000, max_queue_size=10000)
    link = []
    for a, b in links:
        link.append(net.addLink(a, b, cls=TCLink))
    net.start()

    for n in xrange(nb_hosts):
        h = net.get('h%d' % (n + 1))
        for off in ["rx", "tx", "sg"]:
            cmd = "/sbin/ethtool --offload eth0 %s off" % off
            print cmd
            h.cmd(cmd)
        print "disable ipv6"
        h.cmd("sysctl -w net.ipv6.conf.all.disable_ipv6=1")
        h.cmd("sysctl -w net.ipv6.conf.default.disable_ipv6=1")
        h.cmd("sysctl -w net.ipv6.conf.lo.disable_ipv6=1")
        h.cmd("sysctl -w net.ipv4.tcp_congestion_control=reno")
        h.cmd(
            "iptables -I OUTPUT -p icmp --icmp-type destination-unreachable -j DROP"
        )
        h.cmd("ifconfig eth0 mtu 40000")

    sleep(1)

    for i in xrange(nb_switches):
        cmd = [
            args.cli, "--json", args.json, "--thrift-port",
            str(_THRIFT_BASE_PORT + i)
        ]
        with open("commands.txt", "r") as f:
            print " ".join(cmd)
            try:
                output = subprocess.check_output(cmd, stdin=f)
                print output
            except subprocess.CalledProcessError as e:
                print e
                print e.output

    s1 = net.get('s1')
    s1.cmd("ifconfig s1-eth1 mtu 40000")
    s1.cmd("ifconfig s1-eth2 mtu 40000")

    sleep(1)

    print "Ready !"
    net.startTerms()
    net.iperf()
    while True:
        #for i in range (5):
        for j in range(len(link)):
            link[1].intf1.config(bw=0.001)
            sleep(1)
            #print 'link%d' %(j)"""

    CLI(net)
    net.stop()
Example #15
0
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)

    # Add physical interface
    info('Defining physical interface\n')
    intfName = 'enp0s9'

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

    info('*** Add hosts\n')
    h1 = net.addHost('h1',
                     cls=Host,
                     ip='10.0.0.1',
                     defaultRoute='via 10.0.0.254')
    h2 = net.addHost('h2',
                     cls=Host,
                     ip='10.0.0.2',
                     defaultRoute='via 10.0.0.254')
    h3 = net.addHost('h3',
                     cls=Host,
                     ip='10.0.0.3',
                     defaultRoute='via 10.0.0.254')
    r1 = net.addHost('r1', cls=Node, ip='10.0.0.254')

    info('*** Add links\n')
    net.addLink(s1, r1)
    net.addLink(s1, h1)
    net.addLink(s1, h2)
    net.addLink(s1, h3)

    info('Adding hardware interface', intfName, 'to router', r1.name, '\n')
    _intf = Intf(intfName, node=r1, ip='192.168.56.254/24')

    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])

    info('*** Post configure switches and hosts\n')
    r1.cmd('sysctl -w net.ipv4.ip_forward=1')
    h1.cmdPrint('/usr/sbin/sshd')
    h2.cmdPrint('/usr/sbin/sshd')
    h3.cmdPrint('/usr/sbin/sshd')

    net.startTerms()

    CLI(net)
    net.stop()