Skip to content

Instantly share code, notes, and snippets.

@soyo42
Last active April 14, 2016 12:40
Show Gist options
  • Save soyo42/13408658b546184839cc to your computer and use it in GitHub Desktop.
Save soyo42/13408658b546184839cc to your computer and use it in GitHub Desktop.
mininet custom topologies
this is project name keeper
"""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