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


Python link.TCLink方法代码示例

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


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

示例1: test_POXAntiArpPoison

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

# 需要导入模块: from mininet import link [as 别名]
# 或者: from mininet.link import TCLink [as 别名]
def test_RemoteController():
    """Test L3EthStar with a remote controller
    eg: pox controller
    """

    topo = L3EthStarAttack()
    net = Mininet(
        topo=topo,
        controller=None,
        link=TCLink, listenPort=OF_MISC['switch_debug_port'])
    net.addController(
        'c0',
        controller=RemoteController,
        ip='127.0.0.1',
        port=OF_MISC['controller_port'])
    net.start()

    CLI(net)

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

示例4: test_POXL2PairsRtt

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

示例5: create_topology

# 需要导入模块: from mininet import link [as 别名]
# 或者: from mininet.link import TCLink [as 别名]
def create_topology(self):
        self.net = DCNetwork(monitor=False, enable_learning=True)
        self.dc1 = self.net.addDatacenter("dc1")
        self.dc2 = self.net.addDatacenter("dc2")
        self.net.addLink(self.dc1, self.dc2, cls=TCLink, delay="50ms")
        # add OpenStack-like APIs to the emulated DC
        self.api1 = OpenstackApiEndpoint("0.0.0.0", 6001)
        self.api1.connect_datacenter(self.dc1)
        self.api1.connect_dc_network(self.net)
        self.api2 = OpenstackApiEndpoint("0.0.0.0", 6002)
        self.api2.connect_datacenter(self.dc2)
        self.api2.connect_dc_network(self.net)
        # add the command line interface endpoint to the emulated DC (REST API)
        self.rapi1 = RestApiEndpoint("0.0.0.0", 5001)
        self.rapi1.connectDCNetwork(self.net)
        self.rapi1.connectDatacenter(self.dc1)
        self.rapi1.connectDatacenter(self.dc2) 
开发者ID:sonata-nfv,项目名称:son-emu,代码行数:19,代码来源:osm_default_daemon_topology_2_pop.py

示例6: buildLinks

# 需要导入模块: from mininet import link [as 别名]
# 或者: from mininet.link import TCLink [as 别名]
def buildLinks( self, net):
        # Make links
        info( "Getting Links.\n" )
        for key,link in self.links.iteritems():
            tags = self.canvas.gettags(key)
            if 'data' in tags:
                src=link['src']
                dst=link['dest']
                linkopts=link['linkOpts']
                srcName, dstName = src[ 'text' ], dst[ 'text' ]
                srcNode, dstNode = net.nameToNode[ srcName ], net.nameToNode[ dstName ]
                if linkopts:
                    net.addLink(srcNode, dstNode, cls=TCLink, **linkopts)
                else:
                    # debug( str(srcNode) )
                    # debug( str(dstNode), '\n' )
                    net.addLink(srcNode, dstNode)
                self.canvas.itemconfig(key, dash=()) 
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:20,代码来源:miniedit.py

示例7: test_MininetTopoFromNxGraph

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

示例8: test_MininetLinearTopo

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

示例9: test_MiniCPSTCLinkCPULimitedHost

# 需要导入模块: from mininet import link [as 别名]
# 或者: from mininet.link import TCLink [as 别名]
def test_MiniCPSTCLinkCPULimitedHost():

    print
    topo = SingleSwitchTopoTCLinkCPULimitedHost(n=4)
    net = Mininet(
        topo=topo,
        link=TCLink)

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

示例10: test_L3EthStarBuild

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

示例11: test_L3EthStarEnip

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

示例12: test_POXSwatController

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

示例13: test_Workshop

# 需要导入模块: from mininet import link [as 别名]
# 或者: from mininet.link import TCLink [as 别名]
def test_Workshop():
    """Ideal link double MITM"""

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

    plc1, attacker, hmi = net.get('plc1', 'attacker', 'hmi')
    plc2, plc3, plc4 = net.get('plc2', 'plc3', 'plc4')

    CLI(net)

    # PASSIVE remote ARP poisoning
    target_ip1 = plc1.IP()
    target_ip2 = hmi.IP()
    attacker_interface = 'attacker-eth0'
    attacker_cmd = 'scripts/attacks/arp-mitm.sh %s %s %s &' % (
        target_ip1,
        target_ip2,
        attacker_interface)
    attacker.cmd(attacker_cmd)

    target_ip1 = plc3.IP()
    target_ip2 = plc4.IP()
    attacker_interface = 'plc2-eth0'
    attacker_cmd = 'scripts/attacks/arp-mitm.sh %s %s %s &' % (
        target_ip1,
        target_ip2,
        attacker_interface)
    plc2.cmd(attacker_cmd)

    CLI(net)

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

