Enabled TCLinks (e.g. delay property) between data centers.
authorpeusterm <manuel.peuster@uni-paderborn.de>
Tue, 8 Mar 2016 09:25:58 +0000 (10:25 +0100)
committerpeusterm <manuel.peuster@uni-paderborn.de>
Tue, 8 Mar 2016 09:25:58 +0000 (10:25 +0100)
src/emuvim/dcemulator/net.py
src/emuvim/dcemulator/node.py
src/emuvim/examples/sonata_y1_demo_topology_1.py

index e01e950..00bb65c 100755 (executable)
@@ -12,7 +12,7 @@ from mininet.net import Dockernet
 from mininet.node import Controller, OVSSwitch, OVSKernelSwitch, Switch, Docker, Host, RemoteController
 from mininet.cli import CLI
 from mininet.log import setLogLevel, info, debug
-from mininet.link import TCLink, Link
+from mininet.link import TCLink
 import networkx as nx
 from emuvim.dcemulator.monitoring import DCNetworkMonitor
 
@@ -82,17 +82,22 @@ class DCNetwork(Dockernet):
             node2 = node2.switch
         # try to give containers a default IP
         if isinstance( node1, Docker ):
-            if not "params1" in params:
+            if "params1" not in params:
                 params["params1"] = {}
-            if not "ip" in params["params1"]:
+            if "ip" not in params["params1"]:
                 params["params1"]["ip"] = self.getNextIp()
         if isinstance( node2, Docker ):
-            if not "params2" in params:
+            if "params2" not in params:
                 params["params2"] = {}
-            if not "ip" in params["params2"]:
+            if "ip" not in params["params2"]:
                 params["params2"]["ip"] = self.getNextIp()
+        # ensure that we allow TCLinks between data centers
+        # TODO this is not optimal, we use cls=Link for containers and TCLink for data centers
+        # see Dockernet issue: https://github.com/mpeuster/dockernet/issues/3
+        if "cls" not in params:
+            params["cls"] = TCLink
 
-        link = Dockernet.addLink(self, node1, node2, **params)  # TODO we need TCLinks with user defined performance here
+        link = Dockernet.addLink(self, node1, node2, **params)
 
         # add edge and assigned port number to graph in both directions between node1 and node2
         self.DCNetwork_graph.add_edge(node1.name, node2.name, \
index 336126c..74540ab 100755 (executable)
@@ -3,6 +3,7 @@ Distributed Cloud Emulator (dcemulator)
 (c) 2015 by Manuel Peuster <manuel.peuster@upb.de>
 """
 from mininet.node import Docker
+from mininet.link import Link
 import logging
 
 
@@ -128,7 +129,8 @@ class Datacenter(object):
         d = self.net.addDocker("%s" % (name), dimage=image, dcmd=command)
         # connect all given networks
         for nw in network:
-            self.net.addLink(d, self.switch, params1=nw)
+            # TODO we cannot use TCLink here (see: https://github.com/mpeuster/dockernet/issues/3)
+            self.net.addLink(d, self.switch, params1=nw, cls=Link)
         # do bookkeeping
         self.containers[name] = d
         d.datacenter = self
index 5145543..03a3fd0 100644 (file)
@@ -18,8 +18,8 @@ def create_topology1():
     dc1 = net.addDatacenter("dc1")
     dc2 = net.addDatacenter("dc2")
     s1 = net.addSwitch("s1")
-    net.addLink(dc1, s1)
-    net.addLink(dc2, s1)
+    net.addLink(dc1, s1, delay="10ms")
+    net.addLink(dc2, s1, delay="20ms")
 
     # create a new instance of a endpoint implementation
     zapi1 = ZeroRpcApiEndpoint("0.0.0.0", 4242)