blob: 7fd8d5495800bfe4de9bf3f2f132191c1ea1cd06 [file] [log] [blame]
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2011-2015 Regents of the University of California.
*
* This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
* contributors.
*
* ndnSIM is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
// ndn-grid.cpp
#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"
namespace ns3 {
/**
* This scenario simulates a grid topology (using PointToPointGrid module)
*
* (consumer) -- ( ) ----- ( )
* | | |
* ( ) ------ ( ) ----- ( )
* | | |
* ( ) ------ ( ) -- (producer)(2,2)
*
* All links are 1Mbps with propagation 10ms delay.
*
* FIB is populated using NdnGlobalRoutingHelper.
*
* Consumer requests data from producer with frequency 100 interests per second
* (interests contain constantly increasing sequence number).
*
* For every received interest, producer replies with a data packet, containing
* 1024 bytes of virtual payload.
*
* To run scenario and see what is happening, use the following command:
*
* NS_LOG=ndn.Consumer:ndn.ConsumerZipfMandelbrot:ndn.Producer ./waf --run=ndn-zipf-mandelbrot
*/
int
main(int argc, char* argv[])
{
// LogComponentEnable("ndn.CbisGlobalRoutingHelper", LOG_LEVEL_INFO);
// Setting default parameters for PointToPoint links and channels
Config::SetDefault("ns3::PointToPointNetDevice::DataRate", StringValue("1Mbps"));
Config::SetDefault("ns3::PointToPointChannel::Delay", StringValue("1ms"));
Config::SetDefault("ns3::QueueBase::MaxSize", StringValue("10p"));
// Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
CommandLine cmd;
cmd.Parse(argc, argv);
// Creating 3x3 topology
PointToPointHelper p2p;
PointToPointGridHelper grid(3, 3, p2p);
grid.BoundingBox(100, 100, 200, 200);
// Install CCNx stack on all nodes
ndn::StackHelper ndnHelper;
// ndnHelper.SetForwardingStrategy ("ns3::ndn::fw::SmartFlooding");
// ndnHelper.SetContentStore ("ns3::ndn::cs::Lru", "MaxSize", "10");
ndnHelper.InstallAll();
// Choosing forwarding strategy
ndn::StrategyChoiceHelper::InstallAll("/prefix", "/localhost/nfd/strategy/ncc");
// Installing global routing interface on all nodes
// ndn::CbisGlobalRoutingHelper ndnGlobalRoutingHelper;
ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
ndnGlobalRoutingHelper.InstallAll();
// Getting containers for the consumer/producer
Ptr<Node> producer = grid.GetNode(2, 2);
NodeContainer consumerNodes;
consumerNodes.Add(grid.GetNode(0, 0));
// Install CCNx applications
std::string prefix = "/prefix";
ndn::AppHelper consumerHelper("ns3::ndn::ConsumerZipfMandelbrot");
// ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr");
consumerHelper.SetPrefix(prefix);
consumerHelper.SetAttribute("Frequency", StringValue("100")); // 100 interests a second
consumerHelper.SetAttribute("NumberOfContents", StringValue("100")); // 10 different contents
// consumerHelper.SetAttribute ("Randomize", StringValue ("uniform")); // 100 interests a second
consumerHelper.Install(consumerNodes);
ndn::AppHelper producerHelper("ns3::ndn::Producer");
producerHelper.SetPrefix(prefix);
producerHelper.SetAttribute("PayloadSize", StringValue("100"));
producerHelper.Install(producer);
ndnGlobalRoutingHelper.AddOrigins(prefix, producer);
// Calculate and install FIBs
ndn::GlobalRoutingHelper::CalculateRoutes();
Simulator::Stop(Seconds(1.0));
Simulator::Run();
Simulator::Destroy();
return 0;
}
} // namespace ns3
int
main(int argc, char* argv[])
{
return ns3::main(argc, argv);
}