From c53fa3ba32fce123b67654fc8d9f0e6f9bcfdabe Mon Sep 17 00:00:00 2001 From: Bob Lantz <rlantz@cs.stanford.edu> Date: Mon, 14 Dec 2009 21:35:08 -0800 Subject: [PATCH] Second crack at a ripcordtest.py that actually works. ripcord.py was a name conflict - ugh! This one creates a network successfully, but ping doesn't work with nox out of the box at least. --- examples/ripcord.py | 50 --------------------------------- examples/ripcordtest.py | 61 +++++++++++++++++++++++++++++++++++++++++ mininet.py | 1 - 3 files changed, 61 insertions(+), 51 deletions(-) delete mode 100755 examples/ripcord.py create mode 100755 examples/ripcordtest.py diff --git a/examples/ripcord.py b/examples/ripcord.py deleted file mode 100755 index 1c9c15d0..00000000 --- a/examples/ripcord.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/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/examples/ripcordtest.py b/examples/ripcordtest.py new file mode 100755 index 00000000..719ec6d6 --- /dev/null +++ b/examples/ripcordtest.py @@ -0,0 +1,61 @@ +#!/usr/bin/python + +"A FatTree network, using Brandon Heller's ripcord system." + +import ripcord +from ripcord.topo import FatTreeTopo + +from mininet import init, Controller, Network, Host, nameGen, Cli +from mininet import createLink, flush + +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, depth, **kwargs ): + self.depth = depth + Network.__init__( self, **kwargs ) + def makeNet( self, controller ): + ft = FatTreeTopo( self.depth ) + graph = ft.g + switches = [] + hosts = [] + hostnames = nameGen( 'h' ) + switchnames = nameGen( 's' ) + dpnames = nameGen( 'nl:') + graphToMini = {} + miniToGraph = {} + # Create nodes + for graphNode in graph.nodes(): + isLeaf = len( graph.neighbors( graphNode ) ) == 1 + if isLeaf: + mininetNode = Host( hostnames.next() ) + hosts += [ mininetNode ] + else: + mininetNode = self.Switch( switchnames.next(), dpnames.next() ) + switches += [ mininetNode ] + print mininetNode.name, ; flush() + miniToGraph[ mininetNode ] = graphNode + graphToMini[ graphNode ] = mininetNode + print + print "*** Creating links" + for switch in switches: + currentNeighbors = [ switch.connection[ intf ][ 0 ] + for intf in switch.intfs ] + for neighbor in graph.neighbors( miniToGraph[ switch ] ): + miniNeighbor = graphToMini[ neighbor ] + if miniNeighbor not in currentNeighbors: + print ".", ; flush() + createLink( switch, graphToMini[ neighbor ] ) + print + return switches, hosts + +if __name__ == '__main__': + init() + network = FatTree( depth=4, kernel=True, Controller=NoxController) + network.run( Cli ) diff --git a/mininet.py b/mininet.py index 2ecc0113..6adc3046 100755 --- a/mininet.py +++ b/mininet.py @@ -451,7 +451,6 @@ def __init__( self, kernel=True, Controller=Controller, Switch=Switch, hostIpGen=ipGen, hostIpStart=( 192, 168, 123, 1 ) ): - print "NETWORK: Controller=", Controller self.kernel = kernel self.Controller = Controller self.Switch = Switch -- GitLab