Skip to content

Instantly share code, notes, and snippets.

Created May 9, 2016 22:08
Show Gist options
  • Save anonymous/bad4b7d7dcb277958edf0a7a2ae67836 to your computer and use it in GitHub Desktop.
Save anonymous/bad4b7d7dcb277958edf0a7a2ae67836 to your computer and use it in GitHub Desktop.
root@mininet-vm:/home/mininet/mininet/examples# more vxlan.py
#!/usr/bin/python
"""
This example shows how to create an empty Mininet object
(without a topology object) and add nodes to it manually.
"""
from mininet.net import Mininet
from mininet.node import Controller
from mininet.cli import CLI
from mininet.log import setLogLevel, info
def emptyNet():
"Create an empty network and add nodes to it."
net = Mininet( controller=None )
info( '*** Adding controller\n' )
info( '*** Adding hosts\n' )
h1 = net.addHost( 'h1', ip='10.0.0.1' )
h2 = net.addHost( 'h2', ip='10.0.0.2' )
info( '*** Adding switch\n' )
s1 = net.addSwitch( 's1' )
info( '*** Creating links\n' )
net.addLink( h1, s1 )
net.addLink( h2, s1 )
info( '*** Starting network\n')
net.start()
info( '*** Running CLI\n' )
CLI( net )
info( '*** Stopping network' )
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
emptyNet()
root@mininet-vm:/home/mininet/mininet/examples# more vxlan.py
#!/usr/bin/python
"""
This example shows how to create an empty Mininet object
(without a topology object) and add nodes to it manually.
"""
from mininet.net import Mininet
from mininet.node import Controller
from mininet.cli import CLI
from mininet.log import setLogLevel, info
def emptyNet():
"Create an empty network and add nodes to it."
net = Mininet( controller=None )
info( '*** Adding controller\n' )
info( '*** Adding hosts\n' )
h3 = net.addHost( 'h3', ip='10.0.0.3' )
h4 = net.addHost( 'h4', ip='10.0.0.4' )
info( '*** Adding switch\n' )
s3 = net.addSwitch( 's2' )
info( '*** Creating links\n' )
net.addLink( h3, s3 )
net.addLink( h4, s3 )
info( '*** Starting network\n')
net.start()
info( '*** Running CLI\n' )
CLI( net )
info( '*** Stopping network' )
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
emptyNet()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment