Changing reschedule_delay internals
[nepi.git] / src / nepi / resources / linux / ns3 / ns3pingdceapplication.py
1 #
2 #    NEPI, a framework to manage network experiments
3 #    Copyright (C) 2014 INRIA
4 #
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.
9 #
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.
14 #
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/>.
17 #
18 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
19
20 from nepi.execution.attribute import Attribute, Flags, Types
21 from nepi.execution.resource import clsinit_copy, ResourceState
22 from nepi.resources.linux.ns3.ns3dceapplication import LinuxNS3DceApplication
23
24 @clsinit_copy
25 class LinuxDcePing(LinuxNS3DceApplication):
26     _rtype = "ns3::LinuxDcePing"
27
28     @classmethod
29     def _register_attributes(cls):
30         count = Attribute("count",
31             "Sets ping -c option. Determines the number of ECHO_REQUEST "
32             "packates to send before stopping.",
33             type = Types.Integer,
34             flags = Flags.Design)
35
36         mark = Attribute("mark",
37             "Sets ping -m option. Uses 'mark' to tag outgoing packets. ",
38             flags = Flags.Design)
39
40         interval = Attribute("interval",
41             "Sets ping -i option. Leaves interval seconds between "
42             "successive ECHO_REUQEST packets. ",
43             flags = Flags.Design)
44
45         address = Attribute("address",
46             "Sets ping -I option. Sets ECHO_REQUEST packets souce address "
47             "to the specified interface address ",
48             flags = Flags.Design)
49
50         preload = Attribute("preload",
51             "Sets ping -l option. Sends preload amount of packets "
52             "without waiting for a reply ",
53             flags = Flags.Design)
54
55         numeric = Attribute("numeric",
56             "Sets ping -n option. Disables resolution of host addresses into "
57             "symbolic names. ",
58             type = Types.Bool,
59             default = False,
60             flags = Flags.Design)
61
62         pattern = Attribute("pattern",
63             "Sets ping -p option. Species a up to 16 ''pad'' bytes to fill "
64             "out sent packets. ",
65             flags = Flags.Design)
66
67         printtmp = Attribute("printTimestamp",
68             "Sets ping -D option. Prints timestamp befor each line as: "
69             "unix time + microseconds as in gettimeofday ",
70             type = Types.Bool,
71             default = False,
72             flags = Flags.Design)
73
74         tos = Attribute("tos",
75             "Sets ping -Q option. Sets Quality of Service related bits in ICMP "
76             "datagrams. tos can be either a decimal or hexadecime number ",
77             flags = Flags.Design)
78
79         quiet = Attribute("quiet",
80             "Sets ping -q option. Disables ping standard output ",
81             type = Types.Bool,
82             default = False,
83             flags = Flags.Design)
84
85         rec_route = Attribute("recordRoute",
86             "Sets ping -R option. Includes the RECORD_ROUTE option in the "
87             "ECHO REQUEST packet and displays route buffer on the Disables "
88             "ping standard output.",
89             type = Types.Bool,
90             default = False,
91             flags = Flags.Design)
92
93         route_bypass = Attribute("routeBypass",
94             "Sets ping -r option. Bypasses normal routing tables and sends "
95             "ECHO REQUEST packets directly yo a host on an attached interface. ",
96             type = Types.Bool,
97             default = False,
98             flags = Flags.Design)
99
100         packetsize = Attribute("packetSize",
101             "Sets ping -s option. Specifies the number of data bytes to be "
102             "sent. Defaults to 56. ",
103             flags = Flags.Design)
104
105         sendbuff = Attribute("sendBuff",
106             "Sets ping -S option. Specifies the number of packets to buffer. "
107             "Defaults to one. ",
108             flags = Flags.Design)
109
110         ttl = Attribute("ttl",
111             "Sets ping -t option. Specifies the IP Time to Live for the "
112             "packets. ",
113             flags = Flags.Design)
114
115         timestamp = Attribute("timestamp",
116             "Sets ping -T option. Sets special IP timestamp options. ",
117             flags = Flags.Design)
118
119         hint = Attribute("hint",
120             "Sets ping -M option. Selects Path MTU Discovery strategy. ",
121             flags = Flags.Design)
122
123         full_latency = Attribute("fullLatency",
124             "Sets ping -U option. Calculates round trip time taking into "
125             "account the full user-to-user latency instead of only the "
126             "network round trip time. ",
127             type = Types.Bool,
128             default = False,
129             flags = Flags.Design)
130
131         verbose = Attribute("verbose",
132             "Sets ping -v option. Verbose output. ",
133             type = Types.Bool,
134             default = False,
135             flags = Flags.Design)
136
137         flood = Attribute("flood",
138             "Sets ping -f option. Flood ping. ",
139             type = Types.Bool,
140             default = False,
141             flags = Flags.Design)
142
143         deadline = Attribute("deadline",
144             "Sets ping -w option. Specify a timeout, in seconds, before ping "
145             "exits regardless of how many packets have been sent or received.",
146             flags = Flags.Design)
147
148         timeout = Attribute("timeout",
149             "Sets ping -W option. Time to wait for a respone in seconds .",
150             flags = Flags.Design)
151
152         target = Attribute("target",
153             "The host to ping .",
154             flags = Flags.Design)
155
156         cls._register_attribute(count)
157         cls._register_attribute(mark)
158         cls._register_attribute(interval)
159         cls._register_attribute(address)
160         cls._register_attribute(preload)
161         cls._register_attribute(numeric)
162         cls._register_attribute(pattern)
163         cls._register_attribute(printtmp)
164         cls._register_attribute(tos)
165         cls._register_attribute(quiet)
166         cls._register_attribute(rec_route)
167         cls._register_attribute(route_bypass)
168         cls._register_attribute(packetsize)
169         cls._register_attribute(sendbuff)
170         cls._register_attribute(ttl)
171         cls._register_attribute(timestamp)
172         cls._register_attribute(hint)
173         cls._register_attribute(full_latency)
174         cls._register_attribute(verbose)
175         cls._register_attribute(flood)
176         cls._register_attribute(deadline)
177         cls._register_attribute(timeout)
178         cls._register_attribute(target)
179
180     def _instantiate_object(self):
181         self.set("sources", self._sources)
182         self.set("build", self._build)
183         self.set("binary", "ping")
184         self.set("arguments", self._arguments)
185         
186         super(LinuxDcePing, self)._instantiate_object()
187
188     @property
189     def _sources(self):
190         return "http://www.skbuff.net/iputils/iputils-s20101006.tar.bz2"
191
192     @property
193     def _build(self):
194         return  (" ( "
195                 " test -f ${BIN_DCE}/ping && "
196                 " echo 'binaries found, nothing to do' "
197                 " ) || ( "
198                 "tar xvjf ${SRC}/iputils-s20101006.tar.bz2 && "
199                 "cd iputils-s20101006/ && "
200                 "sed -i 's/CFLAGS=/CFLAGS+=/g' Makefile && "
201                 "make CFLAGS=-fPIC LDFLAGS='-pie -rdynamic' ping && "
202                 "cp ping ${BIN_DCE} && cd - "
203                 " )"   
204                 )
205
206     @property
207     def _arguments(self):
208         args = []
209
210         if self.get("count"):
211             args.append("-c %s" % self.get("count"))
212         if self.get("mark"):
213             args.append("-m %s" % self.get("mark"))
214         if self.get("interval"):
215             args.append("-i %s" % self.get("interval"))
216         if self.get("address"):
217             args.append("-I %s" % self.get("address"))
218         if self.get("preload"):
219             args.append("-l %s" % self.get("preload"))
220         if self.get("numeric") == True:
221             args.append("-n")
222         if self.get("pattern"):
223             args.append("-p %s" % self.get("pattern"))
224         if self.get("tos"):
225             args.append("-Q %s" % self.get("tos"))
226         if self.get("quiet"):
227             args.append("-q %s" % self.get("quiet"))
228         if self.get("recordRoute") == True:
229             args.append("-R")
230         if self.get("routeBypass") == True:
231             args.append("-r")
232         if self.get("packetSize"):
233             args.append("-s %s" % self.get("packetSize"))
234         if self.get("sendBuff"):
235             args.append("-S %s" % self.get("sendBuff"))
236         if self.get("ttl"):
237             args.append("-t %s" % self.get("ttl"))
238         if self.get("timestamp"):
239             args.append("-T %s" % self.get("timestamp"))
240         if self.get("hint"):
241             args.append("-M %s" % self.get("hint"))
242         if self.get("fullLatency") == True:
243             args.append("-U")
244         if self.get("verbose") == True:
245             args.append("-v")
246         if self.get("flood") == True:
247             args.append("-f")
248         if self.get("deadline"):
249             args.append("-w %s" % self.get("deadline"))
250         if self.get("timeout"):
251             args.append("-W %s" % self.get("timeout"))
252         args.append(self.get("target"))
253
254         return ";".join(args) 
255