Revision 281f6e59 mininet/net.py
mininet/net.py | ||
---|---|---|
1 | 1 |
#!/usr/bin/python |
2 |
"""Mininet: A simple networking testbed for OpenFlow! |
|
3 |
author: Bob Lantz ( rlantz@cs.stanford.edu ) |
|
4 |
author: Brandon Heller ( brandonh@stanford.edu ) |
|
2 |
""" |
|
3 |
|
|
4 |
Mininet: A simple networking testbed for OpenFlow! |
|
5 |
|
|
6 |
author: Bob Lantz (rlantz@cs.stanford.edu) |
|
7 |
author: Brandon Heller (brandonh@stanford.edu) |
|
5 | 8 |
|
6 | 9 |
Mininet creates scalable OpenFlow test networks by using |
7 | 10 |
process-based virtualization and network namespaces. |
... | ... | |
11 | 14 |
top of a single Linux kernel. |
12 | 15 |
|
13 | 16 |
Each host has: |
14 |
A virtual console ( pipes to a shell )
|
|
15 |
A virtual interfaces ( half of a veth pair )
|
|
16 |
A parent shell ( and possibly some child processes ) in a namespace
|
|
17 |
A virtual console (pipes to a shell)
|
|
18 |
A virtual interfaces (half of a veth pair)
|
|
19 |
A parent shell (and possibly some child processes) in a namespace
|
|
17 | 20 |
|
18 | 21 |
Hosts have a network interface which is configured via ifconfig/ip |
19 | 22 |
link/etc. |
... | ... | |
24 | 27 |
In kernel datapath mode, the controller and switches are simply |
25 | 28 |
processes in the root namespace. |
26 | 29 |
|
27 |
Kernel OpenFlow datapaths are instantiated using dpctl( 8 ), and are
|
|
30 |
Kernel OpenFlow datapaths are instantiated using dpctl(8), and are
|
|
28 | 31 |
attached to the one side of a veth pair; the other side resides in the |
29 | 32 |
host namespace. In this mode, switch processes can simply connect to the |
30 | 33 |
controller via the loopback interface. |
31 | 34 |
|
32 | 35 |
In user datapath mode, the controller and switches are full-service |
33 | 36 |
nodes that live in their own network namespaces and have management |
34 |
interfaces and IP addresses on a control network ( e.g. 10.0.123.1,
|
|
35 |
currently routed although it could be bridged. )
|
|
37 |
interfaces and IP addresses on a control network (e.g. 10.0.123.1, |
|
38 |
currently routed although it could be bridged.) |
|
36 | 39 |
|
37 | 40 |
In addition to a management interface, user mode switches also have |
38 | 41 |
several switch interfaces, halves of veth pairs whose other halves |
39 | 42 |
reside in the host nodes that the switches are connected to. |
40 | 43 |
|
41 | 44 |
Naming: |
42 |
Host nodes are named h1-hN |
|
43 |
Switch nodes are named s0-sN |
|
44 |
Interfaces are named { nodename }-eth0 .. { nodename }-ethN,""" |
|
45 |
|
|
46 |
Host nodes are named h1-hN |
|
47 |
Switch nodes are named s0-sN |
|
48 |
Interfaces are named { nodename }-eth0 .. { nodename }-ethN |
|
49 |
|
|
50 |
""" |
|
51 |
|
|
45 | 52 |
import os |
46 | 53 |
import re |
47 | 54 |
import signal |
... | ... | |
79 | 86 |
autoSetMacs=False, autoStaticArp=False ): |
80 | 87 |
"""Create Mininet object. |
81 | 88 |
topo: Topo object |
82 |
switch: Switch class
|
|
89 |
switch: Switch class |
|
83 | 90 |
host: Host class |
84 | 91 |
controller: Controller class |
85 | 92 |
cparams: ControllerParams object |
... | ... | |
219 | 226 |
lg.info( '\n' ) |
220 | 227 |
lg.info( '*** Testing control network\n' ) |
221 | 228 |
while not controller.intfIsUp( controller.intfs[ 0 ] ): |
222 |
lg.info( '*** Waiting for %s to come up\n', controller.intfs[ 0 ] ) |
|
229 |
lg.info( '*** Waiting for %s to come up\n', |
|
230 |
controller.intfs[ 0 ] ) |
|
223 | 231 |
sleep( 1 ) |
224 | 232 |
for switchDpid in self.topo.switches(): |
225 | 233 |
switch = self.nodes[ switchDpid ] |
... | ... | |
509 | 517 |
# Commands |
510 | 518 |
def help( self, args ): |
511 | 519 |
"Semi-useful help for CLI." |
512 |
helpStr = ( 'Available commands are:' + str( self.cmds ) + '\n' +
|
|
513 |
'You may also send a command to a node using:\n' +
|
|
514 |
' <node> command {args}\n' +
|
|
515 |
'For example:\n' +
|
|
516 |
' mininet> h0 ifconfig\n' +
|
|
517 |
'\n' +
|
|
518 |
'The interpreter automatically substitutes IP ' +
|
|
519 |
'addresses\n' +
|
|
520 |
'for node names, so commands like\n' +
|
|
521 |
' mininet> h0 ping -c1 h1\n' +
|
|
522 |
'should work.\n' +
|
|
523 |
'\n\n' +
|
|
524 |
'Interactive commands are not really supported yet,\n' +
|
|
525 |
'so please limit commands to ones that do not\n' +
|
|
526 |
'require user interaction and will terminate\n' +
|
|
520 |
helpStr = ( 'Available commands are:' + str( self.cmds ) + '\n' |
|
521 |
'You may also send a command to a node using:\n' |
|
522 |
' <node> command {args}\n' |
|
523 |
'For example:\n' |
|
524 |
' mininet> h0 ifconfig\n' |
|
525 |
'\n' |
|
526 |
'The interpreter automatically substitutes IP ' |
|
527 |
'addresses\n' |
|
528 |
'for node names, so commands like\n' |
|
529 |
' mininet> h0 ping -c1 h1\n' |
|
530 |
'should work.\n' |
|
531 |
'\n\n' |
|
532 |
'Interactive commands are not really supported yet,\n' |
|
533 |
'so please limit commands to ones that do not\n' |
|
534 |
'require user interaction and will terminate\n' |
|
527 | 535 |
'after a reasonable amount of time.\n' ) |
528 | 536 |
print( helpStr ) |
529 | 537 |
|
Also available in: Unified diff