Beispiel #1
0
    def deployTopo(self):

        self.topo = self.net.start()
        time.sleep(1)
        # clean previous rules
        self.odl.clean(self.callBackConfs['chain'], self.callBackConfs['sw'])
        time.sleep(1)
        # self.odl.post(self.odl.controller, self.odl.DEFAULT_PORT, self.odl.DISABLE_STATISTICS, self.odl.disableStatistics(), True)


        self.deploySwConf()
        self.deployHostConf()
        self.deploySfConf()

        self.deployODLConf()

        #deploy chain
        self.deploySfc()

        self.disableOffLoadFromIfaces()

        CLI(self.net)
        self.odl.clean(self.callBackConfs['chain'], self.callBackConfs['sw'])
        self.cleanProcess()
        Cleanup()
Beispiel #2
0
def perfTest():
    topo = MyTopo()
    net = Mininet(topo=topo, link=TCLink, controller=None)
    net.addController('mycontroller',
                      controller=RemoteController,
                      ip='127.0.0.1')
    net.start()

    print('Dumping host connections')
    dumpNodeConnections(net.hosts)
    print('Testing network connectivity')
    net.pingFull()
    print('Testing bandwidth between pods')
    h01, h02, h31 = net.get('h01', 'h02', 'h31')
    # iperf server1 in pod 0
    h01.popen('iperf -s -u -i 1 > diff_pod', shell=True)
    # iperf server2 in pod 3
    h31.popen('iperf -s -u -i 1 > same_pod', shell=True)
    # iperf client send to server1 & server2
    h02.cmdPrint('iperf -c ' + h01.IP() + ' -u -t 10 -i 1 -b 100m')
    h02.cmdPrint('iperf -c ' + h31.IP() + ' -u -t 10 -i 1 -b 100m')
    net.stop()
    Cleanup()
