blob: b5be69577f150c745c1fa7b4c73e48c117bbd644 [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
awlane1cec2332025-04-24 17:24:47 -0500215GUI Interface
216--------------
217Mini-NDN provides an optional browser-based GUI interface via `NDN-Play <https://github.com/pulsejet/ndn-play>`__.
218
219An example can be found at ``examples/ndn_play_demo.py``. To start the server, add the following to your Mininet script.
220This will print the URL of the server.
221
222.. code-block:: python
223
224 from minindn.minindn_play.server import PlayServer
225
226 if __name__ == '__main__':
227 # placeholder
228 PlayServer(net).start() # starts the server and blocks
229
230If running remotely, you must make sure to forward the port 8765 to the local
231machine where the browser is running (this port is used by the websocket server). Remember that Mini-NDN runs with superuser
232privileges, so do this judiciously.
233
234Wireshark Visualization
235_______________________
236
237MiniNDN stores the ``hosts.params['params']['homeDir']`` variable for all hosts, used to identify the home directory of the
238nodes. The wireshark dump must be stored in ``shark.log`` in the ``<node-home>/log`` directory for each node. Using the app
239manager, this can be done as,
240
241.. code-block:: python
242
243 from minindn.apps.app_manager import AppManager
244 from minindn.apps.tshark import Tshark
245
246 if __name__ == '__main__':
247 # placeholder
248 ndn.initParams(ndn.net.hosts)
249 sharks = AppManager(ndn, ndn.net.hosts, Tshark, singleLogFile=True)
250
251Once setup, the dump will be visible for each node and the TLV inspector will show each packet on double-clicking it in the GUI.
252If this fails to function, we recommending following the troubleshooting steps for the `NDN Wireshark Dissector
253<https://github.com/named-data/ndn-tools/blob/master/tools/dissect-wireshark/README.md>`__ before filing an issue.
254
255Log Monitor
256___________
257
258The log monitor periodically captures the output of one or more log files on each node and shows the events on the topology
259visually by changing the color of the node. In the following example, the `log/my_app.log` at each host will be monitored
260every `200ms`, for all lines (matching the regex `.*`).
261
262.. code-block:: python
263
264 from minindn.minindn_play.monitor import LogMonitor
265
266 if __name__ == '__main__':
267 ...
268
269 server = PlayServer(net)
270 server.add_monitor(LogMonitor(net.hosts, "log/my_app.log", interval=0.2, regex_filter=".*"))
271 server.start()
272
273
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500274Working Directory Structure
275---------------------------
276
Davide Pesavento750d0402025-02-25 16:50:50 -0500277Currently Mini-NDN uses ``/tmp/minindn`` as the working directory if not
278specified otherwise by using the option ``--work-dir``.
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500279
Davide Pesavento750d0402025-02-25 16:50:50 -0500280Each node is given a HOME directory under ``/tmp/minindn/<node-name>`` where
281``<node-name>`` is the name of the node specified in the ``[nodes]`` section of
Ashlesh Gawande6c86e302019-09-17 22:27:05 -0500282the conf file.
283
284NFD
285___
286
287- NFD conf file is stored at ``/tmp/minindn/<node-name>/nfd.conf``
288
289- NFD log file is stored at ``/tmp/minindn/<node-name>/log/nfd.log``
290
291- ``.ndn`` folder is stored at ``/tmp/minindn/<node-name>/.ndn``
292
293NLSR
294____
295
296- NLSR conf file is stored at ``/tmp/minindn/<node-name>/nlsr.conf``
297- NLSR log file is stored at ``/tmp/minindn/<node-name>/log/nlsr.log``
298
299When security is enabled, NLSR security certificates are stored in:
300``/tmp/minindn/<node-name>/security`` Note that no NLSR publishes the root
301certificate, Mini-NDN installs root.cert in security folder for each
302NLSR.
Saurab Dulal576a4192020-08-25 00:55:22 -0500303
awlaned8e6b8e2022-05-16 23:49:56 -0500304While a host's NLSR neighbors are by default populated by adjacent nodes in wired scenarios,
305for those running NLSR on wifi stations it is required that you specify "neighbor" faces
306manually. The framework for this is provided either via a dictionary object or through
307additional sections in topology files, and may also be used for wired experiments.
308See an example of a topo of this sort in ``mini-ndn/topologies/wifi/nlsr_wifi_example.conf``.
309NLSR faces to be created can be manually specified from topology files in a ``[faces]``
310section, with the format ``nodeA:nodeB [cost=X]``. You should then call the ``setupFaces()``
311method of an initialized Mini-NDN object to get a dictionary based on this parse in the format
312``faceA:[(faceB, cost), (faceC, cost),...]``, which can finally be passed to the NLSR
313helper via the faceDict parameter. An example experiment using this methodology is located
314at ``mini-ndn/examples/wifi/nlsr_wifi.py``. Note that the aforementioned dict can also be
315created manually in the previously established format.
316
Saurab Dulal576a4192020-08-25 00:55:22 -0500317Routing Options
318----------------
319
320Link State Routing (NLSR)
321_________________________
Saurab Dulal576a4192020-08-25 00:55:22 -0500322
Davide Pesavento750d0402025-02-25 16:50:50 -0500323By default, Mini-NDN uses `NLSR <https://github.com/named-data/NLSR>`__ for route management, i.e., route computation, route installation, etc.
324Additionally, the command-line utility ``nlsrc`` can be used to advertise and withdraw prefixes and route status.
Saurab Dulal576a4192020-08-25 00:55:22 -0500325
326NDN Routing Helper
Davide Pesavento750d0402025-02-25 16:50:50 -0500327__________________
328
Saurab Dulal576a4192020-08-25 00:55:22 -0500329Computes 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.
330
331**IMPORTANT:** NLSR and NDN Routing Helper are mutually exclusive, meaning you can only use one at a time, not both.
332
333**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>`.
334
335IP Routing Helper
336____________________
337
338The 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
339reachable, even when relaying is required. Please see ``examples/ip_rounting_experiment.py`` for a simple example.