blob: aa2692d886de413500d35eb4373cdafadd24de40 [file] [log] [blame]
Ashlesh Gawande6c86e302019-09-17 22:27:05 -05001Experiment
2==========
3
4Configuration
5-------------
6
7Mini-NDN uses a configuration file describing the topology and its parameters to setup a network.
8
Davide Pesavento750d0402025-02-25 16:50:50 -05009**The [nodes] section**
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050010
Davide Pesavento750d0402025-02-25 16:50:50 -050011At the bare minimum, the ``nodes`` section describes the nodes present in the
12topology, e.g.:
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050013
Davide Pesavento750d0402025-02-25 16:50:50 -050014.. code-block:: cfg
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050015
16 [nodes]
17 a: key1=value1 key2=value2
18 b: key1=value1
19
20Any key and value passed here is accessible in Mini-NDN as:
21
Davide Pesavento750d0402025-02-25 16:50:50 -050022.. code-block:: python
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050023
24 ndn = Minindn(...)
Davide Pesavento750d0402025-02-25 16:50:50 -050025 value = ndn.net.hosts[0].params['params'].get('key1', 'defaultValue')
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050026
27One can specify log levels for each node's NFD and NLSR using this key-value system:
28
Davide Pesavento750d0402025-02-25 16:50:50 -050029.. code-block:: cfg
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050030
31 [nodes]
32 a: nfd-log-level=DEBUG nlsr-log-level=DEBUG
33 b: nfd-log-level=INFO
34
Davide Pesavento750d0402025-02-25 16:50:50 -050035To specify a log level for certain modules of NFD, the following line can be added to ``nfd.py``:
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050036
Davide Pesavento750d0402025-02-25 16:50:50 -050037.. code-block:: python
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050038
39 node.cmd('infoedit -f {} -s log.Forwarder -v {}'.format(self.confFile, 'INFO'))
40
Davide Pesavento750d0402025-02-25 16:50:50 -050041This will turn on Forwarder logging to INFO for all nodes.
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050042
Davide Pesavento750d0402025-02-25 16:50:50 -050043.. todo::
44 Document [switches] section
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050045
Davide Pesavento750d0402025-02-25 16:50:50 -050046**The [links] section**
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050047
Davide Pesavento750d0402025-02-25 16:50:50 -050048The ``links`` section describes the links in the topology, e.g.:
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050049
Davide Pesavento750d0402025-02-25 16:50:50 -050050.. code-block:: cfg
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050051
52 [links]
53 a:b delay=10ms
54
55This would create a link between a and b. 'b:a' would also result in the
56same. The following parameters can be configured for a node:
57
Davide Pesavento750d0402025-02-25 16:50:50 -050058- ``delay`` : Delay parameter is a required parameter which defines the
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050059 delay of the link (1-1000ms)
60
Davide Pesavento750d0402025-02-25 16:50:50 -050061- ``bw`` : Bandwidth of a link (<1-1000> Mbps)
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050062
Davide Pesavento750d0402025-02-25 16:50:50 -050063- ``loss`` : Percentage of packet loss (<1-100>)
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050064
Davide Pesavento750d0402025-02-25 16:50:50 -050065Example configuration file:
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050066
Davide Pesavento750d0402025-02-25 16:50:50 -050067.. code-block:: cfg
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050068
69 [nodes]
70 a:
71 b:
72 [links]
73 a:b delay=10ms bw=100
74
Davide Pesavento750d0402025-02-25 16:50:50 -050075See the ``topologies`` folder for more sample files.
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050076
Davide Pesavento750d0402025-02-25 16:50:50 -050077Example
78-------
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050079
80Sample experiment may written as follows:
81
Davide Pesavento750d0402025-02-25 16:50:50 -050082.. code-block:: python
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050083
84 from mininet.log import setLogLevel, info
85
86 from minindn.minindn import Minindn
87 from minindn.util import MiniNDNCLI
88 from minindn.apps.appmanager import AppManager
89 from minindn.apps.nfd import Nfd
90 from minindn.apps.nlsr import Nlsr
91 from minindn.helpers.routing_helper import IPRoutingHelper
92
93 if __name__ == '__main__':
94 setLogLevel('info')
95
96 Minindn.cleanUp()
97 Minindn.verifyDependencies()
98
99 # Can pass a custom parser, custom topology, or any Mininet params here
100 ndn = Minindn()
101
102 ndn.start()
103
104 # IP reachability if needed
105 # IPRoutingHelper.calcAllRoutes(ndn.net)
106 # info("IP routes configured, start ping\n")
107 # ndn.net.pingAll()
108
109 # Start apps with AppManager which registers a clean up function with ndn
110 info('Starting NFD on nodes\n')
111 nfds = AppManager(ndn, ndn.net.hosts, Nfd)
112 info('Starting NLSR on nodes\n')
113 nlsrs = AppManager(ndn, ndn.net.hosts, Nlsr)
114
115 # or can not start NLSRs with some delay in between:
116 # nlsrs = AppManager(ndn, ndn.net.hosts, Nlsr)
117 # for host in ndn.net.hosts:
118 # nlsrs.startOnNode(host)
119 # time.sleep(30)
120
121 MiniNDNCLI(ndn.net)
122
123 # Calls the clean up functions registered via AppManager
124 ndn.stop()
125
126Users may look at how the NFD and NLSR applications are written as a sub class of Application
127in the ``minindn/apps`` folder. Or users may choose to directly run their application on nodes
128such as ndnpingserver is run in ``minindn/helpers/experiment.py``.
129
Davide Pesavento750d0402025-02-25 16:50:50 -0500130**Note:** A certain log level can be configured for all the NFD or NLSR nodes at once by passing it as an argument during startup, e.g.:
Saurab Dulal576a4192020-08-25 00:55:22 -0500131
Davide Pesavento750d0402025-02-25 16:50:50 -0500132.. code-block:: python
133
134 nfds = AppManager(self.ndn, self.ndn.net.hosts, Nfd, logLevel='DEBUG')
Saurab Dulal576a4192020-08-25 00:55:22 -0500135
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500136Execution
137---------
138
Davide Pesavento750d0402025-02-25 16:50:50 -0500139To run Mini-NDN with the default topology, ``topologies/default-topology.conf``, type:
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500140
Davide Pesavento750d0402025-02-25 16:50:50 -0500141.. code-block:: sh
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500142
143 sudo python examples/minindn.py
144
145To run Mini-NDN with a topology file, provide the filename as the first
146argument:
147
Davide Pesavento750d0402025-02-25 16:50:50 -0500148.. code-block:: sh
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500149
150 sudo python examples/minindn.py my-topology.conf
151
152After Mini-NDN is installed, users can run examples from anywhere with python directly as follows:
153
Davide Pesavento750d0402025-02-25 16:50:50 -0500154.. code-block:: sh
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500155
156 sudo python /path/to/myexample.py
157
158The user no longer needs to create an experiment in the old Mini-NDN way, then install it to the system before executing it via the minindn binary. The new examples can be separate from the Mini-NDN folder if the core is not being modified.
159
160CLI Interface
161_____________
162
163During set up, the list of nodes in the network will be listed as they
164are initialized:
165
Davide Pesavento750d0402025-02-25 16:50:50 -0500166.. code-block:: none
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500167
168 *** Adding hosts:
169 a b c d
170
171After set up, the command-line interface (CLI) will display a prompt.
172
Davide Pesavento750d0402025-02-25 16:50:50 -0500173.. code-block:: none
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500174
175 mini-ndn>
176
177To interact with a node, first type the node's name and then the command
178to be executed:
179
Davide Pesavento750d0402025-02-25 16:50:50 -0500180.. code-block:: sh
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500181
182 mini-ndn> a echo "Hello, world!"
183 Hello, world!
184
185To see the status of the forwarder on the node:
186
Davide Pesavento750d0402025-02-25 16:50:50 -0500187.. code-block:: sh
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500188
189 mini-ndn> a nfdc status report
190
191To see the status of routing on the node:
192
Davide Pesavento750d0402025-02-25 16:50:50 -0500193.. code-block:: sh
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500194
195 mini-ndn> a nlsrc status
196
Davide Pesavento750d0402025-02-25 16:50:50 -0500197To exit Mini-NDN, type ``quit`` in the CLI or use :kbd:`Ctrl-d`:
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500198
Davide Pesavento750d0402025-02-25 16:50:50 -0500199.. code-block:: sh
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500200
201 mini-ndn> quit
202
Davide Pesavento750d0402025-02-25 16:50:50 -0500203:kbd:`Ctrl-c` is used to quit an application run in the foreground of the command line.
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500204
205For a more in depth explanation of the CLI, please see the `Mininet
Davide Pesavento750d0402025-02-25 16:50:50 -0500206Walkthrough <https://mininet.org/walkthrough/>`__.
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500207
208To run NDN commands from the outside the command line user can also open a new terminal
Davide Pesavento750d0402025-02-25 16:50:50 -0500209and export the HOME folder of a node:
210
211.. code-block:: sh
212
213 export HOME=/tmp/minindn/a && cd ~
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500214
215Working Directory Structure
216---------------------------
217
Davide Pesavento750d0402025-02-25 16:50:50 -0500218Currently Mini-NDN uses ``/tmp/minindn`` as the working directory if not
219specified otherwise by using the option ``--work-dir``.
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500220
Davide Pesavento750d0402025-02-25 16:50:50 -0500221Each node is given a HOME directory under ``/tmp/minindn/<node-name>`` where
222``<node-name>`` is the name of the node specified in the ``[nodes]`` section of
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500223the conf file.
224
225NFD
226___
227
228- NFD conf file is stored at ``/tmp/minindn/<node-name>/nfd.conf``
229
230- NFD log file is stored at ``/tmp/minindn/<node-name>/log/nfd.log``
231
232- ``.ndn`` folder is stored at ``/tmp/minindn/<node-name>/.ndn``
233
234NLSR
235____
236
237- NLSR conf file is stored at ``/tmp/minindn/<node-name>/nlsr.conf``
238- NLSR log file is stored at ``/tmp/minindn/<node-name>/log/nlsr.log``
239
240When security is enabled, NLSR security certificates are stored in:
241``/tmp/minindn/<node-name>/security`` Note that no NLSR publishes the root
242certificate, Mini-NDN installs root.cert in security folder for each
243NLSR.
Saurab Dulal576a4192020-08-25 00:55:22 -0500244
awlaned8e6b8e2022-05-16 23:49:56 -0500245While a host's NLSR neighbors are by default populated by adjacent nodes in wired scenarios,
246for those running NLSR on wifi stations it is required that you specify "neighbor" faces
247manually. The framework for this is provided either via a dictionary object or through
248additional sections in topology files, and may also be used for wired experiments.
249See an example of a topo of this sort in ``mini-ndn/topologies/wifi/nlsr_wifi_example.conf``.
250NLSR faces to be created can be manually specified from topology files in a ``[faces]``
251section, with the format ``nodeA:nodeB [cost=X]``. You should then call the ``setupFaces()``
252method of an initialized Mini-NDN object to get a dictionary based on this parse in the format
253``faceA:[(faceB, cost), (faceC, cost),...]``, which can finally be passed to the NLSR
254helper via the faceDict parameter. An example experiment using this methodology is located
255at ``mini-ndn/examples/wifi/nlsr_wifi.py``. Note that the aforementioned dict can also be
256created manually in the previously established format.
257
Saurab Dulal576a4192020-08-25 00:55:22 -0500258Routing Options
259----------------
260
261Link State Routing (NLSR)
262_________________________
Saurab Dulal576a4192020-08-25 00:55:22 -0500263
Davide Pesavento750d0402025-02-25 16:50:50 -0500264By default, Mini-NDN uses `NLSR <https://github.com/named-data/NLSR>`__ for route management, i.e., route computation, route installation, etc.
265Additionally, the command-line utility ``nlsrc`` can be used to advertise and withdraw prefixes and route status.
Saurab Dulal576a4192020-08-25 00:55:22 -0500266
267NDN Routing Helper
Davide Pesavento750d0402025-02-25 16:50:50 -0500268__________________
269
Saurab Dulal576a4192020-08-25 00:55:22 -0500270Computes link-state or hyperbolic route/s from a given minindn topology and installs them in the FIB. The major benefit of the routing helper is to eliminate the overhead of NLSR when using larger topology. See ``examples/static_routing_experiment.py`` on how to use the helper class.
271
272**IMPORTANT:** NLSR and NDN Routing Helper are mutually exclusive, meaning you can only use one at a time, not both.
273
274**Note:** The current version of ``ndn_routing_helper`` is still in the experimental phase. It doesn't support node or link failure and runtime prefix advertisement/withdrawal. If you find any bug please report `here <https://redmine.named-data.net/projects/mini-ndn>`__ or contact the :doc:`authors <authors>`.
275
276IP Routing Helper
277____________________
278
279The routing helper allows to run IP-based evaluations with Mini-NDN. It configures static IP routes to all nodes, which means that all nodes can reach all other nodes in the network
280reachable, even when relaying is required. Please see ``examples/ip_rounting_experiment.py`` for a simple example.