Last active
December 27, 2016 10:09
-
-
Save kostyll/cff65bb20f49774bbee2e01c9592c545 to your computer and use it in GitHub Desktop.
MininetCustomNetwork_POX_RemoteController
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
""" | |
Works with RemoteController: | |
first install and run pox controller: | |
502 git clone http://github.com/noxrepo/pox | |
503 cd pox/ | |
505 git checkout dart | |
511 ./pox.py log.level --DEBUG misc.of_tutorial | |
then run this script | |
""" | |
""" | |
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, \ | |
RemoteController, \ | |
DefaultController, \ | |
DefaultControllers, \ | |
OVSKernelSwitch, \ | |
OVSBridge, \ | |
OVSSwitch | |
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 = RemoteController) | |
info( '*** Adding controller\n' ) | |
c0 = net.addController( 'c0' ) | |
info( '*** Adding hosts\n' ) | |
h1 = net.addHost( 'h1', ip='10.0.0.1' ) | |
h2 = net.addHost( 'h2', ip='10.0.0.2' ) | |
h3 = net.addHost( 'h3', ip='10.0.0.3' ) | |
h4 = net.addHost( 'h4', ip='10.0.0.4' ) | |
hScanner = net.addHost( 'hScanner', ip='10.0.0.12' ) | |
info( '*** Adding switch\n' ) | |
s3 = net.addSwitch( 's3' ) | |
info( '*** Creating links\n' ) | |
net.addLink( h1, s3 ) | |
net.addLink( h2, s3 ) | |
net.addLink( h3, s3 ) | |
net.addLink( h4, s3 ) | |
net.addLink( hScanner, s3 ) | |
info( '*** Starting network\n') | |
net.start() | |
print h1.popen("xterm") | |
print h2.popen("xterm") | |
print h1.popen("bash", "-c", "touch /tmp/bbbb") | |
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