Fixing nasty ugly bug in DCE ccndc RM. Fix: Adding missing HOME environment set to...
authorAlina Quereilhac <alina.quereilhac@inria.fr>
Wed, 3 Sep 2014 09:35:58 +0000 (11:35 +0200)
committerAlina Quereilhac <alina.quereilhac@inria.fr>
Wed, 3 Sep 2014 09:35:58 +0000 (11:35 +0200)
examples/ccn_emu_live/dce.py
examples/linux/ns3/wifi_ping.py
src/nepi/resources/linux/ns3/ccn/ns3ccnddceapplication.py
src/nepi/resources/linux/ns3/ccn/ns3fibentrydceapplication.py
src/nepi/resources/linux/ns3/ns3simulation.py
src/nepi/resources/ns3/ns3base.py
test/resources/linux/ns3/ccn/ns3dceccn.py

index 06c3405..693293a 100644 (file)
@@ -45,6 +45,8 @@ def get_simulator(ec):
         ec.set(node, "hostname", "localhost")
 
         simu = ec.register_resource("LinuxNS3Simulation")
+        ec.set(simu, "enableDump", True)
+        ec.set(simu, "StopTime", STOP_TIME)
         ec.register_connection(simu, node)
         return simu
 
@@ -79,7 +81,6 @@ def add_dce_ccnd(ec, nid):
     ec.set (ccnd, "debug", 7)
     ec.set (ccnd, "capacity", 50000)
     ec.set (ccnd, "StartTime", "1s")
-    ec.set (ccnd, "StopTime", STOP_TIME)
     ec.register_connection(ccnd, host)
 
     # Collector to retrieve ccnd log
@@ -98,7 +99,6 @@ def add_dce_ccnr(ec, nid):
     ec.set (ccnr, "repoFile1", repofile) 
     ec.set (ccnr, "stackSize", 1<<20)
     ec.set (ccnr, "StartTime", "2s")
-    ec.set (ccnr, "StopTime", STOP_TIME)
     ec.register_connection(ccnr, host)
 
 def add_dce_ccncat(ec, nid):
@@ -110,7 +110,6 @@ def add_dce_ccncat(ec, nid):
     ec.set (ccncat, "contentName", content_name)
     ec.set (ccncat, "stackSize", 1<<20)
     ec.set (ccncat, "StartTime", "8s")
-    ec.set (ccncat, "StopTime", STOP_TIME)
     ec.register_connection(ccncat, host)
 
 def add_dce_fib_entry(ec, nid1, nid2):
@@ -125,8 +124,7 @@ def add_dce_fib_entry(ec, nid1, nid2):
     ec.set (ccndc, "uri", "ccnx:/") 
     ec.set (ccndc, "host", ip2)
     ec.set (ccndc, "stackSize", 1<<20)
-    ec.set (ccndc, "StartTime", "2s")
-    ec.set (ccndc, "StopTime", STOP_TIME)
+    ec.set (ccndc, "StartTime", "4s")
     ec.register_connection(ccndc, host1)
 
 def add_dce_net_iface(ec, nid1, nid2):
@@ -172,7 +170,7 @@ def avg_interests(ec, run):
 
     # TODO: DUMP RESULTS TO FILE
     # TODO: DUMP GRAPH DELAYS!
-    f = open("/tmp/metric", "w+")
+    f = open("/tmp/metric", "a+")
     f.write("%.2f\n" % metric)
     f.close()
     print " METRIC", metric
@@ -211,7 +209,7 @@ if __name__ == '__main__':
     #### Create NEPI Experiment Description with LINEAR topology 
     ec = ExperimentController("dce_ccn", 
             topo_type = TopologyType.LINEAR, 
-            node_count = 4,
+            node_count = 2,
             assign_st = True,
             assign_ips = True,
             add_node_callback = add_dce_node, 
index 47bc335..f0be548 100644 (file)
@@ -126,7 +126,7 @@ ec.set(node, "hostname", "localhost")
 simu = ec.register_resource("LinuxNS3Simulation")
 ec.set(simu, "verbose", True)
 ec.set(simu, "enableDump", True)
-ec.set (simu, "stopTime", "22s")
+ec.set (simu, "StopTime", "22s")
 ec.register_connection(simu, node)
 
 x = 30
index 8bf4ab1..226acf0 100644 (file)
@@ -145,15 +145,15 @@ class LinuxNS3DceCCND(LinuxNS3CCNDceApplication):
                 " ecryptfs-utils-devel libxml2-devel automake gawk " 
                 " gcc gcc-c++ git pcre-devel make ")
         elif self.simulation.node.use_deb:
