2 # NEPI, a framework to manage network experiments
3 # Copyright (C) 2014 INRIA
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
20 from nepi.execution.attribute import Attribute, Flags, Types
21 from nepi.execution.resource import clsinit_copy, ResourceState, reschedule_delay
22 from nepi.resources.linux.ns3.ccn.ns3ccndceapplication import LinuxNS3CCNDceApplication
27 class LinuxNS3DceCCND(LinuxNS3CCNDceApplication):
28 _rtype = "ns3::LinuxDceCCND"
31 def _register_attributes(cls):
32 debug = Attribute("debug", "Sets the CCND_DEBUG environmental variable. "
33 " Allowed values are : \n"
35 " 1 - basic messages (any non-zero value gets these) \n"
36 " 2 - interest messages \n"
37 " 4 - content messages \n"
38 " 8 - matching details \n"
39 " 16 - interest details \n"
40 " 32 - gory interest details \n"
41 " 64 - log occasional human-readable timestamps \n"
42 " 128 - face registration debugging \n"
43 " -1 - max logging \n"
44 " Or apply bitwise OR to these values to get combinations of them",
48 port = Attribute("port", "Sets the CCN_LOCAL_PORT environmental variable. "
52 sockname = Attribute("sockname",
53 "Sets the CCN_LOCAL_SCOKNAME environmental variable. "
54 "Defaults to /tmp/.ccnd.sock",
57 capacity = Attribute("capacity",
58 "Sets the CCND_CAP environmental variable. "
59 "Capacity limit in terms of ContentObjects",
62 mtu = Attribute("mtu", "Sets the CCND_MTU environmental variable. ",
65 data_pause = Attribute("dataPauseMicrosec",
66 "Sets the CCND_DATA_PAUSE_MICROSEC environmental variable. ",
69 default_stale = Attribute("defaultTimeToStale",
70 "Sets the CCND_DEFAULT_TIME_TO_STALE environmental variable. ",
73 max_stale = Attribute("maxTimeToStale",
74 "Sets the CCND_MAX_TIME_TO_STALE environmental variable. ",
77 max_rte = Attribute("maxRteMicrosec",
78 "Sets the CCND_MAX_RTE_MICROSEC environmental variable. ",
81 keystore = Attribute("keyStoreDirectory",
82 "Sets the CCND_KEYSTORE_DIRECTORY environmental variable. ",
85 listen_on = Attribute("listenOn",
86 "Sets the CCND_LISTEN_ON environmental variable. ",
89 autoreg = Attribute("autoreg",
90 "Sets the CCND_AUTOREG environmental variable. ",
93 prefix = Attribute("prefix",
94 "Sets the CCND_PREFIX environmental variable. ",
97 cls._register_attribute(debug)
98 cls._register_attribute(port)
99 cls._register_attribute(sockname)
100 cls._register_attribute(capacity)
101 cls._register_attribute(mtu)
102 cls._register_attribute(data_pause)
103 cls._register_attribute(default_stale)
104 cls._register_attribute(max_stale)
105 cls._register_attribute(max_rte)
106 cls._register_attribute(keystore)
107 cls._register_attribute(listen_on)
108 cls._register_attribute(autoreg)
109 cls._register_attribute(prefix)
115 def _instantiate_object(self):
116 if not self.get("depends"):
117 self.set("depends", self._dependencies)
119 if not self.get("sources"):
120 self.set("sources", self._sources)
122 sources = self.get("sources")
123 source = sources.split(" ")[0]
124 basename = os.path.basename(source)
125 self._version = ( basename.strip().replace(".tar.gz", "")
128 .replace(".zip","") )
130 if not self.get("build"):
131 self.set("build", self._build)
133 if not self.get("binary"):
134 self.set("binary", "ccnd")
136 if not self.get("environment"):
137 self.set("environment", self._environment)
139 super(LinuxNS3DceCCND, self)._instantiate_object()
142 def _dependencies(self):
143 if self.simulation.node.use_rpm:
144 return ( " autoconf openssl-devel expat-devel libpcap-devel "
145 " ecryptfs-utils-devel libxml2-devel automake gawk "
146 " gcc gcc-c++ git pcre-devel make ")
147 elif self.simulation.node.use_deb:
148 return ( " autoconf libssl-dev libexpat-dev libpcap-dev "
149 " libecryptfs0 libxml2-utils automake gawk gcc g++ "
150 " git-core pkg-config libpcre3-dev make ")
156 return "http://www.ccnx.org/releases/ccnx-0.8.1.tar.gz"
160 sources = self.get("sources")
161 source = sources.split(" ")[0]
162 tar = os.path.basename(source)
165 # Evaluate if ccnx binaries are already installed
167 " test -f ${SRC}/%(tar)s && "
168 " echo 'binaries found, nothing to do' "
170 # If not, untar and build
172 " tar zxf ${SRC}/%(tar)s && "
173 " cd %(version)s && "
174 " INSTALL_BASE=${BIN_DCE}/.. ./configure && "
175 " make MORE_LDLIBS=-pie && "
177 " cp ${BIN_DCE}/../bin/ccn* ${BIN_DCE} && "
179 " )") % ({ 'tar': tar,
180 'version': self.version
184 def _environment(self):
186 "debug": "CCND_DEBUG",
187 "port": "CCN_LOCAL_PORT",
188 "sockname" : "CCN_LOCAL_SOCKNAME",
189 "capacity" : "CCND_CAP",
191 "dataPauseMicrosec" : "CCND_DATA_PAUSE_MICROSEC",
192 "defaultTimeToStale" : "CCND_DEFAULT_TIME_TO_STALE",
193 "maxTimeToStale" : "CCND_MAX_TIME_TO_STALE",
194 "maxRteMicrosec" : "CCND_MAX_RTE_MICROSEC",
195 "keyStoreDirectory" : "CCND_KEYSTORE_DIRECTORY",
196 "listenOn" : "CCND_LISTEN_ON",
197 "autoreg" : "CCND_AUTOREG",
198 "prefix" : "CCND_PREFIX",
201 env = ";".join(map(lambda k: "%s=%s" % (envs.get(k), str(self.get(k))),
202 [k for k in envs.keys() if self.get(k)]))