[ndnSIM] A question about printing out PIT contents

Amin Karami amin at ac.upc.edu
Sun Nov 17 07:52:05 PST 2013


Hi Alex,
I wrote a function as follows based on your guidance to print out PIT 
contents:
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/ndnSIM-module.h"
#include "ns3/ndn-fib-entry.h"
#include "ns3/ndn-fib.h"

using namespace ns3;
using namespace ndn;
using namespace fib;

void PeriodicStatsPrinter (Ptr<Node> node, Time next)
{

Ptr<ndn::Pit> pit = node->GetObject<ndn::Pit> ();
for (Ptr<ndn::pit::Entry> entry = pit->Begin (); entry != pit->End (); 
entry = pit->Next (entry))
   {
     std::cout << "=========" << std::endl;
     std::cout << entry->GetPrefix () << std::endl;

     for (FaceMetricContainer::type::index<i_nth>::type::iterator metric 
= entry->m_faces.get<i_nth> ().begin();
          metric != entry->m_faces.get<i_nth> ().end(); metric++)
       {
           os << metric->GetSRtt () << ", " << metric->GetRttVar << "\t";
       }

     // Print Prefix name, In Interface, Out Interface, Nonces
     //std::cout << *entry << std::endl;
   }
   Simulator::Schedule (next, PeriodicStatsPrinter, node, next);
}

When I ran the scenario, I faced with an error:
../scratch/PIT/PITInfo.cc: In function ‘void 
PeriodicStatsPrinter(ns3::Ptr<ns3::Node>, ns3::Time)’:
../scratch/PIT/PITInfo.cc:38:82: error: ‘class ns3::ndn::pit::Entry’ has 
no member named ‘m_faces’
../scratch/PIT/PITInfo.cc:38:99: error: expected primary-expression 
before ‘>’ token
../scratch/PIT/PITInfo.cc:38:102: error: expected primary-expression 
before ‘)’ token
../scratch/PIT/PITInfo.cc:39:27: error: ‘class ns3::ndn::pit::Entry’ has 
no member named ‘m_faces’
../scratch/PIT/PITInfo.cc:39:44: error: expected primary-expression 
before ‘>’ token
../scratch/PIT/PITInfo.cc:39:47: error: expected primary-expression 
before ‘)’ token


But, i call "ndn-fib-entry.h" and "ndn-fib.h" to declare the variables. 
Where is the problem?


/Amin


On 09/28/2013 03:43 ق.ظ, Alex Afanasyev wrote:
> Hi Amin,
>
> Since this information belongs to each individual face (FaceMetric instance) inside FIB entry, you need to access individual items like this:
>
> Ptr<ndn::Pit> pit = node->GetObject<ndn::Pit> ();
> for (Ptr<ndn::pit::Entry> entry = pit->Begin (); entry != pit->End (); entry = pit->Next (entry))
>    {
>      std::cout << "=========" << std::endl;
>      std::cout << entry->GetPrefix () << std::endl;
>
>      for (FaceMetricContainer::type::index<i_nth>::type::iterator metric =
>             entry->m_faces.get<i_nth> ().begin ();
>           metric != entry->m_faces.get<i_nth> ().end ();
>           metric++)
>        {
>          os << metric->GetSRtt () << ", " << metric->GetRttVar << "\t";
>        }
>    }
>
> ---
> Alex
>
> On Sep 27, 2013, at 4:48 AM, Amin Karami <amin at ac.upc.edu> wrote:
>
>> Hi Alex,
>> If we want to print some extra information such as, RTT (or incoming time of Interest into PIT and the response time) for each entry, what we should do?
>> Thanks a lot.
>>
>> I looking forward to your response.
>>
>> Best Regards,
>> Amin
>>
>>
>> On 09/26/2013 06:25 ق.ظ, Alex Afanasyev wrote:
>>> Hi Liu,
>>>
>>> You can do something like this:
>>>
>>> input: Ptr<Node> node;
>>>
>>> Ptr<ndn::Pit> pit = node->GetObject<ndn::Pit> ();
>>> for (Ptr<ndn::pit::Entry> entry = pit->Begin (); entry != pit->End (); entry = pit->Next (entry))
>>>    {
>>>      std::cout << *entry << std::endl;
>>>    }
>>>
>>> This will print out content of each PIT entry in the default format.  If you want some customizations, you can either directly access elements of PIT entry, or modify Print method of Pit implementation.
>>>
>>> ---
>>> Alex
>>>
>>> On Sep 25, 2013, at 6:41 PM, 刘总真 <liuzongzhen at cstnet.cn> wrote:
>>>
>>>> Hi Alex,
>>>>
>>>> I want to print out PIT contents, such as the incoming and outgoing interface. But I don’t know which function to use. Any suggestion?Thanks a lot!
>>>>
>>>> Looking forward to your response.
>>>>
>>>> Liu Zongzhen
>>> _______________________________________________
>>> ndnSIM mailing list
>>> ndnSIM at lists.cs.ucla.edu
>>> http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim
>> _______________________________________________
>> ndnSIM mailing list
>> ndnSIM at lists.cs.ucla.edu
>> http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim



More information about the ndnSIM mailing list