Adding test/resources/linux/ns3/ccn/ns3dceccn.py test
authorAlina Quereilhac <alina.quereilhac@inria.fr>
Wed, 28 May 2014 17:53:25 +0000 (19:53 +0200)
committerAlina Quereilhac <alina.quereilhac@inria.fr>
Wed, 28 May 2014 17:53:25 +0000 (19:53 +0200)
setup.py
src/nepi/resources/linux/ns3/ccn/ns3ccncatdceapplication.py [new file with mode: 0644]
src/nepi/resources/linux/ns3/ccn/ns3ccndceapplication.py [moved from src/nepi/resources/linux/ns3/ns3ccndceapplication.py with 100% similarity]
src/nepi/resources/linux/ns3/ccn/ns3ccnddceapplication.py [new file with mode: 0644]
src/nepi/resources/linux/ns3/ccn/ns3ccnpeekdceapplication.py [new file with mode: 0644]
src/nepi/resources/linux/ns3/ccn/ns3ccnrdceapplication.py [new file with mode: 0644]
src/nepi/resources/linux/ns3/ccn/ns3fibentrydceapplication.py [new file with mode: 0644]
test/resources/linux/ccn/ccnping.py
test/resources/linux/ns3/ccn/ns3dceccn.py [new file with mode: 0644]
test/resources/linux/ns3/ccn/repoFile1 [moved from test/resources/linux/ns3/repoFile1 with 100% similarity]
test/resources/linux/ns3/ns3dceapplication.py

