示例#1
0
def main():
    "Create and run experiment"
    start = time()

    topo = MNTopo()

    host = custom(CPULimitedHost, cpu=.15)  # 15% of system bandwidth
    link = custom(TCLink, max_queue_size=200)

    net = Mininet(topo=topo, host=host, link=link)

    net.start()

    print "*** Dumping network connections:"
    dumpNetConnections(net)

    print "*** Testing connectivity"

    net.pingAll()

    if args.cli:
        # Run CLI instead of experiment
        CLI(net)
    else:
        print "*** Running experiment"
        run_topology_experiment(net)

    net.stop()
    end = time()
    os.system("killall -9 bwm-ng")
    print "Experiment took %.3f seconds" % (end - start)
示例#2
0
def FatTreeNet(args, bw=10, cpu=-1, queue=100, controller='DCController'):
    droptail = {'max_queue_size': args.queue}
    red = {'max_queue_size': args.queue,'enable_red':1,'enable_ecn': 0, \
    'red_burst':55,'red_prob':0.01,'red_avpkt':1000,\
         'red_min':30000, 'red_max':90000,'red_limit':400000}
    red_ecn = {'max_queue_size': args.queue, 'enable_ecn': args.enable_ecn, \
    'enable_red': args.enable_red,\
            'red_min': args.redmin, 'red_max': args.redmax, 'red_burst': args.burst, \
            'red_prob': args.prob, 'red_avpkt': 1000, 'red_limit': 400000}

    info('*** Creating the topology')
    topo = FatTreeTopo(args.K)
    host = custom(CPULimitedHost, cpu=cpu)
    if args.mdtcp or args.dctcp:
        link = custom(TCLink,
                      bw=args.bw,
                      delay=str(args.delay) + 'ms',
                      **red_ecn)
    else:
        link = custom(TCLink, bw=args.bw, delay=str(args.delay) + 'ms', **red)
    net = Mininet(topo,
                  host=host,
                  link=link,
                  switch=OVSKernelSwitch,
                  controller=RemoteController,
                  autoStaticArp=True)

    return net
示例#3
0
def FatTreeNet(args,
               k=4,
               bw=100,
               cpu=-1,
               queue=100,
               controller='DCController'):
    ''' Create a Fat-Tree network '''
    '''info("STARTING CONTROLLER")
    if args.ECMP:
        pox_c = Popen("./pox.py %s --topo=ft,4 --routing=ECMP"%controller, shell=True)
    elif args.dij:
        pox_c = Popen("./pox.py %s --topo=ft,4 --routing=dij"%controller, shell=True)
    else:
        info('**error** the routing scheme should be ecmp or dijkstra\n')'''

    info('*** Creating the topology')
    topo = FatTreeTopo(k)

    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)

    net = Mininet(topo,
                  host=host,
                  link=link,
                  switch=OVSKernelSwitch,
                  controller=RemoteController,
                  autoStaticArp=True)

    return net
示例#4
0
    def set_topo(self, optNet, init_ip = False, init_mac = False):

        # add hosts
        hosts = {}
        for node in optNet.get_logical_nodes():
	    if init_ip and init_mac:
                host = self.addHost('h%d'% node, ip='0.0.0.0', mac=self.hostid_to_mac(node)) #DONT DO IT UNLESS U SET DHCLIENTS
	    elif init_ip:
                host = self.addHost('h%d'% node, ip='0.0.0.0') #DONT DO IT UNLESS U SET DHCLIENTS
	    if init_mac:
                host = self.addHost('h%d'% node, mac=self.hostid_to_mac(node))
	    else:
	        host = self.addHost('h%d'% node)
            hosts[node] = host

        # add switches
        switches = {}
        for node in optNet.nodes():
            switches[node] = self.addSwitch('s%d' % node, mac = "")

        CAPACITY_TO_MBITS = 5
        MAX_MBITS = 50

        # link hosts to switches
        for node in optNet.get_logical_nodes():
            _bw = MAX_MBITS
            intf = custom( TCIntf, bw=_bw )
            self.addLink(switches[node], hosts[node], intf=intf )

        # link switches
        for edge in optNet.physical_links():
            if edge[0] in switches.keys() and edge[1] in switches.keys():
                _bw = CAPACITY_TO_MBITS * optNet.get_plink_capacity(edge)
                intf = custom( TCIntf, bw=_bw )
                self.addLink(switches[edge[0]], switches[edge[1]], intf=intf)
示例#5
0
def create_ecmp_topo(pod,
                     density,
                     ip="127.0.0.1",
                     port=6653,
                     max_queue=100,
                     cpu=-1,
                     bw_c2a=10,
                     bw_a2e=10,
                     bw_e2h=10,
                     dctcp=False):
    """
        Create network topology and run the Mininet.
    """
    # Create Topo.
    topo = Fattree(pod, density)
    topo.create_nodes()
    topo.create_links(max_queue=max_queue,
                      bw_c2a=bw_c2a,
                      bw_a2e=bw_a2e,
                      bw_e2h=bw_e2h,
                      dctcp=dctcp)
    # Start Mininet
    # CONTROLLER_IP = ip
    # CONTROLLER_PORT = port
    link = custom(TCLink, max_queue=max_queue, enable_ecn=dctcp)
    host = custom(CPULimitedHost, cpu=cpu)
    net = Mininet(topo=topo,
                  host=host,
                  link=link,
                  controller=None,
                  autoSetMacs=True)
    # net.addController('controller', controller=RemoteController, ip=CONTROLLER_IP, port=CONTROLLER_PORT)

    # net.start()
    return (net, topo)
示例#6
0
文件: measure.py 项目: tye41/CS-6250
def main():
    "Create and run experiment"
    start = time()

    topo = MNTopo()

    host = custom(CPULimitedHost, cpu=.15)  # 15% of system bandwidth
    link = custom(TCLink, max_queue_size=200)

    net = Mininet(topo=topo, host=host, link=link)

    net.start()

    print "*** Dumping network connections:"
    dumpNetConnections(net)

    print "*** Testing connectivity"

    net.pingAll()

    if args.cli:
        # Run CLI instead of experiment
        CLI(net)
    else:
        print "*** Running experiment"
        run_topology_experiment(net)

    net.stop()
    end = time()
    os.system("killall -9 bwm-ng")
    print "Experiment took %.3f seconds" % (end - start)
