blob: 107459a7b97f0435bc292e5d3905316b30afa5df [file] [log] [blame]
Alexander Afanasyev6315ef72012-06-01 20:56:31 -07001ndnSIM helpers
2==============
3
4Helpers are very important components of ndnSIM, especially for writing simulation scenarios.
5The following summarizes helpers and their basic usage.
6
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -07007NdnStackHelper
Alexander Afanasyev6315ef72012-06-01 20:56:31 -07008---------------
9
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -070010:ndnsim:`NdnStackHelper` is used to install ndnSIM network stack on requested nodes, as well to provide a simple way configure several important parameters of NDN simulation.
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070011
12Example::
13
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -070014 NdnStackHelper ndnHelper;
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070015 NodeContainer nodes;
16 ...
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -070017 ndnHelper.Install (nodes);
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070018
19Forwarding strategy
20+++++++++++++++++++
21
22Forwarding strategy parameter **must** be set before installing stack on a node.
23
24 Currently, there are 2 implemented forwarding strategies that can be used in simulations:
25
Alexander Afanasyev8a53f762012-07-28 14:12:37 -070026 - :ndnsim:`Flooding` (default)
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070027
28 Interests will be forwarded to all available faces available for a route (FIB entry).
29 If there are no available GREEN or YELLOW faces, interests is dropped.
30
31 .. code-block:: c++
32
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -070033 ndnHelper.SetForwardingStrategy ("ns3::ndnSIM::Flooding");
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070034 ...
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -070035 ndnHelper.Install (nodes);
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070036
37
38
Alexander Afanasyev8a53f762012-07-28 14:12:37 -070039 - :ndnsim:`SmartFlooding`
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070040
41 If GREEN face is available, Interest will be sent to the highest-ranked GREEN face.
42 If not, Interest will be forwarded to all available faces available for a route (FIB entry)/
43 If there are no available GREEN or YELLOW faces, interests is dropped.
44
45 .. code-block:: c++
46
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -070047 ndnHelper.SetForwardingStrategy ("ns3::ndnSIM::SmartFlooding");
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070048 ...
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -070049 ndnHelper.Install (nodes);
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070050
Alexander Afanasyev8a53f762012-07-28 14:12:37 -070051 - :ndnsim:`BestRoute`
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070052
53 If GREEN face is available, Interest will be sent to the highest-ranked GREEN face.
54 If not, Interest will be forwarded to the highest-ranked YELLOW face.
55 If there are no available GREEN or YELLOW faces, interests is dropped.
56
57 .. code-block:: c++
58
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -070059 ndnHelper.SetForwardingStrategy ("ns3::ndnSIM::BestRoute");
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070060 ...
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -070061 ndnHelper.Install (nodes);
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070062
63Default routes
64++++++++++++++
65
66.. note::
67 Disabled by default
68
69In simple topologies, like in :doc:`examples <examples>`, or when
70simulating broadcast environment, it is possible to set up *default*
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -070071FIB entries using :ndnsim:`NdnStackHelper::SetDefaultRoutes` call.
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070072More specifically, every installed NDN stack will have a FIB entry to ``/`` prefix, containing all available faces.
73
74The following should be done before installing stack on a node:
75
76 .. code-block:: c++
77
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -070078 ndnHelper.SetDefaultRoutes (true);
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070079 ...
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -070080 ndnHelper.Install (nodes);
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070081
82
83Manually routes
84+++++++++++++++
85
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -070086Routes can be configured manually using :ndnsim:`NdnStackHelper::AddRoute` static methods of :ndnsim:`NdnStackHelper`.
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070087
88These routes **should** be created **after** installing NDN stack on a node:
89
90 .. code-block:: c++
91
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -070092 ndnHelper.Install (nodes);
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070093 ...
94 Ptr<Node> node = ... // FIB entry will be added to FIB on this node
95 std::string prefix = ... // some prefix
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -070096 Ptr<NdnFace> face = ... // NDN face that belongs to the node and through which prefix is accessible
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070097 int32_t metric = ... // some routing metric
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -070098 NdnStackHelper::AddRoute (node, prefix, face, metric);
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070099
100
101.. Enable optional interest limiting
102.. +++++++++++++++++++++++++++++++++
103
104.. EnableLimits
105
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -0700106NdnGlobalRoutingHelper
Alexander Afanasyev6315ef72012-06-01 20:56:31 -0700107-----------------------
108
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -0700109To simplify FIB management in large topologies, ndnSIM contains a global routing controller (:ndnsim:`helper <NdnGlobalRoutingHelper>` and :ndnsim:`special interface <NdnGlobalRouter>`), similar in spirit to ``Ipv4GlobalRoutingHelper``.
Alexander Afanasyev6315ef72012-06-01 20:56:31 -0700110
111There are several necessary steps, in order to take advantage of the global routing controller:
112
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -0700113* install :ndnsim:`special interfaces <NdnGlobalRouter>` on nodes
Alexander Afanasyev6315ef72012-06-01 20:56:31 -0700114
115 .. code-block:: c++
116
117 NodeContainer nodes;
118 ...
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -0700119 NdnGlobalRoutingHelper ndnGlobalRoutingHelper;
120 ndnGlobalRoutingHelper.Install (nodes);
Alexander Afanasyev6315ef72012-06-01 20:56:31 -0700121
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -0700122* specify which node exports which prefix using :ndnsim:`NdnGlobalRoutingHelper::AddOrigins`
Alexander Afanasyev6315ef72012-06-01 20:56:31 -0700123
124 .. code-block:: c++
125
126 Ptr<Node> producer; // producer node that exports prefix
127 std::string prefix; // exported prefix
128 ...
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -0700129 ndnGlobalRoutingHelper.AddOrigins (prefix, producer);
Alexander Afanasyev6315ef72012-06-01 20:56:31 -0700130
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -0700131* calculate and install FIBs on every node using :ndnsim:`NdnGlobalRoutingHelper::CalculateRoutes`
Alexander Afanasyev6315ef72012-06-01 20:56:31 -0700132
133 .. code-block:: c++
134
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -0700135 cdnGlobalRoutingHelper.CalculateRoutes ();
Alexander Afanasyev6315ef72012-06-01 20:56:31 -0700136
137
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -0700138NdnAppHelper
Alexander Afanasyev6315ef72012-06-01 20:56:31 -0700139---------------
140
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -0700141:ndnsim:`NdnAppHelper` simplifies task of creating, configuring, and installing ndnSIM applications.
Alexander Afanasyev6315ef72012-06-01 20:56:31 -0700142
143
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -0700144The basic usage of the :ndnsim:`NdnAppHelper`:
Alexander Afanasyev6315ef72012-06-01 20:56:31 -0700145
146* Create helper for specific applications class:
147
148 .. code-block:: c++
149
150 // Create helper for the consumer generating Interests with constant rate
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -0700151 NdnAppHelper consumerHelper ("ns3::NdnConsumerCbr");
Alexander Afanasyev6315ef72012-06-01 20:56:31 -0700152
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -0700153* Assign prefix on which application operates (either generating Interests using this name or satisfying Interests for this name) using :ndnsim:`NdnAppHelper::SetPrefix`:
Alexander Afanasyev6315ef72012-06-01 20:56:31 -0700154
155 .. code-block:: c++
156
157 consumerHelper.SetPrefix (prefix);
158
Alexander Afanasyevb8d14ad2012-08-09 13:19:37 -0700159* Assign application-specific attributes using :ndnsim:`NdnAppHelper::SetAttribute`:
Alexander Afanasyev6315ef72012-06-01 20:56:31 -0700160
161 .. code-block:: c++
162
163 // Set frequency parameter
164 consumerHelper.SetAttribute ("Frequency", StringValue ("10")); // 10 interests a second
165
166* Install application on one or more nodes:
167
168 .. code-block:: c++
169
170 NodeContainer nodes;
171 ...
172 consumerHelper.Install (nodes)