ecklm / adaptive-network-slicing

Project holding the implementation and results of my thesis project at University of Trento, Italy
20 stars 5 forks source link

Mininet: Implement mininet scipts to perform more automatic functionality testing #6

Closed ecklm closed 4 years ago

ecklm commented 4 years ago

This lies in my stash as WIP not working for some reason. May be good for starting point

diff --git a/slicing/mininet/mn-slicing.py b/slicing/mininet/mn-slicing.py
old mode 100644
new mode 100755
index 5b20cbc..6d8f645
--- a/slicing/mininet/mn-slicing.py
+++ b/slicing/mininet/mn-slicing.py
@@ -1,4 +1,10 @@
+#!/usr/bin/env python2
+
+from mininet.node import RemoteController
 from mininet.topo import Topo
+from mininet.net import Mininet
+from mininet.log import setLogLevel
+from mininet.cli import CLI

 class SlicingTopo(Topo):
@@ -23,3 +29,26 @@ class SlicingTopo(Topo):

 topos = {'slicingtopo': (lambda: SlicingTopo())}
+
+
+def run_process(node, cmd):
+    # type: (object, str) -> int
+    node.cmd(cmd)
+    return int(node.cmd('echo $!'))
+
+
+if __name__ == '__main__':
+    # Tell mininet to print useful information
+    setLogLevel('info')
+    "Create and test a simple network"
+    topo = SlicingTopo()
+    net = Mininet(topo, controller=RemoteController('c0', ip='192.0.2.1', port=6653))
+    net.start()
+    h1 = net.get('h1')
+    h2 = net.get('h2')
+    server_pids = []
+    h1.cmd("ping 10.0.0.1")
+    # for x in [5001, 5002, 5003]:
+    #     server_pids.append(run_process(h1, "iperf -s -u -i 1 -p %d" % x))
+#    CLI(net)
+    net.stop()
ecklm commented 4 years ago

This is not going to be important enough so that I implement it.