// Saran 27/12/2012 // ndn-multicast.cc #include "ns3/core-module.h" #include "ns3/network-module.h" #include "ns3/ndnSIM-module.h" #include #include #include #include // for ndn::L3AggregateTracer #include // for ndn::L3RateTracer #include // for ndn::CsImptTracer #include // for ndn::AppDelayTracer #include using namespace ns3; using namespace std; int main (int argc, char *argv[]) { std::string zipf_s = "1.0"; std::string cache_replacement = "Lfu"; //std::cout<< "Note: s = " << zipf_s << std::endl; //srand ( time(NULL) ); CommandLine cmd; cmd.AddValue("zipf_s", "parameter 's' of Zipf", zipf_s); cmd.AddValue("cache_replacement", "cache replacement policy", cache_replacement); cmd.Parse (argc, argv); std::cout << "Note: s = " << zipf_s << std::endl; std::cout << "Note: Cache Replacement Policy : " << cache_replacement << std::endl; AnnotatedTopologyReader topologyReader ("", 25); topologyReader.SetFileName ("scratch/topology_intersection"); topologyReader.Read (); NodeContainer a = topologyReader.GetNodes (); int numberOfNode = a.GetN (); std::cout << "Number of vertices in the network = " << numberOfNode << std::endl; // Install CCNx stack on all nodes ndn::StackHelper ccnxHelper; ccnxHelper.SetForwardingStrategy ("ns3::ndn::fw::Flooding"); //////////////////////////////////////////////////////////////////////////////////////// // Read the CS size from Topology_CPSP string line; ifstream myfile ("scratch/topology_intersection"); if (myfile.is_open()) { while (!myfile.eof ()) { getline (myfile,line); if (line.compare("router") == 0) continue; // skip "router" if (line[0] == '#') continue; // comments if (line == "link") break; // stop reading nodes istringstream lineBuffer (line); string name, city; double latitude = 0, longitude = 0; string cacheSize = "1"; lineBuffer >> name >> city >> latitude >> longitude >> cacheSize; if (name.empty ()) continue; // Define the designated cache size to a particular node. if (cacheSize.compare("0") == 0) { ccnxHelper.SetContentStore ("ns3::ndn::cs::Nocache"); ccnxHelper.Install (Names::Find (name)); } else { ccnxHelper.SetContentStore ("ns3::ndn::cs::" + cache_replacement, "MaxSize", cacheSize); ccnxHelper.Install (Names::Find (name)); } cout << name << " : " << cacheSize << endl; } myfile.close(); } else { cout << "Unable to open file" << endl; } //////////////////////////////////////////////////////////////////////////////////////// // Installing global routing interface on all nodes ndn::GlobalRoutingHelper ccnxGlobalRoutingHelper; ccnxGlobalRoutingHelper.InstallAll (); ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerZipfMandelbrot"); consumerHelper.SetAttribute ("NumberOfContents", StringValue ("100")); consumerHelper.SetAttribute ("q", StringValue ("0.0")); consumerHelper.SetAttribute ("s", StringValue (zipf_s)); // ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr"); NodeContainer consumerNodes1; consumerNodes1.Add (Names::Find ("Node11")); consumerNodes1.Add (Names::Find ("Node12")); consumerNodes1.Add (Names::Find ("Node13")); consumerNodes1.Add (Names::Find ("Node14")); std::string prefix1 = "/prefix1"; consumerHelper.SetPrefix (prefix1); consumerHelper.SetAttribute ("Frequency", StringValue ("8")); consumerHelper.Install (consumerNodes1); ndn::AppHelper producerHelper ("ns3::ndn::Producer"); Ptr producer1 = Names::Find ("Node0"); producerHelper.SetPrefix (prefix1); producerHelper.SetAttribute ("PayloadSize", StringValue("1040")); producerHelper.Install (producer1); ccnxGlobalRoutingHelper.AddOrigins (prefix1, producer1); // Calculate and install FIBs ccnxGlobalRoutingHelper.CalculateRoutes (); // Simulator::Stop (Seconds (10000.0)); Simulator::Run (); Simulator::Destroy (); return 0; }