Skip to content

Instantly share code, notes, and snippets.

@wh5a
Created July 8, 2013 20:34
Show Gist options
  • Save wh5a/5952253 to your computer and use it in GitHub Desktop.
Save wh5a/5952253 to your computer and use it in GitHub Desktop.
Coursera SDN Module 3
'''
Coursera:
- Software Defined Networking (SDN) course
-- Module 3 Programming Assignment
Professor: Nick Feamster
Teaching Assistant: Muhammad Shahbaz
'''
from mininet.topo import Topo
class CustomTopo(Topo):
"Simple Data Center Topology"
"linkopts - (1:core, 2:aggregation, 3: edge) parameters"
"fanout - number of child switch per parent switch"
def __init__(self, linkopts1, linkopts2, linkopts3, fanout=2, **opts):
# Initialize topology and default options
Topo.__init__(self, **opts)
# Numbering: h1..N, s1..M
self.hostNum = 1
self.switchNum = 1
self.addTree([linkopts1, linkopts2, linkopts3], fanout);
# Derived from class TreeTopo
def addTree(self, linkopts, fanout, depth=0):
isSwitch = depth < 3
if isSwitch:
node = self.addSwitch('s%s' % self.switchNum)
self.switchNum += 1
for _ in range(fanout):
child = self.addTree(linkopts, fanout, depth + 1)
self.addLink(node, child, **linkopts[depth])
else:
# host
node = self.addHost('h%s' % self.hostNum)
self.hostNum += 1
return node
topos = { 'custom': ( lambda: CustomTopo() ) }
from mininet.log import setLogLevel
setLogLevel('info')
@santosh-kamath
Copy link

Hi can anybody help me to figure out this problem ....

net = Mininet(topo = topo, link=TCLink)
File "build/bdist.linux-x86_64/egg/mininet/net.py", line 172, in init
File "build/bdist.linux-x86_64/egg/mininet/net.py", line 444, in build
File "build/bdist.linux-x86_64/egg/mininet/net.py", line 431, in buildFromTopo
File "build/bdist.linux-x86_64/egg/mininet/net.py", line 366, in addLink
File "build/bdist.linux-x86_64/egg/mininet/link.py", line 534, in init
File "build/bdist.linux-x86_64/egg/mininet/link.py", line 424, in init
File "build/bdist.linux-x86_64/egg/mininet/link.py", line 468, in makeIntfPair
File "build/bdist.linux-x86_64/egg/mininet/util.py", line 194, in makeIntfPair
Exception: Error creating interface pair (a1-eth1,c1-eth1): RTNETLINK answers: File exists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment