Skip to content

Instantly share code, notes, and snippets.

@eloydegen
Created April 2, 2018 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eloydegen/94dca0cdd7d712098b81993d680ec8a6 to your computer and use it in GitHub Desktop.
Save eloydegen/94dca0cdd7d712098b81993d680ec8a6 to your computer and use it in GitHub Desktop.
Mininet topology
#!/usr/bin/python
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import Controller
class MyTopo( Topo):
"Simple topology example."
def __init__( self ):
"Create custom topo." # initialize topology
Topo.__init__( self )
# Hosts
leftHost = self.addHost(‘H1’)
rightHost = self.addhost(‘H2’)
# Switches
S1 = self.addSwitch(‘S1’)
S2 = self.addSwitch(‘S2’)
S3 = self.addSwitch(‘S3’)
S4 = self.addSwitch(‘S4’)
S5 = self.addSwitch(‘S5’)
# Links
self.addLink(leftHost, S1)
self.addLink(S1, S3)
self.addlink(S1, S2)
self.addLink(S2, S4)
self.addLink(S4, S5)
self.addLink(S3, S5)
self.addLink(S5, rightHost)
topos = {'mytopo':(lambda:MyTopo())}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment