当前位置: 首页>>代码示例>>Python>>正文


Python Mininet.getNodeByName方法代码示例

本文整理汇总了Python中mininet.net.Mininet.getNodeByName方法的典型用法代码示例。如果您正苦于以下问题:Python Mininet.getNodeByName方法的具体用法?Python Mininet.getNodeByName怎么用?Python Mininet.getNodeByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mininet.net.Mininet的用法示例。


在下文中一共展示了Mininet.getNodeByName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: topoTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import getNodeByName [as 别名]
def topoTest():
  topo = Topo2()
  net = Mininet(topo = topo,controller = lambda name : RemoteController(name, defaultIP = '192.168.42.1'), link = TCLink, switch = OVSSwitch)
  c0 = net.getNodeByName('c0')

  s1 = net.getNodeByName('h7')
  l1 = s1.linkTo(c0)
  i1 = l1.intf1
  i2 = l1.intf2
  s1.setIP('123.123.123.1', 8, i1)
  c0.setIP('123.123.125.1', 8, i2)

  s2 = net.getNodeByName('h8')
  l1 = s2.linkTo(c0)
  i11 = l1.intf1
  i22 = l1.intf2
  s2.setIP('123.123.123.2', 8, i1)
  c0.setIP('123.123.125.2', 8, i2)

  net.start()
  s1.cmd('route add -net 123.123.125.1 netmask 255.255.255.255 dev ' + str(i1))
  s1.cmd('route add -net 123.123.125.1 netmask 255.255.255.255 dev ' + str(i1))
  s2.cmd('route add -net 123.123.125.2 netmask 255.255.255.255 dev ' + str(i11))  s2.cmd('route add -net 123.123.125.2 netmask 255.255.255.255 dev ' + str(i11))

  CLI(net)
  net.stop()
开发者ID:janejeakcy,项目名称:cs258-1,代码行数:28,代码来源:topo3.py

示例2: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import getNodeByName [as 别名]
def main():
    seconds = int(args.t)
    topo = LineTopo(n=args.n, bw=args.bw)
    net = Mininet(topo=topo,switch=Switch, host=CPULimitedHost, link=TCLink)
    net.start()
    h1 = net.getNodeByName('h1')
    h2 = net.getNodeByName('h2')
    h1.sendCmd('ifconfig')
    h1.waitOutput()
    for p in xrange(args.parallel):
        h2 = net.getNodeByName('h%d' % (2*p+2))
        h2.sendCmd('iperf -s')
    clients = []
    for p in xrange(args.parallel):
        h1 = net.getNodeByName('h%d' % (2*p+1))
        h2 = net.getNodeByName('h%d' % (2*p+2))
        if args.proto == "udp":
            cmd = 'iperf -c %s -t %d -i 1 -u -b %sM > %s/iperf_%s.txt' % (h2.IP(), seconds, args.bw, args.dir, 'h%d' % (2*p+1))
        else:
            cmd = 'iperf -c %s -t %d -i 1 > %s/iperf_%s.txt' % (h2.IP(), seconds, args.dir, 'h%d' % (2*p+1))
        h1.sendCmd(cmd)

    progress(seconds)
    #CLI(net)
    Popen("killall -9 top bwm-ng", shell=True).wait()
    net.stop()
开发者ID:Spencerx,项目名称:mininet-tracing,代码行数:28,代码来源:LineTopo.py

