blob: 629832f0032dc4ff0ce5934e36a00a372f7f5079 [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
7CcnxStackHelper
8---------------
9
10:ndnsim:`CcnxStackHelper` is used to install ndnSIM network stack on requested nodes, as well to provide a simple way configure several important parameters of NDN simulation.
11
12Example::
13
14 CcnxStackHelper ccnxHelper;
15 NodeContainer nodes;
16 ...
17 ccnxHelper.Install (nodes);
18
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 Afanasyev8a53f762012-07-28 14:12:37 -070033 ccnxHelper.SetForwardingStrategy ("ns3::ndnSIM::Flooding");
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070034 ...
35 ccnxHelper.Install (nodes);
36
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 Afanasyev8a53f762012-07-28 14:12:37 -070047 ccnxHelper.SetForwardingStrategy ("ns3::ndnSIM::SmartFlooding");
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070048 ...
49 ccnxHelper.Install (nodes);
50
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 Afanasyev8a53f762012-07-28 14:12:37 -070059 ccnxHelper.SetForwardingStrategy ("ns3::ndnSIM::BestRoute");
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070060 ...
61 ccnxHelper.Install (nodes);
62
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*
71FIB entries using :ndnsim:`CcnxStackHelper::SetDefaultRoutes` call.
72More 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
78 ccnxHelper.SetDefaultRoutes (true);
79 ...
80 ccnxHelper.Install (nodes);
81
82
83Manually routes
84+++++++++++++++
85
86Routes can be configured manually using :ndnsim:`CcnxStackHelper::AddRoute` static methods of :ndnsim:`CcnxStackHelper`.
87
88These routes **should** be created **after** installing NDN stack on a node:
89
90 .. code-block:: c++
91
92 ccnxHelper.Install (nodes);
93 ...
94 Ptr<Node> node = ... // FIB entry will be added to FIB on this node
95 std::string prefix = ... // some prefix
96 Ptr<CcnxFace> face = ... // NDN face that belongs to the node and through which prefix is accessible
97 int32_t metric = ... // some routing metric
98 CcnxStackHelper::AddRoute (node, prefix, face, metric);
99
100
101.. Enable optional interest limiting
102.. +++++++++++++++++++++++++++++++++
103
104.. EnableLimits
105
106CcnxGlobalRoutingHelper
107-----------------------
108
109To simplify FIB management in large topologies, ndnSIM contains a global routing controller (:ndnsim:`helper <CcnxGlobalRoutingHelper>` and :ndnsim:`special interface <CcnxGlobalRouter>`), similar in spirit to ``Ipv4GlobalRoutingHelper``.
110
111There are several necessary steps, in order to take advantage of the global routing controller:
112
113* install :ndnsim:`special interfaces <CcnxGlobalRouter>` on nodes
114
115 .. code-block:: c++
116
117 NodeContainer nodes;
118 ...
119 CcnxGlobalRoutingHelper ccnxGlobalRoutingHelper;
120 ccnxGlobalRoutingHelper.Install (nodes);
121
122* specify which node exports which prefix using :ndnsim:`CcnxGlobalRoutingHelper::AddOrigins`
123
124 .. code-block:: c++
125
126 Ptr<Node> producer; // producer node that exports prefix
127 std::string prefix; // exported prefix
128 ...
129 ccnxGlobalRoutingHelper.AddOrigins (prefix, producer);
130
131* calculate and install FIBs on every node using :ndnsim:`CcnxGlobalRoutingHelper::CalculateRoutes`
132
133 .. code-block:: c++
134
135 ccnxGlobalRoutingHelper.CalculateRoutes ();
136
137
138CcnxAppHelper
139---------------
140
141:ndnsim:`CcnxAppHelper` simplifies task of creating, configuring, and installing ndnSIM applications.
142
143
144The basic usage of the :ndnsim:`CcnxAppHelper`:
145
146* Create helper for specific applications class:
147
148 .. code-block:: c++
149
150 // Create helper for the consumer generating Interests with constant rate
151 CcnxAppHelper consumerHelper ("ns3::CcnxConsumerCbr");
152
153* Assign prefix on which application operates (either generating Interests using this name or satisfying Interests for this name) using :ndnsim:`CcnxAppHelper::SetPrefix`:
154
155 .. code-block:: c++
156
157 consumerHelper.SetPrefix (prefix);
158
159* Assign application-specific attributes using :ndnsim:`CcnxAppHelper::SetAttribute`:
160
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)