Beispiel #3
0
    def mininetPrepare(self):

        self.NET = Mininet(topo=None, build=False)
        Cleanup().cleanup()

        for HOST in self.CONFIGURATION.MNHOSTS:
            HOST.ELEM = self.NET.addHost(HOST.ID)
            self.HOSTS[HOST.ID] = HOST

        for SWITCH in self.CONFIGURATION.MNSWITCHES:
            SWITCH.ELEM = self.NET.addSwitch(SWITCH.ID)
            self.SWITCHES[SWITCH.ID] = SWITCH

        if self.SWITCHES:
            self.POX = Popen([
                'python', '/'.join(abspath(__file__).split('/')[:-2]) +
                '/OFCONTROLLERS/pox/pox.py', 'forwarding.l2_learning'
            ],
                             stdout=FNULL,
                             stderr=STDOUT,
                             preexec_fn=pre_exec)
            sleep(3)
            UNICTRL = MNController('UNICTRL', '127.0.0.1', 6633)
            UNICTRL.ELEM = self.NET.addController('UNICTRL',
                                                  controller=RemoteController,
                                                  ip='127.0.0.1',
                                                  port=6633)
            self.CONTROLLERS['UNICTRL'] = UNICTRL

        for CONTROLLER in self.CONFIGURATION.MNCONTROLLER:
            CONTROLLER.ELEM = self.NET.addController(
                CONTROLLER.ID,
                controller=RemoteController,
                ip=CONTROLLER.IP,
                port=CONTROLLER.PORT)
            self.CONTROLLERS[CONTROLLER.ID] = CONTROLLER

        for OVS in self.CONFIGURATION.MNOVSES:
            OVS.ELEM = self.NET.addSwitch(OVS.ID)
            self.OVSSWITCHES[OVS.ID] = OVS

        ifacesData = self.interfacesMaping()
        for LINK in self.CONFIGURATION.CONNECTIONS:

            if not "IN/OUTIFACE" in LINK and not "OUT/INIFACE" in LINK:

                if LINK["IN/OUT"] in self.SWITCHES:
                    Element01 = self.SWITCHES[LINK["IN/OUT"]]
                else:
                    Element01 = self.OVSSWITCHES[LINK["IN/OUT"]]

                if LINK["OUT/IN"] in self.SWITCHES:
                    Element02 = self.SWITCHES[LINK["OUT/IN"]]
                else:
                    Element02 = self.OVSSWITCHES[LINK["OUT/IN"]]

                self.NET.addLink(Element01.ELEM, Element02.ELEM)
                continue

            if "IN/OUTIFACE" in LINK and not "OUT/INIFACE" in LINK:
                if LINK["IN/OUT"] in self.VNFS or LINK["IN/OUT"] in self.VMS:
                    if LINK["IN/OUT"] in self.VNFS:
                        EXTERNALLINKS = self.VNFS[LINK["IN/OUT"]].VM
                    else:
                        EXTERNALLINKS = self.VMS[LINK["IN/OUT"]]
                    for iface in EXTERNALLINKS.INTERFACES:
                        if iface["MAC"] == LINK["IN/OUTIFACE"]:
                            if iface["ID"] in ifacesData:
                                brName = iface["ID"]
                                virtualIface = ifacesData[iface["ID"]]
                                break
                            else:
                                self.STATUS = -1
                                return -1
                    if LINK["OUT/IN"] in self.SWITCHES:
                        Intf(brName, node=self.SWITCHES[LINK["OUT/IN"]].ELEM)
                    elif LINK["OUT/IN"] in self.OVSSWITCHES:
                        Intf(brName,
                             node=self.OVSSWITCHES[LINK["OUT/IN"]].ELEM)
                    else:
                        self.STATUS = -2
                        return -2
                    continue
                else:
                    Element01 = self.HOSTS[LINK["IN/OUT"]]

                    if LINK["OUT/IN"] in self.SWITCHES:
                        Element02 = self.SWITCHES[LINK["OUT/IN"]]
                    else:
                        Element02 = self.OVSSWITCHES[LINK["OUT/IN"]]

                    NodesLink = self.NET.addLink(Element01.ELEM,
                                                 Element02.ELEM)
                    HostIface = Element01.ELEM.intf(NodesLink.intf1)
                    HostIface.setMAC(LINK["IN/OUTIFACE"])
                    for iface in Element01.INTERFACES:
                        if iface["MAC"] == LINK["IN/OUTIFACE"]:
                            iface["ELEM"] = HostIface
                            break
                    continue

            if "OUT/INIFACE" in LINK and not "IN/OUTIFACE" in LINK:
                if LINK["OUT/IN"] in self.VNFS or LINK["OUT/IN"] in self.VMS:
                    if LINK["OUT/IN"] in self.VNFS:
                        EXTERNALLINKS = self.VNFS[LINK["OUT/IN"]].VM
                    else:
                        EXTERNALLINKS = self.VMS[LINK["OUT/IN"]]
                    for iface in EXTERNALLINKS.INTERFACES:
                        if iface["MAC"] == LINK["OUT/INIFACE"]:
                            if iface["ID"] in ifacesData:
                                brName = iface["ID"]
                                virtualIface = ifacesData[iface["ID"]]
                                break
                            else:
                                self.STATUS = -1
                                return -1
                    if LINK["IN/OUT"] in self.SWITCHES:
                        Intf(brName, node=self.SWITCHES[LINK["IN/OUT"]].ELEM)
                    elif LINK["IN/OUT"] in self.OVSSWITCHES:
                        Intf(brName,
                             node=self.OVSSWITCHES[LINK["IN/OUT"]].ELEM)
                    else:
                        self.STATUS = -2
                        return -2
                    continue
                else:
                    if LINK["IN/OUT"] in self.SWITCHES:
                        Element01 = self.SWITCHES[LINK["IN/OUT"]]
                    else:
                        Element01 = self.OVSSWITCHES[LINK["IN/OUT"]]

                    Element02 = self.HOSTS[LINK["OUT/IN"]]

                    NodesLink = self.NET.addLink(Element01.ELEM,
                                                 Element02.ELEM)
                    HostIface = Element01.ELEM.intf(NodesLink.intf2)
                    HostIface.setMAC(LINK["OUT/INIFACE"])
                    for iface in Element02.INTERFACES:
                        if iface["MAC"] == LINK["OUT/INIFACE"]:
                            iface["ELEM"] = HostIface
                            break
                    continue

            else:
                if LINK["IN/OUT"] in self.HOSTS and LINK[
                        "OUT/IN"] in self.HOSTS:
                    Element01 = self.HOSTS[LINK["IN/OUT"]]
                    Element02 = self.HOSTS[LINK["OUT/IN"]]

                    NodesLink = self.NET.addLink(Element01.ELEM,
                                                 Element02.ELEM)
                    HostIface01 = Element01.ELEM.intf(NodesLink.intf1)
                    HostIface02 = Element01.ELEM.intf(NodesLink.intf2)

                    HostIface01.setMAC(LINK["IN/OUTIFACE"])
                    HostIface02.setMAC(LINK["OUT/INIFACE"])

                    for iface in Element01.INTERFACES:
                        if iface["MAC"] == LINK["IN/OUTIFACE"]:
                            iface["ELEM"] = HostIface01
                            break
                    for iface in Element02.INTERFACES:
                        if iface["MAC"] == LINK["OUT/INIFACE"]:
                            iface["ELEM"] = HostIface02
                            break
                    continue

                if LINK["IN/OUT"] in self.HOSTS:
                    Element01 = self.HOSTS[LINK["IN/OUT"]]
                    if LINK["OUT/IN"] in self.VNFS:
                        EXTERNALLINKS = self.VNFS[LINK["OUT/IN"]].VM
                    else:
                        EXTERNALLINKS = self.VMS[LINK["OUT/IN"]]
                    for iface in EXTERNALLINKS.INTERFACES:
                        if iface["MAC"] == LINK["OUT/INIFACE"]:
                            if iface["ID"] in ifacesData:
                                virtualIface = ifacesData[iface["ID"]]
                                break
                            else:
                                self.STATUS = -1
                                return -1

                    HostIface = Intf(virtualIface,
                                     node=Element01.ELEM,
                                     mac=LINK["IN/OUTIFACE"])
                    for iface in Element01.INTERFACES:
                        if iface["MAC"] == LINK["IN/OUTIFACE"]:
                            iface["ELEM"] = HostIface
                            break
                    continue

                if LINK["OUT/IN"] in self.HOSTS:

                    if LINK["IN/OUT"] in self.VNFS:
                        EXTERNALLINKS = self.VNFS[LINK["IN/OUT"]].VM
                    else:
                        EXTERNALLINKS = self.VMS[LINK["IN/OUT"]]
                    for iface in EXTERNALLINKS.INTERFACES:
                        if iface["MAC"] == LINK["IN/OUTIFACE"]:
                            if iface["ID"] in ifacesData:
                                virtualIface = ifacesData[iface["ID"]]
                                break
                            else:
                                self.STATUS = -1
                                return -1

                    Element02 = self.HOSTS[LINK["OUT/IN"]]
                    HostIface = Intf(virtualIface,
                                     node=Element02.ELEM,
                                     mac=LINK["OUT/INIFACE"])
                    for iface in Element02.INTERFACES:
                        if iface["MAC"] == LINK["OUT/INIFACE"]:
                            iface["ELEM"] = HostIface
                            break
                    continue

                else:
                    self.STATUS = -3
                    return -3

        self.NET.build()
        for HOST in self.HOSTS:
            DummyIfaces = 0
            for IFACE in self.HOSTS[HOST].INTERFACES:
                if "ELEM" in IFACE:
                    if IFACE["IP"] != None:
                        IFACE["ELEM"].setIP(IFACE["IP"])
                    else:
                        if IFACE["ELEM"].IP() != None:
                            self.HOSTS[HOST].ELEM.cmd("sudo ip addr flush " +
                                                      str(IFACE["ELEM"].name))
                else:
                    self.HOSTS[HOST].ELEM.cmd("sudo ip link add mn-eth" +
                                              str(DummyIfaces) + " address " +
                                              IFACE["MAC"] + " type dummy")
                    if IFACE["IP"] != None:
                        self.HOSTS[HOST].ELEM.cmd("sudo ip addr add " +
                                                  IFACE["IP"] + " dev " +
                                                  "mn-eth" + str(DummyIfaces))
                    self.HOSTS[HOST].ELEM.cmd("sudo ifconfig mn-eth" +
                                              str(DummyIfaces) + " up")
                    DummyIfaces += 1

        return 0
 def clean_network(self):
     c = Cleanup()
     c.cleanup()
