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


Python Mininet.start方法代码示例

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


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

示例1: run

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import start [as 别名]
def run():
    #clean previous run
    
    os.system("rm -f  /tmp/*.pid logs/*")
    os.system("mn -c >/dev/null 2>&1")
    os.system("killall -9 zebra bgpd > /dev/null 2>&1")
    os.system("/etc/init.d/quagga restart")

    topo = BgpPoisoningTopo()
    net = Mininet( topo=topo )
    net.start()
    
    for router in net.switches:
        router.cmd("sysctl -w net.ipv4.ip_forward=1")
        router.waitOutput()

    #Waiting (sleepytime) seconds for sysctl changes to take effect..
    sleep(sleepytime)

    for R in ['R1','R2','R3','R4','R5','R6','R7']:
        net.get(R).initZebra("conf/zebra-%s.conf" % R)
        router.waitOutput()
        net.get(R).initBgpd("conf/bgpd-%s.conf" % R)
        router.waitOutput()
    
    CLI( net )
    net.stop()
开发者ID:cs236341,项目名称:bgpPoisoning,代码行数:29,代码来源:bgpPoisoning.py

示例2: cs461net

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import start [as 别名]
def cs461net():
    stophttp()
    "Create a simple network for cs461"
    r = get_ip_setting()
    if r == -1:
        exit("Couldn't load config file for ip addresses, check whether %s exists" % IPCONFIG_FILE)
    else:
        info( '*** Successfully loaded ip settings for hosts\n %s\n' % IP_SETTING)

    topo = CS461Topo()
    info( '*** Creating network\n' )
    net = Mininet( topo=topo, controller=RemoteController, ipBase=IPBASE )
    net.start()
    server1, server2, client, router = net.get( 'server1', 'server2', 'client', 'sw0')
    s1intf = server1.defaultIntf()
    s1intf.setIP('%s/8' % IP_SETTING['server1'])
    s2intf = server2.defaultIntf()
    s2intf.setIP('%s/8' % IP_SETTING['server2'])
    clintf = client.defaultIntf()
    clintf.setIP('%s/8' % IP_SETTING['client'])


    for host in server1, server2, client:
        set_default_route(host)
    starthttp( server1 )
    starthttp( server2 )
    CLI( net )
    stophttp()
    net.stop()
开发者ID:petergrabowski,项目名称:networks,代码行数:31,代码来源:lab3.py

示例3: bbnet

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import start [as 别名]
def bbnet():
    "Create network and run Buffer Bloat experiment"
    print "starting mininet ...."
    # Seconds to run iperf; keep this very high
    seconds = 3600
    start = time()
    # Reset to known state
    topo = StarTopo(n=args.n, bw_host=args.bw_host,
                    delay='%sms' % args.delay,
                    bw_net=args.bw_net, maxq=args.maxq, diff=args.diff)
    net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink,
                  autoPinCpus=True, controller=OVSController)
    net.start()
    dumpNodeConnections(net.hosts)
    net.pingAll()
    print args.diff
    if args.diff:
        print "Differentiate Traffic Between iperf and wget"
        os.system("bash tc_cmd_diff.sh")
    else:
        print "exec tc_cmd.sh"
        os.system("bash tc_cmd.sh %s" % args.maxq)
    sleep(2)
    ping_latency(net)
    print "Initially, the delay between two hosts is around %dms" % (int(args.delay)*2)
    h2 = net.getNodeByName('h2')
    h1 = net.getNodeByName('h1')
    h1.cmd('cd ./http/; nohup python2.7 ./webserver.py &')
    h1.cmd('cd ../')
    h2.cmd('iperf -s -w 16m -p 5001 -i 1 > iperf-recv.txt &')
    CLI( net )
    h1.cmd("sudo pkill -9 -f webserver.py")
    h2.cmd("rm -f index.html*")
    Popen("killall -9 cat", shell=True).wait()
开发者ID:bovenyan,项目名称:bufferbloat,代码行数:36,代码来源:bufferbloat.py

示例4: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import start [as 别名]
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")
开发者ID:09beeihaq,项目名称:gt-cs6250,代码行数:34,代码来源:parkinglot.py