示例#7
0
def main():
    "Parse argument"
    args = parse_args()

    if not os.path.exists(args.dir):
        os.makedirs(args.dir)

    "Create network topology, running experiments"
    lg.setLogLevel('info')
    start = time()
    cprint("*** Creating network topology:", "yellow")
    topo = MMwaveTestTopo(mmwavebw=args.bw)
    host = custom(CPULimitedHost, cpu=0.2)  # 20% of system bandwidth (why?)
    link = custom(TCLink)
    net = Mininet(topo=topo, host=host, link=link)
    net.start()
    cprint("*** Dumping network connections:", "green")
    dumpNetConnections(net)
    cprint("*** Configure MPTCP", "red")
    configMPTCP(net, args)
    cprint("*** Testing connectivity", "blue")
    net.pingAll()
    cprint("*** Running experiment", "magenta")
    #CLI(net)
    run(net, args)
    end = time()
    cprint("*** Finishing experiment, took %.3f seconds" % (end - start), "yellow")
    net.stop()
示例#8
0
def main():
    "Create and run experiment"
    start = time()

    #if 'seed' in vars(args):
    #random.seed(args.seed)

    k = args.k
    host = custom(CPULimitedHost, cpu=4.0 / (k**3))
    link = custom(TCLink, bw=args.bw, delay='0ms')

    #if args.control:
    #topo = NonblockingFatTreeTopo(k=k)
    #net = Mininet(topo=topo, host=host, link=link, build=True, cleanup=True, autoPinCpus=True, autoSetMacs=True)
    #else:
    topo = MyTopo()
    net = Mininet(topo=topo,
                  host=host,
                  link=link,
                  build=True,
                  cleanup=True,
                  autoPinCpus=True,
                  autoSetMacs=True,
                  autoStaticArp=True,
                  listenPort=6634)
    net.start()
    CLI(net)
示例#9
0
def pairNet( pairs=1, useSwitches=False, bw=None, cpu=-1, **kwargs ):
    "Convenience function for creating pair networks"
    clients, servers = [], []
    # This is a bit ugly - a lot of work to avoid flushing
    # routes; I think we should rethink how that works.
    class MyHost( CPULimitedHost ):
        "Put clients in root namespace and DON'T flush routes"
        def __init__( self, name, **kwargs ):
            # First N (=pairs) hosts are clients, in root NS
            kwargs.pop('inNamespace', True)
            isServer = int( name[ 1: ] ) > pairs
            CPULimitedHost.__init__( self, name, inNamespace=isServer, **kwargs )
        def setDefaultRoute( self, intf ):
            "Hack of sorts: don't set or flush route"
            pass

    cpu = custom( MyHost, cpu=cpu )
    link = custom( TCLink, bw=bw )
    topo = PairTopo( pairs, useSwitches )
    net = Mininet( topo, host=MyHost, **kwargs )
    net.hosts = sorted( net.hosts, key=lambda h: natural( h.name ) )
    clients, servers = net.hosts[ :pairs ], net.hosts[ pairs: ]
    info( "*** Configuring host routes\n" )
    for client, server in zip( clients, servers ):
        client.setHostRoute( server.IP(), client.defaultIntf() )
        server.setHostRoute( client.IP(), server.defaultIntf() )
    return net, clients, servers
示例#10
0
def main():
    "Create and run experiment"
    start = time()

    topo = ParkingLotTopo(n=args.n)

    host = custom(CPULimitedHost, cpu=.15)  # 15% of system bandwidth
    link = custom(TCLink, bw=args.bw, delay='1ms',
                  max_queue_size=200)

    net = Mininet(topo=topo, host=host, link=link)

    net.start()

    cprint("*** Dumping network connections:", "green")
    dumpNetConnections(net)

    cprint("*** Testing connectivity", "blue")

    net.pingAll()

    if args.cli:
        # Run CLI instead of experiment
        CLI(net)
    else:
        cprint("*** Running experiment", "magenta")
        run_parkinglot_expt(net, n=args.n)

    net.stop()
    end = time()
    os.system("killall -9 bwm-ng")
    cprint("Experiment took %.3f seconds" % (end - start), "yellow")
示例#11
0
def launch_network(k=4, bw=10, ip_alias=True, fair_queues=False, cli=False):
    signal.signal(signal.SIGTERM, signal_term_handler)

    # Cleanup the network
    cleanup()
    sh("killall ospfd zebra getLoads.py nc")

    # Remove tmp files and old namespaces
    subprocess.call(['rm', '/tmp/*.log', '/tmp/*.pid', '/tmp/mice*'])
    subprocess.call(['rm', '/var/run/netns/*'])

    # Flush root namespace mangle table
    subprocess.call(["iptables", "-t", "mangle" ,"-F"])
    subprocess.call(["iptables", "-t", "mangle" ,"-X"])

    # Topology
    topo = FatTree(k=k, sflow=False, ovs_switches=False)

    # Interfaces
    if fair_queues:
        print("*** Using FairQueues at the network interfaces")
        intf = custom(DCTCIntf, bw=bw)
    else:
        print("*** Using normal pFIFO queues at the network interfaces")
        intf = custom(PrioFifoIntf, bw=bw)

    # Network
    net = IPNet(topo=topo, debug=_lib.DEBUG_FLAG, intf=intf)

    # Save the TopoDB object
    TopologyDB(net=net).save(cfg.DB_path)

    # Start the network
    net.start()

    # Setup hash seeds
    setupHashSeeds(topo)

    # Start intreface collectors
    startCounterCollectors(topo, interval=1)

    if ip_alias:
        setupSecondaryIps(net)

    if cli:
        # Start the Fibbing CLI
        FibbingCLI(net)
    else:
        print("*** Looping forever. Press CTRL+C to quit")
        while True:
            try:
                time.sleep(2)
            except KeyboardInterrupt:
                print("*** KeyboardInterrupt catched! Shutting down")
                break

    net.stop()

    stopCounterCollectors(topo)
示例#12
0
def main():
    topo = KLTopo()
    host = custom(CPULimitedHost, cpu=.15)
    link = custom(TCLink, bw=10, delay='1ms', max_queue_size=200)
    net = Mininet(topo=topo, host=host, link=link, controller=RemoteController)
    net.start()
    dumpNetConnections(net)
    CLI(net)
示例#13
0
文件: network.py 项目: mvneves/mremu
def RegularTreeNet(depth=4, fanout=2, bw=BW, cpu=-1, queue=100):
    "Create an empty network and add nodes to it."
    topo = TreeTopo(depth, fanout)
    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)
    #net = Mininet(host=host, link=link, switch=OVSKernelSwitch, controller=RemoteController, autoSetMacs=True, autoStaticArp=False)
    net = Mininet(topo, host=host, link=link, switch=OVSKernelSwitch, controller=OVSController, autoSetMacs=True, autoStaticArp=False)

    return net
