Last active
April 14, 2016 12:40
-
-
Save soyo42/13408658b546184839cc to your computer and use it in GitHub Desktop.
mininet custom topologies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this is project name keeper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Custom testing topologies - lightweight | |
Main goal is to build switches fast with minimum links and hosts. | |
""" | |
from mininet.topo import Topo | |
class LightweightTopo( Topo ): | |
"Simple topology - fast, every 20th switch has a host and previous switch connected." | |
def build(self, topoSize=42, offset = 0): | |
lastSwitch = None | |
for idx in range(topoSize): | |
i = idx + offset | |
switchX = self.addSwitch( 's{0}'.format(i), dpid='{0:x}'.format(i + 0x668A0) ) | |
if lastSwitch: | |
if i % 20 == 0: | |
self.addLink( lastSwitch, switchX ) | |
hostX = self.addHost( 'h{0}'.format(i) ) | |
self.addLink( hostX, switchX ) | |
lastSwitch = switchX | |
topos = { 'fastTopo': LightweightTopo } | |
print('topos prepared: {}'.format(topos)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment