Revision 47e26cce examples/scratchnetuser.py
examples/scratchnetuser.py | ||
---|---|---|
13 | 13 |
from mininet.util import createLink |
14 | 14 |
from mininet.log import lg, info |
15 | 15 |
|
16 |
def scratchNetUser( cname='controller', cargs='ptcp:'): |
|
16 |
def scratchNetUser( cname='controller', cargs='ptcp:' ):
|
|
17 | 17 |
# Create Network |
18 | 18 |
# It's not strictly necessary for the controller and switches |
19 | 19 |
# to be in separate namespaces. For performance, they probably |
... | ... | |
30 | 30 |
createLink( h1, 0, switch, 2 ) |
31 | 31 |
|
32 | 32 |
info( '*** Configuring control network\n' ) |
33 |
controller.setIP( controller.intfs[ 0 ], '10.0.123.1', '/24' )
|
|
34 |
switch.setIP( switch.intfs[ 0 ], '10.0.123.2', '/24' )
|
|
33 |
controller.setIP( controller.intfs[ 0 ], '10.0.123.1', 24 )
|
|
34 |
switch.setIP( switch.intfs[ 0 ], '10.0.123.2', 24 )
|
|
35 | 35 |
|
36 | 36 |
info( '*** Configuring hosts\n' ) |
37 |
h0.setIP( h0.intfs[ 0 ], '192.168.123.1', '/24' )
|
|
38 |
h1.setIP( h1.intfs[ 0 ], '192.168.123.2', '/24' )
|
|
37 |
h0.setIP( h0.intfs[ 0 ], '192.168.123.1', 24 )
|
|
38 |
h1.setIP( h1.intfs[ 0 ], '192.168.123.2', 24 )
|
|
39 | 39 |
|
40 | 40 |
info( '*** Network state:\n' ) |
41 | 41 |
for node in controller, switch, h0, h1: |
... | ... | |
44 | 44 |
info( '*** Starting controller and user datapath\n' ) |
45 | 45 |
controller.cmd( cname + ' ' + cargs + '&' ) |
46 | 46 |
switch.cmd( 'ifconfig lo 127.0.0.1' ) |
47 |
intfs = [ switch.intfs[ port ] for port in (1, 2) ]
|
|
47 |
intfs = [ switch.intfs[ port ] for port in ( 1, 2 ) ]
|
|
48 | 48 |
switch.cmd( 'ofdatapath -i ' + ','.join( intfs ) + ' ptcp: &' ) |
49 | 49 |
switch.cmd( 'ofprotocol tcp:' + controller.IP() + ' tcp:localhost &' ) |
50 | 50 |
|
... | ... | |
55 | 55 |
controller.cmd( 'kill %' + cname ) |
56 | 56 |
switch.cmd( 'kill %ofdatapath' ) |
57 | 57 |
switch.cmd( 'kill %ofprotocol' ) |
58 |
|
|
58 |
switch.deleteIntfs() |
|
59 |
info( '\n' ) |
|
60 |
|
|
59 | 61 |
if __name__ == '__main__': |
62 |
lg.setLogLevel( 'info' ) |
|
60 | 63 |
info( '*** Scratch network demo (user datapath)\n' ) |
61 | 64 |
init() |
62 |
lg.setLogLevel( 'info' ) |
|
63 | 65 |
scratchNetUser() |
Also available in: Unified diff