示例#14
0
def run_experiment( output = "sender.dump"):
    topo = MyTopo()
    host = custom(CPULimitedHost, cpu = .15)
    link = custom(TCLink, bw=1000, delay='100ms')

    net = Mininet(topo=topo, host=host, link=link)
    net.start()
    dumpNetConnections(net)
    net.pingAll()

    sender = net.getNodeByName('sender')
    receiver = net.getNodeByName('receiver')

    if CAPTURE_ACKS:
        sender.cmd("tcpdump -tt -nn 'tcp port 5001' &> %s &" % output)
    else:
        sender.cmd("tcpdump -tt -nn 'tcp dst port 5001' &> %s &" % output)
    sleep(1)


    # randomize address, because after a few repeats, the slow start is not observed anymore
    rand = str(random.randint(0,99)).zfill(2)
    receiver_IP = '1%s.11.0.2' % rand
    gateway_IP = '1%s.11.0.1' % rand


    receiver.cmd('../lwip/tcpsink -p 5001 -i %s -g %s &> receiver.out &' % (receiver_IP, gateway_IP))

    #make receiver forward packets from sender to internal tap interface
    receiver.cmd('sysctl net.ipv4.ip_forward=1')


    sender.cmd('sysctl net.core.netdev_max_backlog=500000')
    sender.cmd('sysctl net.ipv4.tcp_congestion_control=cubic')

    #add default route so that sender can sender to receiver's tap interface through the mininet link
    sender.cmd('route add default gw %s' % receiver.IP())

    #reduce MTU because otherwise the receive window is the limiting factor
    sender.cmd('ifconfig sender-eth0 mtu 200')

    print "starting transmission of data to %s" % receiver_IP
    sender.sendCmd('python sender.py --receiver=%s &> sender.out' % receiver_IP)


    print "waiting for transmission to complete"
    sender.waitOutput()

    print "killing tcpdump"
    sender.cmd('killall tcpdump')

    sleep(1)
    print "killing tcpsink"
    receiver.cmd("killall tcpsink")

    net.stop()
示例#15
0
def NonBlockingNet(k=4, bw=10, cpu=-1, queue=100):
    """ Create a NonBlocking Net """

    topo = NonBlockingTopo(k)
    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)

    net = Mininet(topo, host=host, link=link, switch=OVSKernelSwitch, controller=Controller)

    return net
示例#16
0
def main():
    "Create and run experiment"
    start = time()

    topo = DaSDNTopo(n=args.n)

    host = custom(CPULimitedHost, cpu=.15)  # 15% of system bandwidth
    link = custom(TCLink, bw=args.bw, delay='1ms',
                  max_queue_size=200)

    net = Mininet(topo=topo, host=host, link=link)

    net.start()

    cprint("*** Dumping network connections:", "green")
    dumpNetConnections(net)

    cprint("*** Setting default port config", "green")
    # 设置默认的端口带宽策略
    port_default_config("s2-eth99", bw=50, tx_queue_len=10)

    cprint("*** Testing connectivity", "blue")

    net.pingAll()

    # if args.cli:
        # Run CLI instead of experiment
    #    CLI(net)
    #else:


    if True:
        cprint("*** Running experiment", "magenta")

        print 'thread %s is running...' % threading.current_thread().name
        # Start Bandwith control thread to Simulation SDN Ctl
        if args.switch_bw:
            t1 = threading.Thread(target=monitor_thread_switch_bw, name='ThreadBwCtl')
            t1.start()

        t2 = threading.Thread(target=run_dasdn_expt, args=(net, args.n), name='ThreadRunExpt')
        t2.start()

        if args.switch_bw: # t1.join需要放在  t2.join  cli 之前
            t1.join()
        t2.join()




    net.stop()
    end = time()
    os.system("killall -9 bwm-ng")
    cprint("Experiment took %.3f seconds" % (end - start), "yellow")
def NonBlockingNet(k=4, bw=100, cpu=-1, queue=100):
    "Convenience function for creating a non-blocking network"

    topo = NonBlockingTopo(k)
    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)
	                      
    net = Mininet(topo, host=host, link=link, 
	    switch=OVSKernelSwitch, controller=Controller, 
	    autoPinCpus=opts.static, autoStaticArp=True)
    return net
示例#18
0
文件: network.py 项目: mvneves/mremu
def NonBlockingNet(k=4, bw=10, cpu=-1, queue=100):
    ''' Create a NonBlocking Net '''

    topo = NonBlockingTopo(k)
    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)

    #net = Mininet(topo, host=host, link=link, switch=OVSKernelSwitch, controller=RemoteController)
    net = Mininet(topo, host=host, link=link, switch=OVSKernelSwitch, controller=OVSController, autoSetMacs=True, autoStaticArp=False)

    return net
示例#19
0
def NonBlockingNet(k=4, bw=100, cpu=-1, queue=100):
    "Convenience function for creating a non-blocking network"

    topo = NonBlockingTopo(k)
    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)
	                      
    net = Mininet(topo, host=host, link=link, 
	    switch=OVSKernelSwitch, controller=Controller, 
	    autoPinCpus=opts.static, autoStaticArp=True)
    return net
示例#20
0
def NonBlockingNet(k=4, bw=10, cpu=-1, queue=100):
    ''' Create a NonBlocking Net '''

    topo = NonBlockingTopo(k)
    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)

    net = Mininet(topo, host=host, link=link, switch=OVSKernelSwitch,
            controller=Controller)

    return net