示例3: topoTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import getNodeByName [as 别名]
def topoTest():
    topo = Topo2()
    net = Mininet(topo = topo,controller = lambda name : RemoteController(name, ip = '192.168.42.1'),link = TCLink, switch = OVSSwitch)
    serverList = []
    c = net.getNodeByName('c0')
    for i in range(1, 17):
        serverName = 'hs'+ str(i)
        serverList.append(net.getNodeByName(serverName))
    clientList = []
    for i in range(1, 65):
        clientName = 'hc'+ str(i)
        clientList.append(net.getNodeByName(clientName))
    

    it1List = []
    it2List = []
    cIpList = []
    sIpList = []
    
    for i in range(16):
        server = serverList[i]
        link = server.linkTo(c)
        i1 = link.intf1
        i2 = link.intf2
        sIp = '123.123.123.' + str(i)
        cIp = '125.125.125.' + str(i)
        #msk = '255.255.255.255'
        sIpList.append(sIp)
        cIpList.append(cIp)
        it1List.append(i1)
        it2List.append(i2)
        server.setIP(sIp, 8, i1)
        c.setIP(cIp, 8, i2)
        server.cmd('route add -net ' + cIp + ' netmask 255.255.255.255' + ' dev' + str(i1))
        #c.cmd('route add -net ' + sIp + ' dev' + str(i2))
    net.start()
    for i in range(16):
        server = serverList[i]
        sIp = sIpList[i]
        cIp = cIpList[i]
        it1 = it1List[i]
        it2 = it2List[i]
        #print str(server) + "," + str(ip) + "," + str(it)
        server.cmd('route del -net ' + '123.0.0.0' + ' netmask 255.0.0.0  dev ' + str(it1))
        server.cmd('route add -net ' + cIp + ' netmask 255.255.255.255  dev ' + str(it1))
        c.cmd('route del -net ' + '125.0.0.0' ' netmask 255.0.0.0  dev ' + str(it2))
        c.cmd('route add -net ' + sIp + ' netmask 255.255.255.255  dev ' + str(it2))
        
        server.cmd('cd ~/proj/host/mongoose')
        server.cmd('./mongoose ' + str(i + 1) + ' 125.125.125.' + str(i) + ' &')

    #Test Cases
    for i in range(64):
        client = clientList[i]
        client.cmd('cd ~/proj/host')
        client.cmd('./test.sh &')
        time.sleep(2)

    CLI(net)
    net.stop()
开发者ID:janejeakcy,项目名称:cs258-1,代码行数:62,代码来源:demo4.py

示例4: run_cellsim_topology

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import getNodeByName [as 别名]
def run_cellsim_topology():
    print_welcome_message()

    os.system( "killall -q controller" )
    os.system( "killall -q cellsim" )
    os.system( "killall -q mysender" )
    os.system( "killall -q myreceiver" )

    topo = ProtoTester()
    net = Mininet(topo=topo, host=Host, link=Link)
    net.start()

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

    set_all_IP(net, sender, LTE, receiver)

    #Dump connections
    #dumpNodeConnections(net.hosts)
    #display_routes(net, sender, LTE, receiver)
    
    #run_cellsim(LTE)
    run_datagrump(sender, receiver)

    run_cellsim(LTE)

#    CLI(net)

    net.stop()
开发者ID:ravinet,项目名称:app-prioritization,代码行数:32,代码来源:myrun-trial.py

示例5: small_test

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import getNodeByName [as 别名]
def small_test():
    topo = Rect()
    net = Mininet(topo=topo, switch=UserSwitch, controller=lambda name:RemoteController(name, ip=ip), listenPort=port)
    print len(net.hosts)
    net.start()
    print "mininet started" 
    sleep(15) 
    print "iperf test start"
    h1 = net.getNodeByName('h1')
    h2 = net.getNodeByName('h2')
    h3 = net.getNodeByName('h3')
    #setup all servers
    print "server start"
    iperf_server(h2)
    #h3.cmd('iperf -s');
    #setup all clients
    print "client start"
    iperf_client(h1, h2, 10)
    print "ping start"
    ping_client(h1, h2, 10)
    #h1.cmd('iperf -c ', h3.IP(), ' -t 10 -i 1')
    sleep(3)
    add_policy('{"rules":[{"ip-dst":"10.0.0.2"}], "speed":1}')
    sleep(3)
    delete_policy('{"rules":[{"ip-dst":"10.0.0.2"}], "speed":1}')
    sleep(7)
    print "iperf test end"
    net.stop()
开发者ID:tuoshao,项目名称:floodlight-ratelimiter,代码行数:30,代码来源:mininettest.py

