Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ndn-simple.cc
- #include "ns3/core-module.h"
- #include "ns3/network-module.h"
- #include "ns3/point-to-point-module.h"
- #include "ns3/point-to-point-layout-module.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 ("5Mbps"));
- Config::SetDefault ("ns3::PointToPointChannel::Delay", StringValue ("2ms"));
- Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("10"));
- // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
- CommandLine cmd;
- cmd.Parse (argc, argv);
- // Creating 10x10 topology
- PointToPointHelper p2p;
- PointToPointGridHelper grid (10, 10, p2p);
- grid.BoundingBox(1,1,200,200);
- // Install NDN stack on all nodes
- ndn::StackHelper ndnHelper;
- ndnHelper.SetForwardingStrategy ("ns3::ndn::fw::Flooding");
- ndnHelper.InstallAll ();
- // Installing global routing interface on all nodes
- ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
- ndnGlobalRoutingHelper.InstallAll ();
- // Getting containers for the consumer/producer
- Ptr<Node> producer = grid.GetNode (0, 5);
- NodeContainer consumerNodes;
- consumerNodes.Add (grid.GetNode (0,0));
- // Install NDN applications
- std::string prefix = "/prefix";
- ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr");
- consumerHelper.SetPrefix (prefix);
- consumerHelper.SetAttribute ("Frequency", StringValue ("2")); // 100 interests a second
- consumerHelper.Install (consumerNodes);
- ndn::AppHelper producerHelper ("ns3::ndn::Producer");
- producerHelper.SetPrefix (prefix);
- producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
- producerHelper.Install (producer);
- // Add /prefix origins to ndn::GlobalRouter
- ndnGlobalRoutingHelper.AddOrigins (prefix, producer);
- // Calculate and install FIBs
- ndn::GlobalRoutingHelper::CalculateRoutes ();
- Simulator::Stop (Seconds (5.0));
- Simulator::Run ();
- Simulator::Destroy ();
- return 0;
- }
Add Comment
Please, Sign In to add comment