示例#21
0
def run_experiment(output="sender.dump"):
    topo = MyTopo()
    host = custom(CPULimitedHost, cpu=.15)
    link = custom(TCLink, bw=1000, delay='100ms')

    net = Mininet(topo=topo, host=host, link=link)
    net.start()
    dumpNetConnections(net)
    net.pingAll()

    sender = net.getNodeByName('sender')
    receiver = net.getNodeByName('receiver')

    if CAPTURE_ACKS:
        sender.cmd("tcpdump -tt -nn 'tcp port 5001' &> %s &" % output)
    else:
        sender.cmd("tcpdump -tt -nn 'tcp dst port 5001' &> %s &" % output)
    sleep(1)

    # randomize address, because after a few repeats, the slow start is not observed anymore
    rand = str(random.randint(0, 99)).zfill(2)
    receiver_IP = '1%s.11.0.2' % rand
    gateway_IP = '1%s.11.0.1' % rand

    receiver.cmd('../lwip/tcpsink -p 5001 -i %s -g %s &> receiver.out &' %
                 (receiver_IP, gateway_IP))

    #make receiver forward packets from sender to internal tap interface
    receiver.cmd('sysctl net.ipv4.ip_forward=1')

    sender.cmd('sysctl net.core.netdev_max_backlog=500000')
    sender.cmd('sysctl net.ipv4.tcp_congestion_control=cubic')

    #add default route so that sender can sender to receiver's tap interface through the mininet link
    sender.cmd('route add default gw %s' % receiver.IP())

    #reduce MTU because otherwise the receive window is the limiting factor
    sender.cmd('ifconfig sender-eth0 mtu 200')

    print "starting transmission of data to %s" % receiver_IP
    sender.sendCmd('python sender.py --receiver=%s &> sender.out' %
                   receiver_IP)

    print "waiting for transmission to complete"
    sender.waitOutput()

    print "killing tcpdump"
    sender.cmd('killall tcpdump')

    sleep(1)
    print "killing tcpsink"
    receiver.cmd("killall tcpsink")

    net.stop()
示例#22
0
def main():
  "Create and run experiment"
  start = time()
 
  if 'seed' in vars(args):
    random.seed(args.seed)

  k = args.k
  host = custom(CPULimitedHost, cpu=4.0/(k**3))
  link = custom(TCLink, bw=args.bw, delay='0ms')

  if args.control:
    topo = NonblockingFatTreeTopo(k=k)
    net = Mininet(topo=topo, host=host, link=link, build=True, cleanup=True, autoPinCpus=True, autoSetMacs=True)
  else:
    topo = FatTreeTopo(k=k)
    net = Mininet(topo=topo, host=host, link=link, build=True, cleanup=True, autoPinCpus=True, autoSetMacs=True, controller=RemoteController)
  net.start()

  flowsToCreate = []
  for fcount in range(args.fph):
    if args.traffic.startswith('stride'):
      stride_amt = int(args.traffic.split(',')[1])
      matrix = compute_stride(k, stride_amt)
    elif args.traffic.startswith('stag'):
      edge_prob, pod_prob = map(float, args.traffic.split(',')[1:])
      matrix = compute_stagger_prob(k, edge_prob, pod_prob)
    elif args.traffic.startswith('random'):
      matrix = compute_random(k)
    elif args.traffic.startswith('randbij'):
      matrix = compute_randbij(k)
    else:
      raise Exception('Unrecognized traffic type')
    print "Running with matrix", matrix
    addMatrixToFlow(flowsToCreate, matrix)

  if args.controller:
    controller = Popen(args.controller, shell=True, preexec_fn=os.setsid)

  # NOTE: special signal for random number of flows
  if args.fph >= 6:
   random.shuffle(flowsToCreate)
   flowsToCreate = flowsToCreate[0:len(flowsToCreate)/2]

  start = time()
  run_expt(net, k, flowsToCreate)
  end = time()

  if args.controller:
    os.killpg(controller.pid, signal.SIGKILL)

  net.stop()
示例#23
0
文件: network.py 项目: mvneves/mremu
def LinearNet(n=2, m=4, bw=100, cpu=-1, queue=100):
    ''' Create a Linear network '''

    info('*** Creating the topology')
    topo = LinearMultipathTopo(n,m)

    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)
    
    net = Mininet(topo, host=host, link=link, switch=OVSKernelSwitch,
            controller=RemoteController)

    return net
示例#24
0
文件: network.py 项目: mvneves/mremu
def FatTreeNet(k=4, bw=10, cpu=-1, queue=100):
    ''' Create a Fat-Tree network '''

    info('*** Creating the topology')
    topo = FatTreeTopo(k)

    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)

    net = Mininet(topo, host=host, link=link, switch=OVSKernelSwitch,
            controller=RemoteController, autoStaticArp=True)

    return net
示例#25
0
文件: topology.py 项目: mvneves/mremu
    def __init__(self, k = 4):
        ''' Create FatTree topology 
            
            k : Number of pods (can support upto k^3/4 hosts)
        '''
        super(FatTreeTopo, self).__init__()

        self.k = k
        self.node_gen = FatTreeNode
        self.numPods = k
        self.aggPerPod = k / 2

        pods = range(0, k)
        edge_sw = range(0, k/2)
        agg_sw = range(k/2, k)
        core_sw = range(1, k/2+1)
        hosts = range(2, k/2+2)

        for p in pods:
            for e in edge_sw:
                edge = self.node_gen(p, e, 1)
                edge_opts = self.def_opts(edge.name_str())
                self.addSwitch(edge.name_str(), **edge_opts)

                for h in hosts:
                    host = self.node_gen(p, e, h)
                    host_opts = self.def_opts(host.name_str())
                    self.addHost(host.name_str(), **host_opts)
                    self.addLink(edge.name_str(),host.name_str())

                for a in agg_sw:
                    agg = self.node_gen(p, a, 1)
                    agg_opts = self.def_opts(agg.name_str())
                    self.addSwitch(agg.name_str(), **agg_opts)
                    link = custom(TCLink, bw=100, max_queue_size=100)
                    self.addLink(agg.name_str(),edge.name_str(), cls=link)
            
            for a in agg_sw:
                agg = FatTreeNode(p, a, 1)
                i = 1        
                for c in core_sw:
                    core = self.node_gen(k, a-k/2+1, c)
                    core_opts = self.def_opts(core.name_str())
                    self.addSwitch(core.name_str(), **core_opts)
                    if i == 1:
                        band=100
                    else:
                        band=100
                    i = i + 1
                    link = custom(TCLink, bw=band, max_queue_size=100)
                    self.addLink(agg.name_str(),core.name_str(), cls=link)
