Guest User

Untitled

a guest
Nov 17th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. // ndn-simple.cc
  2. #include "ns3/core-module.h"
  3. #include "ns3/network-module.h"
  4. #include "ns3/point-to-point-module.h"
  5. #include "ns3/point-to-point-layout-module.h"
  6. #include "ns3/ndnSIM-module.h"
  7.  
  8. using namespace ns3;
  9. int
  10. main (int argc, char *argv[])
  11. {
  12. // Setting default parameters for PointToPoint links and channels
  13. Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("5Mbps"));
  14. Config::SetDefault ("ns3::PointToPointChannel::Delay", StringValue ("2ms"));
  15. Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("10"));
  16.  
  17. // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
  18. CommandLine cmd;
  19. cmd.Parse (argc, argv);
  20.  
  21. // Creating 10x10 topology
  22. PointToPointHelper p2p;
  23. PointToPointGridHelper grid (10, 10, p2p);
  24. grid.BoundingBox(1,1,200,200);
  25.  
  26. // Install NDN stack on all nodes
  27. ndn::StackHelper ndnHelper;
  28. ndnHelper.SetForwardingStrategy ("ns3::ndn::fw::Flooding");
  29. ndnHelper.InstallAll ();
  30.  
  31. // Installing global routing interface on all nodes
  32. ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
  33. ndnGlobalRoutingHelper.InstallAll ();
  34.  
  35. // Getting containers for the consumer/producer
  36. Ptr<Node> producer = grid.GetNode (0, 5);
  37. NodeContainer consumerNodes;
  38. consumerNodes.Add (grid.GetNode (0,0));
  39.  
  40. // Install NDN applications
  41. std::string prefix = "/prefix";
  42.  
  43. ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr");
  44. consumerHelper.SetPrefix (prefix);
  45. consumerHelper.SetAttribute ("Frequency", StringValue ("2")); // 100 interests a second
  46. consumerHelper.Install (consumerNodes);
  47.  
  48. ndn::AppHelper producerHelper ("ns3::ndn::Producer");
  49. producerHelper.SetPrefix (prefix);
  50. producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
  51. producerHelper.Install (producer);
  52.  
  53. // Add /prefix origins to ndn::GlobalRouter
  54. ndnGlobalRoutingHelper.AddOrigins (prefix, producer);
  55.  
  56. // Calculate and install FIBs
  57. ndn::GlobalRoutingHelper::CalculateRoutes ();
  58.  
  59. Simulator::Stop (Seconds (5.0));
  60.  
  61. Simulator::Run ();
  62. Simulator::Destroy ();
  63.  
  64. return 0;
  65. }
Add Comment
Please, Sign In to add comment