blob: 758bd3a065f08f4176ee9d6b015eecbd6ffa7502 [file] [log] [blame]
Alexander Afanasyevb1314b12012-11-21 18:23:42 -08001
2Obtaining metrics
3=================
4
5To obtain simulation results, you would need to connect to one or more `trace sources <doxygen/group___trace_source_list.html>`_ provided by ndnSIM classes.
6
Alexander Afanasyevf4a03592012-12-10 16:12:34 -08007It is also possible to use existing trace helpers, which collects and aggregates requested statistical information in text files.
8
Alexander Afanasyev59314802012-11-26 14:56:04 -08009.. _trace classes:
Alexander Afanasyevb1314b12012-11-21 18:23:42 -080010
Alexander Afanasyevf4a03592012-12-10 16:12:34 -080011Packet-level trace helpers
12--------------------------
Alexander Afanasyevb1314b12012-11-21 18:23:42 -080013
14- :ndnsim:`ndn::L3AggregateTracer`
15
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080016 Tracing the aggregate number of Interests/Data packets forwarded by an NDN node
Alexander Afanasyevb1314b12012-11-21 18:23:42 -080017
18 The following example enables tracing on all simulation nodes:
19
20 .. code-block:: c++
21
Alexander Afanasyev59314802012-11-26 14:56:04 -080022 // necessary includes
23 #include <ns3/ndnSIM/utils/tracers/ndn-l3-aggregate-tracer.h>
24
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080025 ...
Alexander Afanasyev59314802012-11-26 14:56:04 -080026
Alexander Afanasyevb1314b12012-11-21 18:23:42 -080027 // the following should be put just before calling Simulator::Run in the scenario
28
Alexander Afanasyev59314802012-11-26 14:56:04 -080029 boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<ndn::L3AggregateTracer> > >
30 aggTracers = ndn::L3AggregateTracer::InstallAll ("aggregate-trace.txt", Seconds (1.0));
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080031
Alexander Afanasyevb1314b12012-11-21 18:23:42 -080032 Simulator::Run ();
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080033
Alexander Afanasyev59314802012-11-26 14:56:04 -080034 ...
Alexander Afanasyevb1314b12012-11-21 18:23:42 -080035
36
37- :ndnsim:`ndn::L3RateTracer`
38
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080039 Tracing the rate in bytes and in number of packets of Interest/Data packets forwarded by an NDN node
Alexander Afanasyevb1314b12012-11-21 18:23:42 -080040
41 The following example enables tracing on all simulation nodes:
42
43 .. code-block:: c++
44
Alexander Afanasyev59314802012-11-26 14:56:04 -080045 // necessary includes
46 #include <ns3/ndnSIM/utils/tracers/ndn-l3-rate-tracer.h>
47
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080048 ...
Alexander Afanasyev59314802012-11-26 14:56:04 -080049
Alexander Afanasyevb1314b12012-11-21 18:23:42 -080050 // the following should be put just before calling Simulator::Run in the scenario
51
Alexander Afanasyev59314802012-11-26 14:56:04 -080052 boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<ndn::L3RateTracer> > >
53 rateTracers = ndn::L3RateTracer::InstallAll ("rate-trace.txt", Seconds (1.0));
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080054
Alexander Afanasyevb1314b12012-11-21 18:23:42 -080055 Simulator::Run ();
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080056
Alexander Afanasyev59314802012-11-26 14:56:04 -080057 ...
Alexander Afanasyevb1314b12012-11-21 18:23:42 -080058
Alexander Afanasyev27370c52013-03-12 13:54:08 -070059- :ndnsim:`L2Tracer`
60
61 This tracer is similar in spirit to :ndnsim:`ndn::L3RateTracer`, but it currently traces only packet drop on layer 2 (e.g.,
62 due to transmission queue overflow).
63
64 The following example enables tracing on all simulation nodes:
65
66 .. code-block:: c++
67
68 // necessary includes
69 #include <ns3/ndnSIM/utils/tracers/l2-rate-tracer.h>
70
71 ...
72
73 // the following should be put just before calling Simulator::Run in the scenario
74
75 boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<L2RateTracer> > >
76 l2tracers = L2RateTracer::InstallAll ("drop-trace.txt", Seconds (0.5));
77
78 Simulator::Run ();
79
80 ...
Alexander Afanasyevb1314b12012-11-21 18:23:42 -080081
82.. note::
83
84 A number of other tracers are available in ``plugins/tracers-broken`` folder, but they do not yet work with the current code.
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080085 Eventually, we will port most of them to the current code, but it is not our main priority at the moment and would really appreciate help with writing new tracers and porting the old ones.
Alexander Afanasyevb1314b12012-11-21 18:23:42 -080086
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080087.. _packet trace helper example:
Alexander Afanasyevb1314b12012-11-21 18:23:42 -080088
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080089Example of packet-level trace helpers
90+++++++++++++++++++++++++++++++++++++
Alexander Afanasyev59314802012-11-26 14:56:04 -080091
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080092This example (``ndn-tree-tracers.cc``) demonstrates basic usage of :ref:`trace classes`.
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080093
94In this scenario we will use a tree-like topology, where consumers are installed on leaf nodes and producer is in the root of the tree:
95
96.. aafig::
97 :aspect: 60
98 :scale: 120
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080099
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800100 /--------\ /--------\ /--------\ /--------\
101 |"leaf-1"| |"leaf-2"| |"leaf-3"| |"leaf-4"|
102 \--------/ \--------/ \--------/ \--------/
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800103 ^ ^ ^ ^
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800104 | | | |
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800105 \ / \ /
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800106 \ / \ / 10Mbps / 1ms
107 \ / \ /
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800108 | | | |
109 v v v v
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800110 /-------\ /-------\
111 |"rtr-1"| |"rtr-2"|
112 \-------/ \-------/
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800113 ^ ^
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800114 | |
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800115 \ / 10 Mpbs / 1ms
116 +--------\ /--------+
117 | |
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800118 v v
119 /--------\
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800120 | "root" |
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800121 \--------/
122
123The corresponding topology file (``topo-tree.txt``):
124
125.. literalinclude:: ../../examples/topologies/topo-tree.txt
126 :language: bash
127 :linenos:
128 :lines: 1-2,27-
129
130Example simulation (``ndn-tree-tracers.cc``) scenario that utilizes trace helpers:
131
132.. literalinclude:: ../../examples/ndn-tree-tracers.cc
133 :language: c++
134 :linenos:
135 :lines: 21-34,67-
136 :emphasize-lines: 7-11,63-67
137
138
139To run this scenario, use the following command::
140
141 ./waf --run=ndn-tree-tracers
142
143The successful run will create ``rate-trace.txt`` and ``aggregate-trace.txt`` files in the current directly, which can be analyzed manually or used as input to some graph/stats packages.
144
145For example, the following `R script <http://www.r-project.org/>`_ will build a number of nice graphs:
146
147.. image:: _static/root-rates.png
148 :alt: Interest/Data packet rates at the root node
149 :align: right
150
151.. image:: _static/root-5sec-counts.png
152 :alt: Interest/Data packet counts at the root node in 5-second intervals
153 :align: right
154
155.. literalinclude:: ../../examples/graphs/rate-graph.R
156 :language: r
157 :linenos:
158
159For more information about R and ggplot2, please refer to `R language manual <http://cran.r-project.org/manuals.html>`_, `ggplot2 module manual <http://docs.ggplot2.org/current/>`_.
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800160
Alexander Afanasyev27370c52013-03-12 13:54:08 -0700161.. _Example of packet drop tracer (L2Tracer):
162
163Example of packet drop tracer (L2Tracer)
164----------------------------------------
165
166This example (``ndn-tree-with-l2tracer.cc``) demonstrates basic usage of :ref:`trace classes`.
167
168In this scenario we will use a tree-like topology:
169
170.. image:: _static/topo-tree-25-node.png
171 :alt: 25-node tree topology
172
173The corresponding topology file (``topo-tree-25-node.txt``):
174
175.. literalinclude:: ../../examples/topologies/topo-tree-25-node.txt
176 :language: bash
177 :linenos:
178 :lines: 2-
179
180Example simulation (``ndn-tree-with-l2tracer.cc``) scenario that utilizes trace helpers:
181
182.. literalinclude:: ../../examples/ndn-tree-with-l2tracer.cc
183 :language: c++
184 :linenos:
185 :lines: 1-
186 :emphasize-lines: 7-8,19,135-139
187
188To run this scenario, use the following command::
189
190 ./waf --run=ndn-tree-with-l2tracer
191
192The successful run will create ``drop-trace.txt`` file in the current directly, which can be analyzed manually or used as input to some graph/stats packages.
193
194For example, the following `R script <http://www.r-project.org/>`_ will build a number of nice graphs:
195
196.. literalinclude:: ../../examples/graphs/drop-graph.R
197 :language: r
198 :linenos:
199
200.. image:: _static/l2-rate-tracer.png
201 :alt: Packet drop rates on routers
202
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800203.. _cs trace helper:
204
205Content store trace helper
206--------------------------
207
Alexander Afanasyevb1d6b032013-01-18 14:11:11 -0800208- :ndnsim:`ndn::CsTracer`
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800209
Alexander Afanasyevb1d6b032013-01-18 14:11:11 -0800210 With the use of :ndnsim:`ndn::CsTracer` it is possible to obtain statistics of cache hits/cache misses on simulation nodes.
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800211
212 The following code enables content store tracing:
213
214 .. code-block:: c++
215
216 // necessary includes
Alexander Afanasyevb1d6b032013-01-18 14:11:11 -0800217 #include <ns3/ndnSIM/utils/tracers/ndn-cs-tracer.h>
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800218
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800219 ...
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800220
221 // Select implementation of content store. By default, the following is applied:
222 // ndnHelper.SetContentStore ("ns3::ndn::cs::Stats::Lru", "MaxSize", "100");
223
224 // the following should be put just before calling Simulator::Run in the scenario
225
Alexander Afanasyevb1d6b032013-01-18 14:11:11 -0800226 boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<ndn::CsTracer> > >
227 aggTracers = ndn::CsTracer::InstallAll ("cs-trace.txt", Seconds (1));
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800228
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800229 Simulator::Run ();
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800230
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800231 ...
232
233.. - Tracing lifetime of content store entries
234
235.. Evaluate lifetime of the content store entries can be accomplished using modified version of the content stores.
236.. In particular,
237
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800238.. _cs trace helper example:
239
240Example of content store trace helper
241+++++++++++++++++++++++++++++++++++++
242
243This example (``ndn-tree-cs-tracers.cc``) demonstrates basic usage of content store tracer.
244
245In this scenario we will use the same tree-like topology as in :ref:`previous example <packet trace helper example>`, where consumers are installed on leaf nodes and producer is in the root of the tree.
246The main difference is that each client request data from the same namespace: /root/1, /root/2, ... Another small difference is that in this scenario we start our application not at the same time, but 10 ms apart.
247
248Example simulation (``ndn-tree-cs-tracers.cc``) scenario that utilizes trace helpers:
249
250.. literalinclude:: ../../examples/ndn-tree-cs-tracers.cc
251 :language: c++
252 :linenos:
253 :lines: 21-31,64-
254 :emphasize-lines: 7-11,25,43,45,62-63
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800255
256
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800257To run this scenario, use the following command::
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800258
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800259 ./waf --run=ndn-tree-cs-tracers
260
261The successful run will create ``cs-trace.txt``, which similarly to trace file from the :ref:`tracing example <packet trace helper example>` can be analyzed manually or used as input to some graph/stats packages.
262
263
264Application-level trace helper
265------------------------------
266
267- :ndnsim:`ndn::AppDelayTracer`
268
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800269 With the use of :ndnsim:`ndn::AppDelayTracer` it is possible to obtain data about for delays between issuing Interest and receiving corresponding Data packet.
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800270
271 The following code enables application-level Interest-Data delay tracing:
272
273 .. code-block:: c++
274
275 // necessary includes
276 #include <ns3/ndnSIM/utils/tracers/ndn-app-delay-tracer.h>
277
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800278 ...
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800279
280 // the following should be put just before calling Simulator::Run in the scenario
281
282 boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<ndn::AppDelayTracer> > >
283 tracers = ndn::AppDelayTracer::InstallAll ("app-delays-trace.txt");
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800284
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800285 Simulator::Run ();
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800286
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800287 ...
288
Alexander Afanasyev29dfb982013-01-18 20:04:15 -0800289 Output file format is tab-separated values, with first row specifying names of the columns. Refer to the following table for the description of the columns:
290
291 +-----------------+---------------------------------------------------------------------+
292 | Column | Description |
293 +=================+=====================================================================+
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800294 | ``Time`` | simulation time when SeqNo was receivied |
295 +-----------------+---------------------------------------------------------------------+
Alexander Afanasyev29dfb982013-01-18 20:04:15 -0800296 | ``Node`` | node id, global unique |
297 +-----------------+---------------------------------------------------------------------+
298 | ``AppId`` | app id, local unique on the node, not global |
299 +-----------------+---------------------------------------------------------------------+
300 | ``SeqNo`` | seq number of the Interest-Data |
301 +-----------------+---------------------------------------------------------------------+
302 | ``Type`` | Type of delay: |
303 | | |
304 | | - ``LastDelay`` means that ``DelayS`` and ``DelayUS`` represent |
305 | | delay between last Interest sent and Data packet received |
306 | | - ``FullDelay`` means that ``DelayS`` and ``DelayUS`` represent |
307 | | delay between first Interest sent and Data packet received |
308 | | (i.e., includes time of Interest retransmissions) |
309 +-----------------+---------------------------------------------------------------------+
310 | ``DelayS`` | delay value, specified in seconds |
311 +-----------------+---------------------------------------------------------------------+
312 | ``DelayUS`` | delay value, specified in microseconds (10^-6) |
313 +-----------------+---------------------------------------------------------------------+
Alexander Afanasyev400aae12013-01-19 13:27:52 -0800314 | ``RetxCount`` | number of Interest retransmissions (for LastDelay always equal to 1)|
315 +-----------------+---------------------------------------------------------------------+
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -0800316 | ``HopCount`` | combined number of number of hops for Interest and Data packet. |
317 | | Note that HopCount is increased anytime somebody calls Send method |
318 | | on a face, including delivery of Interest/Data to application via |
319 | | an AppFace (but not from application to ndn::L3Protocol!). |
320 | | |
321 | | One consequence is that Interests satisfied by an app will have |
322 | | even hop count (min hop count = 2), and Interests satisfied from |
323 | | caches will have off hop count (min hop count = 1) |
324 +-----------------+---------------------------------------------------------------------+
Alexander Afanasyev29dfb982013-01-18 20:04:15 -0800325
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800326.. _app delay trace helper example:
327
328Example of application-level trace helper
329+++++++++++++++++++++++++++++++++++++++++
330
331This example (``ndn-tree-app-delay-tracer.cc``) demonstrates basic usage of application-level Interest-Data delay tracer.
332
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800333In this scenario we will use the same tree-like topology as in :ref:`packet trace helper example <packet trace helper example>`, where consumers are installed on leaf nodes and producer is in the root of the tree and clients request data from the same namespace: /root/1, /root/2, ...
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800334
335Example simulation (``ndn-tree-app-delay-tracer.cc``) scenario that utilizes trace helpers:
336
337.. literalinclude:: ../../examples/ndn-tree-app-delay-tracer.cc
338 :language: c++
339 :linenos:
340 :lines: 21-31,64-
341 :emphasize-lines: 7-8,61-62
342
343
344To run this scenario, use the following command::
345
346 ./waf --run=ndn-tree-app-delay-tracer
347
348The successful run will create ``app-delays-trace.txt``, which similarly to trace file from the :ref:`packet trace helper example <packet trace helper example>` can be analyzed manually or used as input to some graph/stats packages.
349
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800350