示例14: emulate

# 需要导入模块: from mininet import link [as 别名]
# 或者: from mininet.link import TCLink [as 别名]
def emulate():
    # Setting the position of nodes and providing mobility

    # Create a network.
    net = Mininet(controller=Controller, link=TCLink, accessPoint=OVSKernelAP)

    print ("*** Creating nodes")
    # Add the host
    h1 = net.addHost('h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8')

    # Add 3 mobile stations, sta1, sta2, sta3.
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    sta2 = net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8')
    sta3 = net.addStation('sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8')

    # Add an access point
    ap1 = net.addAccessPoint('ap1', ssid='new-ssid', mode='g', channel='1', position='45,40,30')

    # Add a controller
    c1 = net.addController('c1', controller=Controller)

    print ("*** Configuring wifi nodes")
    net.configureWifiNodes()

    print ("*** Associating and Creating links")
    net.addLink(ap1, h1)
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)
    net.addLink(ap1, sta3)

    print ("*** Starting network")
    net.build()
    c1.start()
    ap1.start([c1])

    # Plot a 3-dimensional graph.
    net.plotGraph(max_x=100, max_y=100, max_z=200)

    # Start the mobility at the start of the emulation.
    net.startMobility(time=0)

    # Start the mobile stations from their initial positions.
    net.mobility(sta1, 'start', time=1, position='40.0,30.0,20.0')
    net.mobility(sta2, 'start', time=2, position='40.0,40.0,90.0')
    net.mobility(sta3, 'start', time=3, position='50.0,50.0,160.0')

    # Indicate the final destination of the mobile stations during the emulation.
    net.mobility(sta1, 'stop', time=12, position='31.0,10.0,50.0')
    net.mobility(sta2, 'stop', time=22, position='55.0,31.0,30.0')
    net.mobility(sta3, 'stop', time=32, position='75.0,99.0,120.0')

    # Stop the mobility at certain time.
    net.stopMobility(time=33)

    print ("*** Running CLI")
    CLI(net)

    print ("*** Stopping network")
    net.stop() 
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:61,代码来源:9_4_mininet_wifi_emulation.py

示例15: myNetwork

# 需要导入模块: from mininet import link [as 别名]
# 或者: from mininet.link import TCLink [as 别名]
def myNetwork():

    net = Mininet( topo=None,
                   build=False,
                   ipBase='10.0.0.0/8')

    info( '*** Adding controller\n' )
    c0=net.addController(name='c0',
                      controller=RemoteController,
                      ip='127.0.0.1',
                      protocol='tcp',
                      port=6653)

    info( '*** Add switches\n')
    s2 = net.addSwitch('s2', cls=OVSKernelSwitch)
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch)
    s5 = net.addSwitch('s5', cls=OVSKernelSwitch, failMode='standalone')

    info( '*** Add hosts\n')
    h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None)
    h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)
    h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None)
    h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None)

    info( '*** Add links\n')
    s1s2 = {'bw':400,'loss':0}
    net.addLink(s1, s2, cls=TCLink , **s1s2)
    s2h1 = {'bw':1000,'loss':10,'max_queue_size':10,'speedup':40}
    net.addLink(s2, h1, cls=TCLink , **s2h1)
    s2h2 = {'bw':120,'loss':0}
    net.addLink(s2, h2, cls=TCLink , **s2h2)
    s2h3 = {'bw':400,'loss':20}
    net.addLink(s2, h3, cls=TCLink , **s2h3)
    s1s5 = {'bw':200,'delay':'12','loss':10}
    net.addLink(s1, s5, cls=TCLink , **s1s5)
    s5h4 = {'bw':100,'loss':50}
    net.addLink(s5, h4, cls=TCLink , **s5h4)

    info( '*** Starting network\n')
    net.build()
    info( '*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info( '*** Starting switches\n')
    net.get('s2').start([c0])
    net.get('s1').start([c0])
    net.get('s5').start([])

    info( '*** Post configure switches and hosts\n')

    CLI(net)
    net.stop() 
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:55,代码来源:10_3_sdn_onos.py


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