Alexander Afanasyev | b1314b1 | 2012-11-21 18:23:42 -0800 | [diff] [blame] | 1 | |
| 2 | Obtaining metrics |
| 3 | ================= |
| 4 | |
| 5 | To 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 Afanasyev | f4a0359 | 2012-12-10 16:12:34 -0800 | [diff] [blame] | 7 | It is also possible to use existing trace helpers, which collects and aggregates requested statistical information in text files. |
| 8 | |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 9 | .. _trace classes: |
Alexander Afanasyev | b1314b1 | 2012-11-21 18:23:42 -0800 | [diff] [blame] | 10 | |
Alexander Afanasyev | f4a0359 | 2012-12-10 16:12:34 -0800 | [diff] [blame] | 11 | Packet-level trace helpers |
| 12 | -------------------------- |
Alexander Afanasyev | b1314b1 | 2012-11-21 18:23:42 -0800 | [diff] [blame] | 13 | |
| 14 | - :ndnsim:`ndn::L3AggregateTracer` |
| 15 | |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 16 | Tracing the aggregate number of Interests/Data packets forwarded by an NDN node |
Alexander Afanasyev | b1314b1 | 2012-11-21 18:23:42 -0800 | [diff] [blame] | 17 | |
| 18 | The following example enables tracing on all simulation nodes: |
| 19 | |
| 20 | .. code-block:: c++ |
| 21 | |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 22 | // necessary includes |
| 23 | #include <ns3/ndnSIM/utils/tracers/ndn-l3-aggregate-tracer.h> |
| 24 | |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 25 | ... |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 26 | |
Alexander Afanasyev | b1314b1 | 2012-11-21 18:23:42 -0800 | [diff] [blame] | 27 | // the following should be put just before calling Simulator::Run in the scenario |
| 28 | |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 29 | boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<ndn::L3AggregateTracer> > > |
| 30 | aggTracers = ndn::L3AggregateTracer::InstallAll ("aggregate-trace.txt", Seconds (1.0)); |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 31 | |
Alexander Afanasyev | b1314b1 | 2012-11-21 18:23:42 -0800 | [diff] [blame] | 32 | Simulator::Run (); |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 33 | |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 34 | ... |
Alexander Afanasyev | b1314b1 | 2012-11-21 18:23:42 -0800 | [diff] [blame] | 35 | |
| 36 | |
| 37 | - :ndnsim:`ndn::L3RateTracer` |
| 38 | |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 39 | Tracing the rate in bytes and in number of packets of Interest/Data packets forwarded by an NDN node |
Alexander Afanasyev | b1314b1 | 2012-11-21 18:23:42 -0800 | [diff] [blame] | 40 | |
| 41 | The following example enables tracing on all simulation nodes: |
| 42 | |
| 43 | .. code-block:: c++ |
| 44 | |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 45 | // necessary includes |
| 46 | #include <ns3/ndnSIM/utils/tracers/ndn-l3-rate-tracer.h> |
| 47 | |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 48 | ... |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 49 | |
Alexander Afanasyev | b1314b1 | 2012-11-21 18:23:42 -0800 | [diff] [blame] | 50 | // the following should be put just before calling Simulator::Run in the scenario |
| 51 | |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 52 | boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<ndn::L3RateTracer> > > |
| 53 | rateTracers = ndn::L3RateTracer::InstallAll ("rate-trace.txt", Seconds (1.0)); |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 54 | |
Alexander Afanasyev | b1314b1 | 2012-11-21 18:23:42 -0800 | [diff] [blame] | 55 | Simulator::Run (); |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 56 | |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 57 | ... |
Alexander Afanasyev | b1314b1 | 2012-11-21 18:23:42 -0800 | [diff] [blame] | 58 | |
| 59 | |
| 60 | .. note:: |
| 61 | |
| 62 | A number of other tracers are available in ``plugins/tracers-broken`` folder, but they do not yet work with the current code. |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 63 | 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 Afanasyev | b1314b1 | 2012-11-21 18:23:42 -0800 | [diff] [blame] | 64 | |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 65 | .. _packet trace helper example: |
Alexander Afanasyev | b1314b1 | 2012-11-21 18:23:42 -0800 | [diff] [blame] | 66 | |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 67 | Example of packet-level trace helpers |
| 68 | +++++++++++++++++++++++++++++++++++++ |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 69 | |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 70 | This example (``ndn-tree-tracers.cc``) demonstrates basic usage of :ref:`trace classes`. |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 71 | |
| 72 | In 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: |
| 73 | |
| 74 | .. aafig:: |
| 75 | :aspect: 60 |
| 76 | :scale: 120 |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 77 | |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 78 | /--------\ /--------\ /--------\ /--------\ |
| 79 | |"leaf-1"| |"leaf-2"| |"leaf-3"| |"leaf-4"| |
| 80 | \--------/ \--------/ \--------/ \--------/ |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 81 | ^ ^ ^ ^ |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 82 | | | | | |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 83 | \ / \ / |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 84 | \ / \ / 10Mbps / 1ms |
| 85 | \ / \ / |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 86 | | | | | |
| 87 | v v v v |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 88 | /-------\ /-------\ |
| 89 | |"rtr-1"| |"rtr-2"| |
| 90 | \-------/ \-------/ |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 91 | ^ ^ |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 92 | | | |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 93 | \ / 10 Mpbs / 1ms |
| 94 | +--------\ /--------+ |
| 95 | | | |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 96 | v v |
| 97 | /--------\ |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 98 | | "root" | |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 99 | \--------/ |
| 100 | |
| 101 | The corresponding topology file (``topo-tree.txt``): |
| 102 | |
| 103 | .. literalinclude:: ../../examples/topologies/topo-tree.txt |
| 104 | :language: bash |
| 105 | :linenos: |
| 106 | :lines: 1-2,27- |
| 107 | |
| 108 | Example simulation (``ndn-tree-tracers.cc``) scenario that utilizes trace helpers: |
| 109 | |
| 110 | .. literalinclude:: ../../examples/ndn-tree-tracers.cc |
| 111 | :language: c++ |
| 112 | :linenos: |
| 113 | :lines: 21-34,67- |
| 114 | :emphasize-lines: 7-11,63-67 |
| 115 | |
| 116 | |
| 117 | To run this scenario, use the following command:: |
| 118 | |
| 119 | ./waf --run=ndn-tree-tracers |
| 120 | |
| 121 | The 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. |
| 122 | |
| 123 | For example, the following `R script <http://www.r-project.org/>`_ will build a number of nice graphs: |
| 124 | |
| 125 | .. image:: _static/root-rates.png |
| 126 | :alt: Interest/Data packet rates at the root node |
| 127 | :align: right |
| 128 | |
| 129 | .. image:: _static/root-5sec-counts.png |
| 130 | :alt: Interest/Data packet counts at the root node in 5-second intervals |
| 131 | :align: right |
| 132 | |
| 133 | .. literalinclude:: ../../examples/graphs/rate-graph.R |
| 134 | :language: r |
| 135 | :linenos: |
| 136 | |
| 137 | For 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 Afanasyev | f4a0359 | 2012-12-10 16:12:34 -0800 | [diff] [blame] | 138 | |
| 139 | .. _cs trace helper: |
| 140 | |
| 141 | Content store trace helper |
| 142 | -------------------------- |
| 143 | |
Alexander Afanasyev | b1d6b03 | 2013-01-18 14:11:11 -0800 | [diff] [blame] | 144 | - :ndnsim:`ndn::CsTracer` |
Alexander Afanasyev | f4a0359 | 2012-12-10 16:12:34 -0800 | [diff] [blame] | 145 | |
Alexander Afanasyev | b1d6b03 | 2013-01-18 14:11:11 -0800 | [diff] [blame] | 146 | With the use of :ndnsim:`ndn::CsTracer` it is possible to obtain statistics of cache hits/cache misses on simulation nodes. |
Alexander Afanasyev | f4a0359 | 2012-12-10 16:12:34 -0800 | [diff] [blame] | 147 | |
| 148 | The following code enables content store tracing: |
| 149 | |
| 150 | .. code-block:: c++ |
| 151 | |
| 152 | // necessary includes |
Alexander Afanasyev | b1d6b03 | 2013-01-18 14:11:11 -0800 | [diff] [blame] | 153 | #include <ns3/ndnSIM/utils/tracers/ndn-cs-tracer.h> |
Alexander Afanasyev | f4a0359 | 2012-12-10 16:12:34 -0800 | [diff] [blame] | 154 | |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 155 | ... |
Alexander Afanasyev | f4a0359 | 2012-12-10 16:12:34 -0800 | [diff] [blame] | 156 | |
| 157 | // Select implementation of content store. By default, the following is applied: |
| 158 | // ndnHelper.SetContentStore ("ns3::ndn::cs::Stats::Lru", "MaxSize", "100"); |
| 159 | |
| 160 | // the following should be put just before calling Simulator::Run in the scenario |
| 161 | |
Alexander Afanasyev | b1d6b03 | 2013-01-18 14:11:11 -0800 | [diff] [blame] | 162 | boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<ndn::CsTracer> > > |
| 163 | aggTracers = ndn::CsTracer::InstallAll ("cs-trace.txt", Seconds (1)); |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 164 | |
Alexander Afanasyev | f4a0359 | 2012-12-10 16:12:34 -0800 | [diff] [blame] | 165 | Simulator::Run (); |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 166 | |
Alexander Afanasyev | f4a0359 | 2012-12-10 16:12:34 -0800 | [diff] [blame] | 167 | ... |
| 168 | |
| 169 | .. - Tracing lifetime of content store entries |
| 170 | |
| 171 | .. Evaluate lifetime of the content store entries can be accomplished using modified version of the content stores. |
| 172 | .. In particular, |
| 173 | |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 174 | .. _cs trace helper example: |
| 175 | |
| 176 | Example of content store trace helper |
| 177 | +++++++++++++++++++++++++++++++++++++ |
| 178 | |
| 179 | This example (``ndn-tree-cs-tracers.cc``) demonstrates basic usage of content store tracer. |
| 180 | |
| 181 | In 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. |
| 182 | The 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. |
| 183 | |
| 184 | Example simulation (``ndn-tree-cs-tracers.cc``) scenario that utilizes trace helpers: |
| 185 | |
| 186 | .. literalinclude:: ../../examples/ndn-tree-cs-tracers.cc |
| 187 | :language: c++ |
| 188 | :linenos: |
| 189 | :lines: 21-31,64- |
| 190 | :emphasize-lines: 7-11,25,43,45,62-63 |
Alexander Afanasyev | f4a0359 | 2012-12-10 16:12:34 -0800 | [diff] [blame] | 191 | |
| 192 | |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 193 | To run this scenario, use the following command:: |
Alexander Afanasyev | f4a0359 | 2012-12-10 16:12:34 -0800 | [diff] [blame] | 194 | |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 195 | ./waf --run=ndn-tree-cs-tracers |
| 196 | |
| 197 | The 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. |
| 198 | |
| 199 | |
| 200 | Application-level trace helper |
| 201 | ------------------------------ |
| 202 | |
| 203 | - :ndnsim:`ndn::AppDelayTracer` |
| 204 | |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 205 | 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 Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 206 | |
| 207 | The following code enables application-level Interest-Data delay tracing: |
| 208 | |
| 209 | .. code-block:: c++ |
| 210 | |
| 211 | // necessary includes |
| 212 | #include <ns3/ndnSIM/utils/tracers/ndn-app-delay-tracer.h> |
| 213 | |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 214 | ... |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 215 | |
| 216 | // the following should be put just before calling Simulator::Run in the scenario |
| 217 | |
| 218 | boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<ndn::AppDelayTracer> > > |
| 219 | tracers = ndn::AppDelayTracer::InstallAll ("app-delays-trace.txt"); |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 220 | |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 221 | Simulator::Run (); |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 222 | |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 223 | ... |
| 224 | |
Alexander Afanasyev | 29dfb98 | 2013-01-18 20:04:15 -0800 | [diff] [blame] | 225 | 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: |
| 226 | |
| 227 | +-----------------+---------------------------------------------------------------------+ |
| 228 | | Column | Description | |
| 229 | +=================+=====================================================================+ |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 230 | | ``Time`` | simulation time when SeqNo was receivied | |
| 231 | +-----------------+---------------------------------------------------------------------+ |
Alexander Afanasyev | 29dfb98 | 2013-01-18 20:04:15 -0800 | [diff] [blame] | 232 | | ``Node`` | node id, global unique | |
| 233 | +-----------------+---------------------------------------------------------------------+ |
| 234 | | ``AppId`` | app id, local unique on the node, not global | |
| 235 | +-----------------+---------------------------------------------------------------------+ |
| 236 | | ``SeqNo`` | seq number of the Interest-Data | |
| 237 | +-----------------+---------------------------------------------------------------------+ |
| 238 | | ``Type`` | Type of delay: | |
| 239 | | | | |
| 240 | | | - ``LastDelay`` means that ``DelayS`` and ``DelayUS`` represent | |
| 241 | | | delay between last Interest sent and Data packet received | |
| 242 | | | - ``FullDelay`` means that ``DelayS`` and ``DelayUS`` represent | |
| 243 | | | delay between first Interest sent and Data packet received | |
| 244 | | | (i.e., includes time of Interest retransmissions) | |
| 245 | +-----------------+---------------------------------------------------------------------+ |
| 246 | | ``DelayS`` | delay value, specified in seconds | |
| 247 | +-----------------+---------------------------------------------------------------------+ |
| 248 | | ``DelayUS`` | delay value, specified in microseconds (10^-6) | |
| 249 | +-----------------+---------------------------------------------------------------------+ |
Alexander Afanasyev | 400aae1 | 2013-01-19 13:27:52 -0800 | [diff] [blame] | 250 | | ``RetxCount`` | number of Interest retransmissions (for LastDelay always equal to 1)| |
| 251 | +-----------------+---------------------------------------------------------------------+ |
Alexander Afanasyev | 1a0fff6 | 2013-01-19 14:29:51 -0800 | [diff] [blame] | 252 | | ``HopCount`` | combined number of number of hops for Interest and Data packet. | |
| 253 | | | Note that HopCount is increased anytime somebody calls Send method | |
| 254 | | | on a face, including delivery of Interest/Data to application via | |
| 255 | | | an AppFace (but not from application to ndn::L3Protocol!). | |
| 256 | | | | |
| 257 | | | One consequence is that Interests satisfied by an app will have | |
| 258 | | | even hop count (min hop count = 2), and Interests satisfied from | |
| 259 | | | caches will have off hop count (min hop count = 1) | |
| 260 | +-----------------+---------------------------------------------------------------------+ |
Alexander Afanasyev | 29dfb98 | 2013-01-18 20:04:15 -0800 | [diff] [blame] | 261 | |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 262 | .. _app delay trace helper example: |
| 263 | |
| 264 | Example of application-level trace helper |
| 265 | +++++++++++++++++++++++++++++++++++++++++ |
| 266 | |
| 267 | This example (``ndn-tree-app-delay-tracer.cc``) demonstrates basic usage of application-level Interest-Data delay tracer. |
| 268 | |
Alexander Afanasyev | fc8425c | 2013-01-31 13:33:49 -0800 | [diff] [blame^] | 269 | In 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 Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 270 | |
| 271 | Example simulation (``ndn-tree-app-delay-tracer.cc``) scenario that utilizes trace helpers: |
| 272 | |
| 273 | .. literalinclude:: ../../examples/ndn-tree-app-delay-tracer.cc |
| 274 | :language: c++ |
| 275 | :linenos: |
| 276 | :lines: 21-31,64- |
| 277 | :emphasize-lines: 7-8,61-62 |
| 278 | |
| 279 | |
| 280 | To run this scenario, use the following command:: |
| 281 | |
| 282 | ./waf --run=ndn-tree-app-delay-tracer |
| 283 | |
| 284 | The 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. |
| 285 | |
Alexander Afanasyev | f4a0359 | 2012-12-10 16:12:34 -0800 | [diff] [blame] | 286 | |