docs: modifying documentation examples (now code in the documentation is taken from real code in examples/ folder)
diff --git a/examples/ndn-simple.cc b/examples/ndn-simple.cc
index eaa9d09..78993ee 100644
--- a/examples/ndn-simple.cc
+++ b/examples/ndn-simple.cc
@@ -17,7 +17,7 @@
*
* Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-
+// ndn-simple.cc
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/point-to-point-module.h"
@@ -40,26 +40,21 @@
* For every received interest, producer replies with a data packet, containing
* 1024 bytes of virtual payload.
*
- * Simulation time is 20 seconds, unless --finish parameter is specified
- *
* To run scenario and see what is happening, use the following command:
*
- * NS_LOG=ndn.Simple:ndn.Consumer ./waf --run=ndn-simple
+ * NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-simple
*/
-NS_LOG_COMPONENT_DEFINE ("ndn.Simple");
-
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"));
-
- Time finishTime = Seconds (20.0);
+ // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
CommandLine cmd;
- cmd.AddValue ("finish", "Finish time", finishTime);
cmd.Parse (argc, argv);
// Creating nodes
@@ -71,37 +66,31 @@
p2p.Install (nodes.Get (0), nodes.Get (1));
p2p.Install (nodes.Get (1), nodes.Get (2));
- // Install Ndn stack on all nodes
- NS_LOG_INFO ("Installing Ndn stack");
- ndn::StackHelper ndnHelper;
- ndnHelper.SetDefaultRoutes (true);
- ndnHelper.InstallAll ();
+ // Install CCNx stack on all nodes
+ ndn::StackHelper ccnxHelper;
+ ccnxHelper.SetDefaultRoutes (true);
+ ccnxHelper.InstallAll ();
- NS_LOG_INFO ("Installing Ndn applications");
+ // Installing applications
+
+ // Consumer
ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr");
// Consumer will request /prefix/0, /prefix/1, ...
- consumerHelper.SetPrefix ("/prefix/0");
- consumerHelper.SetAttribute ("Frequency", StringValue ("1")); // 10 interests a second
- ApplicationContainer consumers = consumerHelper.Install (nodes.Get (0)); // first node
- consumers.Stop (Seconds (0.3));
-
consumerHelper.SetPrefix ("/prefix");
- consumers = consumerHelper.Install (nodes.Get (0)); // first node
- consumers.Start (Seconds (1));
- consumers.Stop (Seconds (1.3));
-
+ consumerHelper.SetAttribute ("Frequency", StringValue ("10")); // 10 interests a second
+ consumerHelper.Install (nodes.Get (0)); // first node
+
+ // Producer
ndn::AppHelper producerHelper ("ns3::ndn::Producer");
// Producer will reply to all requests starting with /prefix
producerHelper.SetPrefix ("/prefix");
producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
- ApplicationContainer producers = producerHelper.Install (nodes.Get (2)); // last node
-
- Simulator::Stop (finishTime);
-
- NS_LOG_INFO ("Run Simulation.");
+ producerHelper.Install (nodes.Get (2)); // last node
+
+ Simulator::Stop (Seconds (20.0));
+
Simulator::Run ();
Simulator::Destroy ();
- NS_LOG_INFO ("Done!");
-
+
return 0;
}