From 0b084dd51af5c85ee779397bea8d2640e42e67d3 Mon Sep 17 00:00:00 2001 From: Bob Lantz <rlantz@cs.stanford.edu> Date: Mon, 14 Dec 2009 21:01:45 -0800 Subject: [PATCH] Added ripcord.py, which attempts to make a FatTree using ripcord and instantiate a mininet Network based on its topology. Also minor cleanup of nox.py and GridNet class in mininet.py. --- examples/nox.py | 1 - examples/ripcord.py | 50 +++++++++++++++++++++++++++++++++++++++++++++ mininet.py | 4 ++-- 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100755 examples/ripcord.py diff --git a/examples/nox.py b/examples/nox.py index 84a34960..0280f4c3 100755 --- a/examples/nox.py +++ b/examples/nox.py @@ -2,7 +2,6 @@ "Instantiate a Tree network and use NOX as the controller." -import time from mininet import init, Controller, TreeNet, Cli class NoxController( Controller ): diff --git a/examples/ripcord.py b/examples/ripcord.py new file mode 100755 index 00000000..1c9c15d0 --- /dev/null +++ b/examples/ripcord.py @@ -0,0 +1,50 @@ +#!/usr/bin/python + +"A FatTree network, using Brandon Heller's ripcord system." + +from ripcord.topo import StructuredNode, StructuredNodeSpec, FatTreeTopo, VL2T +opo + +from mininet import Controller, Network, Host, pingTest + +class NoxController( Controller ): + "A customized Controller that uses NOX." + def __init__( self, name, **kwargs ): + Controller.__init__( self, name, + controller='nox_core', cargs='-i ptcp pyswitch', + cdir='/usr/local/bin', **kwargs) + +class FatTree( Network ): + "A customized Network that uses ripcord's FatTree." + def __init__( self, **kwargs ): + Network.__init__( self, depth, **kwargs ) + def makeNetwork( self, controller ): + ft = FatTreeTopo( depth ) + graph = ft.g + switches = [] + hosts = [] + hostnames = nameGen( 'h0' ) + switchnames = nameGen( 's0' ) + graphToMini = {} + miniToGraph = {} + # Create nodes + for graphNode in graph.nodes(): + print "found node", graphNode + isLeaf = len( graph.neighbors( graphNode ) ) = 1 + if isLeaf: + mininetNode = Node( hostnames.next() ) + hosts += [ mininetNode ] + else: + mininetNode = self.Switch( switchnames.next() ) + switches += [ mininetNode ] + miniToGraph[ mininetNode ] = graphNode + graphToMini[ graphNode ] = mininetNode + # Create Links + for switch in switches: + for neighbor in miniToGraph[ switches ]: + makeLink( switch, graphToMini[ neighbor ] ) + +if __name__ == '__main__': + init() + network = FatTree( depth=4, kernel=True, Controller=NoxController) + network.run( pingTest ) diff --git a/mininet.py b/mininet.py index 31d6c200..2ecc0113 100755 --- a/mininet.py +++ b/mininet.py @@ -578,9 +578,9 @@ class GridNet( Network ): """An N x M grid/mesh network of switches, with hosts at the edges. This class also demonstrates creating a somewhat complicated topology.""" - def __init__( self, n, m, kernel=True, linear=False, **kwargs ): + def __init__( self, n, m, linear=False, **kwargs ): self.n, self.m, self.linear = n, m, linear and m == 1 - Network.__init__( self, kernel, **kwargs ) + Network.__init__( self, **kwargs ) def makeNet( self, controller ): snames, hnames, dpnames = defaultNames() n, m = self.n, self.m -- GitLab