Beispiel #5
0
    # are slow to get answered.
    ping_front1 = net.getNodeByName("h1").cmd("ping -c 1 -w 60 10.0.2.100")
    if re.search('1 received', ping_front1):
        successful_pings += 1
    ping_front2 = net.getNodeByName("h2").cmd("ping -c 1 -w 60 10.0.2.100")
    if re.search('1 received', ping_front2):
        successful_pings += 1
    return ((2 - successful_pings) / 2.0) * 100.0


if os.getenv("SUDO_USER") == None:
    print "This program need 'sudo'"
    exit()

# Clean up from the last disaster
Cleanup()
for proc in psutil.process_iter():
    if proc.name() == "frenetic.native" or proc.name() == "openflow.native":
        proc.kill()

# Test Suite
pingall_test("quick_start", "repeater.py", topo=SingleSwitchTopo(2))
pingall_test("netkat_principles", "repeater2.py", topo=SingleSwitchTopo(2))
pingall_test("netkat_principles", "repeater3.py", expect_pct=100)
pingall_test("netkat_principles", "repeater4.py")
pingall_test("netkat_principles", "repeater5.py")
pingall_test("l2_learning_switch", "learning1.py")
pingall_test("l2_learning_switch", "learning2.py", expect_pct=100)
pingall_test("l2_learning_switch", "learning3.py")
pingall_test("l2_learning_switch", "learning4.py")
pingall_test("handling_vlans", "vlan1.py", expect_pct=66)