blob: 9ef32fa83c51789d3e7bdb1f4f3a1f63fb84417f [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
Spyridon Mastorakisaf09eac2018-02-22 11:25:26 -080015.. note::
16 A few mobile simulation scenarios are available. The project code may require a custom version of ndnSIM (see project commits for further details).
17
18 - `Project Repository <https://github.com/4th-ndn-hackathon/ndnSIM-Mobile-Simulation-Package>`__
19 - `Vehicle to Infrastructure Example <https://github.com/4th-ndn-hackathon/ndnSIM-Mobile-Simulation-Package/blob/master/examples/simple-wifi-mobility.cpp>`__
20 - `Vehicle to Vehicle Example <https://github.com/4th-ndn-hackathon/ndnSIM-Mobile-Simulation-Package/blob/master/examples/ndn-v2v-simple.cpp>`__
21
22
Alexander Afanasyev6dbacda2012-10-23 17:20:18 -070023.. _simple-scenario:
24
Alexander Afanasyev4d325162012-06-01 12:28:50 -070025Simple scenario
26---------------
27
Alexander Afanasyevfc9d9e12013-08-10 14:17:49 -070028.. sidebar:: Topology
29
30 .. aafig::
31 :aspect: 60
32 :scale: 90
33
34 +----------+ +--------+ +----------+
35 | | 1Mbps | | 1Mbps | |
36 | Consumer |<-------------->| Router |<-------------->| Producer |
37 | | 10ms | | 10ms | |
38 +----------+ +--------+ +----------+
39
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080040The first example (``ndn-simple.cpp``) shows very basics of ndnSIM. In the simulated
Alexander Afanasyev4d325162012-06-01 12:28:50 -070041topology there are 3 nodes, connected with point-to-point links, one
Alexander Afanasyev07b00632012-06-01 23:46:47 -070042NDN consumer, and one NDN producer:
Alexander Afanasyev4d325162012-06-01 12:28:50 -070043
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080044Consumer is simulated using :ndnsim:`ConsumerCbr` reference application and generates Interests
45towards the producer with frequency of 10 Interests per second (see :doc:`applications`).
Alexander Afanasyev07b00632012-06-01 23:46:47 -070046
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080047Producer is simulated using :ndnsim:`Producer` class, which is used to satisfy all incoming
48Interests with virtual payload data (1024 bytes).
Alexander Afanasyev07b00632012-06-01 23:46:47 -070049
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080050FIB on every node is populated using default routes (see :doc:`helpers`) and the content store
51structure of the original ndnSIM is used.
Alexander Afanasyev4d325162012-06-01 12:28:50 -070052
53The following code represents all that is necessary to run such a
54simple scenario
55
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080056.. literalinclude:: ../../examples/ndn-simple.cpp
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -080057 :language: c++
58 :linenos:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080059 :lines: 20-28,49-
60 :emphasize-lines: 23-24,27-29,42-53
Alexander Afanasyev07b00632012-06-01 23:46:47 -070061
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080062If this code is placed into ``scratch/ndn-simple.cpp`` and NS-3 is compiled in debug mode, you
63can run and see progress of the simulation using the following command (in optimized mode
64nothing will be printed out)::
Alexander Afanasyev07b00632012-06-01 23:46:47 -070065
Alexander Afanasyevf6807a52012-08-10 18:11:43 -070066 NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-simple
Alexander Afanasyev07b00632012-06-01 23:46:47 -070067
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -070068.. note::
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080069 If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can
70 directly run the example without putting scenario into ``scratch/`` folder.
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -070071
Alexander Afanasyev6dbacda2012-10-23 17:20:18 -070072.. _9-node-grid-example:
Alexander Afanasyev6cf83432013-02-15 16:02:04 -080073
Alexander Afanasyev07b00632012-06-01 23:46:47 -0700749-node grid example
75-------------------
76
Alexander Afanasyevfc9d9e12013-08-10 14:17:49 -070077.. sidebar:: Topology
78
79 .. aafig::
80 :aspect: 60
81 :scale: 120
82
83 /--------\ /-\ /-\
84 |Consumer|<---->| |<------->| |
85 \--------/ \-/ \-/
86 ^ ^ ^
87 | | | 1Mbps/10ms delay
88 v v v
89 /-\ /-\ /-\
90 | |<-------->| |<------->| |
91 \-/ \-/ \-/
92 ^ ^ ^
93 | | |
94 v v v
95 /-\ /-\ /--------\
96 | |<-------->| |<---->|Producer|
97 \-/ \-/ \--------/
98
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080099This scenario (``ndn-grid.cpp``) simulates a grid topology, which is constructed using
100PointToPointLayout NS-3 module.
Alexander Afanasyev07b00632012-06-01 23:46:47 -0700101
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800102FIB is populated using :ndnsim:`GlobalRoutingHelper` (see :doc:`helpers`). The content store
103structure of NFD is used in all the nodes.
Alexander Afanasyev07b00632012-06-01 23:46:47 -0700104
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800105Consumer is simulated using :ndnsim:`ConsumerCbr` reference application and generates Interests
106towards the producer with frequency of 100 interests per second (see :doc:`applications`).
Alexander Afanasyev07b00632012-06-01 23:46:47 -0700107
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800108Producer is simulated using :ndnsim:`Producer` class, which is used to satisfy all incoming
109Interests with virtual payload data (1024 bytes).
Alexander Afanasyev07b00632012-06-01 23:46:47 -0700110
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800111The following code represents all that is necessary to run such a simple scenario
Alexander Afanasyev07b00632012-06-01 23:46:47 -0700112
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800113.. literalinclude:: ../../examples/ndn-grid.cpp
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800114 :language: c++
115 :linenos:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800116 :lines: 20-29,54-
117 :emphasize-lines: 24-26,33,36-37,40-42,58,61
Alexander Afanasyev6cf83432013-02-15 16:02:04 -0800118
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800119If this code is placed into ``scratch/ndn-grid.cpp`` and NS-3 is compiled in debug mode, you
120can run and see progress of the simulation using the following command (in optimized mode
121nothing will be printed out)::
Alexander Afanasyev07b00632012-06-01 23:46:47 -0700122
Alexander Afanasyevf6807a52012-08-10 18:11:43 -0700123 NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-grid
Alexander Afanasyev07b00632012-06-01 23:46:47 -0700124
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700125.. note::
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800126 If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can
127 directly run the example without putting scenario into ``scratch/`` folder.
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700128
Alexander Afanasyev6dbacda2012-10-23 17:20:18 -0700129.. _9-node-grid-example-using-topology-plugin:
130
1319-node grid example using topology plugin
132-----------------------------------------
133
Alexander Afanasyevfc9d9e12013-08-10 14:17:49 -0700134.. sidebar:: Topology
135
136 .. aafig::
137 :aspect: 60
138 :scale: 120
139
140 /--------\ /-\ /-\
141 |Consumer|<---->| |<------->| |
142 \--------/ \-/ \-/
143 ^ ^ ^
144 | | | 1Mbps/10ms delay
145 v v v
146 /-\ /-\ /-\
147 | |<-------->| |<------->| |
148 \-/ \-/ \-/
149 ^ ^ ^
150 | | |
151 v v v
152 /-\ /-\ /--------\
153 | |<-------->| |<---->|Producer|
154 \-/ \-/ \--------/
155
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800156Instead of defining topology directly as in :ref:`simple-scenario` or using specialized helpers
157as in :ref:`9-node-grid-example`, ndnSIM provides experimental extended versions of
158TopologyReader classes: :ndnsim:`AnnotatedTopologyReader` and
159:ndnsim:`RocketfuelWeightsReader`.
Alexander Afanasyev6dbacda2012-10-23 17:20:18 -0700160
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800161While :ndnsim:`RocketfuelWeightsReader` is a specialized version intended to be used with
Xinyu Mafc8956c2019-04-08 23:17:52 -0700162`Rocketfuel <https://www.cs.washington.edu/research/networking/rocketfuel/>`_ topology and link
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800163weights files (examples will be provided later), :ndnsim:`AnnotatedTopologyReader` is a more
164general-use class that uses simple user-readable format.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800165
166:ndnsim:`AnnotatedTopologyReader` expects the following format:
Alexander Afanasyev6dbacda2012-10-23 17:20:18 -0700167
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800168.. literalinclude:: ../../examples/topologies/topo-grid-3x3.txt
169 :language: bash
170 :linenos:
Alexander Afanasyeve97c6072012-11-21 23:51:12 -0800171 :lines: 1-2,19-
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800172 :emphasize-lines: 8,24
Alexander Afanasyev6dbacda2012-10-23 17:20:18 -0700173
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800174
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800175This scenario (``ndn-grid-topo-plugin.cpp``) duplicates the functionality of
176:ref:`9-node-grid-example` but with the use of :ndnsim:`AnnotatedTopologyReader`.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800177
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800178.. literalinclude:: ../../examples/ndn-grid-topo-plugin.cpp
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800179 :language: c++
180 :linenos:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800181 :lines: 20-27,52-
182 :emphasize-lines: 15-17,31-33
Alexander Afanasyev6cf83432013-02-15 16:02:04 -0800183
Alexander Afanasyev6dbacda2012-10-23 17:20:18 -0700184As you can see, scenario code became more compact and more readable.
185
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800186:ndnsim:`AnnotatedTopologyReader` provides two ways to access topology nodes. First, you can
187use the method :ndnsim:`AnnotatedTopologyReader::GetNodes` which returns NodeContainer.
Alexander Afanasyev6dbacda2012-10-23 17:20:18 -0700188
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800189Alternatively, nodes can be accessed by name using `Names::Find<Node> ("nodename")` call, as in
190the above example. For this purpose,:ndnsim:`AnnotatedTopologyReader` automatically registers
191all created nodes with names specified in topology file. For more information about `Names`
Xinyu Mafc8956c2019-04-08 23:17:52 -0700192class, please refer to `NS-3 documentation <https://www.nsnam.org/doxygen/classns3_1_1_names.html>`_.
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800193
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800194If the topology file is placed into ``src/ndnSIM/examples/topologies/topo-grid-3x3.txt`` and
195the code is placed into ``scratch/ndn-grid-topo-plugin.cpp``, you can run and see progress of
196the simulation using the following command (in optimized mode nothing will be printed out)::
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800197
198 NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-grid-topo-plugin
199
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700200.. note::
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800201 If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can
202 directly run the example without putting scenario into ``scratch/`` folder.
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800203
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -08002046-node bottleneck topology
205--------------------------
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800206
Alexander Afanasyevfc9d9e12013-08-10 14:17:49 -0700207.. sidebar:: Topology
208
209 .. aafig::
210 :aspect: 60
211 :scale: 90
212
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800213 /------\ /------\
214 | Src1 |<--+ +-->| Dst1 |
215 \------/ \ / \------/
216 \ /
217 +-->/------\ "bottleneck" /------\<-+
218 | Rtr1 |<===============>| Rtr2 |
219 +-->\------/ \------/<-+
220 / \
221 /------\ / \ /------\
222 | Src2 |<--+ +-->| Dst2 |
223 \------/ \------/
Alexander Afanasyevfc9d9e12013-08-10 14:17:49 -0700224
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800225
226This scenario (``ndn-congestion-topo-plugin.cpp``) can be used for congestion-related scenarios
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800227
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800228.. literalinclude:: ../../examples/topologies/topo-6-node.txt
229 :language: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800230 :linenos:
Alexander Afanasyeve97c6072012-11-21 23:51:12 -0800231 :lines: 1-2,15-
Alexander Afanasyev6cf83432013-02-15 16:02:04 -0800232
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800233.. literalinclude:: ../../examples/ndn-congestion-topo-plugin.cpp
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -0800234 :language: c++
235 :linenos:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800236 :lines: 20-27,48-
Alexander Afanasyeve97c6072012-11-21 23:51:12 -0800237
238To run this scenario and see what is happening, use the following command::
239
240 NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-congestion-topo-plugin
241
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700242.. note::
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800243 If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can
244 directly run the example without putting scenario into ``scratch/`` folder.
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700245
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800246.. _11-node 2-bottleneck topology:
Alexander Afanasyeve97c6072012-11-21 23:51:12 -0800247
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080024811-node 2-bottleneck topology
249------------------------------
Alexander Afanasyeve97c6072012-11-21 23:51:12 -0800250
Alexander Afanasyevfc9d9e12013-08-10 14:17:49 -0700251.. sidebar:: Topology
252
253 .. aafig::
254 :aspect: 60
255 :scale: 90
256
257 /------\ 0 0 /------\
258 | c1 |<-----+ +----->| p1 |
259 \------/ \ / \------/
260 \ /-----\ /
261 /------\ 0 \ +==>| r12 |<==+ / 0 /------\
262 | c2 |<--+ \ / \-----/ \ / +-->| p2 |
263 \------/ \ \ | | / / \------/
264 \ | | 1Mbps links | | /
265 \ 1 v0 v5 1v 2v 3 /
266 +->/------\ /------\<-+
267 2| r1 |<===============>| r2 |4
268 +->\------/4 0\------/<-+
269 / 3^ ^5 \
270 / | | \
271 /------\ 0 / / \ \ 0 /------\
272 | c3 |<--+ / \ +-->| p3 |
273 \------/ / \ \------/
274 / "All consumer-router and" \
275 /------\ 0 / "router-producer links are" \ 0 /------\
276 | c4 |<-----+ "10Mbps" +---->| p4 |
277 \------/ \------/
278
279 "Numbers near nodes denote face IDs. Face ID is assigned based on the order of link"
280 "definitions in the topology file"
281
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800282Firstly, we define a meaningful topology:
Alexander Afanasyeve97c6072012-11-21 23:51:12 -0800283
284The corresponding topology file (``topo-11-node-two-bottlenecks.txt``):
285
286.. literalinclude:: ../../examples/topologies/topo-11-node-two-bottlenecks.txt
287 :language: bash
288 :linenos:
289 :lines: 1-2,28-
290
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800291After that, we define the simulation scenario:
Alexander Afanasyeve97c6072012-11-21 23:51:12 -0800292
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800293Example simulation (``ndn-congestion-alt-topo-plugin.cpp``) scenario:
294
295.. literalinclude:: ../../examples/ndn-congestion-alt-topo-plugin.cpp
Alexander Afanasyeve97c6072012-11-21 23:51:12 -0800296 :language: c++
297 :linenos:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800298 :lines: 20-27,60-
Alexander Afanasyeve97c6072012-11-21 23:51:12 -0800299
300To run this scenario and see what is happening, use the following command::
301
302 NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-congestion-alt-topo-plugin
303
304You can also run using visualizer module to verify that both bottleneck links are utilized::
305
306 ./waf --run=ndn-congestion-alt-topo-plugin --visualize
Alexander Afanasyev59314802012-11-26 14:56:04 -0800307
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700308.. note::
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800309 If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can
310 directly run the example without putting scenario into ``scratch/`` folder.
311
312.. _6-node topology with custom NFD forwarding strategy:
313
3146-node topology with custom NFD forwarding strategy
315---------------------------------------------------
316
317.. sidebar:: Topology
318
319 .. aafig::
320 :aspect: 60
321 :scale: 90
322
323 /-----\
324 | CSU |
325 +-----> | HUB | <----+
326 | \-----/ |
327 | | 1Mbps/10ms delay
328 v v
329 /------\ /----------\
330 | UCLA | | Consumer |
331 | HUB | | CSU-1 |
332 +-----> \------/ <-----+ \----------/
333 | |
334 | |
335 v v
336 /----------\ /----------\
337 | Producer | | Producer |
338 | UCLA-1 | | UCLA-2 |
339 \----------/ \----------/
340
341 "All links are 1Mbps with propagation 10ms delay."
342 "FIB is populated using NdnGlobalRoutingHelper."
343
344This scenario simulates a load balancer topology (using topology reader module). The
345corresponding topology file (``topo-load-balancer.txt``):
346
347.. literalinclude:: ../../examples/topologies/topo-load-balancer.txt
348 :language: bash
349 :linenos:
350 :lines: 30-36,43-
351
352After that, we define the simulation scenario:
353
354Example simulation (``ndn-load-balancer.cpp``) scenario:
355
356.. literalinclude:: ../../examples/ndn-load-balancer.cpp
357 :language: c++
358 :linenos:
359 :lines: 20-27,55-
360 :emphasize-lines: 7,44-45
361
362In this simulation scenario, the node called "UCLA-HUB" implements a random load balancing
363strategy for the name prefix "/ucla/hello". In this way, the Interest packets will be
364forwarded randomly either to the producer node called "UCLA-1" or the producer node called
365"UCLA-2".
366
367To run this scenario and see what is happening, use the following command::
368
369 NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-load-balancer
370
371.. note::
372 If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can
373 directly run the example without putting scenario into ``scratch/`` folder.
374
3759-node grid topology with different forwarding strategies per name prefix
376-------------------------------------------------------------------------
377
378This scenario simulates a grid topology (using PointToPointGrid module). In this scenario,
379thanks to NFD, we can choose a different forwarding strategy for each prefix in each node.
380
381Consumer requests data from producer with frequency 100 interests per second (interests
382contain constantly increasing sequence number).
383
384For every received interest, producer replies with a data packet, containing 1024 bytes of
385virtual payload.
386
Alexander Afanasyevc3c7f042015-08-21 11:38:00 -0700387In this scenario, we choose the multicast strategy to be installed for the name prefix
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800388"/prefix1" in all the nodes, while for the name prefix "/prefix2", the best-route strategy
389will be installed in all the topology nodes.
390
391Example simulation (``ndn-different-strategy-per-prefix.cpp``) scenario:
392
393.. literalinclude:: ../../examples/ndn-different-strategy-per-prefix.cpp
394 :language: c++
395 :linenos:
396 :lines: 20-33,61-
397 :emphasize-lines: 51-52
398
399To run this scenario and see what is happening, use the following command::
400
401 NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-different-strategy-per-prefix
402
4039-node grid topology with different forwarding strategy for each node
404---------------------------------------------------------------------
405
406This scenario simulates a grid topology (using PointToPointGrid module). The first six nodes
Alexander Afanasyevc3c7f042015-08-21 11:38:00 -0700407use the best route forwarding strategy, whereas the three remaining nodes use the multicast
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800408forwarding strategy.
409
410Consumer requests data from producer with frequency 100 interests per second (interests
411contain constantly increasing sequence number).
412
413For every received interest, producer replies with a data packet, containing 1024 bytes of
414virtual payload.
415
416Example simulation (``ndn-grid-multiple-strategies.cpp``) scenario:
417
418.. literalinclude:: ../../examples/ndn-grid-multiple-strategies.cpp
419 :language: c++
420 :linenos:
421 :lines: 20-33,61-
422 :emphasize-lines: 49-58
423
424To run this scenario and see what is happening, use the following command::
425
426 NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-grid-multiple-strategies
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700427
Spyridon Mastorakisf34b3192015-02-16 17:42:01 -0800428Simple parallel scenario using MPI
429----------------------------------
430
431:ref:`simple scenario with MPI support`
432
Alexander Afanasyevf4a03592012-12-10 16:12:34 -08004333-level binary tree with packet-level trace helpers
434---------------------------------------------------
Alexander Afanasyev59314802012-11-26 14:56:04 -0800435
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800436:ref:`packet trace helper example`
Alexander Afanasyev59314802012-11-26 14:56:04 -0800437
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800438
4393-level binary tree with content store trace helper
440---------------------------------------------------
441
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800442:ref:`cs trace helper example`
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800443
Alexander Afanasyev27e365b2013-01-18 18:03:43 -08004443-level binary tree with application-level Interest-Data delay tracer
445----------------------------------------------------------------------
446
447:ref:`app delay trace helper example`
448
Alexander Afanasyev71278d42012-12-12 19:16:54 -08004491-node topology with custom application
450---------------------------------------
451
452:ref:`Custom applications`
453
Alexander Afanasyev1ab1aad2013-02-28 11:32:21 -0800454Simple scenario with pcap dump
455------------------------------
456
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800457The following example (``ndn-simple-with-pcap.cpp``) demonstrates how to dump all simulated
458traffic in pcap-formatted data, which can be used for later analysis by conventional tools,
459like tcpdump and wireshark.
Alexander Afanasyev1ab1aad2013-02-28 11:32:21 -0800460
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800461.. literalinclude:: ../../examples/ndn-simple-with-pcap.cpp
Alexander Afanasyev1ab1aad2013-02-28 11:32:21 -0800462 :language: c++
463 :linenos:
464 :lines: 20-
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800465 :emphasize-lines: 24-43,89-91
Alexander Afanasyev1ab1aad2013-02-28 11:32:21 -0800466
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800467If this code is placed into ``scratch/ndn-simple-with-pcap.cpp`` and NS-3 is compiled in debug
468mode, you can run and see progress of the simulation using the following command (in optimized
469mode nothing will be printed out)::
Alexander Afanasyev1ab1aad2013-02-28 11:32:21 -0800470
471 NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-simple-with-pcap
472
473This will generate ``ndn-simple-trace.pcap``, which can be fed to tcpdump::
474
475 tcpdump -r ndn-simple-trace.pcap
Alexander Afanasyevb99cb6c2013-03-12 13:58:30 -0700476
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700477.. note::
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800478 If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can
479 directly run the example without putting scenario into ``scratch/`` folder.
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700480
481.. _Simple scenario with link failures:
482
483Simple scenario with link failures
484----------------------------------
485
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800486The following example (``ndn-simple-with-link-failure.cpp``) shows how to "fail" links in
487ndnSIM simulation. The basic idea is to set ndn::Faces that correspond to the failed link to
488DOWN state. ndnSIM now includes a simple helper that simplifies this process.
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700489
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800490.. literalinclude:: ../../examples/ndn-simple-with-link-failure.cpp
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700491 :language: c++
492 :linenos:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800493 :lines: 20-31,52-
494 :emphasize-lines: 56-57
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700495
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800496If this code is placed into ``scratch/ndn-simple-with-link-failure.cpp`` and NS-3 is compiled
497in debug mode, you can run and see progress of the simulation using the following command (in
498optimized mode nothing will be printed out)::
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700499
500 NS_LOG=ndn.Consumer:ndn.Producer:ndn.LinkControlHelper ./waf --run=ndn-simple-with-link-failure
501
502.. note::
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800503 If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can
504 directly run the example without putting scenario into ``scratch/`` folder.
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700505
506
Alexander Afanasyev27370c52013-03-12 13:54:08 -070050725-node tree topology with L2Tracer
508-----------------------------------
509
510:ref:`Example of packet drop tracer (L2Tracer)`