示例#26
0
    def __init__(self, k=4):
        ''' Create FatTree topology 
            
            k : Number of pods (can support upto k^3/4 hosts)
        '''
        super(FatTreeTopo, self).__init__()

        self.k = k
        self.node_gen = FatTreeNode
        self.numPods = k
        self.aggPerPod = k / 2

        pods = range(0, k)
        edge_sw = range(0, k / 2)
        agg_sw = range(k / 2, k)
        core_sw = range(1, k / 2 + 1)
        hosts = range(2, k / 2 + 2)

        for p in pods:
            for e in edge_sw:
                edge = self.node_gen(p, e, 1)
                edge_opts = self.def_opts(edge.name_str())
                self.addSwitch(edge.name_str(), **edge_opts)

                for h in hosts:
                    host = self.node_gen(p, e, h)
                    host_opts = self.def_opts(host.name_str())
                    self.addHost(host.name_str(), **host_opts)
                    self.addLink(edge.name_str(), host.name_str())

                for a in agg_sw:
                    agg = self.node_gen(p, a, 1)
                    agg_opts = self.def_opts(agg.name_str())
                    self.addSwitch(agg.name_str(), **agg_opts)
                    link = custom(TCLink, bw=100, max_queue_size=100)
                    self.addLink(agg.name_str(), edge.name_str(), cls=link)

            for a in agg_sw:
                agg = FatTreeNode(p, a, 1)
                i = 1
                for c in core_sw:
                    core = self.node_gen(k, a - k / 2 + 1, c)
                    core_opts = self.def_opts(core.name_str())
                    self.addSwitch(core.name_str(), **core_opts)
                    if i == 1:
                        band = 100
                    else:
                        band = 100
                    i = i + 1
                    link = custom(TCLink, bw=band, max_queue_size=100)
                    self.addLink(agg.name_str(), core.name_str(), cls=link)
示例#27
0
def FatTreeNet(k=4, bw=100, cpu=-1,  queue=100):
    "Convenience function for creating pair networks"
    global opts

    pox_c = Popen("~/pox/pox.py --no-cli riplpox.riplpox --topo=ft,%s --routing=st --mode=proactive 1> %s/pox.out 2> %s/pox.out" % (k, opts.outputdir, opts.outputdir), shell=True)

    topo = FatTreeTopo(k, speed=bw/1000.)
    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)
	                      
    net = Mininet(topo, host=host, link=link, 
	    switch=OVSKernelSwitch, controller=RemoteController, 
	    autoPinCpus=opts.static, autoStaticArp=True)
    return net, pox_c
示例#28
0
def SingleSwitchNet(numHosts=16,
                    bw=BW,
                    cpu=-1,
                    queue=100,
                    remoteController=False):
    "Create an empty network and add nodes to it."
    host = custom(CPULimitedHost, cpu=cpu)
    #link = custom(TCLink, bw=bw, max_queue_size=queue, delay="1ms")
    link = custom(TCLink, bw=bw)
    if remoteController is True:
        controller = RemoteController
    else:
        controller = OVSController
    net = Mininet(host=host,
                  link=link,
                  switch=OVSKernelSwitch,
                  controller=controller,
                  autoSetMacs=True,
                  autoStaticArp=False)

    info('*** Adding controller\n')
    net.addController('c0')

    info('*** Adding hosts\n')
    allHosts = []
    i = 1

    info('*** Adding hosts\n')
    # Adding hosts
    for n in irange(1, numHosts):
        print "h%s" % n
        host = net.addHost("h%s" % n, ip=("10.0.0.%s/24" % str(i)))
        i = i + 1
        allHosts.append(host)

    info('*** Adding switches\n')
    i = 1
    # Adding switches
    print "s%s" % i
    switch = net.addSwitch("s%s" % i)

    info('*** Creating links to hosts\n')
    # Creating links to hosts
    for n in irange(0, numHosts - 1):
        host = allHosts[n]
        print "linking %s to %s" % (host.name, switch.name)
        net.addLink(host, switch)
        print ""

    return net
def FatTreeNet(k=4, bw=100, cpu=-1,  queue=100):
    "Convenience function for creating pair networks"
    global opts

    pox_c = Popen("~/pox/pox.py --no-cli riplpox.riplpox --topo=ft,%s --routing=st --mode=proactive 1> %s/pox.out 2> %s/pox.out" % (k, opts.outputdir, opts.outputdir), shell=True)

    topo = FatTreeTopo(k, speed=bw/1000.)
    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)
	                      
    net = Mininet(topo, host=host, link=link, 
	    switch=OVSKernelSwitch, controller=RemoteController, 
	    autoPinCpus=opts.static, autoStaticArp=True)
    return net, pox_c
示例#30
0
def limit(bw=10, cpu=.1):
    """Example/test of link and CPU bandwidth limits
       bw: interface bandwidth limit in Mbps
       cpu: cpu limit as fraction of overall CPU time"""
    intf = custom(TCIntf, bw=bw)
    myTopo = TreeTopo(depth=1, fanout=2)
    for sched in 'rt', 'cfs':
        print '*** Testing with', sched, 'bandwidth limiting'
        host = custom(CPULimitedHost, sched=sched, cpu=cpu)
        net = Mininet(topo=myTopo, intf=intf, host=host)
        net.start()
        testLinkLimit(net, bw=bw)
        net.runCpuLimitTest(cpu=cpu)
        net.stop()
示例#31
0
def limit( bw=10, cpu=.1 ):
    """Example/test of link and CPU bandwidth limits
       bw: interface bandwidth limit in Mbps
       cpu: cpu limit as fraction of overall CPU time"""
    intf = custom( TCIntf, bw=bw )
    myTopo = TreeTopo( depth=1, fanout=2 )
    for sched in 'rt', 'cfs':
        print '*** Testing with', sched, 'bandwidth limiting'
        host = custom( CPULimitedHost, sched=sched, cpu=cpu )
        net = Mininet( topo=myTopo, intf=intf, host=host )
        net.start()
        testLinkLimit( net, bw=bw )
        net.runCpuLimitTest( cpu=cpu )
        net.stop()
示例#32
0
 def __init__( self, **params ):
   """Mininet set up to test barrier transactions with one client
      and a specified number of servers.
      numberOfServers: number of servers 
      linkBandwidth: link bandwidth in Mb/s
      roundTripTime: unloaded round trip time from client to server, in microseconds"""
   
   host = custom( CPULimitedHost, cpu=cpuShare() )  
   link = custom( TCLink, bw=args.bandwidth, delay=delay() )
   
   Mininet.__init__(
     self,
     topo=BarrierTransactionTopo( **params ),
     host=host,
     link=link )
示例#33
0
def main(cpu=.08, remote=False):
    """
    Test link and CPU badwidth limits
    :param cpu: cpu limit as fraction of overall CPU time
    :param remote: True to use remote controller"""
    intf = custom(TCIntf)
    myTopo = CustomTopo()
    host = custom(CPULimitedHost, sched='cfs', cpu=cpu)
    contr = RemoteController if remote else OVSController
    net = Emulation(topo=myTopo,
                    intf=intf,
                    host=host,
                    controller=contr,
                    link=TCLink)
    net.start()
