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


Python net.Mininet方法代码示例

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


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

示例1: test_POXAntiArpPoison

# 需要导入模块: from mininet import net [as 别名]
# 或者: from mininet.net import Mininet [as 别名]
def test_POXAntiArpPoison():
    """TODO Test AntiArpPoison controller."""

    topo = L3EthStar()
    controller = POXAntiArpPoison
    net = Mininet(
        topo=topo,
        controller=controller,
        link=TCLink, listenPort=OF_MISC['switch_debug_port'])
    net.start()
    time.sleep(1)  # allow mininet to init processes

    plc1, plc2, plc3 = net.get('plc1', 'plc2', 'plc3')

    target_ip1 = plc2.IP()
    target_ip2 = plc3.IP()
    attacker_interface = 'plc1-eth0'

    # plc1_cmd = 'scripts/attacks/arp-mitm.sh %s %s %s' % ( target_ip1,
    #         target_ip2, attacker_interface)
    # plc1.cmd(plc1_cmd)

    CLI(net)

    net.stop() 
开发者ID:scy-phy,项目名称:minicps,代码行数:27,代码来源:sdns_tests.py

示例2: test_POXL2Pairs

# 需要导入模块: from mininet import net [as 别名]
# 或者: from mininet.net import Mininet [as 别名]
def test_POXL2Pairs():
    """Test build-in forwarding.l2_pairs controller
    that adds flow entries using only MAC info.
    """

    topo = L3EthStar()
    controller = POXL2Pairs
    net = Mininet(
        topo=topo,
        controller=controller,
        link=TCLink, listenPort=OF_MISC['switch_debug_port'])
    net.start()

    CLI(net)

    net.stop() 
开发者ID:scy-phy,项目名称:minicps,代码行数:18,代码来源:sdns_tests.py

示例3: test_POXL2PairsRtt

# 需要导入模块: from mininet import net [as 别名]
# 或者: from mininet.net import Mininet [as 别名]
def test_POXL2PairsRtt():
    """Test build-in forwarding.l2_pairs controller RTT
    that adds flow entries using only MAC info.
    """

    topo = L3EthStar()
    controller = POXL2Pairs
    net = Mininet(
        topo=topo,
        controller=controller,
        link=TCLink, listenPort=OF_MISC['switch_debug_port'])
    net.start()
    time.sleep(1)  # allow mininet to init processes

    deltas = []
    for i in range(5):
        first_rtt, second_rtt = _arp_cache_rtts(net, 'plc1', 'plc2')
        assert_greater(
            first_rtt, second_rtt,
            c.ASSERTION_ERRORS['no_learning'])
        deltas.append(first_rtt - second_rtt)

    # CLI(net)

    net.stop() 
开发者ID:scy-phy,项目名称:minicps,代码行数:27,代码来源:sdns_tests.py

示例4: test_POXL2LearningRtt

# 需要导入模块: from mininet import net [as 别名]
# 或者: from mininet.net import Mininet [as 别名]
def test_POXL2LearningRtt():
    """Test build-in forwarding.l2_learning controller RTT
    that adds flow entries using only MAC info.
    """

    topo = L3EthStar()
    controller = POXL2Learning
    net = Mininet(
        topo=topo,
        controller=controller,
        link=TCLink, listenPort=OF_MISC['switch_debug_port'])
    net.start()
    time.sleep(1)  # allow mininet to init processes

    deltas = []
    for i in range(5):
        first_rtt, second_rtt = _arp_cache_rtts(net, 'plc1', 'plc2')
        assert_greater(
            first_rtt, second_rtt,
            c.ASSERTION_ERRORS['no_learning'])
        deltas.append(first_rtt - second_rtt)

    # CLI(net)

    net.stop() 
开发者ID:scy-phy,项目名称:minicps,代码行数:27,代码来源:sdns_tests.py

示例5: emulate

# 需要导入模块: from mininet import net [as 别名]
# 或者: from mininet.net import Mininet [as 别名]
def emulate(depth_, fanout_):
    
    # Create a network with tree topology
    tree_ = TreeTopo(depth=depth_,fanout=fanout_)
    
    # Initiating the Mininet instance
    net = Mininet(topo=tree_)
    
    # Start Execution of the Emulated System.
    net.start()

    # Name two of the instances as h1 and h2.
    h1, h2  = net.hosts[0], net.hosts[depth_]

    # Ping from an instance to another, and print the output.
    print (h1.cmd('ping -c1 %s' % h2.IP()))

    # Stop the Mininet Emulation.
    net.stop() 
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:21,代码来源:9_2_mininet_emulation.py

示例6: setCustom

# 需要导入模块: from mininet import net [as 别名]
# 或者: from mininet.net import Mininet [as 别名]
def setCustom( self, name, value ):
        "Set custom parameters for Mininet."
        if name.upper() == 'NET':
            info('*** Loading network from custom file ***\n')
            self.net = value
        elif name in ( 'topos', 'switches', 'hosts', 'controllers' ):
            # Update dictionaries
            param = name.upper()
            try:
                globals()[ param ].update( value )
                globals()[str(param + '_TYPES')].append( value.keys()[0])
            except:
                pass
        elif name == 'validate':
            # Add custom validate function
            self.validate = value

        elif name == 'locations':
            self.nodelocations = value

        else:
            # Add or modify global variable or class
            globals()[ name ] = value 
开发者ID:uccmisl,项目名称:MiniNAM,代码行数:25,代码来源:MiniNAM.py

