Project

General

Profile

Bug #2559 ยป ndn-losing-data.cpp

Example scenario, run ./waf --run ndn-losing-data --vis - Christian Kreuzberger, 02/25/2015 07:29 AM

 
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/ndnSIM-module.h"

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"));

// Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
CommandLine cmd;
cmd.Parse(argc, argv);

// 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 NDN stack on all nodes
ndn::StackHelper ndnHelper;
ndnHelper.SetDefaultRoutes(true);
ndnHelper.setCsSize(1);
ndnHelper.InstallAll();

// Choosing forwarding strategy
ndn::StrategyChoiceHelper::InstallAll("/itec", "/localhost/nfd/strategy/broadcast");

// Installing applications

// Consumer
ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
consumerHelper.SetPrefix("/prefix/abcdefghijklmnopqrstuvwxyz/123456789/need/more/somefile.txt");
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/abcdefghijklmnopqrstuvwxyz/123456789/need/more/somefile.txt");
producerHelper.SetAttribute("PayloadSize", StringValue("449"));
producerHelper.Install(nodes.Get(2)); // last node

Simulator::Stop(Seconds(10.0));

Simulator::Run();
Simulator::Destroy();

std::cout << "Simulation Done!" << std::endl;

return 0;
}

} // namespace ns3

int
main(int argc, char* argv[])
{
return ns3::main(argc, argv);
}
    (1-1/1)