Removed underscores for public Node methods. Minor cleanup & comments.

This commit is contained in:
Bob Lantz committed 2010-03-08 15:32:41 -08:00
1 parent 2626693241
commit 80be564274
12 files changed
+223 -188

No files matched your search

+10 -11
View File
@@ -6,21 +6,20 @@ This is more complicated than using the higher-level classes,
but it exposes the configuration details and allows customization.
"""
import logging
from mininet.net import init
from mininet.node import Node
from mininet.util import createLink
from mininet.log import lg, info
def scratchNet( cname='controller', cargs='ptcp:'):
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, port1=0, node2=switch, port2=0 )
createLink( node1=h1, port1=0, node2=switch, port2=1 )
@@ -30,25 +29,25 @@ def scratchNet( cname='controller', cargs='ptcp:'):
h1.setIP( h1.intfs[ 0 ], '192.168.123.2', 24 )
info( str( h0 ) + '\n' )
info( str( h1 ) + '\n' )
info( "*** Starting network using kernel datapath\n" )
controller.cmd( cname + ' ' + cargs + '&' )
switch.cmd( 'dpctl deldp nl:0' )
switch.cmd( 'dpctl adddp nl:0' )
for intf in switch.intfs.values():
switch.cmd( 'dpctl addif nl:0 ' + intf )
switch.cmd( 'ofprotocol nl:0 tcp:localhost &')
switch.cmd( 'dpctl addif nl:0 ' + intf )
switch.cmd( 'ofprotocol nl:0 tcp:localhost &' )
info( "*** Running test\n" )
h0.cmdPrint( 'ping -c1 ' + h1.IP() )
info( "*** Stopping network\n" )
controller.cmd( 'kill %' + cname)
controller.cmd( 'kill %' + cname )
switch.cmd( 'dpctl deldp nl:0' )
switch.cmd( 'kill %ofprotocol' )
switch.deleteIntfs()
info( '\n' )
if __name__ == '__main__':
lg.setLogLevel( 'info' )
info( '*** Scratch network demo (kernel datapath)\n' )