Skip to content

Instantly share code, notes, and snippets.

@lantz
Created September 12, 2013 20:38
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 lantz/6543406 to your computer and use it in GitHub Desktop.
Save lantz/6543406 to your computer and use it in GitHub Desktop.
Simple example of adding a host to a Mininet network after calling `net.start()`; should work in Mininet 2.1.0.
#!/usr/bin/python
from mininet.net import Mininet
from mininet.topo import SingleSwitchTopo
net = Mininet( topo=SingleSwitchTopo( 2 ) )
net.start()
net.pingAll()
print "*** Attaching new host h3 to s1"
h3 = net.addHost( 'h3' )
s1 = net[ 's1' ]
link = net.addLink( h3, s1 )
s1.attach( link.intf2 )
h3.configDefault()
net.pingAll()
net.stop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment