blob: 6561be5acd793d037248e50b0b41be3c18add4be [file] [log] [blame]
Alexander Afanasyev4d325162012-06-01 12:28:50 -07001Examples
2========
3
Alexander Afanasyev6cf83432013-02-15 16:02:04 -08004.. role:: red
5
6.. note::
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -08007 :red:`!!! This page only shows up examples of how to config topology and perform basic
8 operations in ndnSIM (an example equivalent to "Hello, world1") !!! These are **NOT**
9 examples of real experimentations (just like "Hello, world!" is not a real program).`
Alexander Afanasyev6cf83432013-02-15 16:02:04 -080010
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -070011.. note::
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080012 If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can
13 directly run the example without putting scenario into ``scratch/`` folder.
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -070014
Alexander Afanasyev6dbacda2012-10-23 17:20:18 -070015.. _simple-scenario:
16
Alexander Afanasyev4d325162012-06-01 12:28:50 -070017Simple scenario
18---------------
19
Alexander Afanasyevfc9d9e12013-08-10 14:17:49 -070020.. sidebar:: Topology
21
22 .. aafig::
23 :aspect: 60
24 :scale: 90
25
26 +----------+ +--------+ +----------+
27 | | 1Mbps | | 1Mbps | |
28 | Consumer |<-------------->| Router |<-------------->| Producer |
29 | | 10ms | | 10ms | |
30 +----------+ +--------+ +----------+
31
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080032The first example (``ndn-simple.cpp``) shows very basics of ndnSIM. In the simulated
Alexander Afanasyev4d325162012-06-01 12:28:50 -070033topology there are 3 nodes, connected with point-to-point links, one
Alexander Afanasyev07b00632012-06-01 23:46:47 -070034NDN consumer, and one NDN producer:
Alexander Afanasyev4d325162012-06-01 12:28:50 -070035
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080036Consumer is simulated using :ndnsim:`ConsumerCbr` reference application and generates Interests
37towards the producer with frequency of 10 Interests per second (see :doc:`applications`).
Alexander Afanasyev07b00632012-06-01 23:46:47 -070038
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080039Producer is simulated using :ndnsim:`Producer` class, which is used to satisfy all incoming
40Interests with virtual payload data (1024 bytes).
Alexander Afanasyev07b00632012-06-01 23:46:47 -070041
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080042FIB on every node is populated using default routes (see :doc:`helpers`) and the content store
43structure of the original ndnSIM is used.
Alexander Afanasyev4d325162012-06-01 12:28:50 -070044
45The following code represents all that is necessary to run such a
46simple scenario
47
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080048.. literalinclude:: ../../examples/ndn-simple.cpp
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -080049 :language: c++
50 :linenos:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080051 :lines: 20-28,49-
52 :emphasize-lines: 23-24,27-29,42-53
Alexander Afanasyev07b00632012-06-01 23:46:47 -070053
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080054If this code is placed into ``scratch/ndn-simple.cpp`` and NS-3 is compiled in debug mode, you
55can run and see progress of the simulation using the following command (in optimized mode
56nothing will be printed out)::
Alexander Afanasyev07b00632012-06-01 23:46:47 -070057
Alexander Afanasyevf6807a52012-08-10 18:11:43 -070058 NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-simple
Alexander Afanasyev07b00632012-06-01 23:46:47 -070059
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -070060.. note::
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080061 If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can
62 directly run the example without putting scenario into ``scratch/`` folder.
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -070063
Alexander Afanasyev6dbacda2012-10-23 17:20:18 -070064.. _9-node-grid-example:
Alexander Afanasyev6cf83432013-02-15 16:02:04 -080065
Alexander Afanasyev07b00632012-06-01 23:46:47 -0700669-node grid example
67-------------------
68
Alexander Afanasyevfc9d9e12013-08-10 14:17:49 -070069.. sidebar:: Topology
70
71 .. aafig::
72 :aspect: 60
73 :scale: 120
74
75 /--------\ /-\ /-\
76 |Consumer|<---->| |<------->| |
77 \--------/ \-/ \-/
78 ^ ^ ^
79 | | | 1Mbps/10ms delay
80 v v v
81 /-\ /-\ /-\
82 | |<-------->| |<------->| |
83 \-/ \-/ \-/
84 ^ ^ ^
85 | | |
86 v v v
87 /-\ /-\ /--------\
88 | |<-------->| |<---->|Producer|
89 \-/ \-/ \--------/
90
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080091This scenario (``ndn-grid.cpp``) simulates a grid topology, which is constructed using
92PointToPointLayout NS-3 module.
Alexander Afanasyev07b00632012-06-01 23:46:47 -070093
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080094FIB is populated using :ndnsim:`GlobalRoutingHelper` (see :doc:`helpers`). The content store
95structure of NFD is used in all the nodes.
Alexander Afanasyev07b00632012-06-01 23:46:47 -070096
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080097Consumer is simulated using :ndnsim:`ConsumerCbr` reference application and generates Interests
98towards the producer with frequency of 100 interests per second (see :doc:`applications`).
Alexander Afanasyev07b00632012-06-01 23:46:47 -070099
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800100Producer is simulated using :ndnsim:`Producer` class, which is used to satisfy all incoming
101Interests with virtual payload data (1024 bytes).
Alexander Afanasyev07b00632012-06-01 23:46:47 -0700102
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800103The following code represents all that is necessary to run such a simple scenario
Alexander Afanasyev07b00632012-06-01 23:46:47 -0700104
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800105.. literalinclude:: ../../examples/ndn-grid.cpp
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800106 :language: c++
107 :linenos:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800108 :lines: 20-29,54-
109 :emphasize-lines: 24-26,33,36-37,40-42,58,61
Alexander Afanasyev6cf83432013-02-15 16:02:04 -0800110
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800111If this code is placed into ``scratch/ndn-grid.cpp`` and NS-3 is compiled in debug mode, you
112can run and see progress of the simulation using the following command (in optimized mode
113nothing will be printed out)::
Alexander Afanasyev07b00632012-06-01 23:46:47 -0700114
Alexander Afanasyevf6807a52012-08-10 18:11:43 -0700115 NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-grid
Alexander Afanasyev07b00632012-06-01 23:46:47 -0700116
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700117.. note::
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800118 If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can
119 directly run the example without putting scenario into ``scratch/`` folder.
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700120
Alexander Afanasyev6dbacda2012-10-23 17:20:18 -0700121.. _9-node-grid-example-using-topology-plugin:
122
1239-node grid example using topology plugin
124-----------------------------------------
125
Alexander Afanasyevfc9d9e12013-08-10 14:17:49 -0700126.. sidebar:: Topology
127
128 .. aafig::
129 :aspect: 60
130 :scale: 120
131
132 /--------\ /-\ /-\
133 |Consumer|<---->| |<------->| |
134 \--------/ \-/ \-/
135 ^ ^ ^
136 | | | 1Mbps/10ms delay
137 v v v
138 /-\ /-\ /-\
139 | |<-------->| |<------->| |
140 \-/ \-/ \-/
141 ^ ^ ^
142 | | |
143 v v v
144 /-\ /-\ /--------\
145 | |<-------->| |<---->|Producer|
146 \-/ \-/ \--------/
147
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800148Instead of defining topology directly as in :ref:`simple-scenario` or using specialized helpers
149as in :ref:`9-node-grid-example`, ndnSIM provides experimental extended versions of
150TopologyReader classes: :ndnsim:`AnnotatedTopologyReader` and
151:ndnsim:`RocketfuelWeightsReader`.
Alexander Afanasyev6dbacda2012-10-23 17:20:18 -0700152
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800153While :ndnsim:`RocketfuelWeightsReader` is a specialized version intended to be used with
154`Rocketfuel <http://www.cs.washington.edu/research/networking/rocketfuel/>`_ topology and link
155weights files (examples will be provided later), :ndnsim:`AnnotatedTopologyReader` is a more
156general-use class that uses simple user-readable format.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800157
158:ndnsim:`AnnotatedTopologyReader` expects the following format:
Alexander Afanasyev6dbacda2012-10-23 17:20:18 -0700159
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800160.. literalinclude:: ../../examples/topologies/topo-grid-3x3.txt
161 :language: bash
162 :linenos:
Alexander Afanasyeve97c6072012-11-21 23:51:12 -0800163 :lines: 1-2,19-
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800164 :emphasize-lines: 8,24
Alexander Afanasyev6dbacda2012-10-23 17:20:18 -0700165
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800166
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800167This scenario (``ndn-grid-topo-plugin.cpp``) duplicates the functionality of
168:ref:`9-node-grid-example` but with the use of :ndnsim:`AnnotatedTopologyReader`.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800169
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800170.. literalinclude:: ../../examples/ndn-grid-topo-plugin.cpp
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800171 :language: c++
172 :linenos:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800173 :lines: 20-27,52-
174 :emphasize-lines: 15-17,31-33
Alexander Afanasyev6cf83432013-02-15 16:02:04 -0800175
Alexander Afanasyev6dbacda2012-10-23 17:20:18 -0700176As you can see, scenario code became more compact and more readable.
177
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800178:ndnsim:`AnnotatedTopologyReader` provides two ways to access topology nodes. First, you can
179use the method :ndnsim:`AnnotatedTopologyReader::GetNodes` which returns NodeContainer.
Alexander Afanasyev6dbacda2012-10-23 17:20:18 -0700180
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800181Alternatively, nodes can be accessed by name using `Names::Find<Node> ("nodename")` call, as in
182the above example. For this purpose,:ndnsim:`AnnotatedTopologyReader` automatically registers
183all created nodes with names specified in topology file. For more information about `Names`
184class, please refer to `NS-3 documentation <http://www.nsnam.org/doxygen/classns3_1_1_names.html>`_.
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800185
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800186If the topology file is placed into ``src/ndnSIM/examples/topologies/topo-grid-3x3.txt`` and
187the code is placed into ``scratch/ndn-grid-topo-plugin.cpp``, you can run and see progress of
188the simulation using the following command (in optimized mode nothing will be printed out)::
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800189
190 NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-grid-topo-plugin
191
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700192.. note::
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800193 If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can
194 directly run the example without putting scenario into ``scratch/`` folder.
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800195
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -08001966-node bottleneck topology
197--------------------------
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800198
Alexander Afanasyevfc9d9e12013-08-10 14:17:49 -0700199.. sidebar:: Topology
200
201 .. aafig::
202 :aspect: 60
203 :scale: 90
204
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800205 /------\ /------\
206 | Src1 |<--+ +-->| Dst1 |
207 \------/ \ / \------/
208 \ /
209 +-->/------\ "bottleneck" /------\<-+
210 | Rtr1 |<===============>| Rtr2 |
211 +-->\------/ \------/<-+
212 / \
213 /------\ / \ /------\
214 | Src2 |<--+ +-->| Dst2 |
215 \------/ \------/
Alexander Afanasyevfc9d9e12013-08-10 14:17:49 -0700216
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800217
218This scenario (``ndn-congestion-topo-plugin.cpp``) can be used for congestion-related scenarios
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800219
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800220.. literalinclude:: ../../examples/topologies/topo-6-node.txt
221 :language: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800222 :linenos:
Alexander Afanasyeve97c6072012-11-21 23:51:12 -0800223 :lines: 1-2,15-
Alexander Afanasyev6cf83432013-02-15 16:02:04 -0800224
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800225.. literalinclude:: ../../examples/ndn-congestion-topo-plugin.cpp
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800226 :language: c++
227 :linenos:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800228 :lines: 20-27,48-
Alexander Afanasyeve97c6072012-11-21 23:51:12 -0800229
230To run this scenario and see what is happening, use the following command::
231
232 NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-congestion-topo-plugin
233
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700234.. note::
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800235 If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can
236 directly run the example without putting scenario into ``scratch/`` folder.
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700237
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800238.. _11-node 2-bottleneck topology:
Alexander Afanasyeve97c6072012-11-21 23:51:12 -0800239
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080024011-node 2-bottleneck topology
241------------------------------
Alexander Afanasyeve97c6072012-11-21 23:51:12 -0800242
Alexander Afanasyevfc9d9e12013-08-10 14:17:49 -0700243.. sidebar:: Topology
244
245 .. aafig::
246 :aspect: 60
247 :scale: 90
248
249 /------\ 0 0 /------\
250 | c1 |<-----+ +----->| p1 |
251 \------/ \ / \------/
252 \ /-----\ /
253 /------\ 0 \ +==>| r12 |<==+ / 0 /------\
254 | c2 |<--+ \ / \-----/ \ / +-->| p2 |
255 \------/ \ \ | | / / \------/
256 \ | | 1Mbps links | | /
257 \ 1 v0 v5 1v 2v 3 /
258 +->/------\ /------\<-+
259 2| r1 |<===============>| r2 |4
260 +->\------/4 0\------/<-+
261 / 3^ ^5 \
262 / | | \
263 /------\ 0 / / \ \ 0 /------\
264 | c3 |<--+ / \ +-->| p3 |
265 \------/ / \ \------/
266 / "All consumer-router and" \
267 /------\ 0 / "router-producer links are" \ 0 /------\
268 | c4 |<-----+ "10Mbps" +---->| p4 |
269 \------/ \------/
270
271 "Numbers near nodes denote face IDs. Face ID is assigned based on the order of link"
272 "definitions in the topology file"
273
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800274Firstly, we define a meaningful topology:
Alexander Afanasyeve97c6072012-11-21 23:51:12 -0800275
276The corresponding topology file (``topo-11-node-two-bottlenecks.txt``):
277
278.. literalinclude:: ../../examples/topologies/topo-11-node-two-bottlenecks.txt
279 :language: bash
280 :linenos:
281 :lines: 1-2,28-
282
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800283After that, we define the simulation scenario:
Alexander Afanasyeve97c6072012-11-21 23:51:12 -0800284
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800285Example simulation (``ndn-congestion-alt-topo-plugin.cpp``) scenario:
286
287.. literalinclude:: ../../examples/ndn-congestion-alt-topo-plugin.cpp
Alexander Afanasyeve97c6072012-11-21 23:51:12 -0800288 :language: c++
289 :linenos:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800290 :lines: 20-27,60-
Alexander Afanasyeve97c6072012-11-21 23:51:12 -0800291
292To run this scenario and see what is happening, use the following command::
293
294 NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-congestion-alt-topo-plugin
295
296You can also run using visualizer module to verify that both bottleneck links are utilized::
297
298 ./waf --run=ndn-congestion-alt-topo-plugin --visualize
Alexander Afanasyev59314802012-11-26 14:56:04 -0800299
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700300.. note::
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800301 If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can
302 directly run the example without putting scenario into ``scratch/`` folder.
303
304.. _6-node topology with custom NFD forwarding strategy:
305
3066-node topology with custom NFD forwarding strategy
307---------------------------------------------------
308
309.. sidebar:: Topology
310
311 .. aafig::
312 :aspect: 60
313 :scale: 90
314
315 /-----\
316 | CSU |
317 +-----> | HUB | <----+
318 | \-----/ |
319 | | 1Mbps/10ms delay
320 v v
321 /------\ /----------\
322 | UCLA | | Consumer |
323 | HUB | | CSU-1 |
324 +-----> \------/ <-----+ \----------/
325 | |
326 | |
327 v v
328 /----------\ /----------\
329 | Producer | | Producer |
330 | UCLA-1 | | UCLA-2 |
331 \----------/ \----------/
332
333 "All links are 1Mbps with propagation 10ms delay."
334 "FIB is populated using NdnGlobalRoutingHelper."
335
336This scenario simulates a load balancer topology (using topology reader module). The
337corresponding topology file (``topo-load-balancer.txt``):
338
339.. literalinclude:: ../../examples/topologies/topo-load-balancer.txt
340 :language: bash
341 :linenos:
342 :lines: 30-36,43-
343
344After that, we define the simulation scenario:
345
346Example simulation (``ndn-load-balancer.cpp``) scenario:
347
348.. literalinclude:: ../../examples/ndn-load-balancer.cpp
349 :language: c++
350 :linenos:
351 :lines: 20-27,55-
352 :emphasize-lines: 7,44-45
353
354In this simulation scenario, the node called "UCLA-HUB" implements a random load balancing
355strategy for the name prefix "/ucla/hello". In this way, the Interest packets will be
356forwarded randomly either to the producer node called "UCLA-1" or the producer node called
357"UCLA-2".
358
359To run this scenario and see what is happening, use the following command::
360
361 NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-load-balancer
362
363.. note::
364 If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can
365 directly run the example without putting scenario into ``scratch/`` folder.
366
3679-node grid topology with different forwarding strategies per name prefix
368-------------------------------------------------------------------------
369
370This scenario simulates a grid topology (using PointToPointGrid module). In this scenario,
371thanks to NFD, we can choose a different forwarding strategy for each prefix in each node.
372
373Consumer requests data from producer with frequency 100 interests per second (interests
374contain constantly increasing sequence number).
375
376For every received interest, producer replies with a data packet, containing 1024 bytes of
377virtual payload.
378
379In this scenario, we choose the broadcast strategy to be installed for the name prefix
380"/prefix1" in all the nodes, while for the name prefix "/prefix2", the best-route strategy
381will be installed in all the topology nodes.
382
383Example simulation (``ndn-different-strategy-per-prefix.cpp``) scenario:
384
385.. literalinclude:: ../../examples/ndn-different-strategy-per-prefix.cpp
386 :language: c++
387 :linenos:
388 :lines: 20-33,61-
389 :emphasize-lines: 51-52
390
391To run this scenario and see what is happening, use the following command::
392
393 NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-different-strategy-per-prefix
394
3959-node grid topology with different forwarding strategy for each node
396---------------------------------------------------------------------
397
398This scenario simulates a grid topology (using PointToPointGrid module). The first six nodes
399use the best route forwarding strategy, whereas the three remaining nodes use the broadcast
400forwarding strategy.
401
402Consumer requests data from producer with frequency 100 interests per second (interests
403contain constantly increasing sequence number).
404
405For every received interest, producer replies with a data packet, containing 1024 bytes of
406virtual payload.
407
408Example simulation (``ndn-grid-multiple-strategies.cpp``) scenario:
409
410.. literalinclude:: ../../examples/ndn-grid-multiple-strategies.cpp
411 :language: c++
412 :linenos:
413 :lines: 20-33,61-
414 :emphasize-lines: 49-58
415
416To run this scenario and see what is happening, use the following command::
417
418 NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-grid-multiple-strategies
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700419
Alexander Afanasyevf4a03592012-12-10 16:12:34 -08004203-level binary tree with packet-level trace helpers
421---------------------------------------------------
Alexander Afanasyev59314802012-11-26 14:56:04 -0800422
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800423:ref:`packet trace helper example`
Alexander Afanasyev59314802012-11-26 14:56:04 -0800424
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800425
4263-level binary tree with content store trace helper
427---------------------------------------------------
428
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800429:ref:`cs trace helper example`
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800430
Alexander Afanasyev27e365b2013-01-18 18:03:43 -08004313-level binary tree with application-level Interest-Data delay tracer
432----------------------------------------------------------------------
433
434:ref:`app delay trace helper example`
435
Alexander Afanasyev71278d42012-12-12 19:16:54 -08004361-node topology with custom application
437---------------------------------------
438
439:ref:`Custom applications`
440
Alexander Afanasyev1ab1aad2013-02-28 11:32:21 -0800441Simple scenario with pcap dump
442------------------------------
443
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800444The following example (``ndn-simple-with-pcap.cpp``) demonstrates how to dump all simulated
445traffic in pcap-formatted data, which can be used for later analysis by conventional tools,
446like tcpdump and wireshark.
Alexander Afanasyev1ab1aad2013-02-28 11:32:21 -0800447
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800448.. literalinclude:: ../../examples/ndn-simple-with-pcap.cpp
Alexander Afanasyev1ab1aad2013-02-28 11:32:21 -0800449 :language: c++
450 :linenos:
451 :lines: 20-
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800452 :emphasize-lines: 24-43,89-91
Alexander Afanasyev1ab1aad2013-02-28 11:32:21 -0800453
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800454If this code is placed into ``scratch/ndn-simple-with-pcap.cpp`` and NS-3 is compiled in debug
455mode, you can run and see progress of the simulation using the following command (in optimized
456mode nothing will be printed out)::
Alexander Afanasyev1ab1aad2013-02-28 11:32:21 -0800457
458 NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-simple-with-pcap
459
460This will generate ``ndn-simple-trace.pcap``, which can be fed to tcpdump::
461
462 tcpdump -r ndn-simple-trace.pcap
Alexander Afanasyevb99cb6c2013-03-12 13:58:30 -0700463
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700464.. note::
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800465 If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can
466 directly run the example without putting scenario into ``scratch/`` folder.
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700467
468.. _Simple scenario with link failures:
469
470Simple scenario with link failures
471----------------------------------
472
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800473The following example (``ndn-simple-with-link-failure.cpp``) shows how to "fail" links in
474ndnSIM simulation. The basic idea is to set ndn::Faces that correspond to the failed link to
475DOWN state. ndnSIM now includes a simple helper that simplifies this process.
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700476
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800477.. literalinclude:: ../../examples/ndn-simple-with-link-failure.cpp
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700478 :language: c++
479 :linenos:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800480 :lines: 20-31,52-
481 :emphasize-lines: 56-57
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700482
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800483If this code is placed into ``scratch/ndn-simple-with-link-failure.cpp`` and NS-3 is compiled
484in debug mode, you can run and see progress of the simulation using the following command (in
485optimized mode nothing will be printed out)::
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700486
487 NS_LOG=ndn.Consumer:ndn.Producer:ndn.LinkControlHelper ./waf --run=ndn-simple-with-link-failure
488
489.. note::
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800490 If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can
491 directly run the example without putting scenario into ``scratch/`` folder.
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700492
493
Alexander Afanasyev27370c52013-03-12 13:54:08 -070049425-node tree topology with L2Tracer
495-----------------------------------
496
497:ref:`Example of packet drop tracer (L2Tracer)`