Two sample mininet scripts for two simulated OF networks.
[affinity.git] / scripts / mn2.py
diff --git a/scripts/mn2.py b/scripts/mn2.py
new file mode 100755 (executable)
index 0000000..2243302
--- /dev/null
@@ -0,0 +1,43 @@
+#!/usr/bin/python
+
+from mininet.cli import CLI
+from mininet.topo import Topo
+from mininet.net import Mininet
+from mininet.link import TCLink, Intf
+from mininet.log import setLogLevel
+from mininet.node import CPULimitedHost, Controller, RemoteController
+
+# To use this topology, run:
+#   > sudo ./mn2.py
+# Using spaces rather than '=' is very important, as is having the --link flag
+
+ctrl='172.15.1.151'
+c1 = RemoteController( 'c1', ip=ctrl )
+
+
+class TestTopo(Topo):
+
+    def __init__(self, **opts):
+        Topo.__init__(self, **opts)
+
+        # Three switches
+        s8 = self.addSwitch('s8')
+        # Four hosts
+        h8 = self.addHost('h8')
+        # Connect hosts to switches
+        self.addLink(h8, s8, bw=10) # These two links get limited
+topos = { 'net1' : (lambda: TestTopo()) }
+
+def demo():
+    "Create network"
+    topo = TestTopo()
+    net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink, controller=lambda name:RemoteController(name, ip=ctrl, port=6633))
+    net.start()
+    host8 = net.getNodeByName('h8')
+    host8.setIP('10.0.0.8')
+    
+    CLI( net )
+    
+if __name__ == '__main__':
+    setLogLevel('info')
+    demo()