blob: a0390e7de700498230789583f8e34e501be0a4b2 [file] [log] [blame]
Alexander Afanasyevc74a6022011-08-15 20:01:35 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Alexander Afanasyev45b92d42011-08-14 23:11:38 -07002/*
3 * Copyright (c) 2010 University of Washington
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 version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19#ifndef CCNX_TRACE_HELPER_H
20#define CCNX_TRACE_HELPER_H
21
22#include "ns3/assert.h"
23#include "ns3/ccnx-face-container.h"
24#include "ns3/ccnx.h"
25#include "ns3/trace-helper.h"
26
27namespace ns3 {
28
29/**
30 * @brief Base class providing common user-level pcap operations for helpers
31 * representing Ccnx protocols .
32 */
33class PcapHelperForCcnx
34{
35public:
36 /**
37 * @brief Construct a PcapHelperForCcnx.
38 */
39 PcapHelperForCcnx () {}
40
41 /**
42 * @brief Destroy a PcapHelperForCcnx.
43 */
44 virtual ~PcapHelperForCcnx () {}
45
46 /**
47 * @brief Enable pcap output the indicated Ccnx and interface pair.
48 * @internal
49 *
50 * @param prefix Filename prefix to use for pcap files.
51 * @param Ccnx Ptr<Ccnx> on which you want to enable tracing.
52 * @param interface Interface on Ccnx on which you want to enable tracing.
53 * @param explicitFilename Treat the prefix as an explicit filename if true
54 */
55 virtual void EnablePcapCcnxInternal (std::string prefix,
56 Ptr<Ccnx> ccnx,
57 uint32_t interface,
58 bool explicitFilename) = 0;
59
60 /**
61 * @brief Enable pcap output the indicated Ccnx and interface pair.
62 *
63 * @param prefix Filename prefix to use for pcap files.
64 * @param ccnx Ptr<Ccnx> on which you want to enable tracing.
65 * @param interface Interface on ccnx on which you want to enable tracing.
66 * @param explicitFilename Treat the prefix as an explicit filename if true.
67 */
68 void EnablePcapCcnx (std::string prefix, Ptr<Ccnx> ccnx, uint32_t interface, bool explicitFilename = false);
69
70 /**
71 * @brief Enable pcap output the indicated ccnx and interface pair using a
72 * Ptr<Ccnx> previously named using the ns-3 object name service.
73 *
74 * @param prefix filename prefix to use for pcap files.
75 * @param ccnxName Name of the Ptr<Ccnx> on which you want to enable tracing.
76 * @param interface Interface on ccnx on which you want to enable tracing.
77 * @param explicitFilename Treat the prefix as an explicit filename if true.
78 */
79 void EnablePcapCcnx (std::string prefix, std::string ccnxName, uint32_t interface, bool explicitFilename = false);
80
81 /**
82 * @brief Enable pcap output on each Ccnx and interface pair in the container.
83 *
84 * @param prefix Filename prefix to use for pcap files.
85 * @param c CcnxFaceContainer of Ccnx and interface pairs
86 */
87 void EnablePcapCcnx (std::string prefix, CcnxFaceContainer c);
88
89 /**
90 * @brief Enable pcap output on all Ccnx and interface pairs existing in the
91 * nodes provided in the container.
92 *
93 * \param prefix Filename prefix to use for pcap files.
94 * \param n container of nodes.
95 */
96 void EnablePcapCcnx (std::string prefix, NodeContainer n);
97
98 /**
99 * @brief Enable pcap output on the Ccnx and interface pair specified by a
100 * global node-id (of a previously created node) and interface. Since there
101 * can be only one Ccnx aggregated to a node, the node-id unambiguously
102 * determines the Ccnx.
103 *
104 * @param prefix Filename prefix to use for pcap files.
105 * @param nodeid The node identifier/number of the node on which to enable tracing.
106 * @param interface Interface on ccnx on which you want to enable tracing.
107 * @param explicitFilename Treat the prefix as an explicit filename if true
108 */
109 void EnablePcapCcnx (std::string prefix, uint32_t nodeid, uint32_t interface, bool explicitFilename);
110
111 /**
112 * @brief Enable pcap output on all Ccnx and interface pairs existing in the
113 * set of all nodes created in the simulation.
114 *
115 * @param prefix Filename prefix to use for pcap files.
116 */
117 void EnablePcapCcnxAll (std::string prefix);
118
119};
120
121/**
122 * @brief Base class providing common user-level ascii trace operations for
123 * helpers representing Ccnx protocols .
124 */
125class AsciiTraceHelperForCcnx
126{
127public:
128 /**
129 * @brief Construct an AsciiTraceHelperForCcnx.
130 */
131 AsciiTraceHelperForCcnx () {}
132
133 /**
134 * @brief Destroy an AsciiTraceHelperForCcnx
135 */
136 virtual ~AsciiTraceHelperForCcnx () {}
137
138 /**
139 * @brief Enable ascii trace output on the indicated Ccnx and interface pair.
140 * @internal
141 *
142 * The implementation is expected to use a provided Ptr<OutputStreamWrapper>
143 * if it is non-null. If the OutputStreamWrapper is null, the implementation
144 * is expected to use a provided prefix to construct a new file name for
145 * each net device using the rules described in the class overview.
146 *
147 * If the prefix is provided, there will be one file per Ccnx and interface pair
148 * created. In this case, adding a trace context to the file would be pointless,
149 * so the helper implementation is expected to TraceConnectWithoutContext.
150 *
151 * If the output stream object is provided, there may be many different Ccnx
152 * and interface pairs writing to a single file. In this case, the trace
153 * context could be important, so the helper implementation is expected to
154 * TraceConnect.
155 *
156 * @param stream An OutputStreamWrapper representing an existing file to use
157 * when writing trace data.
158 * @param prefix Filename prefix to use for ascii trace files.
159 * @param ccnx Ptr<Ccnx> on which you want to enable tracing.
160 * @param interface The interface on which you want to enable tracing.
161 * @param explicitFilename Treat the prefix as an explicit filename if true.
162 */
163 virtual void EnableAsciiCcnxInternal (Ptr<OutputStreamWrapper> stream,
164 std::string prefix,
165 Ptr<Ccnx> ccnx,
166 uint32_t interface,
167 bool explicitFilename) = 0;
168
169 /**
170 * @brief Enable ascii trace output on the indicated ccnx and interface pair.
171 *
172 * @param prefix Filename prefix to use for ascii files.
173 * @param ccnx Ptr<Ccnx> on which you want to enable tracing.
174 * @param interface The interface on which you want to enable tracing.
175 * @param explicitFilename Treat the prefix as an explicit filename if true.
176 */
177 void EnableAsciiCcnx (std::string prefix, Ptr<Ccnx> ccnx, uint32_t interface, bool explicitFilename = false);
178
179 /**
180 * @brief Enable ascii trace output on the indicated Ccnx and interface pair.
181 *
182 * @param stream An OutputStreamWrapper representing an existing file to use
183 * when writing trace data.
184 * @param ccnx Ptr<Ccnx> on which you want to enable tracing.
185 * @param interface The interface on which you want to enable tracing.
186 */
187 void EnableAsciiCcnx (Ptr<OutputStreamWrapper> stream, Ptr<Ccnx> ccnx, uint32_t interface);
188
189 /**
190 * @brief Enable ascii trace output the indicated ccnx and interface pair
191 * using an ccnx previously named using the ns-3 object name service.
192 *
193 * @param prefix filename prefix to use for ascii files.
194 * @param ccnxName The name of the ccnx on which you want to enable tracing.
195 * @param interface The interface on which you want to enable tracing.
196 * @param explicitFilename Treat the prefix as an explicit filename if true.
197 */
198 void EnableAsciiCcnx (std::string prefix, std::string ccnxName, uint32_t interface, bool explicitFilename = false);
199
200 /**
201 * @brief Enable ascii trace output the indicated net device using a device
202 * previously named using the ns-3 object name service.
203 *
204 * @param stream An OutputStreamWrapper representing an existing file to use
205 * when writing trace data.
206 * @param ccnxName The name of the ccnx on which you want to enable tracing.
207 * @param interface The interface on which you want to enable tracing.
208 */
209 void EnableAsciiCcnx (Ptr<OutputStreamWrapper> stream, std::string ccnxName, uint32_t interface);
210
211 /**
212 * @brief Enable ascii trace output on each Ccnx and interface pair in the
213 * container
214 *
215 * @param prefix Filename prefix to use for ascii files.
216 * @param c CcnxFaceContainer of Ccnx and interface pairs on which to
217 * enable tracing.
218 */
219 void EnableAsciiCcnx (std::string prefix, CcnxFaceContainer c);
220
221 /**
222 * @brief Enable ascii trace output on each device in the container which is
223 * of the appropriate type.
224 *
225 * @param stream An OutputStreamWrapper representing an existing file to use
226 * when writing trace data.
227 * @param c ccnxInterfaceContainer of ccnx and interface pairs on which to
228 * enable tracing.
229 */
230 void EnableAsciiCcnx (Ptr<OutputStreamWrapper> stream, CcnxFaceContainer c);
231
232 /**
233 * @brief Enable ascii trace output on all ccnx and interface pairs existing
234 * in the nodes provided in the container.
235 *
236 * \param prefix Filename prefix to use for ascii files.
237 * \param n container of nodes.
238 */
239 void EnableAsciiCcnx (std::string prefix, NodeContainer n);
240
241 /**
242 * @brief Enable ascii trace output on all ccnx and interface pairs existing
243 * in the nodes provided in the container.
244 *
245 * @param stream An OutputStreamWrapper representing an existing file to use
246 * when writing trace data.
247 * \param n container of nodes.
248 */
249 void EnableAsciiCcnx (Ptr<OutputStreamWrapper> stream, NodeContainer n);
250
251 /**
252 * @brief Enable ascii trace output on all Ccnx and interface pairs existing
253 * in the set of all nodes created in the simulation.
254 *
255 * @param prefix Filename prefix to use for ascii files.
256 */
257 void EnableAsciiCcnxAll (std::string prefix);
258
259 /**
260 * @brief Enable ascii trace output on each device (which is of the
261 * appropriate type) in the set of all nodes created in the simulation.
262 *
263 * @param stream An OutputStreamWrapper representing an existing file to use
264 * when writing trace data.
265 */
266 void EnableAsciiCcnxAll (Ptr<OutputStreamWrapper> stream);
267
268 /**
269 * @brief Enable pcap output on the Ccnx and interface pair specified by a
270 * global node-id (of a previously created node) and interface. Since there
271 * can be only one Ccnx aggregated to a node, the node-id unambiguously
272 * determines the Ccnx.
273 *
274 * @param prefix Filename prefix to use when creating ascii trace files
275 * @param nodeid The node identifier/number of the node on which to enable
276 * ascii tracing
277 * @param deviceid The device identifier/index of the device on which to enable
278 * ascii tracing
279 * @param explicitFilename Treat the prefix as an explicit filename if true
280 */
281 void EnableAsciiCcnx (std::string prefix, uint32_t nodeid, uint32_t deviceid, bool explicitFilename);
282
283 /**
284 * @brief Enable pcap output on the ccnx and interface pair specified by a
285 * global node-id (of a previously created node) and interface. Since there
286 * can be only one ccnx aggregated to a node, the node-id unambiguously
287 * determines the ccnx.
288 *
289 * @param stream An OutputStreamWrapper representing an existing file to use
290 * when writing trace data.
291 * @param nodeid The node identifier/number of the node on which to enable
292 * ascii tracing
293 * @param interface The interface on which you want to enable tracing.
294 * @param explicitFilename Treat the prefix as an explicit filename if true
295 */
296 void EnableAsciiCcnx (Ptr<OutputStreamWrapper> stream, uint32_t nodeid, uint32_t interface, bool explicitFilename);
297
298private:
299 /**
300 * @internal Avoid code duplication.
301 */
302 void EnableAsciiCcnxImpl (Ptr<OutputStreamWrapper> stream,
303 std::string prefix,
304 uint32_t nodeid,
305 uint32_t interface,
306 bool explicitFilename);
307
308 /**
309 * @internal Avoid code duplication.
310 */
311 void EnableAsciiCcnxImpl (Ptr<OutputStreamWrapper> stream, std::string prefix, NodeContainer n);
312
313 /**
314 * @internal Avoid code duplication.
315 */
316 void EnableAsciiCcnxImpl (Ptr<OutputStreamWrapper> stream, std::string prefix, CcnxFaceContainer c);
317
318 /**
319 * @internal Avoid code duplication.
320 */
321 void EnableAsciiCcnxImpl (Ptr<OutputStreamWrapper> stream,
322 std::string prefix,
323 std::string ccnxName,
324 uint32_t interface,
325 bool explicitFilename);
326
327 /**
328 * @internal Avoid code duplication.
329 */
330 void EnableAsciiCcnxImpl (Ptr<OutputStreamWrapper> stream,
331 std::string prefix,
332 Ptr<Ccnx> ccnx,
333 uint32_t interface,
334 bool explicitFilename);
335};
336
337} // namespace ns3
338
339#endif /* CCNX_TRACE_HELPER_H */