Esempio n. 1
0
def tree_topo_cluster():
    servers = [ 'mininet1', 'mininet2' ]
    topo = TreeTopo( depth=2, fanout=2 )
    # Tunneling options: ssh (default), vxlan, gre
    net = MininetCluster( controller=RemoteController, topo=topo, servers=servers,
                          placement=SwitchBinPlacer, tunneling="gre" )
    net.addController( 'controller', controller=RemoteController, ip="192.168.59.100", port=6633)
    net.start()
    net.pingAll()
    CLI( net )
    net.stop()
Esempio n. 2
0
def tree_topo_cluster():
    servers = ['mininet1', 'mininet2']
    topo = TreeTopo(depth=2, fanout=2)
    # Tunneling options: ssh (default), vxlan, gre
    net = MininetCluster(controller=RemoteController,
                         topo=topo,
                         servers=servers,
                         placement=SwitchBinPlacer,
                         tunneling="gre")
    net.addController('controller',
                      controller=RemoteController,
                      ip="192.168.59.100",
                      port=6633)
    net.start()
    net.pingAll()
    CLI(net)
    net.stop()
def tree_topo_cluster():
    servers = [ 'mininet1', 'mininet2' ]
    topo = LeafSpineTopo( leaf=2, spine=2, fanout=2 )
    net = MininetCluster( controller=RemoteController, topo=topo, servers=servers,
                          placement=DFSPlacer, root_node="spine1", tunneling="vxlan" )
    net.addController( 'controller', controller=RemoteController, ip="192.168.59.100", port=6633)
    net.start()
    CLI( net )
    net.stop()
Esempio n. 4
0
def RunTestBed():

    # NCTU_EC_Topology( Core Switch, Aggregate Switch, Access Switch, Host)
    topo = NCTU_EC_Topology(core=1, agg=6, access=6, host=20)

    net = MininetCluster( controller=RemoteController, topo=topo, servers=SERVER_LIST, placement=DFSPlacer, root_node="core1", tunneling="vxlan" )
    net.addController( 'controller', controller=RemoteController, ip=CONTROLLER_IP, port=CONTROLLER_PORT )
    net.start()
    CLI( net )
    net.stop()
Esempio n. 5
0
def clusterSanity():
    "Sanity check for cluster mode"
    topo = SingleSwitchTopo()
    net = MininetCluster( topo=topo )
    net.start()
    CLI( net )
    net.stop()
Esempio n. 6
0
def tree_topo_cluster():
    servers = ['mininet1', 'mininet2']
    topo = LeafSpineTopo(leaf=2, spine=2, fanout=2)
    net = MininetCluster(controller=RemoteController,
                         topo=topo,
                         servers=servers,
                         placement=DFSPlacer,
                         root_node="spine1",
                         tunneling="vxlan")
    net.addController('controller',
                      controller=RemoteController,
                      ip="192.168.59.100",
                      port=6633)
    net.start()
    CLI(net)
    net.stop()
Esempio n. 7
0
def RunTestBed():

    # NCTU_EC_Topology( Core Switch, Aggregate Switch, Access Switch, Host)
    topo = NCTU_EC_Topology(core=1, agg=6, access=6, host=20)

    net = MininetCluster(controller=RemoteController,
                         topo=topo,
                         servers=SERVER_LIST,
                         placement=DFSPlacer,
                         root_node="core1",
                         tunneling="vxlan")
    net.addController('controller',
                      controller=RemoteController,
                      ip=CONTROLLER_IP,
                      port=CONTROLLER_PORT)
    net.start()
    CLI(net)
    net.stop()
