Removed underscores for public Node methods. Minor cleanup & comments.
This commit is contained in:
+1
-1
@@ -133,7 +133,7 @@ def makeListCompatible( fn ):
|
||||
newfn( 'a', 1, 'b' )"""
|
||||
|
||||
def newfn( *args ):
|
||||
"Generated function."
|
||||
"Generated function. Closure-ish."
|
||||
if len( args ) == 1:
|
||||
return fn( *args )
|
||||
args = ' '.join( [ str( arg ) for arg in args ] )
|
||||
|
||||
+21
-16
@@ -49,27 +49,34 @@ which interfaces belong to which node.
|
||||
|
||||
The basic naming scheme is as follows:
|
||||
|
||||
Host nodes are named h0-hN
|
||||
Switch nodes are named s0-sN
|
||||
Host nodes are named h1-hN
|
||||
Switch nodes are named s1-sN
|
||||
Controller nodes are named c0-cN
|
||||
Interfaces are named {nodename}-eth0 .. {nodename}-ethN
|
||||
|
||||
Note: If the network topology is created using mininet.topo, then
|
||||
node numbers are unique among hosts and switches (e.g. we have
|
||||
h1..hN and SN..SN+M) and also correspond to their default IP addresses
|
||||
of 10.x.y.z/8 where x.y.z is the base-256 representation of N for
|
||||
hN. This mapping allows easy determination of a node's IP
|
||||
address from its name, e.g. h1 -> 10.0.0.1, h257 -> 10.0.1.1.
|
||||
|
||||
Currently we wrap the entire network in a 'mininet' object, which
|
||||
constructs a simulated network based on a network topology created
|
||||
using a topology object (e.g. LinearTopo) from topo.py and a Controller
|
||||
node which the switches will connect to. Several
|
||||
configuration options are provided for functions such as
|
||||
using a topology object (e.g. LinearTopo) from mininet.topo or
|
||||
mininet.topolib, and a Controller which the switches will connect
|
||||
to. Several configuration options are provided for functions such as
|
||||
automatically setting MAC addresses, populating the ARP table, or
|
||||
even running a set of xterms to allow direct interaction with nodes.
|
||||
|
||||
After the mininet is created, it can be started using start(), and a variety
|
||||
of useful tasks maybe performed, including basic connectivity and
|
||||
bandwidth tests and running the mininet CLI.
|
||||
After the network is created, it can be started using start(), and a
|
||||
variety of useful tasks maybe performed, including basic connectivity
|
||||
and bandwidth tests and running the mininet CLI.
|
||||
|
||||
Once the network is up and running, test code can easily get access
|
||||
to host and switch objects, which can then be used
|
||||
for arbitrary experiments, typically involving running a series of
|
||||
commands on the hosts.
|
||||
to host and switch objects which can then be used for arbitrary
|
||||
experiments, typically involving running a series of commands on the
|
||||
hosts.
|
||||
|
||||
After all desired tests or activities have been completed, the stop()
|
||||
method may be called to shut down the network.
|
||||
@@ -187,10 +194,8 @@ class Mininet( object ):
|
||||
#
|
||||
# Notes:
|
||||
#
|
||||
# 1. If the controller and switches are in the same ( e.g. root )
|
||||
# 1. If the controller and switches are in the same (e.g. root)
|
||||
# namespace, they can just use the loopback connection.
|
||||
# We may wish to do this for the user datapath as well as the
|
||||
# kernel datapath.
|
||||
#
|
||||
# 2. If we can get unix domain sockets to work, we can use them
|
||||
# instead of an explicit control network.
|
||||
@@ -244,7 +249,7 @@ class Mininet( object ):
|
||||
exit( 1 )
|
||||
info( '\n' )
|
||||
|
||||
def _configHosts( self ):
|
||||
def configHosts( self ):
|
||||
"Configure a set of hosts."
|
||||
# params were: hosts, ips
|
||||
for host in self.hosts:
|
||||
@@ -294,7 +299,7 @@ class Mininet( object ):
|
||||
self._configureControlNetwork()
|
||||
|
||||
info( '*** Configuring hosts\n' )
|
||||
self._configHosts()
|
||||
self.configHosts()
|
||||
|
||||
if self.xterms:
|
||||
self.startXterms()
|
||||
|
||||
@@ -33,6 +33,12 @@ RemoteController: a remote controller node, which may use any
|
||||
arbitrary OpenFlow-compatible controller, and which is not
|
||||
created or managed by mininet.
|
||||
|
||||
Future enhancements:
|
||||
|
||||
- Possibly make Node, Switch and Controller more abstract so that
|
||||
they can be used for both local and remote nodes
|
||||
|
||||
- Create proxy objects for remote nodes (Mininet: Cluster Edition)
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
+11
-11
@@ -98,7 +98,7 @@ class Topo(object):
|
||||
self.ports = {} # ports[src][dst] is port on src that connects to dst
|
||||
self.id_gen = NodeID # class used to generate dpid
|
||||
|
||||
def _add_node(self, dpid, node):
|
||||
def add_node(self, dpid, node):
|
||||
'''Add Node to graph.
|
||||
|
||||
@param dpid dpid
|
||||
@@ -107,7 +107,7 @@ class Topo(object):
|
||||
self.g.add_node(dpid)
|
||||
self.node_info[dpid] = node
|
||||
|
||||
def _add_edge(self, src, dst, edge = None):
|
||||
def add_edge(self, src, dst, edge = None):
|
||||
'''Add edge (Node, Node) to graph.
|
||||
|
||||
@param src src dpid
|
||||
@@ -119,9 +119,9 @@ class Topo(object):
|
||||
if not edge:
|
||||
edge = Edge()
|
||||
self.edge_info[(src, dst)] = edge
|
||||
self._add_port(src, dst)
|
||||
self.add_port(src, dst)
|
||||
|
||||
def _add_port(self, src, dst):
|
||||
def add_port(self, src, dst):
|
||||
'''Generate port mapping for new edge.
|
||||
|
||||
@param src source switch DPID
|
||||
@@ -329,11 +329,11 @@ class SingleSwitchTopo(Topo):
|
||||
|
||||
self.k = k
|
||||
|
||||
self._add_node(1, Node())
|
||||
self.add_node(1, Node())
|
||||
hosts = range(2, k + 2)
|
||||
for h in hosts:
|
||||
self._add_node(h, Node(is_switch = False))
|
||||
self._add_edge(h, 1, Edge())
|
||||
self.add_node(h, Node(is_switch = False))
|
||||
self.add_edge(h, 1, Edge())
|
||||
|
||||
if enable_all:
|
||||
self.enable_all()
|
||||
@@ -388,12 +388,12 @@ class LinearTopo(Topo):
|
||||
switches = range(1, k + 1)
|
||||
for s in switches:
|
||||
h = s + k
|
||||
self._add_node(s, Node())
|
||||
self._add_node(h, Node(is_switch = False))
|
||||
self._add_edge(s, h, Edge())
|
||||
self.add_node(s, Node())
|
||||
self.add_node(h, Node(is_switch = False))
|
||||
self.add_edge(s, h, Edge())
|
||||
for s in switches:
|
||||
if s != k:
|
||||
self._add_edge(s, s + 1, Edge())
|
||||
self.add_edge(s, s + 1, Edge())
|
||||
|
||||
if enable_all:
|
||||
self.enable_all()
|
||||
|
||||
+2
-2
@@ -20,11 +20,11 @@ class TreeTopo( Topo ):
|
||||
returns: last node added"""
|
||||
me = n
|
||||
isSwitch = depth > 0
|
||||
self._add_node( me, Node( is_switch=isSwitch ) )
|
||||
self.add_node( me, Node( is_switch=isSwitch ) )
|
||||
if isSwitch:
|
||||
for i in range( 0, fanout ):
|
||||
child = n + 1
|
||||
self._add_edge( me, child )
|
||||
self.add_edge( me, child )
|
||||
n = self.addTree( child, depth-1, fanout )
|
||||
return n
|
||||
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ def macColonHex( mac ):
|
||||
return _colonHex( mac, 6 )
|
||||
|
||||
def ipStr( ip ):
|
||||
"""Generate IP address string
|
||||
"""Generate IP address string from an unsigned int
|
||||
ip: unsigned int of form x << 16 | y << 8 | z
|
||||
returns: ip address string 10.x.y.z """
|
||||
hi = ( ip & 0xff0000 ) >> 16
|
||||
|
||||
Reference in New Issue
Block a user