示例#34
0
def FatTreeNet(k=4, bw=10, cpu=-1, queue=100,controller='HController'):
    ''' Create a Fat-Tree network '''

    pox_c = Popen("~/pox/pox.py %s --topo=ft,%s --routing=ECMP --bw=%s --ratio=%s log.level --WARNING"%(controller, k, args.bandwidth, args.ratio), shell=True)

    info('*** Creating the topology')
    topo = FatTreeTopo(k)

    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)
    
    net = Mininet(topo, host=host, link=link, switch=OVSKernelSwitch,
            controller=RemoteController)

    return net
示例#35
0
def RegularTreeNet(depth=4, fanout=2, bw=BW, cpu=-1, queue=100):
    "Create an empty network and add nodes to it."
    topo = TreeTopo(depth, fanout)
    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)
    #net = Mininet(host=host, link=link, switch=OVSKernelSwitch, controller=RemoteController, autoSetMacs=True, autoStaticArp=False)
    net = Mininet(topo,
                  host=host,
                  link=link,
                  switch=OVSKernelSwitch,
                  controller=OVSController,
                  autoSetMacs=True,
                  autoStaticArp=False)

    return net
示例#36
0
def NetCreator(args, bw=10, cpu=-1, queue=100, controller='Controller'):

    info('*** Creating the topology')
    topo = MyTopo()
    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)

    net = Mininet(topo,
                  host=host,
                  link=link,
                  switch=OVSKernelSwitch,
                  controller=RemoteController,
                  autoStaticArp=True)

    return net
示例#37
0
def FatTreeNet(k=4, bw=10, cpu=-1, queue=100,controller='HController'):
    ''' Create a Fat-Tree network '''

    pox_c = Popen("~/pox/pox.py %s --topo=ft,4 --routing=ECMP"%controller, shell=True)

    info('*** Creating the topology')
    topo = FatTreeTopo(k)

    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)
    
    net = Mininet(topo, host=host, link=link, switch=OVSKernelSwitch,
            controller=RemoteController)

    return net
示例#38
0
文件: example.py 项目: tz70s/fie
    def build(self, **_opts):

        # Add switches
        s1, s2, s3 = [self.addSwitch(s) for s in 's1', 's2', 's3']

        # Custom interfaces with bandwidth and delay limitation.
        DriverFogIntf = custom(TCIntf, bw=100, delay='10ms')
        FogCloudIntf = custom(TCIntf, bw=200, delay='100ms')
        InClusterIntf = custom(TCIntf, bw=1000)

        # Hardware interface

        # IntfName = "enp4s30xxxx"
        # checkIntf(IntfName)
        # patch hardware interface to switch s3
        # hardwareIntf = Intf( IntfName, node=s3 )

        # Node capabilities settings.
        # cloud0 represented a node sits in cloud (datacenter), in whick has a larger capacity.
        cloud0 = self.addHost('cloud0',
                              cls=custom(RSLimitedHost, cpu=0.5, mem=512))
        # cloud1 is same as cloud0 as a node sits in cloud.
        cloud1 = self.addHost('cloud1',
                              cls=custom(RSLimitedHost, cpu=0.5, mem=512))

        # fog0 represented a node in fog layer, with medium capacity.
        fog0 = self.addHost('fog0',
                            cls=custom(RSLimitedHost, cpu=0.3, mem=512))
        fog1 = self.addHost('fog1',
                            cls=custom(RSLimitedHost, cpu=0.3, mem=512))

        # To simulate the vehicle data source.
        # These nodes will run vehicle data simulation and sends up to fog or cloud.
        car_src_0 = self.addHost('car_src_0',
                                 cls=custom(RSLimitedHost, cpu=0.3, mem=256))
        car_src_1 = self.addHost('car_src_1',
                                 cls=custom(RSLimitedHost, cpu=0.3, mem=256))

        # Link switch s1 with cloud nodes.
        self.addLink(s1, cloud0, intf=InClusterIntf)
        self.addLink(s1, cloud1, intf=InClusterIntf)

        # s1 -- s2
        self.addLink(s1, s2, intf=FogCloudIntf)
        # s2 -- s3
        self.addLink(s2, s3, intf=DriverFogIntf)

        # Link switch s2 with fog nodes
        self.addLink(s2, fog0, intf=InClusterIntf)
        self.addLink(s2, fog1, intf=InClusterIntf)

        self.addLink(s3, car_src_0, intf=InClusterIntf)
        self.addLink(s3, car_src_1, intf=InClusterIntf)
示例#39
0
def bwtest( cpuLimits, period_us=100000, seconds=5 ):
    """Example/test of link and CPU bandwidth limits
       cpu: cpu limit as fraction of overall CPU time"""

    topo = TreeTopo( depth=1, fanout=2 )

    results = {}

    for sched in 'rt', 'cfs':
        print '*** Testing with', sched, 'bandwidth limiting'
        for cpu in cpuLimits:
            host = custom( CPULimitedHost, sched=sched,
                           period_us=period_us,
                           cpu=cpu )
            net = Mininet( topo=topo, host=host )
            net.start()
            net.pingAll()
            hosts = [ net.getNodeByName( h ) for h in topo.hosts() ]
            client, server = hosts[ 0 ], hosts[ -1 ]
            server.cmd( 'iperf -s -p 5001 &' )
            waitListening( client, server, 5001 )
            result = client.cmd( 'iperf -yc -t %s -c %s' % (
                seconds, server.IP() ) ).split( ',' )
            bps = float( result[ -1 ] )
            server.cmdPrint( 'kill %iperf' )
            net.stop()
            updated = results.get( sched, [] )
            updated += [ ( cpu, bps ) ]
            results[ sched ] = updated

    return results
示例#40
0
def ManagementNet(net, bw=BW, queue=100):
    "Create an empty network and add nodes to it."
    #link = custom(TCLink, bw=bw, max_queue_size=queue, delay="1ms")
    link = custom(TCLink, bw=bw)
    #if remoteController is True:
    #    controller = RemoteController
    #else:
    #    controller = OVSController
    #net = Mininet(host=host, link=link, switch=OVSKernelSwitch, controller=controller, autoSetMacs=True, autoStaticArp=False)

    info('*** Adding second controller\n')
    controller = net.addController('c1', controller=OVSController)

    info('*** Adding management switch\n')
    # Adding switches
    print "mgnt0"
    switch = net.addSwitch("mgnt0")

    info('*** Creating links to hosts\n')
    # Creating links to hosts
    i = 1
    for host in net.hosts:
        print "linking %s to %s" % (host.name, switch.name)
        link = net.addLink(host, switch)
        host.setIP(("10.128.0.%s/9" % str(i)), intf=link.intf1)
        i += 1
        print ""

    return controller, switch