示例7: test_topo

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

    topo = SwatTopo()
    net = Mininet(topo=topo)

    net.start()
    net.pingAll()
    net.stop() 
开发者ID:scy-phy,项目名称:minicps,代码行数:10,代码来源:tests.py

示例8: test_MininetTopoFromNxGraph

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

    graph = build_nx_graph()

    # Build a test graph
    topo = MininetTopoFromNxGraph(graph)

    net = Mininet(topo=topo, link=TCLink, listenPort=6634)
    net.start()
    print
    net.pingAll()

    # CLI(net)
    net.stop() 
开发者ID:scy-phy,项目名称:minicps,代码行数:16,代码来源:networks_tests.py

示例9: test_MininetLinearTopo

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

    net = Mininet(topo=LinearTopo(n=5),
                  link=TCLink)
    net.start()

    print "Dumpingg host connections"
    dumpNodeConnections(net.hosts)

    print "Testing network connectivity"
    net.pingAll()

    # CLI(net)

    net.stop() 
开发者ID:scy-phy,项目名称:minicps,代码行数:17,代码来源:mcps_tests.py

示例10: test_MiniCPS

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

    topo = SingleSwitchTopo(n=4)
    net = Mininet(topo=topo)

    try:
        mcps = MiniCPS(
            name='test_MiniCPS',
            net=net)
    except Exception as e:
        print 'TEST test_MiniCPS error: ', e 
开发者ID:scy-phy,项目名称:minicps,代码行数:13,代码来源:mcps_tests.py

示例11: test_MiniCPSCustomController

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

    print
    topo = SingleSwitchTopo(n=4)
    net = Mininet(
        topo=topo,
        controller=POXBridge)

    mcps = MiniCPS(
        name='name',
        net=net) 
开发者ID:scy-phy,项目名称:minicps,代码行数:13,代码来源:mcps_tests.py

示例12: test_L3EthStarBuild

# 需要导入模块: from mininet import net [as 别名]
# 或者: from mininet.net import Mininet [as 别名]
def test_L3EthStarBuild():
    """Test L3EthStar build process with custom L3_LINKOPTS"""

    topo = L3EthStar()
    net = Mininet(
        topo=topo, link=TCLink,
        listenPort=OF_MISC['switch_debug_port'])
    net.start()

    CLI(net)

    net.stop() 
开发者ID:scy-phy,项目名称:minicps,代码行数:14,代码来源:topologies_tests.py

示例13: test_L3EthStarEnip

# 需要导入模块: from mininet import net [as 别名]
# 或者: from mininet.net import Mininet [as 别名]
def test_L3EthStarEnip():
    """Test L3EthStar ENIP client/server communications
    plc1 is used as a cpppo simulated controller listening
    to from all interfaces at port 44818
    workstn is used as a cpppo client sending couples of
    write/read requests every second.
    """

    # TODO: integrate everything into log folder
    open(TEMP_DIR + '/l3/cppposerver.err', 'w').close()
    open(TEMP_DIR + '/l3/cpppoclient.out', 'w').close()
    open(TEMP_DIR + '/l3/cpppoclient.err', 'w').close()

    topo = L3EthStar()
    net = Mininet(
        topo=topo, link=TCLink,
        listenPort=OF_MISC['switch_debug_port'])
    net.start()

    plc1, workstn = net.get('plc1', 'workstn')

    server_cmd = './scripts/l3/cpppo_plc1server.sh'
    plc1.cmd(server_cmd)

    client_cmd = './scripts/l3/cpppo_client4plc1.sh'
    workstn.cmd(client_cmd)

    net.stop() 
开发者ID:scy-phy,项目名称:minicps,代码行数:30,代码来源:topologies_tests.py

示例14: test_L3EthStarArpMitm

# 需要导入模块: from mininet import net [as 别名]
# 或者: from mininet.net import Mininet [as 别名]
def test_L3EthStarArpMitm():
    """plc1 ARP poisoning MITM attack using ettercap,
    You can pass IP target to the dedicated script.
    """

    open(TEMP_DIR + '/l3/plc1arppoisoning.out', 'w').close()

    topo = L3EthStar()
    net = Mininet(
        topo=topo, link=TCLink,
        listenPort=OF_MISC['switch_debug_port'])
    net.start()

    plc1, plc2, plc3 = net.get('plc1', 'plc2', 'plc3')

    target_ip1 = plc2.IP()
    target_ip2 = plc3.IP()
    attacker_interface = 'plc1-eth0'

    plc1_cmd = 'scripts/attacks/arp-mitm.sh %s %s %s' % (
        target_ip1,
        target_ip2, attacker_interface)
    plc1.cmd(plc1_cmd)

    plc2_cmd = 'ping -c5 %s' % plc3.IP()
    plc2.cmd(plc2_cmd)

    plc1.cmd('tcpdump &')

    # CLI(net)

    net.stop() 
开发者ID:scy-phy,项目名称:minicps,代码行数:34,代码来源:topologies_tests.py

示例15: test_POXSwatController

# 需要导入模块: from mininet import net [as 别名]
# 或者: from mininet.net import Mininet [as 别名]
def test_POXSwatController():
    """See /logs folder for controller info"""

    topo = L3EthStar()
    net = Mininet(
        topo=topo,
        controller=POXSwatController,
        link=TCLink, listenPort=OF_MISC['switch_debug_port'])
    net.start()

    CLI(net)

    net.stop() 
开发者ID:scy-phy,项目名称:minicps,代码行数:15,代码来源:sdns_tests.py


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