-            return ( " autoconf libssl-dev libexpat-dev libpcap-dev "
+            return ( " autoconf libssl-dev libexpat1-dev libpcap-dev "
                 " libecryptfs0 libxml2-utils automake gawk gcc g++ "
                 " git-core pkg-config libpcre3-dev make ")
         return ""
 
-
     @property
     def _sources(self):
-        return "http://www.ccnx.org/releases/ccnx-0.8.1.tar.gz"
+        #return "http://www.ccnx.org/releases/ccnx-0.8.1.tar.gz"
+        return "http://www.ccnx.org/releases/ccnx-0.8.2.tar.gz"
 
     @property
     def _build(self):
index 63e5d19..6137825 100644 (file)
@@ -53,11 +53,16 @@ class LinuxNS3DceFIBEntry(LinuxNS3CCNDceApplication):
                 "Peer host public IP used in network connection for this FIB entry. ",
                 flags = Flags.Design)
 
+        home = Attribute("home", "Sets HOME environmental variable. ",
+                default = "/root",
+            flags = Flags.Design)
         cls._register_attribute(uri)
         cls._register_attribute(protocol)
         cls._register_attribute(host)
         cls._register_attribute(port)
         cls._register_attribute(ip)
+        cls._register_attribute(home)
 
     def _instantiate_object(self):
         if not self.get("binary"):
@@ -66,8 +71,22 @@ class LinuxNS3DceFIBEntry(LinuxNS3CCNDceApplication):
         if not self.get("arguments"):
             self.set("arguments", self._arguments)
 
+        if not self.get("environment"):
+            self.set("environment", self._environment)
+        
         super(LinuxNS3DceFIBEntry, self)._instantiate_object()
 
+    @property
+    def _environment(self):
+        envs = dict({
+            "home": "HOME",
+            })
+
+        env = ";".join(map(lambda k: "%s=%s" % (envs.get(k), str(self.get(k))), 
+            [k for k in envs.keys() if self.get(k)]))
+
+        return env
+
     @property
     def _arguments(self):
         args = ["-v", "add"]
index dae024f..63d8d37 100644 (file)
@@ -114,7 +114,7 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation):
             type = Types.Bool,
             flags = Flags.Design)
 
-        stoptime = Attribute("stopTime",
+        stoptime = Attribute("StopTime",
             "Time at which the simulation will stop",
             flags = Flags.Design)
 
@@ -306,6 +306,10 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation):
             if self.get("populateRoutingTables") == True:
                 self.invoke(IPV4_GLOBAL_ROUTING_HELPER_UUID, "PopulateRoutingTables")
 
+            time = self.get("StopTime")
+            if time:
+                self._client.stop(time=time) 
+
             self._client.start()
 
             self.set_started()
@@ -319,11 +323,8 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation):
 
         """
         if self.state == ResourceState.STARTED:
-            time = None
-            if self.get("stopTime"):
-                time = self.get("stopTime")
-
-            self._client.stop(time=time) 
+            if not self.get("StopTime"):
+                self._client.stop() 
             self.set_stopped()
 
     def do_release(self):
index 455e546..ef345ff 100644 (file)
@@ -51,7 +51,7 @@ class NS3Base(ResourceManager):
         if not self._node:
             from nepi.resources.ns3.ns3node import NS3BaseNode
             nodes = self.get_connected(NS3BaseNode.get_rtype())
-            if nodes: self._nodes[0]
+            if nodes: self._node = nodes[0]
 
         return self._node
 
index f215fa3..78d517e 100755 (executable)
@@ -81,9 +81,9 @@ class LinuxNS3CCNDceApplicationTest(unittest.TestCase):
         #ec.set(node, "cleanHome", True)
 
         simu = ec.register_resource("LinuxNS3Simulation")
-        ec.set(simu, "verbose", True)
-        ec.set(simu, "buildMode", "debug")
-        ec.set(simu, "nsLog", "DceApplication")
+        #ec.set(simu, "verbose", True)
+        #ec.set(simu, "buildMode", "debug")
+        #ec.set(simu, "nsLog", "DceApplication")
         ec.register_connection(simu, node)
 
         nsnode1 = add_ns3_node(ec, simu)