示例#41
0
def graph_network(topo):
    link = custom(TCLink)
    net = Mininet(topo=topo, link=link)
    mininet.util.dumpNetConnections(net)
    nodes = net.controllers + net.switches + net.hosts

    dot = pygraphviz.AGraph()

    edges = []

    for node in nodes:
        if 'c0' == node.name: continue
        dot.add_node(node.name)
        
        for intf in node.intfList():
            if not intf.link: continue
            (a, ai,) = intf.link.intf1.name.split('-')
            (b, bi,) = intf.link.intf2.name.split('-')
            ai = ai.replace('eth', 'p')
            bi = bi.replace('eth', 'p')
            s = [a, b]
            s.sort()
            if s not in edges:
                edges.append(s)
                dot.add_edge(a, b,
                             taillabel=ai+(' '*5),
                             headlabel=bi+(' '*5))

    dot.layout()
    dot.draw('topology.png', prog='dot')
示例#42
0
def LinearNet(n=2, m=4, bw=100, cpu=-1, queue=100):
    ''' Create a Linear network '''

    info('*** Creating the topology')
    topo = LinearMultipathTopo(n, m)

    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)

    net = Mininet(topo,
                  host=host,
                  link=link,
                  switch=OVSKernelSwitch,
                  controller=RemoteController)

    return net
示例#43
0
文件: network.py 项目: mvneves/mremu
def ManagementNet(net, bw=BW, queue=100):
    "Create an empty network and add nodes to it."
    #link = custom(TCLink, bw=bw, max_queue_size=queue, delay="1ms")
    link = custom(TCLink, bw=bw)
    #if remoteController is True:
    #    controller = RemoteController
    #else:
    #    controller = OVSController
    #net = Mininet(host=host, link=link, switch=OVSKernelSwitch, controller=controller, autoSetMacs=True, autoStaticArp=False)

    info('*** Adding second controller\n')
    controller = net.addController('c1', controller=OVSController)

    info('*** Adding management switch\n')
    # Adding switches
    print "mgnt0"
    switch = net.addSwitch("mgnt0")

    info('*** Creating links to hosts\n')
    # Creating links to hosts
    i = 1
    for host in net.hosts:
        print "linking %s to %s" % (host.name, switch.name)
        link = net.addLink(host, switch)
        host.setIP(("10.128.0.%s/9" % str(i)), intf=link.intf1)
        i += 1
        print ""

    return controller, switch
示例#44
0
    def _create_network(self, num_hosts, cpu=-1, bw=10, max_queue=100):
        setLogLevel('output')
        # Create Topo
        topo = DumbbellTopo(num_hosts)
        topo.create_nodes()
        topo.create_links(bw=bw, queue=max_queue)

        # Start Mininet
        host = custom(CPULimitedHost, cpu=cpu)
        link = custom(TCLink, max_queue=max_queue)
        net = Mininet(topo=topo, host=host, link=link,
                      controller=None, autoSetMacs=True)

        net.start()

        return net, topo
示例#45
0
文件: cpu.py 项目: jplsegers/SDN-TEST
def bwtest(cpuLimits, period_us=100000, seconds=5):
    """Example/test of link and CPU bandwidth limits
       cpu: cpu limit as fraction of overall CPU time"""

    topo = TreeTopo(depth=1, fanout=2)

    results = {}

    for sched in "rt", "cfs":
        print "*** Testing with", sched, "bandwidth limiting"
        for cpu in cpuLimits:
            host = custom(CPULimitedHost, sched=sched, period_us=period_us, cpu=cpu)
            try:
                net = Mininet(topo=topo, host=host)
            except:
                info("*** Skipping host %s\n" % sched)
                break
            net.start()
            net.pingAll()
            hosts = [net.getNodeByName(h) for h in topo.hosts()]
            client, server = hosts[0], hosts[-1]
            server.cmd("iperf -s -p 5001 &")
            waitListening(client, server, 5001)
            result = client.cmd("iperf -yc -t %s -c %s" % (seconds, server.IP())).split(",")
            bps = float(result[-1])
            server.cmdPrint("kill %iperf")
            net.stop()
            updated = results.get(sched, [])
            updated += [(cpu, bps)]
            results[sched] = updated

    return results
def CPUIsolationSweep(opts):
    "Check CPU isolation for various no. of nodes."
    outfile = None
    if opts.output:
        outfile_base = 'results/' + opts.machine + '/' + opts.experiment + '/'
        placement = 'static' if opts.static else 'dyn'
        filename = 'cpuiso-%s-%s-%s-%s.out' % (
            opts.host, opts.sched, opts.cores, placement )
        outfile = outfile_base + filename
    info("writing to file: %s\n" % outfile)
    initOutput( outfile, opts )

    i = 0
    for n in opts.counts:
        for util in opts.utils:
            for r in xrange(1, opts.runs+1):

                info('\n*****  Running CPU Test %i: %d nodes,'
                     ' max util = %0.3f, trial %d\n' % (i, n, util, r))

                # Split system utilization evenly across hosts
                cpu = util / float(n)
                
                host = custom(CPUIsolationHost, cpu=cpu, sched=opts.sched)
                net = Mininet(topo=CPUIsolationTopo(n),
                              host=host, autoPinCpus=opts.static)
                net.start()
                info('*** Running test\n')
                appendResults(net, outfile, n, cpu)
                net.stop()
                
                i+=1
示例#47
0
文件: run_topo.py 项目: jglara/MPTCP
def main():
    "Create and run experiment"
    start = time()

    topo = NetworkTopo()

    host = custom(CPULimitedHost)
    net = Mininet(topo=topo, host=host)

    net.start()

    print "*** Dumping network connections:"
    dumpNetConnections(net)

    if args.cli:
        # Run CLI instead of experiment
        CLI(net)
    else:
        print "*** Running experiment"
        #run_topology_experiment(net)

    net.stop()

    end = time()
    #    os.system("killall -9 tshark")
    #    os.system("chown mininet:mininet /tmp/*.cap ; mv /tmp/*.cap %s" % (args.dir))
    print "Experiment took %.3f seconds" % (end - start)
