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 | |
Spyridon Mastorakis | af09eac | 2018-02-22 11:25:26 -0800 | [diff] [blame] | 15 | .. 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 Afanasyev | 6dbacda | 2012-10-23 17:20:18 -0700 | [diff] [blame] | 23 | .. _simple-scenario: |
| 24 | |
Alexander Afanasyev | 4d32516 | 2012-06-01 12:28:50 -0700 | [diff] [blame] | 25 | Simple scenario |
| 26 | --------------- |
| 27 | |
Alexander Afanasyev | fc9d9e1 | 2013-08-10 14:17:49 -0700 | [diff] [blame] | 28 | .. 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 Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 40 | 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] | 41 | topology there are 3 nodes, connected with point-to-point links, one |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 42 | NDN consumer, and one NDN producer: |
Alexander Afanasyev | 4d32516 | 2012-06-01 12:28:50 -0700 | [diff] [blame] | 43 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 44 | Consumer is simulated using :ndnsim:`ConsumerCbr` reference application and generates Interests |
| 45 | 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] | 46 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 47 | Producer is simulated using :ndnsim:`Producer` class, which is used to satisfy all incoming |
| 48 | Interests with virtual payload data (1024 bytes). |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 49 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 50 | FIB on every node is populated using default routes (see :doc:`helpers`) and the content store |
| 51 | structure of the original ndnSIM is used. |
Alexander Afanasyev | 4d32516 | 2012-06-01 12:28:50 -0700 | [diff] [blame] | 52 | |
| 53 | The following code represents all that is necessary to run such a |
| 54 | simple scenario |
| 55 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 56 | .. literalinclude:: ../../examples/ndn-simple.cpp |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 57 | :language: c++ |
| 58 | :linenos: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 59 | :lines: 20-28,49- |
| 60 | :emphasize-lines: 23-24,27-29,42-53 |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 61 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 62 | If this code is placed into ``scratch/ndn-simple.cpp`` and NS-3 is compiled in debug mode, you |
| 63 | can run and see progress of the simulation using the following command (in optimized mode |
| 64 | nothing will be printed out):: |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 65 | |
Alexander Afanasyev | f6807a5 | 2012-08-10 18:11:43 -0700 | [diff] [blame] | 66 | NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-simple |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 67 | |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 68 | .. note:: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 69 | If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can |
| 70 | directly run the example without putting scenario into ``scratch/`` folder. |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 71 | |
Alexander Afanasyev | 6dbacda | 2012-10-23 17:20:18 -0700 | [diff] [blame] | 72 | .. _9-node-grid-example: |
Alexander Afanasyev | 6cf8343 | 2013-02-15 16:02:04 -0800 | [diff] [blame] | 73 | |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 74 | 9-node grid example |
| 75 | ------------------- |
| 76 | |
Alexander Afanasyev | fc9d9e1 | 2013-08-10 14:17:49 -0700 | [diff] [blame] | 77 | .. 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 Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 99 | This scenario (``ndn-grid.cpp``) simulates a grid topology, which is constructed using |
| 100 | PointToPointLayout NS-3 module. |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 101 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 102 | FIB is populated using :ndnsim:`GlobalRoutingHelper` (see :doc:`helpers`). The content store |
| 103 | structure of NFD is used in all the nodes. |
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 | Consumer is simulated using :ndnsim:`ConsumerCbr` reference application and generates Interests |
| 106 | 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] | 107 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 108 | Producer is simulated using :ndnsim:`Producer` class, which is used to satisfy all incoming |
| 109 | Interests with virtual payload data (1024 bytes). |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 110 | |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 111 | 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] | 112 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 113 | .. literalinclude:: ../../examples/ndn-grid.cpp |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 114 | :language: c++ |
| 115 | :linenos: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 116 | :lines: 20-29,54- |
| 117 | :emphasize-lines: 24-26,33,36-37,40-42,58,61 |
Alexander Afanasyev | 6cf8343 | 2013-02-15 16:02:04 -0800 | [diff] [blame] | 118 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 119 | If this code is placed into ``scratch/ndn-grid.cpp`` and NS-3 is compiled in debug mode, you |
| 120 | can run and see progress of the simulation using the following command (in optimized mode |
| 121 | nothing will be printed out):: |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 122 | |
Alexander Afanasyev | f6807a5 | 2012-08-10 18:11:43 -0700 | [diff] [blame] | 123 | NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-grid |
Alexander Afanasyev | 07b0063 | 2012-06-01 23:46:47 -0700 | [diff] [blame] | 124 | |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 125 | .. note:: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 126 | If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can |
| 127 | directly run the example without putting scenario into ``scratch/`` folder. |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 128 | |
Alexander Afanasyev | 6dbacda | 2012-10-23 17:20:18 -0700 | [diff] [blame] | 129 | .. _9-node-grid-example-using-topology-plugin: |
| 130 | |
| 131 | 9-node grid example using topology plugin |
| 132 | ----------------------------------------- |
| 133 | |
Alexander Afanasyev | fc9d9e1 | 2013-08-10 14:17:49 -0700 | [diff] [blame] | 134 | .. 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 Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 156 | Instead of defining topology directly as in :ref:`simple-scenario` or using specialized helpers |
| 157 | as in :ref:`9-node-grid-example`, ndnSIM provides experimental extended versions of |
| 158 | TopologyReader classes: :ndnsim:`AnnotatedTopologyReader` and |
| 159 | :ndnsim:`RocketfuelWeightsReader`. |
Alexander Afanasyev | 6dbacda | 2012-10-23 17:20:18 -0700 | [diff] [blame] | 160 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 161 | While :ndnsim:`RocketfuelWeightsReader` is a specialized version intended to be used with |
Xinyu Ma | fc8956c | 2019-04-08 23:17:52 -0700 | [diff] [blame] | 162 | `Rocketfuel <https://www.cs.washington.edu/research/networking/rocketfuel/>`_ topology and link |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 163 | weights files (examples will be provided later), :ndnsim:`AnnotatedTopologyReader` is a more |
| 164 | general-use class that uses simple user-readable format. |
Alexander Afanasyev | e095f0f | 2012-11-21 17:43:32 -0800 | [diff] [blame] | 165 | |
| 166 | :ndnsim:`AnnotatedTopologyReader` expects the following format: |
Alexander Afanasyev | 6dbacda | 2012-10-23 17:20:18 -0700 | [diff] [blame] | 167 | |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 168 | .. literalinclude:: ../../examples/topologies/topo-grid-3x3.txt |
| 169 | :language: bash |
| 170 | :linenos: |
Alexander Afanasyev | e97c607 | 2012-11-21 23:51:12 -0800 | [diff] [blame] | 171 | :lines: 1-2,19- |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 172 | :emphasize-lines: 8,24 |
Alexander Afanasyev | 6dbacda | 2012-10-23 17:20:18 -0700 | [diff] [blame] | 173 | |
Alexander Afanasyev | e095f0f | 2012-11-21 17:43:32 -0800 | [diff] [blame] | 174 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 175 | This scenario (``ndn-grid-topo-plugin.cpp``) duplicates the functionality of |
| 176 | :ref:`9-node-grid-example` but with the use of :ndnsim:`AnnotatedTopologyReader`. |
Alexander Afanasyev | e095f0f | 2012-11-21 17:43:32 -0800 | [diff] [blame] | 177 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 178 | .. literalinclude:: ../../examples/ndn-grid-topo-plugin.cpp |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 179 | :language: c++ |
| 180 | :linenos: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 181 | :lines: 20-27,52- |
| 182 | :emphasize-lines: 15-17,31-33 |
Alexander Afanasyev | 6cf8343 | 2013-02-15 16:02:04 -0800 | [diff] [blame] | 183 | |
Alexander Afanasyev | 6dbacda | 2012-10-23 17:20:18 -0700 | [diff] [blame] | 184 | As you can see, scenario code became more compact and more readable. |
| 185 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 186 | :ndnsim:`AnnotatedTopologyReader` provides two ways to access topology nodes. First, you can |
| 187 | use the method :ndnsim:`AnnotatedTopologyReader::GetNodes` which returns NodeContainer. |
Alexander Afanasyev | 6dbacda | 2012-10-23 17:20:18 -0700 | [diff] [blame] | 188 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 189 | Alternatively, nodes can be accessed by name using `Names::Find<Node> ("nodename")` call, as in |
| 190 | the above example. For this purpose,:ndnsim:`AnnotatedTopologyReader` automatically registers |
| 191 | all created nodes with names specified in topology file. For more information about `Names` |
Xinyu Ma | fc8956c | 2019-04-08 23:17:52 -0700 | [diff] [blame] | 192 | class, please refer to `NS-3 documentation <https://www.nsnam.org/doxygen/classns3_1_1_names.html>`_. |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 193 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 194 | If the topology file is placed into ``src/ndnSIM/examples/topologies/topo-grid-3x3.txt`` and |
| 195 | the code is placed into ``scratch/ndn-grid-topo-plugin.cpp``, you can run and see progress of |
| 196 | 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] | 197 | |
| 198 | NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-grid-topo-plugin |
| 199 | |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 200 | .. note:: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 201 | If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can |
| 202 | directly run the example without putting scenario into ``scratch/`` folder. |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 203 | |
Alexander Afanasyev | e095f0f | 2012-11-21 17:43:32 -0800 | [diff] [blame] | 204 | 6-node bottleneck topology |
| 205 | -------------------------- |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 206 | |
Alexander Afanasyev | fc9d9e1 | 2013-08-10 14:17:49 -0700 | [diff] [blame] | 207 | .. sidebar:: Topology |
| 208 | |
| 209 | .. aafig:: |
| 210 | :aspect: 60 |
| 211 | :scale: 90 |
| 212 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 213 | /------\ /------\ |
| 214 | | Src1 |<--+ +-->| Dst1 | |
| 215 | \------/ \ / \------/ |
| 216 | \ / |
| 217 | +-->/------\ "bottleneck" /------\<-+ |
| 218 | | Rtr1 |<===============>| Rtr2 | |
| 219 | +-->\------/ \------/<-+ |
| 220 | / \ |
| 221 | /------\ / \ /------\ |
| 222 | | Src2 |<--+ +-->| Dst2 | |
| 223 | \------/ \------/ |
Alexander Afanasyev | fc9d9e1 | 2013-08-10 14:17:49 -0700 | [diff] [blame] | 224 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 225 | |
| 226 | 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] | 227 | |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 228 | .. literalinclude:: ../../examples/topologies/topo-6-node.txt |
| 229 | :language: bash |
Alexander Afanasyev | e095f0f | 2012-11-21 17:43:32 -0800 | [diff] [blame] | 230 | :linenos: |
Alexander Afanasyev | e97c607 | 2012-11-21 23:51:12 -0800 | [diff] [blame] | 231 | :lines: 1-2,15- |
Alexander Afanasyev | 6cf8343 | 2013-02-15 16:02:04 -0800 | [diff] [blame] | 232 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 233 | .. literalinclude:: ../../examples/ndn-congestion-topo-plugin.cpp |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 234 | :language: c++ |
| 235 | :linenos: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 236 | :lines: 20-27,48- |
Alexander Afanasyev | e97c607 | 2012-11-21 23:51:12 -0800 | [diff] [blame] | 237 | |
| 238 | To 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 Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 242 | .. note:: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 243 | If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can |
| 244 | directly run the example without putting scenario into ``scratch/`` folder. |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 245 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 246 | .. _11-node 2-bottleneck topology: |
Alexander Afanasyev | e97c607 | 2012-11-21 23:51:12 -0800 | [diff] [blame] | 247 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 248 | 11-node 2-bottleneck topology |
| 249 | ------------------------------ |
Alexander Afanasyev | e97c607 | 2012-11-21 23:51:12 -0800 | [diff] [blame] | 250 | |
Alexander Afanasyev | fc9d9e1 | 2013-08-10 14:17:49 -0700 | [diff] [blame] | 251 | .. 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 Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 282 | Firstly, we define a meaningful topology: |
Alexander Afanasyev | e97c607 | 2012-11-21 23:51:12 -0800 | [diff] [blame] | 283 | |
| 284 | The 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 Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 291 | After that, we define the simulation scenario: |
Alexander Afanasyev | e97c607 | 2012-11-21 23:51:12 -0800 | [diff] [blame] | 292 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 293 | Example simulation (``ndn-congestion-alt-topo-plugin.cpp``) scenario: |
| 294 | |
| 295 | .. literalinclude:: ../../examples/ndn-congestion-alt-topo-plugin.cpp |
Alexander Afanasyev | e97c607 | 2012-11-21 23:51:12 -0800 | [diff] [blame] | 296 | :language: c++ |
| 297 | :linenos: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 298 | :lines: 20-27,60- |
Alexander Afanasyev | e97c607 | 2012-11-21 23:51:12 -0800 | [diff] [blame] | 299 | |
| 300 | To 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 | |
| 304 | You 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 Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 307 | |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 308 | .. note:: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 309 | 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 | |
| 314 | 6-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 | |
| 344 | This scenario simulates a load balancer topology (using topology reader module). The |
| 345 | corresponding 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 | |
| 352 | After that, we define the simulation scenario: |
| 353 | |
| 354 | Example 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 | |
| 362 | In this simulation scenario, the node called "UCLA-HUB" implements a random load balancing |
| 363 | strategy for the name prefix "/ucla/hello". In this way, the Interest packets will be |
| 364 | forwarded randomly either to the producer node called "UCLA-1" or the producer node called |
| 365 | "UCLA-2". |
| 366 | |
| 367 | To 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 | |
| 375 | 9-node grid topology with different forwarding strategies per name prefix |
| 376 | ------------------------------------------------------------------------- |
| 377 | |
| 378 | This scenario simulates a grid topology (using PointToPointGrid module). In this scenario, |
| 379 | thanks to NFD, we can choose a different forwarding strategy for each prefix in each node. |
| 380 | |
| 381 | Consumer requests data from producer with frequency 100 interests per second (interests |
| 382 | contain constantly increasing sequence number). |
| 383 | |
| 384 | For every received interest, producer replies with a data packet, containing 1024 bytes of |
| 385 | virtual payload. |
| 386 | |
Alexander Afanasyev | c3c7f04 | 2015-08-21 11:38:00 -0700 | [diff] [blame] | 387 | In this scenario, we choose the multicast strategy to be installed for the name prefix |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 388 | "/prefix1" in all the nodes, while for the name prefix "/prefix2", the best-route strategy |
| 389 | will be installed in all the topology nodes. |
| 390 | |
| 391 | Example 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 | |
| 399 | To 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 | |
| 403 | 9-node grid topology with different forwarding strategy for each node |
| 404 | --------------------------------------------------------------------- |
| 405 | |
| 406 | This scenario simulates a grid topology (using PointToPointGrid module). The first six nodes |
Alexander Afanasyev | c3c7f04 | 2015-08-21 11:38:00 -0700 | [diff] [blame] | 407 | use the best route forwarding strategy, whereas the three remaining nodes use the multicast |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 408 | forwarding strategy. |
| 409 | |
| 410 | Consumer requests data from producer with frequency 100 interests per second (interests |
| 411 | contain constantly increasing sequence number). |
| 412 | |
| 413 | For every received interest, producer replies with a data packet, containing 1024 bytes of |
| 414 | virtual payload. |
| 415 | |
| 416 | Example 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 | |
| 424 | To 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 Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 427 | |
Spyridon Mastorakis | f34b319 | 2015-02-16 17:42:01 -0800 | [diff] [blame] | 428 | Simple parallel scenario using MPI |
| 429 | ---------------------------------- |
| 430 | |
| 431 | :ref:`simple scenario with MPI support` |
| 432 | |
Alexander Afanasyev | f4a0359 | 2012-12-10 16:12:34 -0800 | [diff] [blame] | 433 | 3-level binary tree with packet-level trace helpers |
| 434 | --------------------------------------------------- |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 435 | |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 436 | :ref:`packet trace helper example` |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 437 | |
Alexander Afanasyev | f4a0359 | 2012-12-10 16:12:34 -0800 | [diff] [blame] | 438 | |
| 439 | 3-level binary tree with content store trace helper |
| 440 | --------------------------------------------------- |
| 441 | |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 442 | :ref:`cs trace helper example` |
Alexander Afanasyev | f4a0359 | 2012-12-10 16:12:34 -0800 | [diff] [blame] | 443 | |
Alexander Afanasyev | 27e365b | 2013-01-18 18:03:43 -0800 | [diff] [blame] | 444 | 3-level binary tree with application-level Interest-Data delay tracer |
| 445 | ---------------------------------------------------------------------- |
| 446 | |
| 447 | :ref:`app delay trace helper example` |
| 448 | |
Alexander Afanasyev | 71278d4 | 2012-12-12 19:16:54 -0800 | [diff] [blame] | 449 | 1-node topology with custom application |
| 450 | --------------------------------------- |
| 451 | |
| 452 | :ref:`Custom applications` |
| 453 | |
Alexander Afanasyev | 1ab1aad | 2013-02-28 11:32:21 -0800 | [diff] [blame] | 454 | Simple scenario with pcap dump |
| 455 | ------------------------------ |
| 456 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 457 | The following example (``ndn-simple-with-pcap.cpp``) demonstrates how to dump all simulated |
| 458 | traffic in pcap-formatted data, which can be used for later analysis by conventional tools, |
| 459 | like tcpdump and wireshark. |
Alexander Afanasyev | 1ab1aad | 2013-02-28 11:32:21 -0800 | [diff] [blame] | 460 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 461 | .. literalinclude:: ../../examples/ndn-simple-with-pcap.cpp |
Alexander Afanasyev | 1ab1aad | 2013-02-28 11:32:21 -0800 | [diff] [blame] | 462 | :language: c++ |
| 463 | :linenos: |
| 464 | :lines: 20- |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 465 | :emphasize-lines: 24-43,89-91 |
Alexander Afanasyev | 1ab1aad | 2013-02-28 11:32:21 -0800 | [diff] [blame] | 466 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 467 | If this code is placed into ``scratch/ndn-simple-with-pcap.cpp`` and NS-3 is compiled in debug |
| 468 | mode, you can run and see progress of the simulation using the following command (in optimized |
| 469 | mode nothing will be printed out):: |
Alexander Afanasyev | 1ab1aad | 2013-02-28 11:32:21 -0800 | [diff] [blame] | 470 | |
| 471 | NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-simple-with-pcap |
| 472 | |
| 473 | This will generate ``ndn-simple-trace.pcap``, which can be fed to tcpdump:: |
| 474 | |
| 475 | tcpdump -r ndn-simple-trace.pcap |
Alexander Afanasyev | b99cb6c | 2013-03-12 13:58:30 -0700 | [diff] [blame] | 476 | |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 477 | .. note:: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 478 | If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can |
| 479 | directly run the example without putting scenario into ``scratch/`` folder. |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 480 | |
| 481 | .. _Simple scenario with link failures: |
| 482 | |
| 483 | Simple scenario with link failures |
| 484 | ---------------------------------- |
| 485 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 486 | The following example (``ndn-simple-with-link-failure.cpp``) shows how to "fail" links in |
| 487 | ndnSIM simulation. The basic idea is to set ndn::Faces that correspond to the failed link to |
| 488 | DOWN state. ndnSIM now includes a simple helper that simplifies this process. |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 489 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 490 | .. literalinclude:: ../../examples/ndn-simple-with-link-failure.cpp |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 491 | :language: c++ |
| 492 | :linenos: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 493 | :lines: 20-31,52- |
| 494 | :emphasize-lines: 56-57 |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 495 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 496 | If this code is placed into ``scratch/ndn-simple-with-link-failure.cpp`` and NS-3 is compiled |
| 497 | in debug mode, you can run and see progress of the simulation using the following command (in |
| 498 | optimized mode nothing will be printed out):: |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 499 | |
| 500 | NS_LOG=ndn.Consumer:ndn.Producer:ndn.LinkControlHelper ./waf --run=ndn-simple-with-link-failure |
| 501 | |
| 502 | .. note:: |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 503 | If you compiled ndnSIM with examples (``./waf configure --enable-examples``) you can |
| 504 | directly run the example without putting scenario into ``scratch/`` folder. |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 505 | |
| 506 | |
Alexander Afanasyev | 27370c5 | 2013-03-12 13:54:08 -0700 | [diff] [blame] | 507 | 25-node tree topology with L2Tracer |
| 508 | ----------------------------------- |
| 509 | |
| 510 | :ref:`Example of packet drop tracer (L2Tracer)` |
Klaus Schneider | 3878430 | 2019-08-31 18:26:36 -0700 | [diff] [blame] | 511 | |
| 512 | |
| 513 | LFID (Loop-Free Inport-Dependent) Routing for ndnSIM |
| 514 | ---------------------------------------------------- |
| 515 | |
| 516 | LFID (Loop-Free Inport-Dependent) Routing extends the ndnSIM route calculation to provide loop-free and on average shorter loop-free paths than existing work. |
Alexander Afanasyev | 28da73c | 2020-06-01 22:51:37 -0400 | [diff] [blame^] | 517 | For details see the `tech report. <https://named-data.net/publications/techreports/mp_routing_tech_report/>`__ |
Klaus Schneider | 3878430 | 2019-08-31 18:26:36 -0700 | [diff] [blame] | 518 | |
| 519 | LFID provides a better trade-off than the existing route calculation algorithms: |
| 520 | |
| 521 | 1. ``CalculateRoutes():`` Only provides a single shortest path nexthop. |
| 522 | 2. ``CalculateAllPossibleRoutes():`` Provides all possible nexthops, but many of them lead to loops. |
| 523 | |
| 524 | LFID, on the other hand, maximizes the nexthop choice while also completely avoiding loops. |
| 525 | |
| 526 | |
| 527 | We provide two example topologies (abilene and grid) to compare against the existing route calculation methods: |
| 528 | |
| 529 | .. literalinclude:: ../../examples/lfid.cpp |
| 530 | :language: c++ |
| 531 | :linenos: |
| 532 | :lines: 71-148 |
| 533 | |
| 534 | |
| 535 | Simply run:: |
| 536 | |
| 537 | ./waf --run "lfid [--grid] [--routing={lfid|sp|allroutes}]" |
| 538 | |
| 539 | The output will show the nexthops at each node for the given name prefix, and any loops during forwarding. |