Restored scratchnet and scratchnetuser demos.
Also changed the str format for nodes to use str() rather than repr() so we don't end up with extraneous quotes.
This commit is contained in:
+27
-27
@@ -11,44 +11,44 @@ import logging
|
||||
from mininet.net import init
|
||||
from mininet.node import Node
|
||||
from mininet.util import createLink
|
||||
from mininet.log import info
|
||||
|
||||
# print out info() messages, including cmdPrint
|
||||
logging.LOGLEVELDEFAULT = logging.INFO
|
||||
from mininet.log import lg, info
|
||||
|
||||
def scratchNet( cname='controller', cargs='ptcp:'):
|
||||
# Create Network
|
||||
print "*** creating Nodes"
|
||||
|
||||
info( "*** Creating nodes\n" )
|
||||
controller = Node( 'c0', inNamespace=False )
|
||||
switch = Node( 's0', inNamespace=False )
|
||||
h0 = Node( 'h0' )
|
||||
h1 = Node( 'h1' )
|
||||
print "*** creating links"
|
||||
|
||||
info( "*** Creating links\n" )
|
||||
createLink( node1=h0, port1=0, node2=switch, port2=0 )
|
||||
createLink( node1=h1, port1=0, node2=switch, port2=1 )
|
||||
# Configure hosts
|
||||
print "*** configuring hosts"
|
||||
|
||||
info( "*** Configuring hosts\n" )
|
||||
h0.setIP( h0.intfs[ 0 ], '192.168.123.1', '/24' )
|
||||
h1.setIP( h1.intfs[ 0 ], '192.168.123.2', '/24' )
|
||||
print h0
|
||||
print h1
|
||||
# Start network using kernel datapath
|
||||
controller.cmdPrint( cname + ' ' + cargs + '&' )
|
||||
switch.cmdPrint( 'dpctl deldp nl:0' )
|
||||
switch.cmdPrint( 'dpctl adddp nl:0' )
|
||||
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.cmdPrint( 'dpctl addif nl:0 ' + intf )
|
||||
switch.cmdPrint( 'ofprotocol nl:0 tcp:localhost &')
|
||||
# Run test
|
||||
print h0.cmd( 'ping -c1 ' + h1.IP() )
|
||||
# Stop network
|
||||
controller.cmdPrint( 'kill %' + cname)
|
||||
switch.cmdPrint( 'dpctl deldp nl:0' )
|
||||
switch.cmdPrint( 'kill %ofprotocol' )
|
||||
switch.stop()
|
||||
controller.stop()
|
||||
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)
|
||||
switch.cmd( 'dpctl deldp nl:0' )
|
||||
switch.cmd( 'kill %ofprotocol' )
|
||||
|
||||
if __name__ == '__main__':
|
||||
info( '*** Scratch network demo\n' )
|
||||
init()
|
||||
info( '*** Scratch network demo (kernel datapath)\n' )
|
||||
init()
|
||||
lg.setLogLevel( 'info' )
|
||||
scratchNet()
|
||||
|
||||
Reference in New Issue
Block a user