Alexander Afanasyev | 6315ef7 | 2012-06-01 20:56:31 -0700 | [diff] [blame] | 1 | ndnSIM helpers |
| 2 | ============== |
| 3 | |
| 4 | Helpers are very important components of ndnSIM, especially for writing simulation scenarios. |
| 5 | The following summarizes helpers and their basic usage. |
| 6 | |
| 7 | CcnxStackHelper |
| 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 | |
| 12 | Example:: |
| 13 | |
| 14 | CcnxStackHelper ccnxHelper; |
| 15 | NodeContainer nodes; |
| 16 | ... |
| 17 | ccnxHelper.Install (nodes); |
| 18 | |
| 19 | Forwarding strategy |
| 20 | +++++++++++++++++++ |
| 21 | |
| 22 | Forwarding 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 Afanasyev | 8a53f76 | 2012-07-28 14:12:37 -0700 | [diff] [blame] | 26 | - :ndnsim:`Flooding` (default) |
Alexander Afanasyev | 6315ef7 | 2012-06-01 20:56:31 -0700 | [diff] [blame] | 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 | |
Alexander Afanasyev | 8a53f76 | 2012-07-28 14:12:37 -0700 | [diff] [blame] | 33 | ccnxHelper.SetForwardingStrategy ("ns3::ndnSIM::Flooding"); |
Alexander Afanasyev | 6315ef7 | 2012-06-01 20:56:31 -0700 | [diff] [blame] | 34 | ... |
| 35 | ccnxHelper.Install (nodes); |
| 36 | |
| 37 | |
| 38 | |
Alexander Afanasyev | 8a53f76 | 2012-07-28 14:12:37 -0700 | [diff] [blame] | 39 | - :ndnsim:`SmartFlooding` |
Alexander Afanasyev | 6315ef7 | 2012-06-01 20:56:31 -0700 | [diff] [blame] | 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 | |
Alexander Afanasyev | 8a53f76 | 2012-07-28 14:12:37 -0700 | [diff] [blame] | 47 | ccnxHelper.SetForwardingStrategy ("ns3::ndnSIM::SmartFlooding"); |
Alexander Afanasyev | 6315ef7 | 2012-06-01 20:56:31 -0700 | [diff] [blame] | 48 | ... |
| 49 | ccnxHelper.Install (nodes); |
| 50 | |
Alexander Afanasyev | 8a53f76 | 2012-07-28 14:12:37 -0700 | [diff] [blame] | 51 | - :ndnsim:`BestRoute` |
Alexander Afanasyev | 6315ef7 | 2012-06-01 20:56:31 -0700 | [diff] [blame] | 52 | |
| 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 Afanasyev | 8a53f76 | 2012-07-28 14:12:37 -0700 | [diff] [blame] | 59 | ccnxHelper.SetForwardingStrategy ("ns3::ndnSIM::BestRoute"); |
Alexander Afanasyev | 6315ef7 | 2012-06-01 20:56:31 -0700 | [diff] [blame] | 60 | ... |
| 61 | ccnxHelper.Install (nodes); |
| 62 | |
| 63 | Default routes |
| 64 | ++++++++++++++ |
| 65 | |
| 66 | .. note:: |
| 67 | Disabled by default |
| 68 | |
| 69 | In simple topologies, like in :doc:`examples <examples>`, or when |
| 70 | simulating broadcast environment, it is possible to set up *default* |
| 71 | FIB entries using :ndnsim:`CcnxStackHelper::SetDefaultRoutes` call. |
| 72 | More specifically, every installed NDN stack will have a FIB entry to ``/`` prefix, containing all available faces. |
| 73 | |
| 74 | The 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 | |
| 83 | Manually routes |
| 84 | +++++++++++++++ |
| 85 | |
| 86 | Routes can be configured manually using :ndnsim:`CcnxStackHelper::AddRoute` static methods of :ndnsim:`CcnxStackHelper`. |
| 87 | |
| 88 | These 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 | |
| 106 | CcnxGlobalRoutingHelper |
| 107 | ----------------------- |
| 108 | |
| 109 | To 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 | |
| 111 | There 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 | |
| 138 | CcnxAppHelper |
| 139 | --------------- |
| 140 | |
| 141 | :ndnsim:`CcnxAppHelper` simplifies task of creating, configuring, and installing ndnSIM applications. |
| 142 | |
| 143 | |
| 144 | The 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) |