Spyridon Mastorakis | 2a3aefb | 2017-01-06 18:56:10 -0800 | [diff] [blame] | 1 | .. _best-practices: |
| 2 | |
| 3 | Best Practices on Using ndnSIM |
| 4 | ============================== |
| 5 | |
| 6 | We highly recommend that ndnSIM users follow the principles below: |
| 7 | |
| 8 | #. **The latest version of the simulator should be used whenever possible.** |
| 9 | |
| 10 | The ndnSIM team is able to address users's questions more efficiently |
| 11 | when the latest released version of the simulator is used. |
| 12 | |
| 13 | #. **Users should fork and use the provided scenario template in order to |
| 14 | implement their simulation scenarios.** |
| 15 | |
| 16 | The scenario template can be found `here <https://github.com/named-data-ndnSIM/scenario-template>`__. |
| 17 | |
| 18 | Examples of using the scenario template can be found `here <https://github.com/named-data-ndnSIM/scenario-ndn-ping>`__ |
| 19 | and `here <https://github.com/named-data-ndnSIM/scenario-ChronoSync>`__. |
| 20 | |
| 21 | - Scenario template structure |
| 22 | |
| 23 | The scenario template contains the following directories: |
| 24 | |
| 25 | #. **extensions:** This directory is supposed to contain simulator extensions |
| 26 | necessary for the written simulation scenarios. Specifically, these are |
| 27 | any .cpp/.hpp files that will be linked to each of the included scenario. |
| 28 | |
| 29 | #. **scenarios:** Under this directory, the actual simulations are |
| 30 | supposed to be placed (each .cpp file becomes its own simulation |
| 31 | scenario -- it must contain the ``main`` function). |
| 32 | |
| 33 | - How to compile a scenario template |
| 34 | |
| 35 | To configure in optimized mode without logging **(default)**: |
| 36 | |
| 37 | .. code-block:: c++ |
| 38 | |
| 39 | ./waf configure |
| 40 | |
| 41 | To configure in optimized mode with scenario logging enabled (logging in NS-3 and ndnSIM modules will still be disabled, |
| 42 | but you can see output from NS_LOG* calls from your scenarios and extensions): |
| 43 | |
| 44 | .. code-block:: c++ |
| 45 | |
| 46 | ./waf configure --logging |
| 47 | |
| 48 | To configure in debug mode with all logging enabled |
| 49 | |
| 50 | .. code-block:: c++ |
| 51 | |
| 52 | ./waf configure --debug |
| 53 | |
| 54 | If you have installed NS-3 in a non-standard location, you may need to set up ``PKG_CONFIG_PATH`` variable. |
| 55 | |
| 56 | - How to run the simulation scenarios **(without visualizer)** |
| 57 | |
| 58 | Normally, you can run scenarios either directly: |
| 59 | |
| 60 | .. code-block:: shell |
| 61 | |
| 62 | ./build/<scenario_name> |
| 63 | |
| 64 | or using waf: |
| 65 | |
| 66 | .. code-block:: shell |
| 67 | |
| 68 | ./waf --run <scenario_name> |
| 69 | |
| 70 | If NS-3 is installed in a non-standard location, on some platforms (e.g., Linux) you need to specify the ``LD_LIBRARY_PATH`` variable: |
| 71 | |
| 72 | .. code-block:: shell |
| 73 | |
| 74 | LD_LIBRARY_PATH=/usr/local/lib ./build/<scenario_name> |
| 75 | |
| 76 | or: |
| 77 | |
| 78 | .. code-block:: shell |
| 79 | |
| 80 | LD_LIBRARY_PATH=/usr/local/lib ./waf --run <scenario_name> |
| 81 | |
| 82 | To run a scenario using the debugger, use the following command: |
| 83 | |
| 84 | .. code-block:: shell |
| 85 | |
| 86 | gdb --args ./build/<scenario_name> |
| 87 | |
| 88 | - How to run the simulation scenarios **(with visualizer)** |
| 89 | |
| 90 | To run a scenario with the visualizer, you will have to setup some python |
| 91 | environment variables to find the visualizer module. The easiest way to do |
| 92 | so is by using the following commands: |
| 93 | |
| 94 | .. code-block:: shell |
| 95 | |
| 96 | cd ns-dev/ns-3 |
| 97 | ./waf shell |
| 98 | |
| 99 | After these commands, you will have the complete environment to run the vizualizer. |
| 100 | |
| 101 | The following command will run a scenario with the visualizer: |
| 102 | |
| 103 | .. code-block:: shell |
| 104 | |
| 105 | ./waf --run <scenario_name> --vis |
| 106 | |
| 107 | or: |
| 108 | |
| 109 | .. code-block:: shell |
| 110 | |
| 111 | PKG_LIBRARY_PATH=/usr/local/lib ./waf --run <scenario_name> --vis |
| 112 | |
| 113 | If you need automatic node placement, set up an additional environment variable: |
| 114 | |
| 115 | .. code-block:: shell |
| 116 | |
| 117 | NS_VIS_ASSIGN=1 ./waf --run <scenario_name> --vis |
| 118 | |
| 119 | or: |
| 120 | |
| 121 | .. code-block:: shell |
| 122 | |
| 123 | PKG_LIBRARY_PATH=/usr/local/lib NS_VIS_ASSIGN=1 ./waf --run <scenario_name> --vis |
| 124 | |
| 125 | #. **Users should modify the README file of their fork of the scenario |
| 126 | template repo to clearly note the version/fork of ndnSIM that their |
| 127 | scenarios are supposed to work in.** |
| 128 | |
| 129 | Our effort is to keep ndnSIM updated with the latest advancements of NDN |
| 130 | research. As a result, the ndnSIM API might change from one release to |
| 131 | another, while the API of a new release might not be fully compatible with |
| 132 | the API of previous releases. Therefore, we **strongly** encourage you to |
| 133 | note the specific version (commit hash of the ndnSIM repository and |
| 134 | base NS-3 repository) that was used for your simulations. This will |
| 135 | guarantee the reproducibility of your results, which is critical |
| 136 | for simulations that are published in scientific papers. |
| 137 | |
| 138 | .. note:: We highly encourage that users share their simulation scenarios |
| 139 | with the rest of the ndnSIM users' community. To achieve that, please let |
| 140 | us know if you would like us to fork your simulation |
| 141 | scenarios under the named-data-ndnSIM GitHub organization. |