示例6: run_cellsim_topology

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import getNodeByName [as 别名]
def run_cellsim_topology(qdisc, random_seed):
    print_welcome_message()

    os.system( "killall -q controller" )
    os.system( "killall -q cellsim" )
    os.system( "killall -q datagrump-sender" )
    os.system( "killall -q datagrump-receiver" )
    os.system( "service apache2 stop" )
    os.system( "killall -q apache2" )
    os.system( "killall -q on-off.py")

    topo = ProtoTester()
    net = Mininet(topo=topo, host=Host, link=Link)
    net.start()

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

    set_all_IP(net, sender, LTE, receiver)
    
    #Dump connections
    #dumpNodeConnections(net.hosts)
    #display_routes(net, sender, LTE, receiver)

    run_apache(sender)
    run_flowrequestr(receiver, random_seed)

    run_cellsim(LTE, qdisc)

#    CLI(net)

    net.stop()
开发者ID:anirudhSK,项目名称:contest,代码行数:35,代码来源:run-trial.py

示例7: simpleTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import getNodeByName [as 别名]
def simpleTest():
   "Create and test a simple network"
   topo = DiamondTopo(k=4)
   net = Mininet(topo=topo,link=TCLink,controller=RemoteController)
   if args.sim!=1:
        print "Adding real interfaces" 
   	s1 = net.getNodeByName('s1')
   	s3 = net.getNodeByName('s3')
   	addRealIntf(net,args.intf1,s1)
   	addRealIntf(net,args.intf2,s3)
   	opts = '-D -o UseDNS=no -u0'
   	rootnode=sshd(net, opts=opts)
	h2 = net.getNodeByName('h2')
   	h2.cmd('iperf -s -p 5001 -i 1 > iperf-recv_TCP.txt &')
   	h2.cmd('iperf -s -p 5003 -u -i 1 > iperf-recv_UDP.txt &')
   else:
   	net.start()
   CLI(net)

   os.system('killall -9 iperf' )
   
   if args.sim!=1:
	net.hosts[0].cmd('killall -9 dhcpd')   
	for host in net.hosts:
       		host.cmd('kill %'+ '/usr/sbin/sshd')
   	stopNAT(rootnode)
   net.stop()
开发者ID:Gigglebit,项目名称:PathExp,代码行数:29,代码来源:diamond.py

示例8: run_experiment

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import getNodeByName [as 别名]
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()
开发者ID:jamesbw,项目名称:tcp-daytona,代码行数:58,代码来源:run_exps.py

示例9: inicializaRed

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import getNodeByName [as 别名]
def inicializaRed():
    "Create network and run simple performance test"
    topo = MyTopo()
    net = Mininet(topo=topo, link=TCLink, controller=RemoteController)
    net.start()
    print "*** Pruebas en h1"
    switches = net.getNodeByName('I1', 's2', 'E3', 'E4')
    for i in switches:
        for j in i.intfNames()[1:]:
            if j in ['s2-eth2', 's3-eth3']:
                continue
            #if j in ['s1-eth3', 's3-eth2', 's3-eth4', 's4-eth5', 's2-eth3', 's4-eth3']:
            cmd  = 'ovs-vsctl -- set port ' + j + ' [email protected] -- [email protected] create qos type=linux-htb other-config:max-rate=1500000\
                    queues:[email protected] -- [email protected] create queue other-config:min-rate=1000 other-config:max-rate=1500000'
            cmd2 = 'ovs-vsctl -- set port ' + j + ' [email protected] -- [email protected] create qos type=linux-htb other-config:max-rate=1500000\
                    queues:[email protected] -- [email protected] create queue other-config:min-rate=1500000 other-config:max-rate=1500000'
            cmd3 = 'ovs-vsctl -- set Port ' + j + ' [email protected]\
                    -- [email protected] create QoS type=linux-htb  other-config:max-rate=3000000 [email protected],[email protected]\
                    -- [email protected] create Queue other-config:min-rate=2300000 other-config:max-rate=2800000\
                    -- [email protected] create Queue other-config:min-rate=80000   other-config:max-rate=1500000'
            #cmd4 = 'tc class change dev ' + j + ' parent 1:fffe classid 1:1 htb rate 1kbit ceil 1500kbit burst 1563b cburst 1563b'
            #i.cmd(cmd)                   # Usar i.cmdPrint(cmd) para imprimir el resultado
            #i.cmd(cmd2)
            i.cmd(cmd3)
            #i.cmdPrint(cmd4)
    #for i in switches:
        #for j in i.intfNames()[1:]:
            #cmd4 = 'tc class change dev ' + j + ' parent 1:fffe classid 1:1 htb rate 1kbit ceil 770kbit burst 1563b cburst 1563b'
            #i.cmd(cmd4)
            #for k in [1, 2]:
            #   cmd5 = 'tc qdisc add dev ' + j +' parent 1:' + str(k) + ' handle ' + str(k) + '0: sfq perturb 10'
            #   i.cmd(cmd5)