Esempio n. 8
0
def emulation():

    # Use MininetCluster for cluster emulation of hosts and switches
    servers = ['master']
    # For multiple hosts: servers = ['master', 'slave']

    # Do not use 127.0.0.1
    serverIP = {'master': IP}
    # For multiple hosts: serverIP = {'master': "192.168.0.1", 'slave': "192.168.0.2"}
    net = MininetCluster(controller=None,
                         user='******',
                         servers=servers,
                         serverIP=serverIP)
    switches = [None]

    # Add OpenFlow Switches (OVS)
    info("*** Add OFS\n")
    switch = net.addSwitch("ofs1",
                           failMode='standalone',
                           user='******',
                           server='master',
                           serverIP=IP)
    switches.append(switch)

    switch = net.addSwitch("ofs2",
                           failMode='standalone',
                           user='******',
                           server='master',
                           serverIP=IP)
    switches.append(switch)

    # For multiple hosts:
    # switch = net.addSwitch ("ofs3", failMode='standalone', user='******', server='slave', serverIP="192.168.0.2")
    # switches.append (switch)

    info("*** Add link between OFS\n")
    net.addLink(switches[1], switches[2])

    # For multiple hosts:
    # net.addLink (switches[1], switches[3])

    hosts = []
    ueIpList = []
    lteList = []

    # Create one LTE object for each available CPU
    for c in range(0, CPU):
        # Master will responsible for emulation of EPC (MME/SGW/PGW)
        if c == 0:
            MODE = 'Master'
        else:
            MODE = 'Slave'

        LOG = "/tmp/ns-3-log-{0}.txt".format(c)

        # IP address format of UE
        UE_IP_BASE = '7.0.{0}.1'.format(c)

        # The TAP interface which is used as junction point of Mininet and NS-3
        SLAVE_DEVICE = 'slaveTap{0}'.format(c)

        # Reference mininet/lte.py for more detail of Lte class
        lte = Lte(tdf=TDF,
                  mode=MODE,
                  epcSwitch=switches[1],
                  agentIp=IP,
                  logFile=LOG,
                  imsiBase=c * (UE / CPU),
                  cellIdBase=c * (ENB / CPU),
                  ueIpBase=UE_IP_BASE,
                  slaveName=SLAVE_DEVICE)
        # For multiple hosts: agentIp="192.168.0.2"

        info('*** Add eNodeB on LTE {0}\n'.format(c))
        for i in range(c * (ENB / CPU) + 1, (c + 1) * (ENB / CPU) + 1):
            info('enbTap{0} '.format(i))

            lte.addEnb(switches[2],
                       "enbTap{0}".format(i),
                       position=[distance * i, distance * i * c, 0])

            # For multiple hosts: agentIp="192.168.0.2"
            # lte.addEnb (switches[3], "enbTap{0}".format (i), position=[distance * i, distance * i * c, 0])
        info('\n')

        info('*** Add UE on LTE {0}\n'.format(c))
        for i in range(c * (UE / CPU) + 1, (c + 1) * (UE / CPU) + 1):
            info('h{0} '.format(i))

            # UE is combination of Mininet host and NS-3 node
            host = net.addHost("h{0}".format(i),
                               user='******',
                               server='master',
                               serverIP=IP,
                               tdf=TDF)
            # For multiple hosts:
            # host = net.addHost ("h{0}".format (i), user='******', server='slave', serverIP="192.168.0.2", tdf=TDF)

            ueIP, ueIndex = lte.addUe(
                host, position=[distance * i, distance * i * c, 0])

            # Add EpsBearer to UE
            lte.addEpsBearer(ueIndex=ueIndex,
                             localPortStart=3000,
                             localPortEnd=3999,
                             qci='EpsBearer.NGBR_IMS')
            lte.addEpsBearer(ueIndex=ueIndex,
                             remotePortStart=3000,
                             remotePortEnd=3999,
                             qci='EpsBearer.NGBR_IMS')
            lte.addEpsBearer(ueIndex=ueIndex,
                             localPortStart=4000,
                             localPortEnd=4999,
                             qci='EpsBearer.GBR_CONV_VOICE')
            lte.addEpsBearer(ueIndex=ueIndex,
                             remotePortStart=4000,
                             remotePortEnd=4999,
                             qci='EpsBearer.GBR_CONV_VOICE')

            # Record IP address for further usage (depends on scenario)
            ueIpList.append(ueIP)
            hosts.append(host)
        info('\n')

        lteList.append(lte)

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

    info('*** lte.start ()\n')
    for lte in lteList:
        lte.start()

    info('*** Please wait for activation of EPS bearer...\n')
    call('sleep 15', shell=True)

    info('*** Notification: GTP-U tunnel does not support ping\n')
    # Emulation example:
    #  h1 iperf3 -s
    #  h2 iperf3 -c h1 -M 1024 -R -t 3
    #  or h2 iperf3 -c h1 -u -l 1024 -R -t 3 -b 1M
    ClusterCLI(net)

    for lte in lteList:
        lte.stop()
        lte.clear()
    net.stop()
