blob: 51a3b161b4c6a14efb05cf0c4f92f6d9731b2172 [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
26 - :ndnsim:`CcnxFloodingStrategy` (default)
27
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
33 ccnxHelper.SetForwardingStrategy ("ns3::CcnxFloodingStrategy");
34 ...
35 ccnxHelper.Install (nodes);
36
37
38
39 - :ndnsim:`CcnxFloodingStrategy` with smart forwarding
40
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
47 Config::SetDefault ("ns3::CcnxFloodingStrategy::SmartFlooding", BooleanValue (true));
48 ccnxHelper.SetForwardingStrategy ("ns3::CcnxFloodingStrategy");
49 ...
50 ccnxHelper.Install (nodes);
51
52 - :ndnsim:`CcnxBestRouteStrategy`
53
54 If GREEN face is available, Interest will be sent to the highest-ranked GREEN face.
55 If not, Interest will be forwarded to the highest-ranked YELLOW face.
56 If there are no available GREEN or YELLOW faces, interests is dropped.
57
58 .. code-block:: c++
59
60 ccnxHelper.SetForwardingStrategy ("ns3::CcnxBestRouteStrategy");
61 ...
62 ccnxHelper.Install (nodes);
63
64Default routes
65++++++++++++++
66
67.. note::
68 Disabled by default
69
70In simple topologies, like in :doc:`examples <examples>`, or when
71simulating broadcast environment, it is possible to set up *default*
72FIB entries using :ndnsim:`CcnxStackHelper::SetDefaultRoutes` call.
73More specifically, every installed NDN stack will have a FIB entry to ``/`` prefix, containing all available faces.
74
75The following should be done before installing stack on a node:
76
77 .. code-block:: c++
78
79 ccnxHelper.SetDefaultRoutes (true);
80 ...
81 ccnxHelper.Install (nodes);
82
83
84Manually routes
85+++++++++++++++
86
87Routes can be configured manually using :ndnsim:`CcnxStackHelper::AddRoute` static methods of :ndnsim:`CcnxStackHelper`.
88
89These routes **should** be created **after** installing NDN stack on a node:
90
91 .. code-block:: c++
92
93 ccnxHelper.Install (nodes);
94 ...
95 Ptr<Node> node = ... // FIB entry will be added to FIB on this node
96 std::string prefix = ... // some prefix
97 Ptr<CcnxFace> face = ... // NDN face that belongs to the node and through which prefix is accessible
98 int32_t metric = ... // some routing metric
99 CcnxStackHelper::AddRoute (node, prefix, face, metric);
100
101
102.. Enable optional interest limiting
103.. +++++++++++++++++++++++++++++++++
104
105.. EnableLimits
106
107CcnxGlobalRoutingHelper
108-----------------------
109
110To 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``.
111
112There are several necessary steps, in order to take advantage of the global routing controller:
113
114* install :ndnsim:`special interfaces <CcnxGlobalRouter>` on nodes
115
116 .. code-block:: c++
117
118 NodeContainer nodes;
119 ...
120 CcnxGlobalRoutingHelper ccnxGlobalRoutingHelper;
121 ccnxGlobalRoutingHelper.Install (nodes);
122
123* specify which node exports which prefix using :ndnsim:`CcnxGlobalRoutingHelper::AddOrigins`
124
125 .. code-block:: c++
126
127 Ptr<Node> producer; // producer node that exports prefix
128 std::string prefix; // exported prefix
129 ...
130 ccnxGlobalRoutingHelper.AddOrigins (prefix, producer);
131
132* calculate and install FIBs on every node using :ndnsim:`CcnxGlobalRoutingHelper::CalculateRoutes`
133
134 .. code-block:: c++
135
136 ccnxGlobalRoutingHelper.CalculateRoutes ();
137
138
139CcnxAppHelper
140---------------
141
142:ndnsim:`CcnxAppHelper` simplifies task of creating, configuring, and installing ndnSIM applications.
143
144
145The basic usage of the :ndnsim:`CcnxAppHelper`:
146
147* Create helper for specific applications class:
148
149 .. code-block:: c++
150
151 // Create helper for the consumer generating Interests with constant rate
152 CcnxAppHelper consumerHelper ("ns3::CcnxConsumerCbr");
153
154* Assign prefix on which application operates (either generating Interests using this name or satisfying Interests for this name) using :ndnsim:`CcnxAppHelper::SetPrefix`:
155
156 .. code-block:: c++
157
158 consumerHelper.SetPrefix (prefix);
159
160* Assign application-specific attributes using :ndnsim:`CcnxAppHelper::SetAttribute`:
161
162 .. code-block:: c++
163
164 // Set frequency parameter
165 consumerHelper.SetAttribute ("Frequency", StringValue ("10")); // 10 interests a second
166
167* Install application on one or more nodes:
168
169 .. code-block:: c++
170
171 NodeContainer nodes;
172 ...
173 consumerHelper.Install (nodes)