#def testQoS():
    h1 = net.getNodeByName('h1')
    h5 = net.getNodeByName('h5')
    print 'Waiting for topology recognition ...'
    h1.cmd('sleep 12')
    print 'Initiating clients at h5, h6 and h8 (SMART) ...'
    h5.cmd('source ~/Documents/mininet_scripts/tests1/client1.sh &')
    h5.cmd('sleep 2')
    h5.cmd('source ~/Documents/mininet_scripts/tests1/client2.sh &')
    h5.cmd('sleep 2')
    h5.cmd('source ~/Documents/mininet_scripts/tests1/client3_SMART.sh &')
    print 'Initiating servers at h1 ...'
    h5.cmd('sleep 2')
    h1.cmd('source ~/Documents/mininet_scripts/tests1/server1.sh &')
    h5.cmd('sleep 1')
    h1.cmd('source ~/Documents/mininet_scripts/tests1/server2.sh &')
    h5.cmd('sleep 1')
    h1.cmd('source ~/Documents/mininet_scripts/tests1/server3_SMART.sh')
    print 'Experiment finished.'
    #CLI(net)
    net.stop()
开发者ID:josecastillolema,项目名称:smart-OF-controller,代码行数:56,代码来源:testQoS.py

示例10: startNetworkWithLinearTopo

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import getNodeByName [as 别名]
def startNetworkWithLinearTopo( hostCount ):
    global net
    net = Mininet(topo=LinearTopo(hostCount), build=False)

    remote_ip = getControllerIP()
    info('** Adding Floodlight Controller\n')
    net.addController('c1', controller=RemoteController,
                      ip=remote_ip, port=6653)

    # Build the network
    net.build()
    net.start()

    # Start L3 Routing
    ret = enableL3Routing()
    print (ret)

    ret = addVirtualGateway('mininet-gateway-1')
    print (ret)

    ret = addInterfaceToGateway('mininet-gateway-1')
    print (ret)

    ret = addNodePortTupleToGateway('mininet-gateway-1')
    print (ret)

    # Need to configure default gw for host
    host1 = net.getNodeByName('h1')
    host1.setIP('10.0.0.10', prefixLen=24)
    defaultGatewayIP1 = "10.0.0.1"
    configureDefaultGatewayForHost(host1, defaultGatewayIP1)

    host2 = net.getNodeByName('h2')
    host2.setIP('20.0.0.10', prefixLen=24)
    defaultGatewayIP2 = "20.0.0.1"
    configureDefaultGatewayForHost(host2, defaultGatewayIP2)

    host3 = net.getNodeByName('h3')
    host3.setIP('30.0.0.10', prefixLen=24)
    defaultGatewayIP3 = "30.0.0.1"
    configureDefaultGatewayForHost(host3, defaultGatewayIP3)

    host4 = net.getNodeByName('h4')
    host4.setIP('40.0.0.10', prefixLen=24)
    defaultGatewayIP4 = "40.0.0.1"
    configureDefaultGatewayForHost(host4, defaultGatewayIP4)

    host5 = net.getNodeByName('h5')
    host5.setIP('50.0.0.10', prefixLen=24)
    defaultGatewayIP5 = "50.0.0.1"
    configureDefaultGatewayForHost(host5, defaultGatewayIP5)
开发者ID:cbarrin,项目名称:floodlight,代码行数:53,代码来源:routing_L3_npt.py

