First crack at allowing Controller to be customized.

Network may now be used with custom controllers.
An example of doing this is in nox.py, which instantiates at TreeNet
using a custom Controller, NoxController, that runs nox_core rather
than the reference controller.
This commit is contained in:
Bob Lantz
2009-12-14 20:14:44 -08:00
parent 845dedca32
commit 2f53491343
7 changed files with 54 additions and 70 deletions
+10 -32
View File
@@ -1,39 +1,17 @@
#!/usr/bin/python
"Create a network from scratch and use NOX as the controller."
"Instantiate a Tree network and use NOX as the controller."
from mininet import init, Controller, Switch, Host, createLink
import time
from mininet import init, Controller, TreeNet, Cli
def scratchNet( cname='controller', cargs='ptcp:'):
# Create Network
controller = Node( 'c0', inNamespace=False )
switch = Node( 's0', inNamespace=False )
h0 = Node( 'h0' )
h1 = Node( 'h1' )
createLink( h0, switch )
createLink( h1, switch )
# Configure hosts
h0.setIP( h0.intfs[ 0 ], '192.168.123.1', '/24' )
h1.setIP( h1.intfs[ 0 ], '192.168.123.2', '/24' )
# Start network using kernel datapath
controller.cmdPrint( cname + ' ' + cargs + '&' )
switch.cmdPrint( 'dpctl deldp nl:0' )
switch.cmdPrint( 'dpctl adddp nl:0' )
for intf in switch.intfs:
switch.cmdPrint( 'dpctl addif nl:0 ' + intf )
switch.cmdPrint( 'ofprotocol nl:0 tcp:localhost &')
# Run test
h0.cmdPrint( 'ping -c1 ' + h1.IP() )
# Stop network
controller.cmdPrint( 'kill %' + cname)
switch.cmdPrint( 'dpctl deldp nl:0' )
switch.cmdPrint( 'kill %ofprotocol' )
switch.stop()
controller.stop()
class NoxController( Controller ):
def __init__( self, name, **kwargs ):
Controller.__init__( self, name,
controller='nox_core', cargs='-i ptcp pyswitch',
cdir='/usr/local/bin', **kwargs)
if __name__ == '__main__':
init()
scratchNet( cname='nox_core', cargs='-i ptcp:' )
network = TreeNet( depth=2, fanout=4, kernel=True, Controller=NoxController)
network.run( Cli )
+1
View File
@@ -7,6 +7,7 @@ While something like rshd(8) would be lighter and faster,
(and perfectly adequate on an in-machine network)
the advantage of running sshd is that scripts can work
unchanged on mininet and hardware.
"""
import sys ; readline = sys.stdin.readline
-15
View File
@@ -1,15 +0,0 @@
#!/usr/bin/python
"""
Create a 1024-host network, and run the CLI on it.
If this fails because of kernel limits, you may have
to adjust them, e.g. by adding entries to /etc/sysctl.conf
and running sysctl -p.
"""
from mininet import init, TreeNet
if __name__ == '__main__':
init()
network = TreeNet( depth=2, fanout=32, kernel=True )
network.run( Cli )
+2 -2
View File
@@ -6,9 +6,9 @@ from mininet import init, TreeNet, pingTestVerbose
def treePing64():
results = {}
datapaths = [ 'kernel', 'user' ]
datapaths = [ 'user', 'kernel' ]
print "*** Testing Mininet with kernel and user datapaths"
print "*** Testing Mininet with user and kernel datapaths"
for datapath in datapaths:
k = datapath == 'kernel'