MCPcopy Create free account
hub / github.com/mininet/mininet / scratchNetUser

Function scratchNetUser

examples/scratchnetuser.py:23–67  ·  view source on GitHub ↗

Create network from scratch using user switch.

( cname='controller', cargs='ptcp:' )

Source from the content-addressed store, hash-verified

21 return link.intf1, link.intf2
22
23def scratchNetUser( cname='controller', cargs='ptcp:' ):
24 "Create network from scratch using user switch."
25
26 # It's not strictly necessary for the controller and switches
27 # to be in separate namespaces. For performance, they probably
28 # should be in the root namespace. However, it's interesting to
29 # see how they could work even if they are in separate namespaces.
30
31 info( '*** Creating Network\n' )
32 controller = Node( 'c0' )
33 switch = Node( 's0')
34 h0 = Node( 'h0' )
35 h1 = Node( 'h1' )
36 cintf, sintf = linkIntfs( controller, switch )
37 h0intf, sintf1 = linkIntfs( h0, switch )
38 h1intf, sintf2 = linkIntfs( h1, switch )
39
40 info( '*** Configuring control network\n' )
41 controller.setIP( '10.0.123.1/24', intf=cintf )
42 switch.setIP( '10.0.123.2/24', intf=sintf)
43
44 info( '*** Configuring hosts\n' )
45 h0.setIP( '192.168.123.1/24', intf=h0intf )
46 h1.setIP( '192.168.123.2/24', intf=h1intf )
47
48 info( '*** Network state:\n' )
49 for node in controller, switch, h0, h1:
50 info( str( node ) + '\n' )
51
52 info( '*** Starting controller and user datapath\n' )
53 controller.cmd( cname + ' ' + cargs + '&' )
54 switch.cmd( 'ifconfig lo 127.0.0.1' )
55 intfs = str( sintf1 ), str( sintf2 )
56 switch.cmd( 'ofdatapath -i ' + ','.join( intfs ) + ' ptcp: &' )
57 switch.cmd( 'ofprotocol tcp:' + controller.IP() + ' tcp:localhost &' )
58
59 info( '*** Running test\n' )
60 h0.cmdPrint( 'ping -c1 ' + h1.IP() )
61
62 info( '*** Stopping network\n' )
63 controller.cmd( 'kill %' + cname )
64 switch.cmd( 'kill %ofdatapath' )
65 switch.cmd( 'kill %ofprotocol' )
66 switch.deleteIntfs()
67 info( '\n' )
68
69
70if __name__ == '__main__':

Callers 1

scratchnetuser.pyFile · 0.85

Calls 7

setIPMethod · 0.95
cmdMethod · 0.95
IPMethod · 0.95
cmdPrintMethod · 0.95
deleteIntfsMethod · 0.95
NodeClass · 0.90
linkIntfsFunction · 0.85

Tested by

no test coverage detected