Esempio n. 9
0
def emulation():

    # Use MininetCluster for cluster emulation of hosts and switches
    servers = ['master']
    # For multiple hosts: servers = ['master', 'slave']

    # Do not use 127.0.0.1
    serverIP = {'master': IP}
    # For multiple hosts: serverIP = {'master': "192.168.0.1", 'slave': "192.168.0.2"}
    net = MininetCluster(controller=None,
                         user='******',
                         servers=servers,
                         serverIP=serverIP)

    # Add OpenFlow Switches (OVS)
    info("*** Add OFS\n")
    rootSwitch = net.addSwitch("sw0",
                               failMode='standalone',
                               user='******',
                               server='master',
                               serverIP=IP)
    # For multiple hosts:
    # rootSwitch1 = net.addSwitch ("sw1", failMode='standalone', user='******', server='master', serverIP="192.168.0.1")
    # rootSwitch2 = net.addSwitch ("sw2", failMode='standalone', user='******', server='slave', serverIP="192.168.0.2")

    wifiList = []

    stationIP = {"h1": "10.0.0.1", "h2": "10.0.0.2"}
    adhocIP = {
        "adhoc1": "10.0.1.1",
        "adhoc2": "10.0.1.2",
        "adhoc3": "10.0.1.3"
    }

    # Reference mininet/wifi.py for more detail of WIFI class
    wifi = WIFI(enableQos=True, rootSwitch=rootSwitch, agentIP=IP)
    # For multiple hosts, multiple WIFI object is required:
    # wifi1 = WIFI (enableQos=True, rootSwitch=rootSwitch1, agentIP="192.168.0.1")
    # wifi2 = WIFI (enableQos=True, rootSwitch=rootSwitch2, agentIP="192.168.0.2")

    info('*** Add Access Point on WIFI\n')
    for i in range(1, AP + 1):
        name = "ap{0}".format(i)
        info(name + " ")
        sw = net.addSwitch(name,
                           failMode='standalone',
                           user='******',
                           server='master',
                           serverIP=IP)
        wifi.addAP(sw, channelNumber=1, ssid="opennet")

        # For multiple hosts:
        # sw2 = net.addSwitch ("ap2", failMode='standalone', user='******', server='slave', serverIP="192.168.0.2")
        # wifi2.addAP (sw2, channelNumber=1, ssid="opennet")
    info('\n')

    info('*** Add Station on WIFI\n')
    for i in range(1, STA + 1):
        name = "h{0}".format(i)
        info(name + " ")
        # Station is combination of Mininet host and NS-3 node
        host = net.addHost(name,
                           ip=stationIP[name],
                           user='******',
                           server='master',
                           serverIP=IP)
        wifi.addSta(host, channelNumber=1, ssid="opennet")

        # The following line is an example about using mobility model
        # wifi.addSta (host, channelNumber=1, ssid="opennet", mobilityType="ns3::ConstantVelocityMobilityModel", velocity=[0,0,0], position=[0,0,0])

        # For multiple hosts:
        # host = net.addHost ("sta2", ip=stationIP["sta2"], user='******', server='slave', serverIP="192.168.0.2")
        # wifi2.addSta (host, channelNumber=1, ssid="opennet")
    info('\n')

    info('*** Add Adhoc on WIFI {0}\n')
    for i in range(1, ADHOC + 1):
        name = "adhoc{0}".format(i)
        info(name + " ")
        host = net.addHost(name,
                           ip=adhocIP[name],
                           user='******',
                           server='master',
                           serverIP=IP)
        wifi.addAdhoc(host)

        # The following line is an example about using mobility model
        # wifi.addAdhoc (host, mobilityType="ns3::ConstantVelocityMobilityModel", velocity=[0,0,0], position=[0,0,0])

        # For multiple hosts:
        # host = net.addHost ("adhoc2", ip=adhocIP[name], user='******', server='slave', serverIP="192.168.0.2")
        # wifi2.addAdhoc (host)
    info('\n')

    wifiList.append(wifi)

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

    info('*** wifi.start ()\n')
    for wifi in wifiList:
        wifi.start()

    ClusterCLI(net)

    for wifi in wifiList:
        wifi.stop()
        wifi.clear()
    net.stop()
