[ndnSIM] Question for ndn-simple-with-pit-operation-stats.cc
Alex Afanasyev
alexander.afanasyev at ucla.edu
Fri Feb 14 15:32:48 PST 2014
Hi Aaron,
Which version of ndnSIM are you using (commit ID)? My latest version already contained GetPolicy() method in ContentStoreImpl class...
Not sure if you have modified content-store-impl.cc class to instantiate ContentStores with AggregateStats policy, but that could be a problem. In any case, after I added instantiations (I pushed my commit to github), I successfully run your scenario:
[cawka at cawka-mac ns-3 (ndnSIM)]$ ./waf --run ndn-simple-with-pit-operation-stats
Waf: Entering directory `/Users/cawka/Botan/ns3-ndn/ns-3/build'
Waf: Leaving directory `/Users/cawka/Botan/ns3-ndn/ns-3/build'
'build' finished successfully (1.386s)
PIT-Operation
Time NodeId Updates Inserts Lookups Erases
CS-Operation
Time NodeId Updates Inserts Lookups Erases
20 0 0 200 200 200
20 1 0 200 200 200
20 2 0 200 200 200
20 0 0 200 0 195
20 1 0 200 0 195
20 2 0 200 0 195
---
Alex
On Feb 12, 2014, at 7:56 PM, aaronishere <aaronishere at qq.com> wrote:
> Hi, Alex
>
> I changed ndn-simple-with-pit-operation-stats.cc like below so that both the times of insert/lookup/update/erase of CS and PIT can be shown:
>
> /////////////////////////////////////////////////////////////////////////////////////////////
> #include "ns3/core-module.h"
> #include "ns3/network-module.h"
> #include "ns3/point-to-point-module.h"
> #include "ns3/ndnSIM-module.h"
> #include "ns3/ndnSIM/model/pit/ndn-pit-impl.h"
> #include "ns3/ndnSIM/model/cs/content-store-impl.h"
> #include "ns3/ndnSIM/utils/trie/persistent-policy.h"
> #include "ns3/ndnSIM/utils/trie/random-policy.h"
> #include "ns3/ndnSIM/utils/trie/lru-policy.h"
> #include "ns3/ndnSIM/utils/trie/lfu-policy.h"
> #include "ns3/ndnSIM/utils/trie/multi-policy.h"
> #include "ns3/ndnSIM/utils/trie/aggregate-stats-policy.h"
> using namespace ns3;
>
> typedef ndn::ndnSIM::multi_policy_traits< boost::mpl::vector2< ndn::ndnSIM::persistent_policy_traits,
> ndn::ndnSIM::aggregate_stats_policy_traits > > PersistentWithCountsTraits;
> typedef ndn::ndnSIM::multi_policy_traits< boost::mpl::vector2< ndn::ndnSIM::random_policy_traits,
> ndn::ndnSIM::aggregate_stats_policy_traits > > RandomWithCountsTraits;
> typedef ndn::ndnSIM::multi_policy_traits< boost::mpl::vector2< ndn::ndnSIM::lru_policy_traits,
> ndn::ndnSIM::aggregate_stats_policy_traits > > LruWithCountsTraits;
> typedef ndn::ndnSIM::multi_policy_traits< boost::mpl::vector2< ndn::ndnSIM::lfu_policy_traits,
> ndn::ndnSIM::aggregate_stats_policy_traits > > LfuWithCountsTraits;
>
> void
> PITPeriodicStatsPrinter (Ptr<Node> node, Time next)
> {
> if (DynamicCast<ndn::pit::PitImpl<PersistentWithCountsTraits> > (node->GetObject<ndn::Pit> ()) == 0)
> {
> std::cerr << "Invalid PIT class, please correct the scenario" << std::endl;
> return;
> }
> // "ns3::ndn::pit::Persistent::AggregateStats"
> ndn::pit::PitImpl<PersistentWithCountsTraits>::super::policy_container &policy =
> DynamicCast<ndn::pit::PitImpl<PersistentWithCountsTraits> > (node->GetObject<ndn::Pit> ())->GetPolicy ();
>
> std::cout << Simulator::Now ().ToDouble (Time::S) << "\t"
> << node->GetId () << "\t"
> << policy.get<1> ().GetUpdates () << "\t"
> << policy.get<1> ().GetInserts () << "\t"
> << policy.get<1> ().GetLookups () << "\t"
> << policy.get<1> ().GetErases () << "\n";
>
> policy.get<1> ().ResetStats ();
> Simulator::Schedule (next, PITPeriodicStatsPrinter, node, next);
> }
>
> void
> CSPeriodicStatsPrinter (Ptr<Node> node, Time next)
> {
> if (DynamicCast<ndn::cs::ContentStoreImpl<LfuWithCountsTraits> > (node->GetObject<ndn::ContentStore> ()) == 0)
> {
> std::cerr << "Invalid CS class, please correct the scenario" << std::endl;
> return;
> }
>
> ndn::cs::ContentStoreImpl<LfuWithCountsTraits>::super::policy_container &policy =
> DynamicCast<ndn::cs::ContentStoreImpl<LfuWithCountsTraits> > (node->GetObject<ndn::ContentStore> ())->GetPolicy ();
>
> std::cout << Simulator::Now ().ToDouble (Time::S) << "\t"
> << node->GetId () << "\t"
> << policy.get<1> ().GetUpdates () << "\t"
> << policy.get<1> ().GetInserts () << "\t"
> << policy.get<1> ().GetLookups () << "\t"
> << policy.get<1> ().GetErases () << "\n";
>
> policy.get<1> ().ResetStats ();
> Simulator::Schedule (next, CSPeriodicStatsPrinter, node, next);
> }
>
> 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 CCNx stack on all nodes
> ndn::StackHelper ndnHelper;
> ndnHelper.SetDefaultRoutes (true);
> ndnHelper.SetPit ("ns3::ndn::pit::Persistent::AggregateStats");
> ndnHelper.SetContentStore ("ns3::ndn::cs::Lfu::AggregateStats", "MaxSize", "5");
> ndnHelper.InstallAll ();
> std::cout << "PIT-Operation"<<"\n";
> std::cout << "Time" << "\t"
> << "NodeId" << "\t"
> << "Updates" << "\t"
> << "Inserts" << "\t"
> << "Lookups" << "\t"
> << "Erases" << "\n";
> for (uint32_t i=0; i<nodes.GetN (); i++)
> // set up periodic PIT stats printer on node 1
> {
> Simulator::Schedule (Seconds (20), PITPeriodicStatsPrinter, nodes.Get (i), Seconds (20));
> }
>
> std::cout << "CS-Operation"<<"\n";
> std::cout << "Time" << "\t"
> << "NodeId" << "\t"
> << "Updates" << "\t"
> << "Inserts" << "\t"
> << "Lookups" << "\t"
> << "Erases" << "\n";
> for (uint32_t i=0; i<nodes.GetN (); i++)
> // set up periodic PIT stats printer on node 1
> {
> Simulator::Schedule (Seconds (20), CSPeriodicStatsPrinter, nodes.Get (i), Seconds (20));
> }
> // Installing applications
> ........
> /////////////////////////////////////////////////////////////////
> However, it errors like below
>
> [1207/2311] cxx: src/ndnSIM/examples/ndn-simple-with-pit-operation-stats.cc -> build/src/ndnSIM/examples/ndn-simple-with-pit-operation-stats.cc.21.o
> ../src/ndnSIM/examples/ndn-simple-with-pit-operation-stats.cc: In function ‘void CSPeriodicStatsPrinter(ns3::Ptr<ns3::Node>, ns3::Time)’:
> ../src/ndnSIM/examples/ndn-simple-with-pit-operation-stats.cc:102:107: error: ‘class ns3::ndn::cs::ContentStoreImpl<ns3::ndn::ndnSIM::multi_policy_traits<boost::mpl::vector2<ns3::ndn::ndnSIM::lfu_policy_traits, ns3::ndn::ndnSIM::aggregate_stats_policy_traits> > >’ has no member named ‘GetPolicy’
>
> I checked the content-store-impl.h and there is no function called GetPolicy while in the pit-impl.h has.
> And I add
> const typename super::policy_container &
> GetPolicy () const { return super::getPolicy (); }
> typename super::policy_container &
> GetPolicy () { return super::getPolicy (); }
> to the content-store-impl.h as the pit-impl.h has and it can compile but has a segment default.
>
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007ffff0abcf28 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&) ()
> from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
>
> Thus, how to write GetPolicy( ) function in the content-store-impl.h?
>
> Thanks in advance!
>
> Aaron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20140214/61e1ec66/attachment.html>
More information about the ndnSIM
mailing list