示例5: output

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import start [as 别名]
def output(partIdx):
    """Uses the student code to compute the output for test cases."""
    outputString = ""

    if partIdx == 0:  # This is agPA2
        "Set up link parameters"
        print "a. Setting link parameters"
        "--- core to aggregation switches"
        linkopts1 = {"bw": 50, "delay": "5ms"}
        "--- aggregation to edge switches"
        linkopts2 = {"bw": 30, "delay": "10ms"}
        "--- edge switches to hosts"
        linkopts3 = {"bw": 10, "delay": "15ms"}

        "Creating network and run simple performance test"
        print "b. Creating Custom Topology"
        topo = CustomTopo(linkopts1, linkopts2, linkopts3, fanout=3)

        print "c. Firing up Mininet"
        net = Mininet(topo=topo, link=TCLink)
        net.start()
        h1 = net.get("h1")
        h27 = net.get("h27")

        print "d. Starting Test"
        # Start pings
        outputString = h1.cmd("ping", "-c6", h27.IP())

        print "e. Stopping Mininet"
        net.stop()

    return outputString.strip()
开发者ID:jabbson,项目名称:SDN,代码行数:34,代码来源:CustomTopo.py

示例6: sdnTopo

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

    CONTROLLER_IP='10.0.0.200'

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

    # Create nodes
    h1 = net.addHost( 'h1', ip='10.0.0.1/8' )
    h2 = net.addHost( 'h2', ip='10.0.0.2/8' )

    # Create switches
    s1 = net.addSwitch( 's1')

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

    # Add Controllers
    odl_ctrl = net.addController( 'c0', controller=RemoteController, ip=CONTROLLER_IP)


    info( "*** Creation de l'architecture réseau\n" )
    net.build()

    # Connect each switch to a different controller
    s1.start( [odl_ctrl] )


    info( "*** Ajout de l'interface",interface_name,"au switch" )
    _intf = Intf( interface_name, node=s1)
    net.start()
    CLI( net )
    net.stop()
开发者ID:LeGaulois,项目名称:pox_nac,代码行数:34,代码来源:sdn.py

示例7: run

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import start [as 别名]
def run():
    "Create control and data networks, and invoke the CLI"

    info( '* Creating Control Network\n' )
    ctopo = ControlNetwork( n=4, dataController=DataController )
    cnet = Mininet( topo=ctopo, ipBase='192.168.123.0/24', controller=None )
    info( '* Adding Control Network Controller\n')
    cnet.addController( 'cc0', controller=Controller )
    info( '* Starting Control Network\n')
    cnet.start()

    info( '* Creating Data Network\n' )
    topo = TreeTopo( depth=2, fanout=2 )
    # UserSwitch so we can easily test failover
    sw = partial( UserSwitch, opts='--inactivity-probe=1 --max-backoff=1' )
    net = Mininet( topo=topo, switch=sw, controller=None )
    info( '* Adding Controllers to Data Network\n' )
    for host in cnet.hosts:
        if isinstance(host, Controller):
            net.addController( host )
    info( '* Starting Data Network\n')
    net.start()

    mn = MininetFacade( net, cnet=cnet )

    CLI( mn )

    info( '* Stopping Data Network\n' )
    net.stop()

    info( '* Stopping Control Network\n' )
    cnet.stop()
开发者ID:MatheusRagoso,项目名称:mininet,代码行数:34,代码来源:controlnet.py

