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
22 from nepi.resources.linux.ns3.ccn.ns3ccndceapplication import LinuxNS3CCNDceApplication
25 class LinuxNS3DceFIBEntry(LinuxNS3CCNDceApplication):
26 _rtype = "ns3::LinuxDceFIBEntry"
29 def _register_attributes(cls):
30 uri = Attribute("uri",
31 "URI prefix to match and route for this FIB entry",
35 protocol = Attribute("protocol",
36 "Transport protocol used in network connection to peer "
37 "for this FIB entry. One of 'udp' or 'tcp'.",
38 type = Types.Enumerate,
40 allowed = ["udp", "tcp"],
43 host = Attribute("host",
44 "Peer hostname used in network connection for this FIB entry. ",
47 port = Attribute("port",
48 "Peer port address used in network connection to peer "
49 "for this FIB entry.",
53 "Peer host public IP used in network connection for this FIB entry. ",
56 home = Attribute("home", "Sets HOME environmental variable. ",
60 cls._register_attribute(uri)
61 cls._register_attribute(protocol)
62 cls._register_attribute(host)
63 cls._register_attribute(port)
64 cls._register_attribute(ip)
65 cls._register_attribute(home)
67 def _instantiate_object(self):
68 if not self.get("binary"):
69 self.set("binary", "ccndc")
71 if not self.get("arguments"):
72 self.set("arguments", self._arguments)
74 if not self.get("environment"):
75 self.set("environment", self._environment)
77 super(LinuxNS3DceFIBEntry, self)._instantiate_object()
80 def _environment(self):
85 env = ";".join(map(lambda k: "%s=%s" % (envs.get(k), str(self.get(k))),
86 [k for k in envs.keys() if self.get(k)]))
95 args.append(self.get("uri"))
96 if self.get("protocol"):
97 args.append(self.get("protocol"))
99 args.append(self.get("host"))
101 args.append(self.get("port"))
103 args.append(self.get("ip"))
105 return ";".join(args)