Added configurable DCE dlm loader (not yet working)
authorAlina Quereilhac <alina.quereilhac@inria.fr>
Thu, 2 Oct 2014 09:40:39 +0000 (11:40 +0200)
committerAlina Quereilhac <alina.quereilhac@inria.fr>
Thu, 2 Oct 2014 09:40:39 +0000 (11:40 +0200)
examples/dce/custom_dlm_ping.py [new file with mode: 0644]
src/nepi/resources/linux/ns3/ns3simulation.py
src/nepi/resources/ns3/ns3dceapplication.py

diff --git a/examples/dce/custom_dlm_ping.py b/examples/dce/custom_dlm_ping.py
new file mode 100644 (file)
index 0000000..8f04f75
--- /dev/null
@@ -0,0 +1,106 @@
+#!/usr/bin/env python
+#
+#    NEPI, a framework to manage network experiments
+#    Copyright (C) 2013 INRIA
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+
+from nepi.execution.ec import ExperimentController 
+
+def add_ns3_node(ec, simu):
+    node = ec.register_resource("ns3::Node")
+    ec.register_connection(node, simu)
+
+    ipv4 = ec.register_resource("ns3::Ipv4L3Protocol")
+    ec.register_connection(node, ipv4)
+
+    arp = ec.register_resource("ns3::ArpL3Protocol")
+    ec.register_connection(node, arp)
+    
+    icmp = ec.register_resource("ns3::Icmpv4L4Protocol")
+    ec.register_connection(node, icmp)
+
+    udp = ec.register_resource("ns3::UdpL4Protocol")
+    ec.register_connection(node, udp)
+
+    tcp = ec.register_resource("ns3::TcpL4Protocol")
+    ec.register_connection(node, tcp)
+
+    return node
+
+def add_device(ec, node, ip,  prefix):
+    dev = ec.register_resource("ns3::PointToPointNetDevice")
+    ec.set(dev, "ip", ip)
+    ec.set(dev, "prefix", prefix)
+    ec.register_connection(node, dev)
+
+    queue = ec.register_resource("ns3::DropTailQueue")
+    ec.register_connection(dev, queue)
+
+    return dev
+
+ec = ExperimentController(exp_id = "dce-custom-dlm-ping")
+
+node = ec.register_resource("LinuxNode")
+ec.set(node, "hostname", "localhost")
+ec.set(node, "cleanProcesses", True)
+
+simu = ec.register_resource("LinuxNS3Simulation")
+ec.set(simu, "verbose", True)
+#ec.set(simu, "enableDump", True)
+ec.register_connection(simu, node)
+
+nsnode1 = add_ns3_node(ec, simu)
+dev1 = add_device(ec, nsnode1, "10.0.0.1", "30")
+ec.set(dev1, "DataRate", "5Mbps")
+
+nsnode2 = add_ns3_node(ec, simu)
+dev2 = add_device(ec, nsnode2, "10.0.0.2", "30")
+ec.set(dev2, "DataRate", "5Mbps")
+
+# Create channel
+chan = ec.register_resource("ns3::PointToPointChannel")
+ec.set(chan, "Delay", "2ms")
+
+ec.register_connection(chan, dev1)
+ec.register_connection(chan, dev2)
+
+### create applications
+ping = ec.register_resource("ns3::LinuxDceApplication")
+ec.set (ping, "sources", "http://www.skbuff.net/iputils/iputils-s20101006.tar.bz2")
+ec.set (ping, "build", "tar xvjf ${SRC}/iputils-s20101006.tar.bz2 && "
+        "cd iputils-s20101006/ && "
+        "sed -i 's/CFLAGS=/CFLAGS+=/g' Makefile && "
+        "make CFLAGS=-fPIC LDFLAGS='-pie -rdynamic' ping && "
+        "cp ping ${BIN_DCE} && cd - ")
+ec.set (ping, "binary", "ping")
+ec.set (ping, "stackSize", 1<<20)
+ec.set (ping, "arguments", "-c 10;-s 1000;10.0.0.2")
+#ec.set (ping, "useDlmLoader", True)
+ec.set (ping, "StartTime", "1s")
+ec.set (ping, "StopTime", "20s")
+ec.register_connection(ping, nsnode1)
+
+ec.deploy()
+
+ec.wait_finished([ping])
+
+stdout = ec.trace(ping, "stdout") 
+
+ec.shutdown()
+
+print "PING OUTPUT", stdout
+
index 63d8d37..cb5c6c5 100644 (file)
@@ -104,8 +104,8 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation):
 
         dce_version = Attribute("dceVersion",
             "Version of dce to install from nsam repo (tag branch for repo)",
-            default = "dce-1.3", 
-            #default = "dce-dev", 
+            #default = "dce-1.3", 
+            default = "dce-dev", 
             flags = Flags.Design)
 
         populate_routing_tables = Attribute("populateRoutingTables",
index 10b2433..c42e32b 100644 (file)
@@ -60,12 +60,10 @@ class NS3BaseDceApplication(NS3BaseApplication):
                 "DCE environment variables.",
                 flags = Flags.Design)
 
-        """
         use_dlm = Attribute("useDlmLoader",
                 "Use ns3::DlmLoaderFactory as library loader",
                 type = Types.Bool,
                 flags = Flags.Design)
-        """
         
         starttime = Attribute("StartTime",
             "Time at which the application will start",
@@ -81,9 +79,7 @@ class NS3BaseDceApplication(NS3BaseApplication):
         cls._register_attribute(stack_size)
         cls._register_attribute(arguments)
         cls._register_attribute(environment)
-        """
         cls._register_attribute(use_dlm)
-        """
         cls._register_attribute(stoptime)
         cls._register_attribute(starttime)
 
@@ -104,12 +100,12 @@ class NS3BaseDceApplication(NS3BaseApplication):
         if not self._dce_manager_helper_uuid:
             self._dce_manager_helper_uuid = self.simulation.create(
                     "DceManagerHelper")
-            """
+
             if self.get("useDlmLoader"):
                 self.simulation.invoke(
                     self._dce_manager_helper_uuid, "SetLoader", 
                     "ns3::DlmLoaderFactory")
-            """
+
         return self._dce_manager_helper_uuid
 
     @property