[ndnSIM] Add a tag to packet
Alex Afanasyev
aa at CS.UCLA.EDU
Tue Dec 27 13:57:27 PST 2016
> On Dec 27, 2016, at 11:15 AM, Fatemeh Goudarzi <fatemeh.university at gmail.com> wrote:
>
> Hi,
>
> I want to access the packet in the cache policy (for example random-policy.hpp ) for adding a tag to it. I create a new tag to record node-Id and If the node cache the content, it will add this tag to the content packet. In the insert() method, I have the following code: "Ptr<const Packet> pkt = item->payload()->GetPacket ();" to access packet and then "pkt->AddPacketTag (tag_id); " but I get this error:
>
> error: ‘class ns3::ndn::cs::EntryImpl<ns3::ndn::cs::ContentStoreImpl<ns3::ndn::ndnSIM::rand2_policy_traits> >’ has no member named ‘GetPacket’
Yes, there is not "GetPacket" method in the ns3::ndn::cs::EntryImpl or it's base class.
>
> I also try the following code:
>
> auto data = item->payload()->GetData();
> auto dataTag = data-> getTag <ns3::ndn::Ns3PacketTag> ();
> bool hasTag = dataTag->getPacket()->PeekPacketTag(tag);
>
>
> and also get this error:
>
> error: expected primary-expression before ‘>’ token
> auto dataTag = data-> getTag <ns3::ndn::Ns3PacketTag> ();
> could you give me some hint?
For this one gcc is not too helpful with C++ syntactic sugar (clang actually gives a good suggestion), but it is easily fixable. You need to add "template" keyword:
auto dataTag = data-> template getTag <ns3::ndn::Ns3PacketTag> ();
Should work afterwards.
--
Alex
More information about the ndnSIM
mailing list