diff --git a/examples/scratchnet.py b/examples/scratchnet.py index cbb3269264b9183c498c086f8e1f817b55365819..5f21ca113760d5f82d48ede70aa405173ce2df03 100755 --- a/examples/scratchnet.py +++ b/examples/scratchnet.py @@ -21,8 +21,8 @@ def scratchNet( cname='controller', cargs='ptcp:' ): h1 = Node( 'h1' ) info( "*** Creating links\n" ) - createLink( node1=h0, port1=0, node2=switch, port2=0 ) - createLink( node1=h1, port1=0, node2=switch, port2=1 ) + 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 ) diff --git a/examples/scratchnetuser.py b/examples/scratchnetuser.py index 1304508b92c9c6a5772bd2cee493ab5ec957e11d..3c000ebdd03fb58aadc61a6b723e90d5f1325344 100755 --- a/examples/scratchnetuser.py +++ b/examples/scratchnetuser.py @@ -26,17 +26,17 @@ def scratchNetUser( cname='controller', cargs='ptcp:' ): switch = Node( 's0') h0 = Node( 'h0' ) h1 = Node( 'h1' ) - createLink( controller, 0, switch, 0 ) - createLink( h0, 0, switch, 1 ) - createLink( h1, 0, switch, 2 ) + cintf, sintf = createLink( controller, switch ) + h0intf, sintf1 = createLink( h0, switch ) + h1intf, sintf2 = createLink( h1, switch ) info( '*** Configuring control network\n' ) - controller.setIP( controller.intfs[ 0 ], '10.0.123.1', 24 ) - switch.setIP( switch.intfs[ 0 ], '10.0.123.2', 24 ) + controller.setIP( cintf, '10.0.123.1', 24 ) + switch.setIP( sintf, '10.0.123.2', 24 ) info( '*** Configuring hosts\n' ) - h0.setIP( h0.intfs[ 0 ], '192.168.123.1', 24 ) - h1.setIP( h1.intfs[ 0 ], '192.168.123.2', 24 ) + 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: @@ -45,7 +45,7 @@ def scratchNetUser( cname='controller', cargs='ptcp:' ): info( '*** Starting controller and user datapath\n' ) controller.cmd( cname + ' ' + cargs + '&' ) switch.cmd( 'ifconfig lo 127.0.0.1' ) - intfs = [ switch.intfs[ port ] for port in ( 1, 2 ) ] + intfs = [ sintf1, sintf2 ] switch.cmd( 'ofdatapath -i ' + ','.join( intfs ) + ' ptcp: &' ) switch.cmd( 'ofprotocol tcp:' + controller.IP() + ' tcp:localhost &' )