Alexander Afanasyev | 4d32516 | 2012-06-01 12:28:50 -0700 | [diff] [blame] | 1 | Examples |
| 2 | ======== |
| 3 | |
Alexander Afanasyev | 6cf8343 | 2013-02-15 16:02:04 -0800 | [diff] [blame] | 4 | .. role:: red |
| 5 | |
| 6 | .. note:: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 7 | :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 Afanasyev | 6cf8343 | 2013-02-15 16:02:04 -0800 | [diff] [blame] | 10 | |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 11 | .. note:: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 12 | If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can |
| 13 | directly run the example without putting scenario into ``scratch/`` folder. |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 14 | |
Alexander Afanasyev | 6dbacda | 2012-10-23 17:20:18 -0700 | [diff] [blame] | 15 | .. _simple-scenario: |
| 16 | |
Alexander Afanasyev | 4d32516 | 2012-06-01 12:28:50 -0700 | [diff] [blame] | 17 | Simple scenario |
| 18 | --------------- |
| 19 | |
Alexander Afanasyev | fc9d9e1 | 2013-08-10 14:17:49 -0700 | [diff] [blame] | 20 | .. 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 Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 32 | The first example (``ndn-simple.cpp``) shows very basics of ndnSIM. In the simulated |
Alexander Afanasyev | 4d32516 | 2012-06-01 12:28:50 -0700 | [diff] [blame] | 33 | topology there are 3 nodes, connected with point-to-point links, one |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 34 | NDN consumer, and one NDN producer: |
Alexander Afanasyev | 4d32516 | 2012-06-01 12:28:50 -0700 | [diff] [blame] | 35 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 36 | Consumer is simulated using :ndnsim:`ConsumerCbr` reference application and generates Interests |
| 37 | towards the producer with frequency of 10 Interests per second (see :doc:`applications`). |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 38 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 39 | Producer is simulated using :ndnsim:`Producer` class, which is used to satisfy all incoming |
| 40 | Interests with virtual payload data (1024 bytes). |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 41 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 42 | FIB on every node is populated using default routes (see :doc:`helpers`) and the content store |
| 43 | structure of the original ndnSIM is used. |
Alexander Afanasyev | 4d32516 | 2012-06-01 12:28:50 -0700 | [diff] [blame] | 44 | |
| 45 | The following code represents all that is necessary to run such a |
| 46 | simple scenario |
| 47 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 48 | .. literalinclude:: ../../examples/ndn-simple.cpp |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 49 | :language: c++ |
| 50 | :linenos: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 51 | :lines: 20-28,49- |
| 52 | :emphasize-lines: 23-24,27-29,42-53 |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 53 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 54 | If this code is placed into ``scratch/ndn-simple.cpp`` and NS-3 is compiled in debug mode, you |
| 55 | can run and see progress of the simulation using the following command (in optimized mode |
| 56 | nothing will be printed out):: |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 57 | |
Alexander Afanasyev | f6807a5 | 2012-08-10 18:11:43 -0700 | [diff] [blame] | 58 | NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-simple |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 59 | |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 60 | .. note:: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 61 | If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can |
| 62 | directly run the example without putting scenario into ``scratch/`` folder. |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 63 | |
Alexander Afanasyev | 6dbacda | 2012-10-23 17:20:18 -0700 | [diff] [blame] | 64 | .. _9-node-grid-example: |
Alexander Afanasyev | 6cf8343 | 2013-02-15 16:02:04 -0800 | [diff] [blame] | 65 | |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 66 | 9-node grid example |
| 67 | ------------------- |
| 68 | |
Alexander Afanasyev | fc9d9e1 | 2013-08-10 14:17:49 -0700 | [diff] [blame] | 69 | .. 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 Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 91 | This scenario (``ndn-grid.cpp``) simulates a grid topology, which is constructed using |
| 92 | PointToPointLayout NS-3 module. |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 93 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 94 | FIB is populated using :ndnsim:`GlobalRoutingHelper` (see :doc:`helpers`). The content store |
| 95 | structure of NFD is used in all the nodes. |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 96 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 97 | Consumer is simulated using :ndnsim:`ConsumerCbr` reference application and generates Interests |
| 98 | towards the producer with frequency of 100 interests per second (see :doc:`applications`). |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 99 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 100 | Producer is simulated using :ndnsim:`Producer` class, which is used to satisfy all incoming |
| 101 | Interests with virtual payload data (1024 bytes). |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 102 | |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 103 | The following code represents all that is necessary to run such a simple scenario |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 104 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 105 | .. literalinclude:: ../../examples/ndn-grid.cpp |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 106 | :language: c++ |
| 107 | :linenos: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 108 | :lines: 20-29,54- |
| 109 | :emphasize-lines: 24-26,33,36-37,40-42,58,61 |
Alexander Afanasyev | 6cf8343 | 2013-02-15 16:02:04 -0800 | [diff] [blame] | 110 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 111 | If this code is placed into ``scratch/ndn-grid.cpp`` and NS-3 is compiled in debug mode, you |
| 112 | can run and see progress of the simulation using the following command (in optimized mode |
| 113 | nothing will be printed out):: |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 114 | |
Alexander Afanasyev | f6807a5 | 2012-08-10 18:11:43 -0700 | [diff] [blame] | 115 | NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-grid |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 116 | |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 117 | .. note:: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 118 | If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can |
| 119 | directly run the example without putting scenario into ``scratch/`` folder. |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 120 | |
Alexander Afanasyev | 6dbacda | 2012-10-23 17:20:18 -0700 | [diff] [blame] | 121 | .. _9-node-grid-example-using-topology-plugin: |
| 122 | |
| 123 | 9-node grid example using topology plugin |
| 124 | ----------------------------------------- |
| 125 | |
Alexander Afanasyev | fc9d9e1 | 2013-08-10 14:17:49 -0700 | [diff] [blame] | 126 | .. 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 Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 148 | Instead of defining topology directly as in :ref:`simple-scenario` or using specialized helpers |
| 149 | as in :ref:`9-node-grid-example`, ndnSIM provides experimental extended versions of |
| 150 | TopologyReader classes: :ndnsim:`AnnotatedTopologyReader` and |
| 151 | :ndnsim:`RocketfuelWeightsReader`. |
Alexander Afanasyev | 6dbacda | 2012-10-23 17:20:18 -0700 | [diff] [blame] | 152 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 153 | While :ndnsim:`RocketfuelWeightsReader` is a specialized version intended to be used with |
| 154 | `Rocketfuel <http://www.cs.washington.edu/research/networking/rocketfuel/>`_ topology and link |
| 155 | weights files (examples will be provided later), :ndnsim:`AnnotatedTopologyReader` is a more |
| 156 | general-use class that uses simple user-readable format. |
Alexander Afanasyev | e095f0f | 2012-11-21 17:43:32 -0800 | [diff] [blame] | 157 | |
| 158 | :ndnsim:`AnnotatedTopologyReader` expects the following format: |
Alexander Afanasyev | 6dbacda | 2012-10-23 17:20:18 -0700 | [diff] [blame] | 159 | |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 160 | .. literalinclude:: ../../examples/topologies/topo-grid-3x3.txt |
| 161 | :language: bash |
| 162 | :linenos: |
Alexander Afanasyev | e97c607 | 2012-11-21 23:51:12 -0800 | [diff] [blame] | 163 | :lines: 1-2,19- |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 164 | :emphasize-lines: 8,24 |
Alexander Afanasyev | 6dbacda | 2012-10-23 17:20:18 -0700 | [diff] [blame] | 165 | |
Alexander Afanasyev | e095f0f | 2012-11-21 17:43:32 -0800 | [diff] [blame] | 166 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 167 | This scenario (``ndn-grid-topo-plugin.cpp``) duplicates the functionality of |
| 168 | :ref:`9-node-grid-example` but with the use of :ndnsim:`AnnotatedTopologyReader`. |
Alexander Afanasyev | e095f0f | 2012-11-21 17:43:32 -0800 | [diff] [blame] | 169 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 170 | .. literalinclude:: ../../examples/ndn-grid-topo-plugin.cpp |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 171 | :language: c++ |
| 172 | :linenos: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 173 | :lines: 20-27,52- |
| 174 | :emphasize-lines: 15-17,31-33 |
Alexander Afanasyev | 6cf8343 | 2013-02-15 16:02:04 -0800 | [diff] [blame] | 175 | |
Alexander Afanasyev | 6dbacda | 2012-10-23 17:20:18 -0700 | [diff] [blame] | 176 | As you can see, scenario code became more compact and more readable. |
| 177 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 178 | :ndnsim:`AnnotatedTopologyReader` provides two ways to access topology nodes. First, you can |
| 179 | use the method :ndnsim:`AnnotatedTopologyReader::GetNodes` which returns NodeContainer. |
Alexander Afanasyev | 6dbacda | 2012-10-23 17:20:18 -0700 | [diff] [blame] | 180 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 181 | Alternatively, nodes can be accessed by name using `Names::Find<Node> ("nodename")` call, as in |
| 182 | the above example. For this purpose,:ndnsim:`AnnotatedTopologyReader` automatically registers |
| 183 | all created nodes with names specified in topology file. For more information about `Names` |
| 184 | class, please refer to `NS-3 documentation <http://www.nsnam.org/doxygen/classns3_1_1_names.html>`_. |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 185 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 186 | If the topology file is placed into ``src/ndnSIM/examples/topologies/topo-grid-3x3.txt`` and |
| 187 | the code is placed into ``scratch/ndn-grid-topo-plugin.cpp``, you can run and see progress of |
| 188 | the simulation using the following command (in optimized mode nothing will be printed out):: |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 189 | |
| 190 | NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-grid-topo-plugin |
| 191 | |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 192 | .. note:: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 193 | If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can |
| 194 | directly run the example without putting scenario into ``scratch/`` folder. |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 195 | |
Alexander Afanasyev | e095f0f | 2012-11-21 17:43:32 -0800 | [diff] [blame] | 196 | 6-node bottleneck topology |
| 197 | -------------------------- |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 198 | |
Alexander Afanasyev | fc9d9e1 | 2013-08-10 14:17:49 -0700 | [diff] [blame] | 199 | .. sidebar:: Topology |
| 200 | |
| 201 | .. aafig:: |
| 202 | :aspect: 60 |
| 203 | :scale: 90 |
| 204 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 205 | /------\ /------\ |
| 206 | | Src1 |<--+ +-->| Dst1 | |
| 207 | \------/ \ / \------/ |
| 208 | \ / |
| 209 | +-->/------\ "bottleneck" /------\<-+ |
| 210 | | Rtr1 |<===============>| Rtr2 | |
| 211 | +-->\------/ \------/<-+ |
| 212 | / \ |
| 213 | /------\ / \ /------\ |
| 214 | | Src2 |<--+ +-->| Dst2 | |
| 215 | \------/ \------/ |
Alexander Afanasyev | fc9d9e1 | 2013-08-10 14:17:49 -0700 | [diff] [blame] | 216 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 217 | |
| 218 | This scenario (``ndn-congestion-topo-plugin.cpp``) can be used for congestion-related scenarios |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 219 | |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 220 | .. literalinclude:: ../../examples/topologies/topo-6-node.txt |
| 221 | :language: bash |
Alexander Afanasyev | e095f0f | 2012-11-21 17:43:32 -0800 | [diff] [blame] | 222 | :linenos: |
Alexander Afanasyev | e97c607 | 2012-11-21 23:51:12 -0800 | [diff] [blame] | 223 | :lines: 1-2,15- |
Alexander Afanasyev | 6cf8343 | 2013-02-15 16:02:04 -0800 | [diff] [blame] | 224 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 225 | .. literalinclude:: ../../examples/ndn-congestion-topo-plugin.cpp |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 226 | :language: c++ |
| 227 | :linenos: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 228 | :lines: 20-27,48- |
Alexander Afanasyev | e97c607 | 2012-11-21 23:51:12 -0800 | [diff] [blame] | 229 | |
| 230 | To 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 Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 234 | .. note:: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 235 | If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can |
| 236 | directly run the example without putting scenario into ``scratch/`` folder. |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 237 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 238 | .. _11-node 2-bottleneck topology: |
Alexander Afanasyev | e97c607 | 2012-11-21 23:51:12 -0800 | [diff] [blame] | 239 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 240 | 11-node 2-bottleneck topology |
| 241 | ------------------------------ |
Alexander Afanasyev | e97c607 | 2012-11-21 23:51:12 -0800 | [diff] [blame] | 242 | |
Alexander Afanasyev | fc9d9e1 | 2013-08-10 14:17:49 -0700 | [diff] [blame] | 243 | .. 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 Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 274 | Firstly, we define a meaningful topology: |
Alexander Afanasyev | e97c607 | 2012-11-21 23:51:12 -0800 | [diff] [blame] | 275 | |
| 276 | The 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 Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 283 | After that, we define the simulation scenario: |
Alexander Afanasyev | e97c607 | 2012-11-21 23:51:12 -0800 | [diff] [blame] | 284 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 285 | Example simulation (``ndn-congestion-alt-topo-plugin.cpp``) scenario: |
| 286 | |
| 287 | .. literalinclude:: ../../examples/ndn-congestion-alt-topo-plugin.cpp |
Alexander Afanasyev | e97c607 | 2012-11-21 23:51:12 -0800 | [diff] [blame] | 288 | :language: c++ |
| 289 | :linenos: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 290 | :lines: 20-27,60- |
Alexander Afanasyev | e97c607 | 2012-11-21 23:51:12 -0800 | [diff] [blame] | 291 | |
| 292 | To 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 | |
| 296 | You 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 Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 299 | |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 300 | .. note:: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 301 | 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 | |
| 306 | 6-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 | |
| 336 | This scenario simulates a load balancer topology (using topology reader module). The |
| 337 | corresponding 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 | |
| 344 | After that, we define the simulation scenario: |
| 345 | |
| 346 | Example 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 | |
| 354 | In this simulation scenario, the node called "UCLA-HUB" implements a random load balancing |
| 355 | strategy for the name prefix "/ucla/hello". In this way, the Interest packets will be |
| 356 | forwarded randomly either to the producer node called "UCLA-1" or the producer node called |
| 357 | "UCLA-2". |
| 358 | |
| 359 | To 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 | |
| 367 | 9-node grid topology with different forwarding strategies per name prefix |
| 368 | ------------------------------------------------------------------------- |
| 369 | |
| 370 | This scenario simulates a grid topology (using PointToPointGrid module). In this scenario, |
| 371 | thanks to NFD, we can choose a different forwarding strategy for each prefix in each node. |
| 372 | |
| 373 | Consumer requests data from producer with frequency 100 interests per second (interests |
| 374 | contain constantly increasing sequence number). |
| 375 | |
| 376 | For every received interest, producer replies with a data packet, containing 1024 bytes of |
| 377 | virtual payload. |
| 378 | |
| 379 | In 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 |
| 381 | will be installed in all the topology nodes. |
| 382 | |
| 383 | Example 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 | |
| 391 | To 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 | |
| 395 | 9-node grid topology with different forwarding strategy for each node |
| 396 | --------------------------------------------------------------------- |
| 397 | |
| 398 | This scenario simulates a grid topology (using PointToPointGrid module). The first six nodes |
| 399 | use the best route forwarding strategy, whereas the three remaining nodes use the broadcast |
| 400 | forwarding strategy. |
| 401 | |
| 402 | Consumer requests data from producer with frequency 100 interests per second (interests |
| 403 | contain constantly increasing sequence number). |
| 404 | |
| 405 | For every received interest, producer replies with a data packet, containing 1024 bytes of |
| 406 | virtual payload. |
| 407 | |
| 408 | Example 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 | |
| 416 | To 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 Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 419 | |
Spyridon Mastorakis | f34b319 | 2015-02-16 17:42:01 -0800 | [diff] [blame] | 420 | Simple parallel scenario using MPI |
| 421 | ---------------------------------- |
| 422 | |
| 423 | :ref:`simple scenario with MPI support` |
| 424 | |
Alexander Afanasyev | f4a0359 | 2012-12-10 16:12:34 -0800 | [diff] [blame] | 425 | 3-level binary tree with packet-level trace helpers |
| 426 | --------------------------------------------------- |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 427 | |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 428 | :ref:`packet trace helper example` |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 429 | |
Alexander Afanasyev | f4a0359 | 2012-12-10 16:12:34 -0800 | [diff] [blame] | 430 | |
| 431 | 3-level binary tree with content store trace helper |
| 432 | --------------------------------------------------- |
| 433 | |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 434 | :ref:`cs trace helper example` |
Alexander Afanasyev | f4a0359 | 2012-12-10 16:12:34 -0800 | [diff] [blame] | 435 | |
Alexander Afanasyev | 27e365b | 2013-01-18 18:03:43 -0800 | [diff] [blame] | 436 | 3-level binary tree with application-level Interest-Data delay tracer |
| 437 | ---------------------------------------------------------------------- |
| 438 | |
| 439 | :ref:`app delay trace helper example` |
| 440 | |
Alexander Afanasyev | 71278d4 | 2012-12-12 19:16:54 -0800 | [diff] [blame] | 441 | 1-node topology with custom application |
| 442 | --------------------------------------- |
| 443 | |
| 444 | :ref:`Custom applications` |
| 445 | |
Alexander Afanasyev | 1ab1aad | 2013-02-28 11:32:21 -0800 | [diff] [blame] | 446 | Simple scenario with pcap dump |
| 447 | ------------------------------ |
| 448 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 449 | The following example (``ndn-simple-with-pcap.cpp``) demonstrates how to dump all simulated |
| 450 | traffic in pcap-formatted data, which can be used for later analysis by conventional tools, |
| 451 | like tcpdump and wireshark. |
Alexander Afanasyev | 1ab1aad | 2013-02-28 11:32:21 -0800 | [diff] [blame] | 452 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 453 | .. literalinclude:: ../../examples/ndn-simple-with-pcap.cpp |
Alexander Afanasyev | 1ab1aad | 2013-02-28 11:32:21 -0800 | [diff] [blame] | 454 | :language: c++ |
| 455 | :linenos: |
| 456 | :lines: 20- |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 457 | :emphasize-lines: 24-43,89-91 |
Alexander Afanasyev | 1ab1aad | 2013-02-28 11:32:21 -0800 | [diff] [blame] | 458 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 459 | If this code is placed into ``scratch/ndn-simple-with-pcap.cpp`` and NS-3 is compiled in debug |
| 460 | mode, you can run and see progress of the simulation using the following command (in optimized |
| 461 | mode nothing will be printed out):: |
Alexander Afanasyev | 1ab1aad | 2013-02-28 11:32:21 -0800 | [diff] [blame] | 462 | |
| 463 | NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-simple-with-pcap |
| 464 | |
| 465 | This will generate ``ndn-simple-trace.pcap``, which can be fed to tcpdump:: |
| 466 | |
| 467 | tcpdump -r ndn-simple-trace.pcap |
Alexander Afanasyev | b99cb6c | 2013-03-12 13:58:30 -0700 | [diff] [blame] | 468 | |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 469 | .. note:: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 470 | If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can |
| 471 | directly run the example without putting scenario into ``scratch/`` folder. |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 472 | |
| 473 | .. _Simple scenario with link failures: |
| 474 | |
| 475 | Simple scenario with link failures |
| 476 | ---------------------------------- |
| 477 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 478 | The following example (``ndn-simple-with-link-failure.cpp``) shows how to "fail" links in |
| 479 | ndnSIM simulation. The basic idea is to set ndn::Faces that correspond to the failed link to |
| 480 | DOWN state. ndnSIM now includes a simple helper that simplifies this process. |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 481 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 482 | .. literalinclude:: ../../examples/ndn-simple-with-link-failure.cpp |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 483 | :language: c++ |
| 484 | :linenos: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 485 | :lines: 20-31,52- |
| 486 | :emphasize-lines: 56-57 |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 487 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 488 | If this code is placed into ``scratch/ndn-simple-with-link-failure.cpp`` and NS-3 is compiled |
| 489 | in debug mode, you can run and see progress of the simulation using the following command (in |
| 490 | optimized mode nothing will be printed out):: |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 491 | |
| 492 | NS_LOG=ndn.Consumer:ndn.Producer:ndn.LinkControlHelper ./waf --run=ndn-simple-with-link-failure |
| 493 | |
| 494 | .. note:: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 495 | If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can |
| 496 | directly run the example without putting scenario into ``scratch/`` folder. |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 497 | |
| 498 | |
Alexander Afanasyev | 27370c5 | 2013-03-12 13:54:08 -0700 | [diff] [blame] | 499 | 25-node tree topology with L2Tracer |
| 500 | ----------------------------------- |
| 501 | |
| 502 | :ref:`Example of packet drop tracer (L2Tracer)` |