From c98514ae44fad32c698c0748f339de43ba8da190 Mon Sep 17 00:00:00 2001 From: Brandon Heller Date: Sun, 3 Jan 2010 02:44:08 -0800 Subject: [PATCH] Support more topologies --- bin/mn_run.py | 10 ++++--- mininet/test/test_nets.py | 55 +++++++++++++++++++++++---------------- mininet/topo.py | 4 +-- 3 files changed, 42 insertions(+), 27 deletions(-) diff --git a/bin/mn_run.py b/bin/mn_run.py index 0cf43c5..e0fb160 100755 --- a/bin/mn_run.py +++ b/bin/mn_run.py @@ -7,7 +7,7 @@ from optparse import OptionParser import time -from ripcord.topo import FatTreeTopo +from ripcord.topo import FatTreeTopo, SingleSwitchTopo, LinearTopo from mininet.logging_mod import lg, set_loglevel, LEVELS from mininet.net import Mininet, init @@ -16,12 +16,16 @@ from mininet.topo import TreeTopo # built in topologies, created only when run TOPO_DEF = 'minimal' -TOPOS = {'minimal' : (lambda: TreeTopo(depth = 2, fanout = 2)), +TOPOS = {'minimal' : (lambda: SingleSwitchTopo(k = 2)), 'tree16' : (lambda: TreeTopo(depth = 3, fanout = 4)), 'tree64' : (lambda: TreeTopo(depth = 4, fanout = 4)), 'tree1024' : (lambda: TreeTopo(depth = 3, fanout = 32)), 'fattree4' : (lambda: FatTreeTopo(k = 4)), - 'fattree6' : (lambda: FatTreeTopo(k = 6))} + 'fattree6' : (lambda: FatTreeTopo(k = 6)), + 'single4' : (lambda: SingleSwitchTopo(k = 4)), + 'single100' : (lambda: SingleSwitchTopo(k = 100)), + 'linear2' : (lambda: LinearTopo(k = 2)), + 'linear100' : (lambda: LinearTopo(k = 100))} SWITCH_DEF = 'kernel' SWITCHES = {'kernel' : KernelSwitch} diff --git a/mininet/test/test_nets.py b/mininet/test/test_nets.py index 2c65fd1..02b61d6 100755 --- a/mininet/test/test_nets.py +++ b/mininet/test/test_nets.py @@ -7,7 +7,9 @@ Test creation and all-pairs ping for each included mininet topo type. from time import sleep import unittest -from mininet.net import init, Mininet #, DATAPATHS +from ripcord.topo import SingleSwitchTopo, LinearTopo + +from mininet.net import init, Mininet from mininet.node import KernelSwitch, Host, ControllerParams from mininet.node import Controller from mininet.topo import TreeTopo @@ -15,18 +17,39 @@ from mininet.topo import TreeTopo # temporary, until user-space side is tested SWITCHES = {'kernel' : KernelSwitch} -class testMinimal(unittest.TestCase): - '''For each datapath type, test ping with a minimal topology. - - Each topology has two hosts and one switch. - ''' +class testSingleSwitch(unittest.TestCase): + '''For each datapath type, test ping with single switch topologies.''' def testMinimal(self): '''Ping test with both datapaths on minimal topology''' init() for switch in SWITCHES.values(): controller_params = ControllerParams(0x0a000000, 8) # 10.0.0.0/8 - mn = Mininet(TreeTopo(), switch, Host, Controller, + mn = Mininet(SingleSwitchTopo(), switch, Host, Controller, + controller_params) + dropped = mn.run('ping') + self.assertEqual(dropped, 0) + + def testSingle5(self): + '''Ping test with both datapaths on 5-host single-switch topology''' + init() + for switch in SWITCHES.values(): + controller_params = ControllerParams(0x0a000000, 8) # 10.0.0.0/8 + mn = Mininet(SingleSwitchTopo(k = 5), switch, Host, Controller, + controller_params) + dropped = mn.run('ping') + self.assertEqual(dropped, 0) + + +class testLinear(unittest.TestCase): + '''For each datapath type, test all-pairs ping with LinearNet.''' + + def testLinear5(self): + '''Ping test with both datapaths on a 5-switch topology''' + init() + for switch in SWITCHES.values(): + controller_params = ControllerParams(0x0a000000, 8) # 10.0.0.0/8 + mn = Mininet(LinearTopo(k = 5), switch, Host, Controller, controller_params) dropped = mn.run('ping') self.assertEqual(dropped, 0) @@ -35,29 +58,17 @@ class testMinimal(unittest.TestCase): class testTree(unittest.TestCase): '''For each datapath type, test all-pairs ping with TreeNet.''' - def testTree16(self): - '''Ping test with both datapaths on 16-host topology''' + def testTree9(self): + '''Ping test with both datapaths on 9-host topology''' init() for switch in SWITCHES.values(): controller_params = ControllerParams(0x0a000000, 8) # 10.0.0.0/8 - tree_topo = TreeTopo(depth = 3, fanout = 4) + tree_topo = TreeTopo(depth = 3, fanout = 3) mn = Mininet(tree_topo, switch, Host, Controller, controller_params) dropped = mn.run('ping') self.assertEqual(dropped, 0) -#class testLinear(unittest.TestCase): -# '''For each datapath type, test all-pairs ping with LinearNet.''' -# -# def testLinear10(self): -# '''Ping test with both datapaths on 10-switch topology''' -# init() -# for datapath in DATAPATHS: -# k = datapath == 'kernel' -# network = network = LinearNet(10, kernel=k) -# dropped = network.run(pingTest) -# self.assertEqual(dropped, 0) - if __name__ == '__main__': unittest.main() \ No newline at end of file diff --git a/mininet/topo.py b/mininet/topo.py index 9417c6a..702212d 100644 --- a/mininet/topo.py +++ b/mininet/topo.py @@ -87,9 +87,9 @@ class TreeTopo(StructuredTopo): self.enable_all() def port(self, src, dst): - '''Get port number (optional) + '''Get port number - Note that the topological significance of DPIDs in FatTreeTopo enables + Note that the topological significance of DPIDs enables this function to be implemented statelessly. @param src source switch DPID