blob: 6b86e9f23b75a07603a49ca862ac53315cfefb3b [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
22 // the following should be put just before calling Simulator::Run in the scenario
23
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -070024 ndn::L3AggregateTracer::InstallAll ("aggregate-trace.txt", Seconds (1.0));
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080025
Alexander Afanasyevb1314b12012-11-21 18:23:42 -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
30
31- :ndnsim:`ndn::L3RateTracer`
32
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080033 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 -080034
35 The following example enables tracing on all simulation nodes:
36
37 .. code-block:: c++
38
39 // the following should be put just before calling Simulator::Run in the scenario
40
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -070041 ndn::L3RateTracer::InstallAll ("rate-trace.txt", Seconds (1.0));
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080042
Alexander Afanasyevb1314b12012-11-21 18:23:42 -080043 Simulator::Run ();
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080044
Alexander Afanasyev59314802012-11-26 14:56:04 -080045 ...
Alexander Afanasyevb1314b12012-11-21 18:23:42 -080046
Alexander Afanasyev27370c52013-03-12 13:54:08 -070047- :ndnsim:`L2Tracer`
48
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -070049 This tracer is similar in spirit to :ndnsim:`ndn::L3RateTracer`, but it currently traces only packet drop on layer 2 (e.g.,
50 due to transmission queue overflow).
Alexander Afanasyev27370c52013-03-12 13:54:08 -070051
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -070052 The following example enables tracing on all simulation nodes:
Alexander Afanasyev27370c52013-03-12 13:54:08 -070053
54 .. code-block:: c++
55
Alexander Afanasyev27370c52013-03-12 13:54:08 -070056 // the following should be put just before calling Simulator::Run in the scenario
57
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -070058 L2RateTracer::InstallAll ("drop-trace.txt", Seconds (0.5));
Alexander Afanasyev27370c52013-03-12 13:54:08 -070059
60 Simulator::Run ();
61
62 ...
Alexander Afanasyevb1314b12012-11-21 18:23:42 -080063
64.. note::
65
66 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 -080067 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 -080068
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080069.. _packet trace helper example:
Alexander Afanasyevb1314b12012-11-21 18:23:42 -080070
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080071Example of packet-level trace helpers
72+++++++++++++++++++++++++++++++++++++
Alexander Afanasyev59314802012-11-26 14:56:04 -080073
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080074This example (``ndn-tree-tracers.cc``) demonstrates basic usage of :ref:`trace classes`.
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080075
76In 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:
77
78.. aafig::
79 :aspect: 60
80 :scale: 120
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080081
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080082 /--------\ /--------\ /--------\ /--------\
83 |"leaf-1"| |"leaf-2"| |"leaf-3"| |"leaf-4"|
84 \--------/ \--------/ \--------/ \--------/
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080085 ^ ^ ^ ^
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080086 | | | |
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080087 \ / \ /
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080088 \ / \ / 10Mbps / 1ms
89 \ / \ /
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080090 | | | |
91 v v v v
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080092 /-------\ /-------\
93 |"rtr-1"| |"rtr-2"|
94 \-------/ \-------/
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080095 ^ ^
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080096 | |
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -080097 \ / 10 Mpbs / 1ms
98 +--------\ /--------+
99 | |
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800100 v v
101 /--------\
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800102 | "root" |
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800103 \--------/
104
105The corresponding topology file (``topo-tree.txt``):
106
107.. literalinclude:: ../../examples/topologies/topo-tree.txt
108 :language: bash
109 :linenos:
110 :lines: 1-2,27-
111
112Example simulation (``ndn-tree-tracers.cc``) scenario that utilizes trace helpers:
113
114.. literalinclude:: ../../examples/ndn-tree-tracers.cc
115 :language: c++
116 :linenos:
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -0700117 :lines: 21-28,61-
118 :emphasize-lines: 57-58
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800119
120To run this scenario, use the following command::
121
122 ./waf --run=ndn-tree-tracers
123
124The 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.
125
126For example, the following `R script <http://www.r-project.org/>`_ will build a number of nice graphs:
127
128.. image:: _static/root-rates.png
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -0700129 :alt: Interest/Data packet rates at the root node
130 :align: right
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800131
132.. image:: _static/root-5sec-counts.png
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -0700133 :alt: Interest/Data packet counts at the root node in 5-second intervals
134 :align: right
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800135
136.. literalinclude:: ../../examples/graphs/rate-graph.R
137 :language: r
138 :linenos:
139
140For 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 -0800141
Alexander Afanasyev27370c52013-03-12 13:54:08 -0700142.. _Example of packet drop tracer (L2Tracer):
143
144Example of packet drop tracer (L2Tracer)
145----------------------------------------
146
147This example (``ndn-tree-with-l2tracer.cc``) demonstrates basic usage of :ref:`trace classes`.
148
149In this scenario we will use a tree-like topology:
150
151.. image:: _static/topo-tree-25-node.png
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -0700152 :alt: 25-node tree topology
153 :width: 600px
154 :align: right
Alexander Afanasyev27370c52013-03-12 13:54:08 -0700155
156The corresponding topology file (``topo-tree-25-node.txt``):
157
158.. literalinclude:: ../../examples/topologies/topo-tree-25-node.txt
159 :language: bash
160 :linenos:
161 :lines: 2-
162
163Example simulation (``ndn-tree-with-l2tracer.cc``) scenario that utilizes trace helpers:
164
165.. literalinclude:: ../../examples/ndn-tree-with-l2tracer.cc
166 :language: c++
167 :linenos:
168 :lines: 1-
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -0700169 :emphasize-lines: 16,135
Alexander Afanasyev27370c52013-03-12 13:54:08 -0700170
171To run this scenario, use the following command::
172
173 ./waf --run=ndn-tree-with-l2tracer
174
175The 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.
176
177For example, the following `R script <http://www.r-project.org/>`_ will build a number of nice graphs:
178
179.. literalinclude:: ../../examples/graphs/drop-graph.R
180 :language: r
181 :linenos:
182
183.. image:: _static/l2-rate-tracer.png
184 :alt: Packet drop rates on routers
185
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800186.. _cs trace helper:
187
188Content store trace helper
189--------------------------
190
Alexander Afanasyevb1d6b032013-01-18 14:11:11 -0800191- :ndnsim:`ndn::CsTracer`
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800192
Alexander Afanasyevb1d6b032013-01-18 14:11:11 -0800193 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 -0800194
195 The following code enables content store tracing:
196
197 .. code-block:: c++
198
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800199 // the following should be put just before calling Simulator::Run in the scenario
200
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -0700201 ndn::CsTracer::InstallAll ("cs-trace.txt", Seconds (1));
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800202
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800203 Simulator::Run ();
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800204
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800205 ...
206
207.. - Tracing lifetime of content store entries
208
209.. Evaluate lifetime of the content store entries can be accomplished using modified version of the content stores.
210.. In particular,
211
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800212.. _cs trace helper example:
213
214Example of content store trace helper
215+++++++++++++++++++++++++++++++++++++
216
217This example (``ndn-tree-cs-tracers.cc``) demonstrates basic usage of content store tracer.
218
219In 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.
220The 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.
221
222Example simulation (``ndn-tree-cs-tracers.cc``) scenario that utilizes trace helpers:
223
224.. literalinclude:: ../../examples/ndn-tree-cs-tracers.cc
225 :language: c++
226 :linenos:
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -0700227 :lines: 21-28,61-
228 :emphasize-lines: 59
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800229
230
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800231To run this scenario, use the following command::
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800232
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800233 ./waf --run=ndn-tree-cs-tracers
234
235The 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.
236
237
238Application-level trace helper
239------------------------------
240
241- :ndnsim:`ndn::AppDelayTracer`
242
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800243 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 -0800244
245 The following code enables application-level Interest-Data delay tracing:
246
247 .. code-block:: c++
248
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800249 // the following should be put just before calling Simulator::Run in the scenario
250
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -0700251 ndn::AppDelayTracer::InstallAll ("app-delays-trace.txt");
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800252
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800253 Simulator::Run ();
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800254
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800255 ...
256
Alexander Afanasyev29dfb982013-01-18 20:04:15 -0800257 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:
258
259 +-----------------+---------------------------------------------------------------------+
260 | Column | Description |
261 +=================+=====================================================================+
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800262 | ``Time`` | simulation time when SeqNo was receivied |
263 +-----------------+---------------------------------------------------------------------+
Alexander Afanasyev29dfb982013-01-18 20:04:15 -0800264 | ``Node`` | node id, global unique |
265 +-----------------+---------------------------------------------------------------------+
266 | ``AppId`` | app id, local unique on the node, not global |
267 +-----------------+---------------------------------------------------------------------+
268 | ``SeqNo`` | seq number of the Interest-Data |
269 +-----------------+---------------------------------------------------------------------+
270 | ``Type`` | Type of delay: |
271 | | |
272 | | - ``LastDelay`` means that ``DelayS`` and ``DelayUS`` represent |
273 | | delay between last Interest sent and Data packet received |
274 | | - ``FullDelay`` means that ``DelayS`` and ``DelayUS`` represent |
275 | | delay between first Interest sent and Data packet received |
276 | | (i.e., includes time of Interest retransmissions) |
277 +-----------------+---------------------------------------------------------------------+
278 | ``DelayS`` | delay value, specified in seconds |
279 +-----------------+---------------------------------------------------------------------+
280 | ``DelayUS`` | delay value, specified in microseconds (10^-6) |
281 +-----------------+---------------------------------------------------------------------+
Alexander Afanasyev400aae12013-01-19 13:27:52 -0800282 | ``RetxCount`` | number of Interest retransmissions (for LastDelay always equal to 1)|
283 +-----------------+---------------------------------------------------------------------+
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -0800284 | ``HopCount`` | combined number of number of hops for Interest and Data packet. |
285 | | Note that HopCount is increased anytime somebody calls Send method |
286 | | on a face, including delivery of Interest/Data to application via |
287 | | an AppFace (but not from application to ndn::L3Protocol!). |
288 | | |
289 | | One consequence is that Interests satisfied by an app will have |
290 | | even hop count (min hop count = 2), and Interests satisfied from |
291 | | caches will have off hop count (min hop count = 1) |
292 +-----------------+---------------------------------------------------------------------+
Alexander Afanasyev29dfb982013-01-18 20:04:15 -0800293
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800294.. _app delay trace helper example:
295
296Example of application-level trace helper
297+++++++++++++++++++++++++++++++++++++++++
298
299This example (``ndn-tree-app-delay-tracer.cc``) demonstrates basic usage of application-level Interest-Data delay tracer.
300
Alexander Afanasyevfc8425c2013-01-31 13:33:49 -0800301In 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 -0800302
303Example simulation (``ndn-tree-app-delay-tracer.cc``) scenario that utilizes trace helpers:
304
305.. literalinclude:: ../../examples/ndn-tree-app-delay-tracer.cc
306 :language: c++
307 :linenos:
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -0700308 :lines: 21-28,61-
309 :emphasize-lines: 59
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800310
311
312To run this scenario, use the following command::
313
314 ./waf --run=ndn-tree-app-delay-tracer
315
316The 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.
317
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800318
Alexander Afanasyevb5e77d82013-04-10 15:55:26 -0700319Other types of stats
320--------------------
321
322.. _periodic tracing of Pending Interest Table (PIT) size:
323
324Periodic tracing of Pending Interest Table (PIT) size
325+++++++++++++++++++++++++++++++++++++++++++++++++++++
326
327This example (``ndn-simple-with-pit-count-stats.cc``) shows how you can periodically print out current size of PIT on the selected nodes.
328
329.. literalinclude:: ../../examples/ndn-simple-with-pit-count-stats.cc
330 :language: c++
331 :linenos:
332 :lines: 20-26,47-
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -0700333 :emphasize-lines: 9-20,43-46,59-61
Alexander Afanasyevb5e77d82013-04-10 15:55:26 -0700334
335To run this scenario, use the following command::
336
337 ./waf --run=ndn-simple-with-pit-count-stats
338