示例#48
0
def runTest(file_name,
            controller,
            tdf,
            size,
            set_cpu,
            set_bw,
            set_delay="10us"):
    lg.setLogLevel('info')
    """in fact, Controller and Remotecontroller have no difference
    all we need to do is start or not start POX in another shell"""
    if controller == "POX":
        controller = partial(RemoteController, ip='127.0.0.1', port=6633)
    else:
        controller = DefaultController
    link = partial(TCLink, bw=set_bw, delay=set_delay)
    """config host's cpu share and time dilation factor"""
    host = custom(CPULimitedHost,
                  sched='cfs',
                  period_us=100000,
                  cpu=set_cpu,
                  tdf=tdf)
    """with w option, it automatically overwrite everytime"""
    data_file = open('%s.log' % file_name, 'w')
    print "Results are written to %s.log file" % file_name
    data_file.write("********* Running stringBandwidthTest *********\n")
    data_file.flush()

    # seems mininet cannot handle more than 640 switches
    print "******* Running with %d switches, TDF = %d *******" % (size, tdf)
    client_avg, client_stdev = stringBandwidthTest(host, controller, link,
                                                   size, tdf, data_file)
    cleanup()
    return client_avg, client_stdev
示例#49
0
def BWIsolation(bmark, N, runs):

    "Check bandwidth isolation for various topology sizes."

    cliout = [''] * N
    iperf = 'iperf'
    topo = bmarkToTopo[bmark](N)
    host = custom(CPULimitedHost, cpu=.2)
    link = custom(TCLink, bw=100)
    net = Mininet(topo=topo, host=host, link=link, autoSetMacs=True)
    net.start()

    for _ in range(0, runs):
        result = [''] * N
        servercmd = [None] * N
        clientcmd = [None] * N

        #start the servers
        for n in range(0, N):
            server = net.hosts[2*n + 1]
            scmd = iperf + ' -yc -s'
            servercmd[n] = server.popen(scmd)

        sleep(1)
        
        #start the clients
        for n in range(0, N):
            client, server = net.hosts[2*n], net.hosts[2*n + 1]
            ccmd = iperf + ' -yc -t 10 -c ' + server.IP()
            clientcmd[n] = client.popen(ccmd)

        #fetch the client and server results
        for n in range(0, N):
            cout, cerr = clientcmd[n].communicate()
            cliout[n] = cout
            try:
                result[n] = str(getBandwidth(cliout[n]))
            except Exception:
                result[n] = 'NaN'
            servercmd[n].kill()
            servercmd[n].wait()

        print ','.join(result)
        flush()

    net.stop()
示例#50
0
def launch_network():
    net = IPNet(topo=SIGTopo(),
                debug=_lib.DEBUG_FLAG,
                intf=custom(TCIntf, bw=BW))
    TopologyDB(net=net).save(DB_path)
    net.start()
    FibbingCLI(net)
    net.stop()
示例#51
0
def FatTreeNet(k=4, bw=10, cpu=-1, queue=100, controller="HController"):
    """ Create a Fat-Tree network """

    pox_c = Popen(
        "~/pox/pox.py %s --topo=ft,%s --routing=ECMP --bw=%s --ratio=%s log.level --WARNING"
        % (controller, k, args.bandwidth, args.ratio),
        shell=True,
    )

    info("*** Creating the topology")
    topo = FatTreeTopo(k)

    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)

    net = Mininet(topo, host=host, link=link, switch=OVSKernelSwitch, controller=RemoteController)

    return net
示例#52
0
def launch_network(testfile):
    net = IPNet(topo = Lab1Topo(testfile=testfile),#Lab1ECMPTopo(testfile=testfile),#
                debug =_lib.DEBUG_FLAG,
                intf = custom(TCIntf, bw = BW),
                host = MyCustomHost)
    
    TopologyDB(net = net).save(dconf.DB_Path)
    net.start()
    FibbingCLI(net)
    net.stop()
示例#53
0
文件: limit.py 项目: Azmonkh/mininet
def limit( bw=10, cpu=.1 ):
    """Example/test of link and CPU bandwidth limits
       bw: interface bandwidth limit in Mbps
       cpu: cpu limit as fraction of overall CPU time"""
    intf = custom( TCIntf, bw=bw )
    myTopo = TreeTopo( depth=1, fanout=2 )
    for sched in 'rt', 'cfs':
        info( '*** Testing with', sched, 'bandwidth limiting\n' )
        if sched == 'rt':
            release = quietRun( 'uname -r' ).strip('\r\n')
            output = quietRun( 'grep CONFIG_RT_GROUP_SCHED /boot/config-%s' % release )
            if output == '# CONFIG_RT_GROUP_SCHED is not set\n':
                info( '*** RT Scheduler is not enabled in your kernel. Skipping this test\n' )
                continue
        host = custom( CPULimitedHost, sched=sched, cpu=cpu )
        net = Mininet( topo=myTopo, intf=intf, host=host )
        net.start()
        testLinkLimit( net, bw=bw )
        net.runCpuLimitTest( cpu=cpu )
        net.stop()
示例#54
0
文件: network.py 项目: mvneves/mremu
def SingleSwitchNet(numHosts=16, bw=BW, cpu=-1, queue=100, remoteController=False):
    "Create an empty network and add nodes to it."
    host = custom(CPULimitedHost, cpu=cpu)
    #link = custom(TCLink, bw=bw, max_queue_size=queue, delay="1ms")
    link = custom(TCLink, bw=bw)
    if remoteController is True:
        controller = RemoteController
    else:
        controller = OVSController
    net = Mininet(host=host, link=link, switch=OVSKernelSwitch, controller=controller, autoSetMacs=True, autoStaticArp=False)

    info('*** Adding controller\n')
    net.addController( 'c0' )

    info('*** Adding hosts\n')
    allHosts = []
    i = 1

    info('*** Adding hosts\n')
    # Adding hosts
    for n in irange(1, numHosts):
        print "h%s" % n
        host = net.addHost("h%s" % n, ip=("10.0.0.%s/24" % str(i)))
        i = i + 1
        allHosts.append(host)

    info('*** Adding switches\n')
    i = 1
    # Adding switches
    print "s%s" % i
    switch = net.addSwitch("s%s" % i)

    info('*** Creating links to hosts\n')
    # Creating links to hosts
    for n in irange(0, numHosts-1):
        host = allHosts[n]
        print "linking %s to %s" % (host.name, switch.name)
        net.addLink(host, switch)
        print ""

    return net