示例8: run_cellsim_topology

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import start [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

示例9: emptyNet

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

    "Create an empty network and add nodes to it."

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

    net.addController( 'c0',
                       controller=RemoteController,
                       ip='0.0.0.0'  )

    h1 = net.addHost( 'h1', ip='10.0.0.1' )
    h2 = net.addHost( 'h2', ip='10.0.0.2' )
    h3 = net.addHost( 'h3', ip='10.0.0.3' )

    s1 = net.addSwitch( 's1', cls=OVSSwitch )

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

    net.start()
    s1.cmd('ifconfig s1 inet 10.0.0.10')

    CLI( net )
    net.stop()
开发者ID:VishrutMehta,项目名称:OpenFlow-Table-Transfer-Optimization,代码行数:28,代码来源:version_1.2.py

示例10: LowMnNet

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import start [as 别名]
def LowMnNet(n, nn, nnn):
	print "############ Instanitiate a mininet of topology LowMnTopo ###############\n"
	topo = LowMnTopo(n, nn, nnn)
	ctrl_port=6633
	net = Mininet(topo=topo, ipBase='10.0.0.0/8', autoSetMacs=True, host=CPULimitedHost, link=TCLink)
 	net.start()
	return net
开发者ID:UrbanLynx,项目名称:datacenter_simulation,代码行数:9,代码来源:final.py

示例11: test

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import start [as 别名]
def test():
    topo = DssTopo()
    net = Mininet(topo, link=TCLink)
    net.start()
    
    with open("pause.test","a") as myfile:
        for x in range(0,2000):
            st1 = net.pingPairFull()
            #print 'pausing'
            time.sleep(0.01)
            pause()
            myfile.write( repr(st1[0][2][3]))
            myfile.write('\n')

    with open("noPause.test","a") as myffile:
        for x in range(0,2000):
            st1 = net.pingPairFull()
            #print 'pausing'
            time.sleep(0.01)
            #pause()
            myffile.write( repr(st1[0][2][3]))
            myffile.write('\n')

        
            


    net.stop()    
开发者ID:annonch,项目名称:DSSnet,代码行数:30,代码来源:ping.py

示例12: testCPULimits

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import start [as 别名]
    def testCPULimits( self ):
        "Verify topology creation with CPU limits set for both schedulers."
        CPU_FRACTION = 0.1
        CPU_TOLERANCE = 0.8  # CPU fraction below which test should fail
        hopts = { 'cpu': CPU_FRACTION }
        #self.runOptionsTopoTest( N, hopts=hopts )

        mn = Mininet( SingleSwitchOptionsTopo( n=N, hopts=hopts ),
                      host=CPULimitedHost, switch=self.switchClass,
                      waitConnected=True )
        mn.start()
        results = mn.runCpuLimitTest( cpu=CPU_FRACTION )
        mn.stop()
        hostUsage = '\n'.join( 'h%s: %s' %
                               ( n + 1,
                                 results[ (n - 1) * 5 : (n * 5) - 1 ] )
                               for n in range( N ) )
        hoptsStr = ', '.join( '%s: %s' % ( opt, value )
                              for opt, value in hopts.items() )
        msg = ( '\nTesting cpu limited to %d%% of cpu per host\n'
                'cpu usage percent per host:\n%s\n'
                'Topo = SingleSwitchTopo, %s hosts\n'
                'hopts = %s\n'
                'host = CPULimitedHost\n'
                'Switch = %s\n'
                % ( CPU_FRACTION * 100, hostUsage, N, hoptsStr,
                    self.switchClass ) )
        for pct in results:
            #divide cpu by 100 to convert from percentage to fraction
            self.assertWithinTolerance( pct/100, CPU_FRACTION,
                                        CPU_TOLERANCE, msg )
开发者ID:1514louluo,项目名称:mininet,代码行数:33,代码来源:test_hifi.py

示例13: testLinkLoss

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import start [as 别名]
    def testLinkLoss( self ):
        "Verify that we see packet drops with a high configured loss rate."
        LOSS_PERCENT = 99
        REPS = 1
        lopts = { 'loss': LOSS_PERCENT, 'use_htb': True }
        mn = Mininet( topo=SingleSwitchOptionsTopo( n=N, lopts=lopts ),
                      host=CPULimitedHost, link=TCLink,
                      switch=self.switchClass,
                      waitConnected=True )
        # Drops are probabilistic, but the chance of no dropped packets is
        # 1 in 100 million with 4 hops for a link w/99% loss.
        dropped_total = 0
        mn.start()
        for _ in range(REPS):
            dropped_total += mn.ping(timeout='1')
        mn.stop()

        loptsStr = ', '.join( '%s: %s' % ( opt, value )
                              for opt, value in lopts.items() )
        msg = ( '\nTesting packet loss with %d%% loss rate\n'
                'number of dropped pings during mininet.ping(): %s\n'
                'expected number of dropped packets: 1\n'
                'Topo = SingleSwitchTopo, %s hosts\n'
                'Link = TCLink\n'
                'lopts = %s\n'
                'host = default\n'
                'switch = %s\n'
                % ( LOSS_PERCENT, dropped_total, N, loptsStr,
                    self.switchClass ) )

        self.assertGreater( dropped_total, 0, msg )
开发者ID:1514louluo,项目名称:mininet,代码行数:33,代码来源:test_hifi.py

示例14: run_cellsim_topology

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import start [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

示例15: emptyNet

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

    "Create an empty network and add nodes to it."

    net = Mininet( controller=lambda a: RemoteController(a, ip='128.208.125.60' ))

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

    info( '*** Adding hosts\n' )
    h1 = net.addHost( 'h1', ip='10.0.0.1' )
    h2 = net.addHost( 'h2', ip='10.0.0.2' )

    info( '*** Adding switch\n' )
    s3 = net.addSwitch( 's3' )
    s4 = net.addSwitch( 's4' )
    s5 = net.addSwitch( 's5' )

    info( '*** Creating links\n' )
    net.addLink( h1, s3 )
    net.addLink( h2, s5 )
    net.addLink( s3 , s4 )
    net.addLink( s4 , s5 )

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

    info( '*** Running CLI\n' )
    CLI( net )

    info( '*** Stopping network' )
    net.stop()
开发者ID:chrissmall22,项目名称:mininet-topo,代码行数:34,代码来源:uw.py


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