Skip to content

Instantly share code, notes, and snippets.

@rustyeddy
Last active March 14, 2016 22:30
Show Gist options
  • Save rustyeddy/6055e0fe619ec5e6fbd2 to your computer and use it in GitHub Desktop.
Save rustyeddy/6055e0fe619ec5e6fbd2 to your computer and use it in GitHub Desktop.
Mininet simple 3 switch
#!/usr/bin/python
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import Controller, RemoteController
from mininet.cli import CLI
from mininet.log import setLogLevel
class SimpleTopo(Topo):
dpid = 1
def build( self ):
# create 3 switches
sw1 = self.addSwitch("s1", dpid++)
sw2 = self.addSwitch("s2", dpid++)
sw3 = self.addSwitch("s3", dpid++)
# Link all switches to each other
self.addLink(sw1, sw2)
self.addLink(sw1, sw3)
self.addLink(sw2, sw3)
# create hosts and attach to each other
h1 = self.addHost('h1', ip='10.1.1.1/24')
h2 = self.addHost('h2', ip='10.1.1.2/24')
# Link hosts
self.addLink(h1, sw1)
self.addLink(h2, sw2)
if __name__ == '__main__':
topo = SimpleTopo()
net = Mininet( topo=topo )
net.start()
success = net.pingAll()
net.stop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment