本文整理汇总了Python中mininet.node.Node.cmdPrint方法的典型用法代码示例。如果您正苦于以下问题:Python Node.cmdPrint方法的具体用法?Python Node.cmdPrint怎么用?Python Node.cmdPrint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.node.Node
的用法示例。
在下文中一共展示了Node.cmdPrint方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scratchNetUser
# 需要导入模块: from mininet.node import Node [as 别名]
# 或者: from mininet.node.Node import cmdPrint [as 别名]
def scratchNetUser( cname='controller', cargs='ptcp:' ):
"Create network from scratch using user switch."
# It's not strictly necessary for the controller and switches
# to be in separate namespaces. For performance, they probably
# should be in the root namespace. However, it's interesting to
# see how they could work even if they are in separate namespaces.
info( '*** Creating Network\n' )
controller = Node( 'c0' )
switch = Node( 's0')
h0 = Node( 'h0' )
h1 = Node( 'h1' )
cintf, sintf = createLink( controller, switch )
h0intf, sintf1 = createLink( h0, switch )
h1intf, sintf2 = createLink( h1, switch )
info( '*** Configuring control network\n' )
controller.setIP( cintf, '10.0.123.1', 24 )
switch.setIP( sintf, '10.0.123.2', 24 )
info( '*** Configuring hosts\n' )
h0.setIP( h0intf, '192.168.123.1', 24 )
h1.setIP( h1intf, '192.168.123.2', 24 )
info( '*** Network state:\n' )
for node in controller, switch, h0, h1:
info( str( node ) + '\n' )
info( '*** Starting controller and user datapath\n' )
controller.cmd( cname + ' ' + cargs + '&' )
switch.cmd( 'ifconfig lo 127.0.0.1' )
intfs = [ sintf1, sintf2 ]
switch.cmd( 'ofdatapath -i ' + ','.join( intfs ) + ' ptcp: &' )
switch.cmd( 'ofprotocol tcp:' + controller.IP() + ' tcp:localhost &' )
info( '*** Running test\n' )
h0.cmdPrint( 'ping -c1 ' + h1.IP() )
info( '*** Stopping network\n' )
controller.cmd( 'kill %' + cname )
switch.cmd( 'kill %ofdatapath' )
switch.cmd( 'kill %ofprotocol' )
switch.deleteIntfs()
info( '\n' )
示例2: scratchNet
# 需要导入模块: from mininet.node import Node [as 别名]
# 或者: from mininet.node.Node import cmdPrint [as 别名]
def scratchNet( cname='controller', cargs='-v ptcp:' ):
"Create network from scratch using Open vSwitch."
info( "*** Creating nodes\n" )
controller = Node( 'c0', inNamespace=False )
switch = Node( 's0', inNamespace=False )
h0 = Node( 'h0' )
h1 = Node( 'h1' )
info( "*** Creating links\n" )
Link( h0, switch )
Link( h1, switch )
info( "*** Configuring hosts\n" )
h0.setIP( '192.168.123.1/24' )
h1.setIP( '192.168.123.2/24' )
info( str( h0 ) + '\n' )
info( str( h1 ) + '\n' )
info( "*** Starting network using Open vSwitch\n" )
controller.cmd( cname + ' ' + cargs + '&' )
switch.cmd( 'ovs-vsctl del-br dp0' )
switch.cmd( 'ovs-vsctl add-br dp0' )
for intf in switch.intfs.values():
print switch.cmd( 'ovs-vsctl add-port dp0 %s' % intf )
# Note: controller and switch are in root namespace, and we
# can connect via loopback interface
switch.cmd( 'ovs-vsctl set-controller dp0 tcp:127.0.0.1:6633' )
info( '*** Waiting for switch to connect to controller' )
while 'is_connected' not in quietRun( 'ovs-vsctl show' ):
sleep( 1 )
info( '.' )
info( '\n' )
info( "*** Running test\n" )
h0.cmdPrint( 'ping -c1 ' + h1.IP() )
info( "*** Stopping network\n" )
controller.cmd( 'kill %' + cname )
switch.cmd( 'ovs-vsctl del-br dp0' )
switch.deleteIntfs()
info( '\n' )
示例3: scratchNet
# 需要导入模块: from mininet.node import Node [as 别名]
# 或者: from mininet.node.Node import cmdPrint [as 别名]
def scratchNet(cname="controller", cargs="-v ptcp:"):
"Create network from scratch using Open vSwitch."
info("*** Creating nodes\n")
controller = Node("c0", inNamespace=False)
switch = Node("s0", inNamespace=False)
h0 = Node("h0")
h1 = Node("h1")
info("*** Creating links\n")
Link(h0, switch)
Link(h1, switch)
info("*** Configuring hosts\n")
h0.setIP("192.168.123.1/24")
h1.setIP("192.168.123.2/24")
info(str(h0) + "\n")
info(str(h1) + "\n")
info("*** Starting network using Open vSwitch\n")
controller.cmd(cname + " " + cargs + "&")
switch.cmd("ovs-vsctl del-br dp0")
switch.cmd("ovs-vsctl add-br dp0")
for intf in switch.intfs.values():
print(switch.cmd("ovs-vsctl add-port dp0 %s" % intf))
# Note: controller and switch are in root namespace, and we
# can connect via loopback interface
switch.cmd("ovs-vsctl set-controller dp0 tcp:127.0.0.1:6633")
info("*** Waiting for switch to connect to controller")
while "is_connected" not in quietRun("ovs-vsctl show"):
sleep(1)
info(".")
info("\n")
info("*** Running test\n")
h0.cmdPrint("ping -c1 " + h1.IP())
info("*** Stopping network\n")
controller.cmd("kill %" + cname)
switch.cmd("ovs-vsctl del-br dp0")
switch.deleteIntfs()
info("\n")
示例4: scratchNet
# 需要导入模块: from mininet.node import Node [as 别名]
# 或者: from mininet.node.Node import cmdPrint [as 别名]
def scratchNet( cname='controller', cargs='ptcp:' ):
"Create network from scratch using kernel switch."
info( "*** Creating nodes\n" )
controller = Node( 'c0', inNamespace=False )
switch = Node( 's0', inNamespace=False )
h0 = Node( 'h0' )
h1 = Node( 'h1' )
info( "*** Creating links\n" )
createLink( node1=h0, node2=switch, port1=0, port2=0 )
createLink( node1=h1, node2=switch, port1=0, port2=1 )
info( "*** Configuring hosts\n" )
h0.setIP( h0.intfs[ 0 ], '192.168.123.1', 24 )
h1.setIP( h1.intfs[ 0 ], '192.168.123.2', 24 )
info( str( h0 ) + '\n' )
info( str( h1 ) + '\n' )
info( "*** Starting network using Open vSwitch kernel datapath\n" )
controller.cmd( cname + ' ' + cargs + '&' )
switch.cmd( 'ovs-dpctl del-dp dp0' )
switch.cmd( 'ovs-dpctl add-dp dp0' )
for intf in switch.intfs.values():
print switch.cmd( 'ovs-dpctl add-if dp0 ' + intf )
print switch.cmd( 'ovs-openflowd dp0 tcp:127.0.0.1 &' )
info( "*** Running test\n" )
h0.cmdPrint( 'ping -c1 ' + h1.IP() )
info( "*** Stopping network\n" )
controller.cmd( 'kill %' + cname )
switch.cmd( 'ovs-dpctl del-dp dp0' )
switch.cmd( 'kill %ovs-openflowd' )
switch.deleteIntfs()
info( '\n' )