[ndnSIM] How to Use Tag in ndnSIM 2.1

Junxiao Shi shijunxiao at email.arizona.edu
Tue Nov 1 06:45:06 PDT 2016

Hi Jiebo

TagHost can only be used with subclass of ndn::Tag, not ns-3 tag.
ndn::Tag can only be used to pass information between components of the same software. Once a Data is encoded, the Tag isn't part of wire encoding, and thus will not reappear on the next node when the wire encoding is decoded again. Likewise, Tag will be lost when a packet goes between NFD and a local application, which also traverses a face.

ndnSIM 2.2 and below allows passing ns-3 packet tags between nodes. This feature is pending removal in the next ndnSIM release.
You should really encode information as part of wire encoding, such as in part of Name or Content, instead of relying on Tag.

Yours, Junxiao

-----Original Message-----
From: "cjb0725 at mail.ustc.edu.cn" <cjb0725 at mail.ustc.edu.cn>
Sent: ‎11/‎1/‎2016 3:47
To: "shijunxiao at email.arizona.edu" <shijunxiao at email.arizona.edu>
Subject: How to Use Tag in ndnSIM 2.1

Hi junxiao,
  I'm a postgraduate in University of Science and Technology of China, and a beginer for ndnSIM. 
  I found that the class Data is inherited from tag-host, so I wrote a MyTag inhrited from ns3::ndn::Tag, and there's only an Integer in MyTag, and I added it to data, but once the data was send to next node, I got nullptr when the function getTag<ns3::ndn::MyTag>() was called.

ns-3/src/ndnSIM/NFD/daemon/fw/forwarder.cpp   void Forwarder::onIncomingData(Face& inFace, const Data& data)

shared_ptr<ns3::ndn::MyTag> mytag_ptr = data.getTag<ns3::ndn::MyTag>();
    if(mytag_ptr == nullptr){
      std::cout<<"forwarder: onIncomingData: mytag_ptr = null"<<std::endl;
      int tag = mytag_ptr->get();
      std::cout<<"forwarder: onIncomingData: mytag = "<<tag<<std::endl;
      if(tag > 0){
        std::cout<<"forwarder: onIncomingData: after dec :mytag = "<<mytag_ptr->get()<<std::endl;

        if (m_csFromNdnSim == nullptr)
I got "forwarder: onIncomingData: mytag_ptr = null" using ndn-simple. Part of the result below:
producer:  mytag = 2
producer:  setTag 
node(2) responding with Data: /prefix/%FE%1D
onIncomingData face=258 data=/prefix/%FE%1D
forwarder: onIncomingData: mytag = 2
forwarder: onIncomingData: after dec :mytag = 1
onOutgoingData: face: 256; data:/prefix/%FE%1D
onOutgoingData: tag: 1
onIncomingData face=257 data=/prefix/%FE%1D
forwarder: onIncomingData: mytag_ptr = null
onOutgoingData: face: 256; data:/prefix/%FE%1D
onOutgoingData: tagptr=null: 
onIncomingData face=256 data=/prefix/%FE%1D
forwarder: onIncomingData: mytag_ptr = null
onOutgoingData: face: 258; data:/prefix/%FE%1D
onOutgoingData: tagptr=null: 
Please kindly let me get your guidance how can I get this correctly.

With Best Regards.Chen Jiebo-----------------------------------------------
University of Science and Technology of China
Department of Automation
cjb0725 at mail.ustc.edu.cn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20161101/5f214813/attachment.html>

More information about the ndnSIM mailing list