blob: 2476d4380c5d7ca16bbb9b3fc30f335bfe8a5dc0 [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
Alexander Afanasyevb1314b12012-11-21 18:23:42 -080014- :ndnsim:`ndn::L3RateTracer`
15
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080016 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 -080017
18 The following example enables tracing on all simulation nodes:
19
20 .. code-block:: c++
21
22 // the following should be put just before calling Simulator::Run in the scenario
23
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080024 L3RateTracer::InstallAll("rate-trace.txt", Seconds(1.0));
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080025
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080026 Simulator::Run();
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080027
Alexander Afanasyev59314802012-11-26 14:56:04 -080028 ...
Alexander Afanasyevb1314b12012-11-21 18:23:42 -080029
Alexander Afanasyev45977412014-03-11 13:21:46 -070030 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:
31
32 +------------------+---------------------------------------------------------------------+
33 | Column | Description |
34 +==================+=====================================================================+
35 | ``Time`` | simulation time |
36 +------------------+---------------------------------------------------------------------+
37 | ``Node`` | node id, globally unique |
38 +------------------+---------------------------------------------------------------------+
39 | ``FaceId`` | interface ID (-1 for combined metric) |
40 +------------------+---------------------------------------------------------------------+
41 | ``Type`` | Type of measurements: |
42 | | |
43 | | - ``InInterests`` measurements of incoming Interests |
44 | | - ``OutInterests`` measurements of outgoing Interests |
Alexander Afanasyev45977412014-03-11 13:21:46 -070045 | | - ``InData`` measurements of incoming Data |
46 | | - ``OutData`` measurements of outgoing Data |
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080047 | | - ``SatisfiedInterests`` measurements of satisfied Interests |
48 | | (totals for all faces) |
49 | | - ``TimedOutInterests`` measurements of timed out Interests |
50 | | (totals for all faces) |
Alexander Afanasyev45977412014-03-11 13:21:46 -070051 | | - ``InSatisfiedInterests`` measurements of incoming satisfied |
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080052 | | Interests (per incoming face) |
Alexander Afanasyev45977412014-03-11 13:21:46 -070053 | | - ``InTimedOutInterests`` measurements of incoming timed out |
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080054 | | Interests (per incoming face) |
Alexander Afanasyev45977412014-03-11 13:21:46 -070055 | | - ``OutSatisfiedInterests`` measurements of outgoing satisfied |
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080056 | | Interests (per outgoing face) |
Alexander Afanasyev45977412014-03-11 13:21:46 -070057 | | - ``OutTimedOutInterests`` measurements of outgoing satisfied |
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080058 | | Interests (per outgoing face) |
Alexander Afanasyev45977412014-03-11 13:21:46 -070059 +------------------+---------------------------------------------------------------------+
60 | ``Packets`` | estimated rate (EWMA average) of packets within the last averaging |
61 | | period (number of packets/s). |
62 +------------------+---------------------------------------------------------------------+
63 | ``Kilobytes`` | estimated rate (EWMA average) within last averaging |
64 | | period (kilobytes/s) |
65 +------------------+---------------------------------------------------------------------+
66 | ``PacketsRaw`` | absolute number of packets within last averaging period |
67 | | (number of packets). |
68 +------------------+---------------------------------------------------------------------+
69 | ``KilobytesRaw`` | absolute number of kilobytes transferred within the last averaging |
70 | | period (number of packets). |
71 +------------------+---------------------------------------------------------------------+
72
Alexander Afanasyev27370c52013-03-12 13:54:08 -070073- :ndnsim:`L2Tracer`
Alexander Afanasyevfc9d9e12013-08-10 14:17:49 -070074
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -070075 This tracer is similar in spirit to :ndnsim:`ndn::L3RateTracer`, but it currently traces only packet drop on layer 2 (e.g.,
76 due to transmission queue overflow).
Alexander Afanasyev27370c52013-03-12 13:54:08 -070077
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -070078 The following example enables tracing on all simulation nodes:
Alexander Afanasyev27370c52013-03-12 13:54:08 -070079
80 .. code-block:: c++
81
Alexander Afanasyev27370c52013-03-12 13:54:08 -070082 // the following should be put just before calling Simulator::Run in the scenario
83
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080084 L2RateTracer::InstallAll("drop-trace.txt", Seconds(0.5));
Alexander Afanasyev27370c52013-03-12 13:54:08 -070085
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080086 Simulator::Run();
Alexander Afanasyev27370c52013-03-12 13:54:08 -070087
88 ...
Alexander Afanasyevb1314b12012-11-21 18:23:42 -080089
Alexander Afanasyev45977412014-03-11 13:21:46 -070090 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:
91
92 +------------------+---------------------------------------------------------------------+
93 | Column | Description |
94 +==================+=====================================================================+
95 | ``Time`` | simulation time |
96 +------------------+---------------------------------------------------------------------+
97 | ``Node`` | node id, globally unique |
98 +------------------+---------------------------------------------------------------------+
99 | ``Interface`` | interface name (currently only "combined") |
100 +------------------+---------------------------------------------------------------------+
101 | ``Type`` | Type of measurements: |
102 | | |
103 | | - ``Drop`` measurements of dropped packets |
104 +------------------+---------------------------------------------------------------------+
105 | ``Packets`` | estimated rate (EWMA average) of packets within the last averaging |
106 | | period (number of packets/s). |
107 +------------------+---------------------------------------------------------------------+
108 | ``Kilobytes`` | estimated rate (EWMA average) within last averaging |
109 | | period (kilobytes/s) |
110 +------------------+---------------------------------------------------------------------+
111 | ``PacketsRaw`` | absolute number of packets within last averaging period |
112 | | (number of packets). |
113 +------------------+---------------------------------------------------------------------+
114 | ``KilobytesRaw`` | absolute number of kilobytes transferred within the last averaging |
115 | | period (number of packets). |
116 +------------------+---------------------------------------------------------------------+
117
Alexander Afanasyevb1314b12012-11-21 18:23:42 -0800118.. note::
119
120 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 -0800121 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 -0800122
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800123.. _packet trace helper example:
Alexander Afanasyevb1314b12012-11-21 18:23:42 -0800124
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800125Example of packet-level trace helpers
126+++++++++++++++++++++++++++++++++++++
Alexander Afanasyev59314802012-11-26 14:56:04 -0800127
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800128This example (``ndn-tree-tracers.cpp``) demonstrates basic usage of :ref:`trace classes`.
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800129
130In 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:
131
Alexander Afanasyevfc9d9e12013-08-10 14:17:49 -0700132.. sidebar:: Topology
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800133
Alexander Afanasyevfc9d9e12013-08-10 14:17:49 -0700134 .. aafig::
135 :aspect: 60
136 :scale: 100
137
138 /--------\ /--------\ /--------\ /--------\
139 |"leaf-1"| |"leaf-2"| |"leaf-3"| |"leaf-4"|
140 \--------/ \--------/ \--------/ \--------/
141 ^ ^ ^ ^
142 | | | |
143 \ / \ /
144 \ / \ / 10Mbps / 1ms
145 \ / \ /
146 | | | |
147 v v v v
148 /-------\ /-------\
149 |"rtr-1"| |"rtr-2"|
150 \-------/ \-------/
151 ^ ^
152 | |
153 \ / 10 Mpbs / 1ms
154 +--------\ /--------+
155 | |
156 v v
157 /--------\
158 | "root" |
159 \--------/
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800160
161The corresponding topology file (``topo-tree.txt``):
162
163.. literalinclude:: ../../examples/topologies/topo-tree.txt
164 :language: bash
165 :linenos:
166 :lines: 1-2,27-
167
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800168Example simulation (``ndn-tree-tracers.cpp``) scenario that utilizes trace helpers:
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800169
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800170.. literalinclude:: ../../examples/ndn-tree-tracers.cpp
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800171 :language: c++
172 :linenos:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800173 :lines: 20-27,60-
174 :emphasize-lines: 58
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800175
176To run this scenario, use the following command::
177
178 ./waf --run=ndn-tree-tracers
179
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800180The successful run will create ``rate-trace.txt`` files in the current directly, which can be analyzed manually or used as input to some graph/stats packages.
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800181
Alexander Afanasyevfc9d9e12013-08-10 14:17:49 -0700182.. sidebar:: Graph build using the `R script <http://www.r-project.org/>`_
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800183
Alexander Afanasyevfc9d9e12013-08-10 14:17:49 -0700184 .. image:: _static/root-rates.png
185 :alt: Interest/Data packet rates at the root node
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800186
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800187.. literalinclude:: ../../examples/graphs/rate-graph.R
188 :language: r
189 :linenos:
190
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800191For more information about R and ggplot2, please refer to `R language manual <http://cran.r-project.org/manuals.html>`_ and `ggplot2 module manual <http://docs.ggplot2.org/current/>`_.
192
193 ::
194
195 Rscript src/ndnSIM/examples/graphs/rate-graph.R
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800196
Alexander Afanasyev27370c52013-03-12 13:54:08 -0700197.. _Example of packet drop tracer (L2Tracer):
198
199Example of packet drop tracer (L2Tracer)
200----------------------------------------
201
Alexander Afanasyevfc9d9e12013-08-10 14:17:49 -0700202.. sidebar:: Topology
203
204 .. image:: _static/topo-tree-25-node.png
205 :alt: 25-node tree topology
206 :width: 550px
207
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800208This example (``ndn-tree-with-l2tracer.cpp``) demonstrates basic usage of :ref:`trace classes`.
Alexander Afanasyev27370c52013-03-12 13:54:08 -0700209
Alexander Afanasyev27370c52013-03-12 13:54:08 -0700210The corresponding topology file (``topo-tree-25-node.txt``):
211
212.. literalinclude:: ../../examples/topologies/topo-tree-25-node.txt
213 :language: bash
214 :linenos:
215 :lines: 2-
216
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800217Example simulation (``ndn-tree-with-l2tracer.cpp``) scenario that utilizes trace helpers:
Alexander Afanasyev27370c52013-03-12 13:54:08 -0700218
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800219.. literalinclude:: ../../examples/ndn-tree-with-l2tracer.cpp
Alexander Afanasyev27370c52013-03-12 13:54:08 -0700220 :language: c++
221 :linenos:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800222 :lines: 20-
223 :emphasize-lines: 16,134
Alexander Afanasyev27370c52013-03-12 13:54:08 -0700224
225To run this scenario, use the following command::
226
227 ./waf --run=ndn-tree-with-l2tracer
228
229The 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.
230
231For example, the following `R script <http://www.r-project.org/>`_ will build a number of nice graphs:
232
233.. literalinclude:: ../../examples/graphs/drop-graph.R
234 :language: r
235 :linenos:
236
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800237Run R script::
238
239 Rscript src/ndnSIM/examples/graphs/drop-graph.R
240
Alexander Afanasyev27370c52013-03-12 13:54:08 -0700241.. image:: _static/l2-rate-tracer.png
242 :alt: Packet drop rates on routers
243
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800244.. _cs trace helper:
245
246Content store trace helper
247--------------------------
248
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800249NOTE: This tracer works ONLY when the content store structure of ndnSIM is used!
250
Alexander Afanasyevb1d6b032013-01-18 14:11:11 -0800251- :ndnsim:`ndn::CsTracer`
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800252
Alexander Afanasyevb1d6b032013-01-18 14:11:11 -0800253 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 -0800254
255 The following code enables content store tracing:
256
257 .. code-block:: c++
258
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800259 // the following should be put just before calling Simulator::Run in the scenario
260
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800261 CsTracer::InstallAll("cs-trace.txt", Seconds(1));
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800262
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800263 Simulator::Run();
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800264
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800265 ...
266
267.. - Tracing lifetime of content store entries
268
269.. Evaluate lifetime of the content store entries can be accomplished using modified version of the content stores.
270.. In particular,
271
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800272.. _cs trace helper example:
273
274Example of content store trace helper
275+++++++++++++++++++++++++++++++++++++
276
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800277This example (``ndn-tree-cs-tracers.cpp``) demonstrates basic usage of content store tracer.
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800278
279In 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.
280The 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.
281
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800282Example simulation (``ndn-tree-cs-tracers.cpp``) scenario that utilizes trace helpers:
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800283
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800284.. literalinclude:: ../../examples/ndn-tree-cs-tracers.cpp
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800285 :language: c++
286 :linenos:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800287 :lines: 20-27,60-
288 :emphasize-lines: 61
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800289
290
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800291To run this scenario, use the following command::
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800292
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800293 ./waf --run=ndn-tree-cs-tracers
294
295The 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.
296
297
298Application-level trace helper
299------------------------------
300
301- :ndnsim:`ndn::AppDelayTracer`
302
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800303 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 -0800304
305 The following code enables application-level Interest-Data delay tracing:
306
307 .. code-block:: c++
308
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800309 // the following should be put just before calling Simulator::Run in the scenario
310
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800311 AppDelayTracer::InstallAll("app-delays-trace.txt");
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800312
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800313 Simulator::Run();
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800314
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800315 ...
316
Alexander Afanasyev29dfb982013-01-18 20:04:15 -0800317 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:
318
319 +-----------------+---------------------------------------------------------------------+
320 | Column | Description |
321 +=================+=====================================================================+
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800322 | ``Time`` | simulation time when SeqNo was receivied |
323 +-----------------+---------------------------------------------------------------------+
Alexander Afanasyev29dfb982013-01-18 20:04:15 -0800324 | ``Node`` | node id, global unique |
325 +-----------------+---------------------------------------------------------------------+
326 | ``AppId`` | app id, local unique on the node, not global |
327 +-----------------+---------------------------------------------------------------------+
328 | ``SeqNo`` | seq number of the Interest-Data |
329 +-----------------+---------------------------------------------------------------------+
330 | ``Type`` | Type of delay: |
331 | | |
332 | | - ``LastDelay`` means that ``DelayS`` and ``DelayUS`` represent |
333 | | delay between last Interest sent and Data packet received |
334 | | - ``FullDelay`` means that ``DelayS`` and ``DelayUS`` represent |
335 | | delay between first Interest sent and Data packet received |
336 | | (i.e., includes time of Interest retransmissions) |
337 +-----------------+---------------------------------------------------------------------+
338 | ``DelayS`` | delay value, specified in seconds |
339 +-----------------+---------------------------------------------------------------------+
340 | ``DelayUS`` | delay value, specified in microseconds (10^-6) |
341 +-----------------+---------------------------------------------------------------------+
Alexander Afanasyev400aae12013-01-19 13:27:52 -0800342 | ``RetxCount`` | number of Interest retransmissions (for LastDelay always equal to 1)|
343 +-----------------+---------------------------------------------------------------------+
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800344 | ``HopCount`` | the number of hops that the retrieved Data packet traveled on the |
345 | | way back from producer application or cache. |
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -0800346 +-----------------+---------------------------------------------------------------------+
Alexander Afanasyev29dfb982013-01-18 20:04:15 -0800347
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800348.. _app delay trace helper example:
349
350Example of application-level trace helper
351+++++++++++++++++++++++++++++++++++++++++
352
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800353This example (``ndn-tree-app-delay-tracer.cpp``) demonstrates basic usage of application-level Interest-Data delay tracer.
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800354
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800355In 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 -0800356
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800357Example simulation (``ndn-tree-app-delay-tracer.cpp``) scenario that utilizes trace helpers:
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800358
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800359.. literalinclude:: ../../examples/ndn-tree-app-delay-tracer.cpp
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800360 :language: c++
361 :linenos:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800362 :lines: 20-27,60-
363 :emphasize-lines: 60
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800364
365To run this scenario, use the following command::
366
367 ./waf --run=ndn-tree-app-delay-tracer
368
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800369The successful run will create ``app-delays-trace.txt``, which similarly to trace file from the
370:ref:`packet trace helper example <packet trace helper example>` can be analyzed manually or used as
371input to some graph/stats packages.