| /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| /* |
| * Copyright (c) 2011-2012 University of California, Los Angeles |
| * |
| * This program is free software; you can redistribute it and/or modify |
| * it under the terms of the GNU General Public License version 2 as |
| * published by the Free Software Foundation; |
| * |
| * This program 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 this program; if not, write to the Free Software |
| * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| * |
| * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| */ |
| // ndn-grid-topo-plugin.cc |
| #include "ns3/core-module.h" |
| #include "ns3/network-module.h" |
| #include "ns3/ndnSIM-module.h" |
| |
| using namespace ns3; |
| |
| /** |
| * This scenario simulates a grid topology (using topology reader module) |
| * |
| * (consumer) -- ( ) ----- ( ) |
| * | | | |
| * ( ) ------ ( ) ----- ( ) |
| * | | | |
| * ( ) ------ ( ) -- (producer) |
| * |
| * All links are 1Mbps with propagation 10ms delay. |
| * |
| * FIB is populated using NdnGlobalRoutingHelper. |
| * |
| * Consumer requests data from producer with frequency 10 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.Producer ./waf --run=ndn-grid-topo-plugin |
| */ |
| |
| int |
| main (int argc, char *argv[]) |
| { |
| CommandLine cmd; |
| cmd.Parse (argc, argv); |
| |
| AnnotatedTopologyReader topologyReader ("", 25); |
| topologyReader.SetFileName ("src/ndnSIM/examples/topology/topo-grid-3x3.txt"); |
| topologyReader.Read (); |
| |
| // Install CCNx stack on all nodes |
| ndn::StackHelper ccnxHelper; |
| ccnxHelper.InstallAll (); |
| |
| // Installing global routing interface on all nodes |
| ndn::GlobalRoutingHelper ccnxGlobalRoutingHelper; |
| ccnxGlobalRoutingHelper.InstallAll (); |
| |
| // Getting containers for the consumer/producer |
| Ptr<Node> producer = Names::Find<Node> ("Node8"); |
| NodeContainer consumerNodes; |
| consumerNodes.Add (Names::Find<Node> ("Node0")); |
| |
| // Install CCNx applications |
| std::string prefix = "/prefix"; |
| |
| ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr"); |
| consumerHelper.SetPrefix (prefix); |
| consumerHelper.SetAttribute ("Frequency", StringValue ("100")); // 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 |
| ccnxGlobalRoutingHelper.AddOrigins (prefix, producer); |
| |
| // Calculate and install FIBs |
| ccnxGlobalRoutingHelper.CalculateRoutes (); |
| |
| Simulator::Stop (Seconds (20.0)); |
| |
| Simulator::Run (); |
| Simulator::Destroy (); |
| |
| return 0; |
| } |