示例11: Test

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import getNodeByName [as 别名]
def Test():
   "Create network and run simple performance test"
   topo = SimpleTopo(k=2)
   net = Mininet(topo=topo,
                 host=CPULimitedHost, link=TCLink)#, controller=RemoteController)
   s1 = net.getNodeByName('s1')
   s2 = net.getNodeByName('s2')
   if args.intf1 is not None:
	addRealIntf(net,args.intf1,s1)
   if args.intf2 is not None:
   	addRealIntf(net,args.intf2,s2)
#   net.start()
   opts = '-D -o UseDNS=no -u0'

#' '.join( sys.argv[ 1: ] ) if len( sys.argv ) > 1 else (
   rootnode=sshd(net, opts=opts)
#   print "Dumping host connections"
   dumpNodeConnections(net.hosts)
    
#   net.pingAll()
   h2 = net.getNodeByName('h2')
#   dhcp = net.getNodeByName('dhcp')
#   out = dhcp.cmd('sudo dhcpd')
#   print "DHCPD = "+ out
   #h1.cmd("bash tc_cmd_diff.sh h1-eth0")
   #h1.cmd("tc -s show dev h1-eth0")
   h2.cmd('iperf -s -p 5001 -i 1 > iperf-recv_TCP.txt &')
   h2.cmd('iperf -s -p 5003 -u -i 1 > iperf-recv_UDP.txt &')
   #h2.cmd('iperf -s -p %s -i 1 > iperf_server_TCP.txt &' % 5001)
#               (CUSTOM_IPERF_PATH, 5001, args.dir))
   #monitoring the network
  #monitor = Process(target=monitor_qlen,
                     #args=("%s"%args.iface,float(args.sampleR),int(args.nQ), "%s_%s"% (args.exp,args.out)))   
       

   for host in net.hosts:
       #host.cmd('tc qdisc del dev %s-eth0 root'%host)              
       #host.cmd('tc qdisc add dev %s-eth0 root tbf rate 10Mbit latency 2s burst 15k mtu 1512'%host)              
       host.cmd('ethtool -K %s-eth0 tso off gso off ufo off'%host)
   #start mininet CLI
   CLI(net)
   #terminate
   for host in net.hosts:
       host.cmd('kill %'+ '/usr/sbin/sshd')
   os.system('killall -9 iperf' )
   net.hosts[0].cmd('killall -9 dhcpd')
   stopNAT(rootnode)
   net.stop()

   Popen("killall -9 cat", shell=True).wait()
开发者ID:Gigglebit,项目名称:stats_exp,代码行数:52,代码来源:minitopo.py

示例12: general_rule_test

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import getNodeByName [as 别名]
def general_rule_test():
    topo = FatTreeTopo()
    net = Mininet(topo=topo, switch=UserSwitch, controller=lambda name:RemoteController(name, ip=ip), listenPort=port)
    print len(net.hosts)
    net.start()
    print "mininet started" 
    sleep(15) 
    print "iperf test start"
    add_policy('{"rules":[{"ip-src":"10.0.0.2"}, {"ip-src":"10.0.0.3"}, {"ip-src":"10.2.1.2"}, {"ip-src":"10.3.1.3"}], "speed":30}')
    h1 = net.getNodeByName('0_0_2')
    h2 = net.getNodeByName('0_0_3')
    h3 = net.getNodeByName('0_1_2')
    h4 = net.getNodeByName('0_1_3')
    h5 = net.getNodeByName('1_0_2')
    h6 = net.getNodeByName('1_0_3')
    h7 = net.getNodeByName('2_1_2')
    h8 = net.getNodeByName('3_1_3')
    #setup all servers
    print "server start"
    iperf_server_tcp(h5)
    iperf_server_tcp(h6)
    iperf_server_tcp(h3)
    #iperf_server_tcp(h4)
    #setup all clients
    print "client start"
    sleep(10)
    iperf_client_tcp(h1, h5, 30, '2K')
    ping_client(h1, h5, 30)
    sleep(10)
    iperf_client_tcp(h2, h6, 20, '2K')
    ping_client(h2, h6, 20)
    sleep(10)
    iperf_client_tcp(h7, h3, 10, '2K')
    ping_client(h7, h3, 10)
    #iperf_client_tcp(h8, h4, 60, '2K')
    print "ping start"
    #ping_client(h8, h4, 60)
    #h1.cmd('iperf -c ', h3.IP(), ' -t 10 -i 1')
    #sleep(10)
    #add_policy('{"rules":[{"ip-src":"10.0.0.2"}, {"ip-src":"10.0.0.3"}, {"ip-src":"10.2.1.2"}, {"ip-src":"10.3.1.3"}], "speed":50}')
    #sleep(10)
    #add_policy('{"rules":[{"ip-src":"10.0.0.2"}, {"ip-src":"10.0.0.3"}], "speed":10}')
    #sleep(10)
    #delete_policy('{"rules":[{"ip-src":"10.0.0.2"}, {"ip-src":"10.0.0.3"}], "speed":10}')
    #sleep(10)
    #delete_policy('{"rules":[{"ip-src":"10.0.0.2"}, {"ip-src":"10.0.0.3"}, {"ip-src":"10.2.1.2"}, {"ip-src":"10.3.1.3"}], "speed":50}')
    sleep(20)
    print "iperf test end"
    net.stop()