Esempio n. 10
0
def RunTestBed():

    # NCTU_EC_Topology( Core Switch, Aggregate Switch, Access Switch, Host)
    topo = NCTU_EC_Topology(core=1, agg=3, access=3, host=2)

    net = MininetCluster(controller=RemoteController,
                         topo=topo,
                         servers=SERVER_LIST,
                         placement=DFSPlacer,
                         root_node="core1",
                         tunneling="vxlan")
    net.addController('controller',
                      controller=RemoteController,
                      ip=CONTROLLER_IP,
                      port=CONTROLLER_PORT)

    wifi = WifiSegment()
    """
    Create AP
    """
    ap_to_access_sw = 0
    for i in xrange(1):
        AP_NAME = "ap" + str(i)
        ap = net.addSwitch(AP_NAME, server=SERVER_LIST[0])
        mininet.ns3.setMobilityModel(ap, None)
        mininet.ns3.setPosition(ap, 0, 0, 0)
        wifi.addAp(ap, channelNumber=6, ssid="opennet-ap", port=0)
        net.addLink(ap, topo.access_sw_list[ap_to_access_sw])
        ap_to_access_sw += 1
    """
    Create Station
    """
    STA_NAME = "sta" + str(0)
    sta = net.addHost(STA_NAME, server=SERVER_LIST[0])
    mininet.ns3.setMobilityModel(sta, None)
    mininet.ns3.setPosition(sta, 0, 0, 0)
    wifi.addSta(sta, channelNumber=6, ssid="opennet-ap", port=0)

    net.start()
    mininet.ns3.start()
    """
    Post Handle
    """
    # XXX Need to fixed
    AP_NAME = "ap" + str(0)
    cmd = "ovs-vsctl add-port {0} {0}-eth0".format(AP_NAME)
    net.getNodeByName(AP_NAME).cmdPrint(cmd)

    STA_NAME = "sta" + str(0)
    cmd = "ip addr add 10.0.0.{0}/8 dev {1}-eth0".format(
        str(200 + i), STA_NAME)
    net.getNodeByName(STA_NAME).cmdPrint(cmd)
    net.getNodeByName(STA_NAME).cmdPrint(
        "ip addr show dev {0}-eth0".format(STA_NAME))
    """
    Show interface object in ns3
    """
    print("*** allTBintfs: {0}\n".format(mininet.ns3.allTBIntfs))
    CLI(net)
    mininet.ns3.stop()
    mininet.ns3.clear()
    net.stop()
def RunTestBed():

    # NCTU_EC_Topology( Core Switch, Aggregate Switch, Access Switch, Host)
    topo = NCTU_EC_Topology(core=1, agg=3, access=3, host=2)

    net = MininetCluster( controller=RemoteController, topo=topo, servers=SERVER_LIST, placement=DFSPlacer, root_node="core1", tunneling="vxlan" )
    net.addController( 'controller', controller=RemoteController, ip=CONTROLLER_IP, port=CONTROLLER_PORT )

    wifi = WifiSegment()

    """
    Create AP
    """
    ap_to_access_sw = 0
    for i in xrange(1):
        AP_NAME = "ap" + str(i)
        ap = net.addSwitch(AP_NAME, server=SERVER_LIST[0])
        mininet.ns3.setMobilityModel(ap, None)
        mininet.ns3.setPosition(ap, 0, 0, 0)
        wifi.addAp(ap, channelNumber=6, ssid="opennet-ap", port=0)
        net.addLink(ap, topo.access_sw_list[ap_to_access_sw])
        ap_to_access_sw += 1

    """
    Create Station
    """
    STA_NAME = "sta" + str(0)
    sta = net.addHost(STA_NAME, server=SERVER_LIST[0])
    mininet.ns3.setMobilityModel(sta, None)
    mininet.ns3.setPosition(sta, 0, 0, 0)
    wifi.addSta(sta, channelNumber=6, ssid="opennet-ap", port=0)

    net.start()
    mininet.ns3.start()

    """
    Post Handle
    """
    # XXX Need to fixed
    AP_NAME = "ap" + str(0)
    cmd = "ovs-vsctl add-port {0} {0}-eth0".format(AP_NAME)
    net.getNodeByName(AP_NAME).cmdPrint(cmd)

    STA_NAME = "sta" + str(0)
    cmd = "ip addr add 10.0.0.{0}/8 dev {1}-eth0".format(str(200+i), STA_NAME)
    net.getNodeByName(STA_NAME).cmdPrint(cmd)
    net.getNodeByName(STA_NAME).cmdPrint("ip addr show dev {0}-eth0".format(STA_NAME))

    """
    Show interface object in ns3
    """
    print("*** allTBintfs: {0}\n".format(mininet.ns3.allTBIntfs))
    CLI( net )
    mininet.ns3.stop()
    mininet.ns3.clear()
    net.stop()