From ea8db83259fd1f87774ffb3b80c8ab455481da28 Mon Sep 17 00:00:00 2001 From: peusterm Date: Tue, 8 Mar 2016 10:25:58 +0100 Subject: [PATCH] Enabled TCLinks (e.g. delay property) between data centers. --- src/emuvim/dcemulator/net.py | 17 +++++++++++------ src/emuvim/dcemulator/node.py | 4 +++- .../examples/sonata_y1_demo_topology_1.py | 4 ++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/emuvim/dcemulator/net.py b/src/emuvim/dcemulator/net.py index e01e950..00bb65c 100755 --- a/src/emuvim/dcemulator/net.py +++ b/src/emuvim/dcemulator/net.py @@ -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, \ diff --git a/src/emuvim/dcemulator/node.py b/src/emuvim/dcemulator/node.py index 336126c..74540ab 100755 --- a/src/emuvim/dcemulator/node.py +++ b/src/emuvim/dcemulator/node.py @@ -3,6 +3,7 @@ Distributed Cloud Emulator (dcemulator) (c) 2015 by Manuel Peuster """ 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 diff --git a/src/emuvim/examples/sonata_y1_demo_topology_1.py b/src/emuvim/examples/sonata_y1_demo_topology_1.py index 5145543..03a3fd0 100644 --- a/src/emuvim/examples/sonata_y1_demo_topology_1.py +++ b/src/emuvim/examples/sonata_y1_demo_topology_1.py @@ -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) -- 2.25.1