index 01ac52a..710c67d 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -21,6 +21,7 @@ setup(
             "nepi.resources.linux",
             "nepi.resources.linux.ccn",
             "nepi.resources.linux.ns3",
+            "nepi.resources.linux.ns3.ccn",
             "nepi.resources.netns",
             "nepi.resources.ns3",
             "nepi.resources.ns3.classes",
diff --git a/src/nepi/resources/linux/ns3/ccn/ns3ccncatdceapplication.py b/src/nepi/resources/linux/ns3/ccn/ns3ccncatdceapplication.py
new file mode 100644 (file)
index 0000000..e7c3731
--- /dev/null
@@ -0,0 +1,64 @@
+#
+#    NEPI, a framework to manage network experiments
+#    Copyright (C) 2014 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.attribute import Attribute, Flags, Types
+from nepi.execution.resource import clsinit_copy, ResourceState, reschedule_delay
+from nepi.resources.linux.ns3.ccn.ns3ccndceapplication import LinuxNS3CCNDceApplication
+
+@clsinit_copy
+class LinuxNS3DceCCNCat(LinuxNS3CCNDceApplication):
+    _rtype = "ns3::LinuxDceCCNCat"
+
+    @classmethod
+    def _register_attributes(cls):
+        content_name = Attribute("contentName",
+                "Content name for the requested content object. ",
+                flags = Flags.Design)
+
+        cls._register_attribute(content_name)
+
+    def _instantiate_object(self):
+        if not self.get("binary"):
+            self.set("binary", "ccncat")
+            
+        if self.get("contentName"):
+            self.set("arguments", self.get("contentName"))
+
+        self.set("stdinFile", "")
+
+        super(LinuxNS3DceCCNCat, self)._instantiate_object()
+
+    @property
+    def _arguments(self):
+        args = ["-v", "add"]
+
+        if self.get("uri"):
+            args.append(self.get("uri"))
+        if self.get("protocol"):
+            args.append(self.get("protocol"))
+        if self.get("host"):
+            args.append(self.get("host"))
+        if self.get("port"):
+            args.append(self.get("port"))
+        if self.get("ip"):
+            args.append(self.get("ip"))
+
+        return ";".join(args) 
+
+
diff --git a/src/nepi/resources/linux/ns3/ccn/ns3ccnddceapplication.py b/src/nepi/resources/linux/ns3/ccn/ns3ccnddceapplication.py
new file mode 100644 (file)
index 0000000..eb97b7b
--- /dev/null
@@ -0,0 +1,204 @@
+#
+#    NEPI, a framework to manage network experiments
+#    Copyright (C) 2014 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.attribute import Attribute, Flags, Types
+from nepi.execution.resource import clsinit_copy, ResourceState, reschedule_delay
+from nepi.resources.linux.ns3.ccn.ns3ccndceapplication import LinuxNS3CCNDceApplication
+
+import os
+
+@clsinit_copy
+class LinuxNS3DceCCND(LinuxNS3CCNDceApplication):
+    _rtype = "ns3::LinuxDceCCND"
+
+    @classmethod
+    def _register_attributes(cls):
+        debug = Attribute("debug", "Sets the CCND_DEBUG environmental variable. "
+            " Allowed values are : \n"
+            "  0 - no messages \n"
+            "  1 - basic messages (any non-zero value gets these) \n"
+            "  2 - interest messages \n"
+            "  4 - content messages \n"
+            "  8 - matching details \n"
+            "  16 - interest details \n"
+            "  32 - gory interest details \n"
+            "  64 - log occasional human-readable timestamps \n"
+            "  128 - face registration debugging \n"
+            "  -1 - max logging \n"
+            "  Or apply bitwise OR to these values to get combinations of them",
+            type = Types.Integer,
+            flags = Flags.Design)
+
+        port = Attribute("port", "Sets the CCN_LOCAL_PORT environmental variable. "
+            "Defaults to 9695 ", 
+            flags = Flags.Design)
+        sockname = Attribute("sockname",
+            "Sets the CCN_LOCAL_SCOKNAME environmental variable. "
+            "Defaults to /tmp/.ccnd.sock", 
+            flags = Flags.Design)
+
+        capacity = Attribute("capacity",
+            "Sets the CCND_CAP environmental variable. "
+            "Capacity limit in terms of ContentObjects",
+            flags = Flags.Design)
+
+        mtu = Attribute("mtu", "Sets the CCND_MTU environmental variable. ",
+            flags = Flags.Design)
+  
+        data_pause = Attribute("dataPauseMicrosec",
+            "Sets the CCND_DATA_PAUSE_MICROSEC environmental variable. ",
+            flags = Flags.Design)
+
+        default_stale = Attribute("defaultTimeToStale",
+             "Sets the CCND_DEFAULT_TIME_TO_STALE environmental variable. ",
+            flags = Flags.Design)
+
+        max_stale = Attribute("maxTimeToStale",
+            "Sets the CCND_MAX_TIME_TO_STALE environmental variable. ",
+            flags = Flags.Design)
+
+        max_rte = Attribute("maxRteMicrosec",
+            "Sets the CCND_MAX_RTE_MICROSEC environmental variable. ",
+            flags = Flags.Design)
+
+        keystore = Attribute("keyStoreDirectory",
+            "Sets the CCND_KEYSTORE_DIRECTORY environmental variable. ",
+            flags = Flags.Design)
+
+        listen_on = Attribute("listenOn",
+            "Sets the CCND_LISTEN_ON environmental variable. ",
+            flags = Flags.Design)
+
+        autoreg = Attribute("autoreg",
+            "Sets the CCND_AUTOREG environmental variable. ",
+            flags = Flags.Design)
+
+        prefix = Attribute("prefix",
+            "Sets the CCND_PREFIX environmental variable. ",
+            flags = Flags.Design)
+
+        cls._register_attribute(debug)
+        cls._register_attribute(port)
+        cls._register_attribute(sockname)
+        cls._register_attribute(capacity)
+        cls._register_attribute(mtu)
+        cls._register_attribute(data_pause)
+        cls._register_attribute(default_stale)
+        cls._register_attribute(max_stale)
+        cls._register_attribute(max_rte)
+        cls._register_attribute(keystore)
+        cls._register_attribute(listen_on)
+        cls._register_attribute(autoreg)
+        cls._register_attribute(prefix)
+
+    @property
+    def version(self):
+        return self._version
+
+    def _instantiate_object(self):
+        if not self.get("depends"):
+            self.set("depends", self._dependencies)
+
+        if not self.get("sources"):
+            self.set("sources", self._sources)
+
+        sources = self.get("sources")
+        source = sources.split(" ")[0]
+        basename = os.path.basename(source)
+        self._version = ( basename.strip().replace(".tar.gz", "")
+                .replace(".tar","")
+                .replace(".gz","")
+                .replace(".zip","") )
+
+        if not self.get("build"):
+            self.set("build", self._build)
+
+        if not self.get("binary"):
+            self.set("binary", "ccnd")
+
+        if not self.get("environment"):
+            self.set("environment", self._environment)
+        
+        super(LinuxNS3DceCCND, self)._instantiate_object()
+
+    @property
+    def _dependencies(self):
+        if self.simulation.node.use_rpm:
+            return ( " autoconf openssl-devel  expat-devel libpcap-devel "
+                " 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 "
+                " 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"
+
+    @property
+    def _build(self):
+        sources = self.get("sources")
+        source = sources.split(" ")[0]
+        tar = os.path.basename(source)
+
+        return (
+            # Evaluate if ccnx binaries are already installed
+            " ( "
+                " test -f ${SRC}/%(tar)s && "
+                " echo 'binaries found, nothing to do' "
+            " ) || "
+            # If not, untar and build
+            " ( "
+                " cd %(version)s && "
+                " INSTALL_BASE=${BIN_DCE}/.. ./configure && "
+                " make MORE_LDLIBS=-pie && "
+                " make install && "
+                " cp ${BIN_DCE}/../bin/ccn* ${BIN_DCE} && "
+                " cd -"
+             " )") % ({ 'tar': tar,
+                        'version': self.version
+                 })
+
+    @property
+    def _environment(self):
+        envs = dict({
+            "debug": "CCND_DEBUG",
+            "port": "CCN_LOCAL_PORT",
+            "sockname" : "CCN_LOCAL_SOCKNAME",
+            "capacity" : "CCND_CAP",
+            "mtu" : "CCND_MTU",
+            "dataPauseMicrosec" : "CCND_DATA_PAUSE_MICROSEC",
+            "defaultTimeToStale" : "CCND_DEFAULT_TIME_TO_STALE",
+            "maxTimeToStale" : "CCND_MAX_TIME_TO_STALE",
+            "maxRteMicrosec" : "CCND_MAX_RTE_MICROSEC",
+            "keyStoreDirectory" : "CCND_KEYSTORE_DIRECTORY",
+            "listenOn" : "CCND_LISTEN_ON",
+            "autoreg" : "CCND_AUTOREG",
+            "prefix" : "CCND_PREFIX",
+            })
+
+        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
+
diff --git a/src/nepi/resources/linux/ns3/ccn/ns3ccnpeekdceapplication.py b/src/nepi/resources/linux/ns3/ccn/ns3ccnpeekdceapplication.py
new file mode 100644 (file)
index 0000000..e8cf108
--- /dev/null
@@ -0,0 +1,64 @@
+#
+#    NEPI, a framework to manage network experiments
+#    Copyright (C) 2014 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.attribute import Attribute, Flags, Types
+from nepi.execution.resource import clsinit_copy, ResourceState, reschedule_delay
+from nepi.resources.linux.ns3.ccn.ns3ccndceapplication import LinuxNS3CCNDceApplication
+
+@clsinit_copy
+class LinuxNS3DceCCNPeek(LinuxNS3CCNDceApplication):
+    _rtype = "ns3::LinuxDceCCNPeek"
+
+    @classmethod
+    def _register_attributes(cls):
+        content_name = Attribute("contentName",
+                "Content name for the requested content object. ",
+                flags = Flags.Design)
+
+        cls._register_attribute(content_name)
+
+    def _instantiate_object(self):
+        if not self.get("binary"):
+            self.set("binary", "ccnpeek")
+            
+        if self.get("contentName"):
+            self.set("arguments", self.get("contentName"))
+
+        self.set("stdinFile", "")
+
+        super(LinuxNS3DceCCNPeek, self)._instantiate_object()
+
+    @property
+    def _arguments(self):
+        args = ["-v", "add"]
+
+        if self.get("uri"):
+            args.append(self.get("uri"))
+        if self.get("protocol"):
+            args.append(self.get("protocol"))
+        if self.get("host"):
+            args.append(self.get("host"))
+        if self.get("port"):
+            args.append(self.get("port"))
+        if self.get("ip"):
+            args.append(self.get("ip"))
+
+        return ";".join(args) 
+
+
diff --git a/src/nepi/resources/linux/ns3/ccn/ns3ccnrdceapplication.py b/src/nepi/resources/linux/ns3/ccn/ns3ccnrdceapplication.py
new file mode 100644 (file)
index 0000000..a9a548d
--- /dev/null
@@ -0,0 +1,230 @@
+#
+#    NEPI, a framework to manage network experiments
+#    Copyright (C) 2014 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.attribute import Attribute, Flags, Types
+from nepi.execution.resource import clsinit_copy, ResourceState, reschedule_delay
+from nepi.resources.linux.ns3.ccn.ns3ccndceapplication import LinuxNS3CCNDceApplication
+
+@clsinit_copy
+class LinuxNS3DceCCNR(LinuxNS3CCNDceApplication):
+    _rtype = "ns3::LinuxDceCCNR"
+
+    @classmethod
+    def _register_attributes(cls):
+        max_fanout = Attribute("maxFanout",
+            "Sets the CCNR_BTREE_MAX_FANOUT environmental variable. ",
+            flags = Flags.Design)
+
+        max_leaf_entries = Attribute("maxLeafEntries",
+            "Sets the CCNR_BTREE_MAX_LEAF_ENTRIES environmental variable. ",
+            flags = Flags.Design)
+
+        max_node_bytes = Attribute("maxNodeBytes",
+            "Sets the CCNR_BTREE_MAX_NODE_BYTES environmental variable. ",
+            flags = Flags.Design)
+
+        max_node_pool = Attribute("maxNodePool",
+            "Sets the CCNR_BTREE_MAX_NODE_POOL environmental variable. ",
+            flags = Flags.Design)
+
+        content_cache = Attribute("contentCache",
+            "Sets the CCNR_CONTENT_CACHE environmental variable. ",
+            flags = Flags.Design)
+
+        debug = Attribute("debug",
+            "Sets the CCNR_DEBUG environmental variable. "
+            "Logging level for ccnr. Defaults to WARNING.",
+            type = Types.Enumerate,
+            allowed = [
+                    "NONE",
+                    "SEVERE",
+                    "ERROR",
+                    "WARNING",
+                    "INFO",
+                    "FINE, FINER, FINEST"],
+            flags = Flags.Design)
+
+        directory = Attribute("directory",
+            "Sets the CCNR_DIRECTORY environmental variable. ",
+            flags = Flags.Design)
+
+        global_prefix = Attribute("globalPrefix",
+            "Sets the CCNR_GLOBAL_PREFIX environmental variable. ",
+            flags = Flags.Design)
+
+        listen_on = Attribute("listenOn",
+            "Sets the CCNR_LISTEN_ON environmental variable. ",
+            flags = Flags.Design)
+
+        min_send_bufsize = Attribute("minSendBufsize",
+            "Sets the CCNR_MIN_SEND_BUFSIZE environmental variable. ",
+            flags = Flags.Design)
+
+        proto = Attribute("proto",
+            "Sets the CCNR_PROTO environmental variable. ",
+            flags = Flags.Design)
+
+        status_port = Attribute("statusPort",
+            "Sets the CCNR_STATUS_PORT environmental variable. ",
+            flags = Flags.Design)
+
+        start_write_scope_limit = Attribute("startWriteScopeLimit",
+            "Sets the CCNR_START_WRITE_SCOPE_LIMIT environmental variable. ",
+            flags = Flags.Design)
+
+        ccns_debug = Attribute("ccnsDebug",
+            "Sets the CCNS_DEBUG environmental variable. ",
+            flags = Flags.Design)
+
+        ccns_enable = Attribute("ccnsEnable",
+            "Sets the CCNS_ENABLE environmental variable. ",
+            flags = Flags.Design)
+
+        ccns_faux_error = Attribute("ccnsFauxError",
+            "Sets the CCNS_FAUX_ERROR environmental variable. ",
+            flags = Flags.Design)
+
+        ccns_heartbeat_micros = Attribute("ccnsHeartBeatMicros",
+            "Sets the CCNS_HEART_BEAT_MICROS environmental variable. ",
+            flags = Flags.Design)
+
+        ccns_max_compares_busy = Attribute("ccnsMaxComparesBusy",
+            "Sets the CCNS_MAX_COMPARES_BUSY environmental variable. ",
+            flags = Flags.Design)
+
+        ccns_max_fetch_busy = Attribute("ccnsMaxFetchBusy",
+            "Sets the CCNS_MAX_FETCH_BUSY environmental variable. ",
+            flags = Flags.Design)
+
+        ccns_node_fetch_lifetime = Attribute("ccnsNodeFetchLifetime",
+            "Sets the CCNS_NODE_FETCH_LIFETIME environmental variable. ",
+            flags = Flags.Design)
+
+        ccns_note_err = Attribute("ccnsNoteErr",
+            "Sets the CCNS_NOTE_ERR environmental variable. ",
+            flags = Flags.Design)
+
+        ccns_repo_store = Attribute("ccnsRepoStore",
+            "Sets the CCNS_REPO_STORE environmental variable. ",
+            flags = Flags.Design)
+
+        ccns_root_advise_fresh = Attribute("ccnsRootAdviseFresh",
+            "Sets the CCNS_ROOT_ADVISE_FRESH environmental variable. ",
+            flags = Flags.Design)
+
+        ccns_root_advise_lifetime = Attribute("ccnsRootAdviseLifetime",
+            "Sets the CCNS_ROOT_ADVISE_LIFETIME environmental variable. ",
+            flags = Flags.Design)
+
+        ccns_stable_enabled = Attribute("ccnsStableEnabled",
+            "Sets the CCNS_STABLE_ENABLED environmental variable. ",
+            flags = Flags.Design)
+
+        ccns_sync_scope = Attribute("ccnsSyncScope",
+            "Sets the CCNS_SYNC_SCOPE environmental variable. ",
+            flags = Flags.Design)
+
+        repo_file = Attribute("repoFile1",
+            "The Repository uses $CCNR_DIRECTORY/repoFile1 for "
+            "persistent storage of CCN Content Objects",
+            flags = Flags.Design)
+
+        cls._register_attribute(max_fanout)
+        cls._register_attribute(max_leaf_entries)
+        cls._register_attribute(max_node_bytes)
+        cls._register_attribute(max_node_pool)
+        cls._register_attribute(content_cache)
+        cls._register_attribute(debug)
+        cls._register_attribute(directory)
+        cls._register_attribute(global_prefix)
+        cls._register_attribute(listen_on)
+        cls._register_attribute(min_send_bufsize)
+        cls._register_attribute(proto)
+        cls._register_attribute(status_port)
+        cls._register_attribute(start_write_scope_limit)
+        cls._register_attribute(ccns_debug)
+        cls._register_attribute(ccns_enable)
+        cls._register_attribute(ccns_faux_error)
+        cls._register_attribute(ccns_heartbeat_micros)
+        cls._register_attribute(ccns_max_compares_busy)
+        cls._register_attribute(ccns_max_fetch_busy)
+        cls._register_attribute(ccns_node_fetch_lifetime)
+        cls._register_attribute(ccns_note_err)
+        cls._register_attribute(ccns_repo_store)
+        cls._register_attribute(ccns_root_advise_fresh)
+        cls._register_attribute(ccns_root_advise_lifetime)
+        cls._register_attribute(ccns_stable_enabled)
+        cls._register_attribute(ccns_sync_scope)
+        cls._register_attribute(repo_file)
+
+    def _instantiate_object(self):
+        if not self.get("binary"):
+            self.set("binary", "ccnr")
+
+        if not self.get("environment"):
+            self.set("environment", self._environment)
+       
+        repoFile1 = self.get("repoFile1")
+        if repoFile1:
+            env = "CCNR_DIRECTORY=/REPO/" 
+            environment = self.get("environment")
+            if environment:
+                env += ";" + environment
+            self.set("environment", env)
+            self.set("files", "%s=/REPO/repoFile1" % repoFile1) 
+
+        super(LinuxNS3DceCCNR, self)._instantiate_object()
+
+    @property
+    def _environment(self):
+        envs = dict({
+            "maxFanout": "CCNR_BTREE_MAX_FANOUT",
+            "maxLeafEntries": "CCNR_BTREE_MAX_LEAF_ENTRIES",
+            "maxNodeBytes": "CCNR_BTREE_MAX_NODE_BYTES",
+            "maxNodePool": "CCNR_BTREE_MAX_NODE_POOL",
+            "contentCache": "CCNR_CONTENT_CACHE",
+            "debug": "CCNR_DEBUG",
+            "directory": "CCNR_DIRECTORY",
+            "globalPrefix": "CCNR_GLOBAL_PREFIX",
+            "listenOn": "CCNR_LISTEN_ON",
+            "minSendBufsize": "CCNR_MIN_SEND_BUFSIZE",
+            "proto": "CCNR_PROTO",
+            "statusPort": "CCNR_STATUS_PORT",
+            "startWriteScopeLimit": "CCNR_START_WRITE_SCOPE_LIMIT",
+            "ccnsDebug": "CCNS_DEBUG",
+            "ccnsEnable": "CCNS_ENABLE",
+            "ccnsFauxError": "CCNS_FAUX_ERROR",
+            "ccnsHeartBeatMicros": "CCNS_HEART_BEAT_MICROS",
+            "ccnsMaxComparesBusy": "CCNS_MAX_COMPARES_BUSY",
+            "ccnsMaxFetchBusy": "CCNS_MAX_FETCH_BUSY",
+            "ccnsNodeFetchLifetime": "CCNS_NODE_FETCH_LIFETIME",
+            "ccnsNoteErr": "CCNS_NOTE_ERR",
+            "ccnsRepoStore": "CCNS_REPO_STORE",
+            "ccnsRootAdviseFresh": "CCNS_ROOT_ADVISE_FRESH",
+            "ccnsRootAdviseLifetime": "CCNS_ROOT_ADVISE_LIFETIME",
+            "ccnsStableEnabled": "CCNS_STABLE_ENABLED",
+            "ccnsSyncScope": "CCNS_SYNC_SCOPE",
+            })
+
+        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
+
+
diff --git a/src/nepi/resources/linux/ns3/ccn/ns3fibentrydceapplication.py b/src/nepi/resources/linux/ns3/ccn/ns3fibentrydceapplication.py
new file mode 100644 (file)
index 0000000..63e5d19
--- /dev/null
@@ -0,0 +1,88 @@
+#
+#    NEPI, a framework to manage network experiments
+#    Copyright (C) 2014 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.attribute import Attribute, Flags, Types
+from nepi.execution.resource import clsinit_copy, ResourceState, reschedule_delay
+from nepi.resources.linux.ns3.ccn.ns3ccndceapplication import LinuxNS3CCNDceApplication
+
+@clsinit_copy
+class LinuxNS3DceFIBEntry(LinuxNS3CCNDceApplication):
+    _rtype = "ns3::LinuxDceFIBEntry"
+
+    @classmethod
+    def _register_attributes(cls):
+        uri = Attribute("uri",
+                "URI prefix to match and route for this FIB entry",
+                default = "ccnx:/",
+                flags = Flags.Design)
+
+        protocol = Attribute("protocol",
+                "Transport protocol used in network connection to peer "
+                "for this FIB entry. One of 'udp' or 'tcp'.",
+                type = Types.Enumerate, 
+                default = "udp",
+                allowed = ["udp", "tcp"],
+                flags = Flags.Design)
+
+        host = Attribute("host",
+                "Peer hostname used in network connection for this FIB entry. ",
+                flags = Flags.Design)
+
+        port = Attribute("port",
+                "Peer port address used in network connection to peer "
+                "for this FIB entry.",
+                flags = Flags.Design)
+
+        ip = Attribute("ip",
+                "Peer host public IP used in network connection for this FIB entry. ",
+                flags = Flags.Design)
+
+        cls._register_attribute(uri)
+        cls._register_attribute(protocol)
+        cls._register_attribute(host)
+        cls._register_attribute(port)
+        cls._register_attribute(ip)
+
+    def _instantiate_object(self):
+        if not self.get("binary"):
+            self.set("binary", "ccndc")
+            
+        if not self.get("arguments"):
+            self.set("arguments", self._arguments)
+
+        super(LinuxNS3DceFIBEntry, self)._instantiate_object()
+
+    @property
+    def _arguments(self):
+        args = ["-v", "add"]
+
+        if self.get("uri"):
+            args.append(self.get("uri"))
+        if self.get("protocol"):
+            args.append(self.get("protocol"))
+        if self.get("host"):
+            args.append(self.get("host"))
+        if self.get("port"):
+            args.append(self.get("port"))
+        if self.get("ip"):
+            args.append(self.get("ip"))
+
+        return ";".join(args) 
+
+
index a740128..2deef2d 100644 (file)
@@ -92,7 +92,7 @@ class LinuxCCNPingTestCase(unittest.TestCase):
                 self.target)
 
     def test_count_ubuntu(self):
-        self.t_count(self.ubuntu_user, self.ubuntu_host, self.fedora_user,
+        self.t_count(self.ubuntu_user, self.ubuntu_host, self.ubuntu_user,
                 self.target)
 
 if __name__ == '__main__':
diff --git a/test/resources/linux/ns3/ccn/ns3dceccn.py b/test/resources/linux/ns3/ccn/ns3dceccn.py
new file mode 100644 (file)
index 0000000..63b7400
--- /dev/null
@@ -0,0 +1,184 @@
+#!/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 
+from nepi.execution.trace import TraceAttr
+
+import os
+import time
+import unittest
+
+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_point2point_device(ec, node, address = None,  prefix = None):
+    dev = ec.register_resource("ns3::PointToPointNetDevice")
+    if address:
+       ec.set(dev, "ip", address)
+    if prefix:
+       ec.set(dev, "prefix", prefix)
+    ec.register_connection(node, dev)
+
+    queue = ec.register_resource("ns3::DropTailQueue")
+    ec.register_connection(dev, queue)
+
+    return dev
+
+class LinuxNS3PingDceApplicationTest(unittest.TestCase):
+    def setUp(self):
+        #self.fedora_host = "nepi2.pl.sophia.inria.fr"
+        #self.fedora_host = "planetlabpc1.upf.edu"
+        #self.fedora_user = "inria_nepi"
+        #self.fedora_identity = "%s/.ssh/id_rsa_planetlab" % (os.environ['HOME'])
+        self.fedora_host = "mimas.inria.fr"
+        self.fedora_user = "aquereil"
+        self.fedora_identity = "%s/.ssh/id_rsa" % (os.environ['HOME'])
+
+    def test_dce_ccn(self):
+        ec = ExperimentController(exp_id = "test-dceccn")
+        
+        node = ec.register_resource("LinuxNode")
+        ec.set(node, "hostname", self.fedora_host)
+        ec.set(node, "username", self.fedora_user)
+        ec.set(node, "identity", self.fedora_identity)
+        #ec.set(node, "cleanProcesses", True)
+        #ec.set(node, "cleanHome", True)
+
+        simu = ec.register_resource("LinuxNS3Simulation")
+        ec.set(simu, "verbose", True)
+        ec.set(simu, "enableDCE", True)
+        ec.set(simu, "buildMode", "debug")
+        ec.set(simu, "nsLog", "DceApplication")
+        ec.register_connection(simu, node)
+
+        nsnode1 = add_ns3_node(ec, simu)
+        p2p1 = add_point2point_device(ec, nsnode1, "10.0.0.1", "30")
+        ec.set(p2p1, "DataRate", "5Mbps")
+
+        nsnode2 = add_ns3_node(ec, simu)
+        p2p2 = add_point2point_device(ec, nsnode2, "10.0.0.2", "30")
+        ec.set(p2p2, "DataRate", "5Mbps")
+
+        # Create channel
+        chan = ec.register_resource("ns3::PointToPointChannel")
+        ec.set(chan, "Delay", "2ms")
+
+        ec.register_connection(chan, p2p1)
+        ec.register_connection(chan, p2p2)
+
+        ### create applications
+        ccnd1 = ec.register_resource("ns3::LinuxDceCCND")
+        ec.set (ccnd1, "stackSize", 1<<20)
+        ec.set (ccnd1, "debug", 7)
+        ec.set (ccnd1, "capacity", 50000)
+        ec.set (ccnd1, "StartTime", "1s")
+        ec.set (ccnd1, "StopTime", "20s")
+        ec.register_connection(ccnd1, nsnode1)
+
+        repofile = os.path.join(
+            os.path.dirname(os.path.realpath(__file__)),
+            "repoFile1")
+
+        ccnr = ec.register_resource("ns3::LinuxDceCCNR")
+        ec.set (ccnr, "repoFile1", repofile) 
+        ec.set (ccnr, "stackSize", 1<<20)
+        ec.set (ccnr, "StartTime", "2s")
+        ec.set (ccnr, "StopTime", "120s")
+        ec.register_connection(ccnr, nsnode1)
+
+        ccndc1 = ec.register_resource("ns3::LinuxDceFIBEntry")
+        ec.set (ccndc1, "protocol", "udp") 
+        ec.set (ccndc1, "uri", "ccnx:/") 
+        ec.set (ccndc1, "host", "10.0.0.2") 
+        ec.set (ccndc1, "stackSize", 1<<20)
+        ec.set (ccndc1, "StartTime", "2s")
+        ec.set (ccndc1, "StopTime", "120s")
+        ec.register_connection(ccndc1, nsnode1)
+
+        ccnd2 = ec.register_resource("ns3::LinuxDceCCND")
+        ec.set (ccnd2, "stackSize", 1<<20)
+        ec.set (ccnd2, "debug", 7)
+        ec.set (ccnd2, "capacity", 50000)
+        ec.set (ccnd2, "StartTime", "1s")
+        ec.set (ccnd2, "StopTime", "20s")
+        ec.register_connection(ccnd2, nsnode2)
+
+        ccndc2 = ec.register_resource("ns3::LinuxDceFIBEntry")
+        ec.set (ccndc2, "protocol", "udp") 
+        ec.set (ccndc2, "uri", "ccnx:/") 
+        ec.set (ccndc2, "host", "10.0.0.1") 
+        ec.set (ccndc2, "stackSize", 1<<20)
+        ec.set (ccndc2, "StartTime", "2s")
+        ec.set (ccndc2, "StopTime", "120s")
+        ec.register_connection(ccndc2, nsnode2)
+
+        ccnpeek = ec.register_resource("ns3::LinuxDceCCNPeek")
+        ec.set (ccnpeek, "contentName", "ccnx:/test/bunny.ts")
+        ec.set (ccnpeek, "stackSize", 1<<20)
+        ec.set (ccnpeek, "StartTime", "4s")
+        ec.set (ccnpeek, "StopTime", "120s")
+        ec.register_connection(ccnpeek, nsnode2)
+
+        ccncat = ec.register_resource("ns3::LinuxDceCCNCat")
+        ec.set (ccncat, "contentName", "ccnx:/test/bunny.ts")
+        ec.set (ccncat, "stackSize", 1<<20)
+        ec.set (ccncat, "StartTime", "4s")
+        ec.set (ccncat, "StopTime", "120s")
+        ec.register_connection(ccncat, nsnode2)
+
+        ec.deploy()
+
+        ec.wait_finished([ccncat])
+
+        expected = "ccncat ccnx:/test/bunny.ts"
+        cmdline = ec.trace(ccncat, "cmdline")
+        self.assertTrue(cmdline.find(expected) > -1, cmdline)
+
+        expected = "Start Time: NS3 Time:          4s ("
+        status = ec.trace(ccncat, "status")
+        self.assertTrue(status.find(expected) > -1, status)
+
+        expected = 2873956
+        stdout = ec.trace(ccncat, "stdout")
+        self.assertTrue(len(stdout) == expected , stdout)
+
+        ec.shutdown()
+
+if __name__ == '__main__':
+    unittest.main()
index b3f21ca..fa6448f 100644 (file)
@@ -268,7 +268,7 @@ class LinuxNS3DceApplicationTest(unittest.TestCase):
         ec.register_connection(ccnd1, nsnode1)
 
         repofile = os.path.join(
-            os.path.dirname(os.path.realpath(__file__)),
+            os.path.dirname(os.path.realpath(__file__)), "ccn", 
             "repoFile1")
 
         ccnr = ec.register_resource("ns3::LinuxCCNDceApplication")