Support more topologies
This commit is contained in:
+7
-3
@@ -7,7 +7,7 @@
|
|||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import time
|
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.logging_mod import lg, set_loglevel, LEVELS
|
||||||
from mininet.net import Mininet, init
|
from mininet.net import Mininet, init
|
||||||
@@ -16,12 +16,16 @@ from mininet.topo import TreeTopo
|
|||||||
|
|
||||||
# built in topologies, created only when run
|
# built in topologies, created only when run
|
||||||
TOPO_DEF = 'minimal'
|
TOPO_DEF = 'minimal'
|
||||||
TOPOS = {'minimal' : (lambda: TreeTopo(depth = 2, fanout = 2)),
|
TOPOS = {'minimal' : (lambda: SingleSwitchTopo(k = 2)),
|
||||||
'tree16' : (lambda: TreeTopo(depth = 3, fanout = 4)),
|
'tree16' : (lambda: TreeTopo(depth = 3, fanout = 4)),
|
||||||
'tree64' : (lambda: TreeTopo(depth = 4, fanout = 4)),
|
'tree64' : (lambda: TreeTopo(depth = 4, fanout = 4)),
|
||||||
'tree1024' : (lambda: TreeTopo(depth = 3, fanout = 32)),
|
'tree1024' : (lambda: TreeTopo(depth = 3, fanout = 32)),
|
||||||
'fattree4' : (lambda: FatTreeTopo(k = 4)),
|
'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'
|
SWITCH_DEF = 'kernel'
|
||||||
SWITCHES = {'kernel' : KernelSwitch}
|
SWITCHES = {'kernel' : KernelSwitch}
|
||||||
|
|||||||
+33
-22
@@ -7,7 +7,9 @@ Test creation and all-pairs ping for each included mininet topo type.
|
|||||||
from time import sleep
|
from time import sleep
|
||||||
import unittest
|
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 KernelSwitch, Host, ControllerParams
|
||||||
from mininet.node import Controller
|
from mininet.node import Controller
|
||||||
from mininet.topo import TreeTopo
|
from mininet.topo import TreeTopo
|
||||||
@@ -15,18 +17,39 @@ from mininet.topo import TreeTopo
|
|||||||
# temporary, until user-space side is tested
|
# temporary, until user-space side is tested
|
||||||
SWITCHES = {'kernel' : KernelSwitch}
|
SWITCHES = {'kernel' : KernelSwitch}
|
||||||
|
|
||||||
class testMinimal(unittest.TestCase):
|
class testSingleSwitch(unittest.TestCase):
|
||||||
'''For each datapath type, test ping with a minimal topology.
|
'''For each datapath type, test ping with single switch topologies.'''
|
||||||
|
|
||||||
Each topology has two hosts and one switch.
|
|
||||||
'''
|
|
||||||
|
|
||||||
def testMinimal(self):
|
def testMinimal(self):
|
||||||
'''Ping test with both datapaths on minimal topology'''
|
'''Ping test with both datapaths on minimal topology'''
|
||||||
init()
|
init()
|
||||||
for switch in SWITCHES.values():
|
for switch in SWITCHES.values():
|
||||||
controller_params = ControllerParams(0x0a000000, 8) # 10.0.0.0/8
|
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)
|
controller_params)
|
||||||
dropped = mn.run('ping')
|
dropped = mn.run('ping')
|
||||||
self.assertEqual(dropped, 0)
|
self.assertEqual(dropped, 0)
|
||||||
@@ -35,29 +58,17 @@ class testMinimal(unittest.TestCase):
|
|||||||
class testTree(unittest.TestCase):
|
class testTree(unittest.TestCase):
|
||||||
'''For each datapath type, test all-pairs ping with TreeNet.'''
|
'''For each datapath type, test all-pairs ping with TreeNet.'''
|
||||||
|
|
||||||
def testTree16(self):
|
def testTree9(self):
|
||||||
'''Ping test with both datapaths on 16-host topology'''
|
'''Ping test with both datapaths on 9-host topology'''
|
||||||
init()
|
init()
|
||||||
for switch in SWITCHES.values():
|
for switch in SWITCHES.values():
|
||||||
controller_params = ControllerParams(0x0a000000, 8) # 10.0.0.0/8
|
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,
|
mn = Mininet(tree_topo, switch, Host, Controller,
|
||||||
controller_params)
|
controller_params)
|
||||||
dropped = mn.run('ping')
|
dropped = mn.run('ping')
|
||||||
self.assertEqual(dropped, 0)
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
+2
-2
@@ -87,9 +87,9 @@ class TreeTopo(StructuredTopo):
|
|||||||
self.enable_all()
|
self.enable_all()
|
||||||
|
|
||||||
def port(self, src, dst):
|
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.
|
this function to be implemented statelessly.
|
||||||
|
|
||||||
@param src source switch DPID
|
@param src source switch DPID
|
||||||
|
|||||||
Reference in New Issue
Block a user