Documentation update
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 54b990e..8f063e3 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -25,7 +25,7 @@
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = [ "sphinx.ext.autodoc", "sphinxcontrib.doxylink" ]
+extensions = [ "sphinx.ext.autodoc", "sphinxcontrib.doxylink", "sphinxcontrib.aafig" ]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
diff --git a/docs/source/examples.rst b/docs/source/examples.rst
index 3e08120..867f006 100644
--- a/docs/source/examples.rst
+++ b/docs/source/examples.rst
@@ -6,17 +6,24 @@
The first example (``ccnx-simple.cc``) shows very basics of ndnSIM. In the simulated
topology there are 3 nodes, connected with point-to-point links, one
-NDN consumer, and one NDN producer::
+NDN consumer, and one NDN producer:
- +----------+ 1Mbps +--------+ 1Mbps +----------+
- | consumer | <------------> | router | <------------> | producer |
- +----------+ 10ms +--------+ 10ms +----------+
+.. aafig::
+ :aspect: 60
+ :scale: 120
-Consumer requests data from producer with frequency 10 interests per second
-(interests contain constantly increasing sequence number).
+ +----------+ +--------+ +----------+
+ | | 1Mbps | | 1Mbps | |
+ | Consumer |<-------------->| Router |<-------------->| Producer |
+ | | 10ms | | 10ms | |
+ +----------+ +--------+ +----------+
-For every received interest, producer replies with a data packet, containing
-1024 bytes of virtual payload.
+Consumer is simulated using :ndnsim:`CcnxConsumerCbr` reference application and generates Interests towards the producer
+with frequency of 10 Interests per second (see :doc:`applications`).
+
+Producer is simulated using :ndnsim:`CcnxProducer` class, which is used to satisfy all incoming Interests with virtual payload data (1024 bytes).
+
+FIB on every node is populated using default routes (see :doc:`helpers`).
The following code represents all that is necessary to run such a
simple scenario
@@ -27,32 +34,32 @@
#include "ns3/network-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/ndnSIM-module.h"
-
+
using namespace ns3;
- int
+ int
main (int argc, char *argv[])
{
// setting default parameters for PointToPoint links and channels
Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("1Mbps"));
Config::SetDefault ("ns3::PointToPointChannel::Delay", StringValue ("10ms"));
Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("20"));
-
+
// Creating nodes
NodeContainer nodes;
nodes.Create (3);
-
+
// Connecting nodes using two links
PointToPointHelper p2p;
p2p.Install (nodes.Get (0), nodes.Get (1));
p2p.Install (nodes.Get (1), nodes.Get (2));
-
+
// Install CCNx stack on all nodes
CcnxStackHelper ccnxHelper;
ccnxHelper.SetDefaultRoutes (true);
ccnxHelper.InstallAll ();
- // Installing applications
+ // Installing applications
// Consumer
CcnxAppHelper consumerHelper ("ns3::CcnxConsumerCbr");
@@ -60,13 +67,119 @@
consumerHelper.SetPrefix ("/prefix");
consumerHelper.SetAttribute ("Frequency", StringValue ("10")); // 10 interests a second
consumerHelper.Install (nodes.Get (0)); // first node
-
+
// Producer
CcnxAppHelper producerHelper ("ns3::CcnxProducer");
// Producer will reply to all requests starting with /prefix
producerHelper.SetPrefix ("/prefix");
producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
producerHelper.Install (nodes.Get (2)); // last node
+
+ Simulator::Stop (Seconds (20.0));
+
+ Simulator::Run ();
+ Simulator::Destroy ();
+
+ return 0;
+ }
+
+If this code is placed into ``scratch/ccnx-simple.cc`` and NS-3 is compiled in debug mode, you can run and see progress of the
+simulation using the following command (in optimized mode nothing will be printed out)::
+
+ NS_LOG=CcnxConsumer:CcnxProducer ./waf --run=ccnx-simple
+
+
+9-node grid example
+-------------------
+
+This scenario (``ccnx-grid.cc``) simulates using a grid topology build with PointToPointGrid NS-3 module
+
+.. aafig::
+ :aspect: 60
+ :scale: 120
+
+ /--------\ /-\ /-\
+ |Consumer|<---->| |<------->| |
+ \--------/ \-/ \-/
+ ^ ^ ^
+ | | | 1Mbps/10ms delay
+ v v v
+ /-\ /-\ /-\
+ | |<-------->| |<------->| |
+ \-/ \-/ \-/
+ ^ ^ ^
+ | | |
+ v v v
+ /-\ /-\ /--------\
+ | |<-------->| |<---->|Producer|
+ \-/ \-/ \--------/
+
+
+FIB is populated using :ndnsim:`CcnxGlobalRoutingHelper` (see :doc:`helpers`).
+
+Consumer is simulated using :ndnsim:`CcnxConsumerCbr` reference application and generates Interests towards the producer
+with frequency of 10 Interests per second (see :doc:`applications`).
+
+Producer is simulated using :ndnsim:`CcnxProducer` class, which is used to satisfy all incoming Interests with virtual payload data (1024 bytes).
+
+
+The following code represents all that is necessary to run such a
+simple scenario
+
+.. code-block:: c++
+
+ #include "ns3/core-module.h"
+ #include "ns3/network-module.h"
+ #include "ns3/point-to-point-module.h"
+ #include "ns3/point-to-point-grid.h"
+ #include "ns3/ndnSIM-module.h"
+
+ using namespace ns3;
+
+ int
+ main (int argc, char *argv[])
+ {
+ // Setting default parameters for PointToPoint links and channels
+ Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("1Mbps"));
+ Config::SetDefault ("ns3::PointToPointChannel::Delay", StringValue ("10ms"));
+ Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("20"));
+
+ // Creating 3x3 topology
+ PointToPointHelper p2p;
+ PointToPointGridHelper grid (3, 3, p2p);
+ grid.BoundingBox(100,100,200,200);
+
+ // Install CCNx stack on all nodes
+ CcnxStackHelper ccnxHelper;
+ ccnxHelper.InstallAll ();
+
+ // Installing global routing interface on all nodes
+ CcnxGlobalRoutingHelper ccnxGlobalRoutingHelper;
+ ccnxGlobalRoutingHelper.InstallAll ();
+
+ // Getting containers for the consumer/producer
+ Ptr<Node> producer = grid.GetNode (nGrid-1, nGrid-1);
+ NodeContainer consumerNodes;
+ consumerNodes.Add (grid.GetNode (0,0));
+
+ // Install CCNx applications
+ std::string prefix = "/prefix";
+
+ CcnxAppHelper consumerHelper ("ns3::CcnxConsumerCbr");
+ consumerHelper.SetPrefix (prefix);
+ consumerHelper.SetAttribute ("Frequency", StringValue ("10")); // 10 interests a second
+ consumerHelper.Install (consumerNodes);
+
+ CcnxAppHelper producerHelper ("ns3::CcnxProducer");
+ producerHelper.SetPrefix (prefix);
+ producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
+ producerHelper.Install (producer);
+
+ // Add /prefix origins to CcnxGlobalRouter
+ ccnxGlobalRoutingHelper.AddOrigins (prefix, producer);
+
+ // Calculate and install FIBs
+ ccnxGlobalRoutingHelper.CalculateRoutes ();
Simulator::Stop (Seconds (20.0));
@@ -76,7 +189,9 @@
return 0;
}
-If NS-3 is compiled in debug mode, you can run and see progress of the
-simulation using the following command::
- NS_LOG=CcnxConsumer:CcnxProducer ./waf --run=ccnx-simple
+If this code is placed into ``scratch/ccnx-grid.cc`` and NS-3 is compiled in debug mode, you can run and see progress of the
+simulation using the following command (in optimized mode nothing will be printed out)::
+
+ NS_LOG=CcnxConsumer:CcnxProducer ./waf --run=ccnx-grid
+
diff --git a/examples/ccnx-grid.cc b/examples/ccnx-grid.cc
index a0f98ad..f5ed94f 100644
--- a/examples/ccnx-grid.cc
+++ b/examples/ccnx-grid.cc
@@ -42,11 +42,7 @@
*
* All links are 1Mbps with propagation 10ms delay.
*
- * FIB is populated based on hacks of GlobalRoutingController: in
- * addition to normal assignment of IP addresses for every NetDevice
- * interface, every node is assigned an IP address that numerically
- * equals to node id (i.e., if node id is 15, the special address is
- * 0.0.0.15/255.255.255.255).
+ * FIB is populated using CcnxGlobalRoutingHelper.
*
* Consumer requests data from producer with frequency 10 interests per second
* (interests contain constantly increasing sequence number).