开发者ID:tuoshao,项目名称:floodlight-ratelimiter,代码行数:51,代码来源:mininettest.py

示例13: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import getNodeByName [as 别名]
def main(logFile, depth, uMin, uMax, runtime, seeding, cli):

    # create residential WiFi topology
    mytopo = MnTopo(depth, uMin, uMax, seeding)

    # create & start Mininet
    net = Mininet(topo=mytopo, controller=None, link=TCLink, autoStaticArp=True)
    net.addController(Controller('c0'))
    net.start()
    # assign IP addresses to interfaces
    linklist = mytopo.links(sort=True)
    linklist.reverse()

    idx = 1
    while linklist:
        item = linklist.pop()
        if re.match("gsw\d", item[1]):
            apid = re.findall(r'\d+',item[0])[0]
            swid = str(int(re.findall(r'\d+',item[1])[0]))
            net.getNodeByName(item[0]).setIP("192.168.%s.%s/24" % (swid, str(int(apid)+1)), intf="ap%s-eth%s" % (apid, idx))
            idx += 1
        else:
            idx = 1

    if cli == 1:
        CLI( net )
    time.sleep(10)
    nodelist = mytopo.nodes(sort=True)
    no_nodes = 0
    while nodelist:
        item = nodelist.pop()
        if re.match("ap\d", item):
            with open("measurements/stdout" + item + ".txt","wb") as out, open("measurements/stderr" + item + ".txt","wb") as err:
                time.sleep(5)
                net.getNodeByName(item).popen("python ../resfi_loader.py -r %s" % runtime, stdout=out, stderr=err)
                no_nodes = no_nodes + 1

    print "script running. please wait."

    # wait until end time is reached
    start = datetime.datetime.now()
    while True:
        now = datetime.datetime.now()
        if (now - start).seconds < runtime:
            time.sleep(0.5)
        else:
            break

    net.stop()
开发者ID:resfi,项目名称:resfi,代码行数:51,代码来源:mn_driver.py

示例14: createTopo

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import getNodeByName [as 别名]
def createTopo():
    "Creating network"
    
    topo = SwitchHostTopo()
    net = Mininet(topo=topo, 
                  controller=OVSController, link=TCLink)
    net.start()
    print "Testing network connectivity"
    net.pingAll()

    print "Testing bandwidth between odd hosts"
    net.iperf((net.getNodeByName(hosts_array[0]), net.getNodeByName(hosts_array[2])))
    print "Testing bandwidth between even hosts"
    net.iperf((net.getNodeByName(hosts_array[1]), net.getNodeByName(hosts_array[3])))
    net.stop()
开发者ID:thakurakhil,项目名称:201302181_cloud_assignments,代码行数:17,代码来源:topology.py

示例15: bwtest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import getNodeByName [as 别名]
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
开发者ID:jplsegers,项目名称:SDN-TEST,代码行数:34,代码来源:cpu.py


注:本文中的mininet.net.Mininet.getNodeByName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。