[ndnSIM] How to Use Tag in ndnSIM 2.1

cjb0725 at mail.ustc.edu.cn cjb0725 at mail.ustc.edu.cn
Tue Nov 1 20:01:47 PDT 2016


Hi Junxiao,


Many thanks for the reply.


I learned that I can attach ns3 packet tags to deliver message just after I sent the first email, but I didn't understand why ndn tag could not do the same thing, so thanks again for the explanation for ndn tag, now I understand that. But I still got something to figure out:


1.Since the feature is pending removal in the next ndnSIM release, how can I encode information in packet or data, can you give me some usual/common methods to do so.


2.You mentioned encoding information in part of Name or Content, Consumer requests content by name, if I changed its name, will it be correctly consumed ?


3.I got this code in Producer::OnInterest: 
  data->setContent(make_shared< ::ndn::Buffer>(m_virtualPayloadSize)); 
 It seems the producer makes a virtual content and adds it to data's payload, how can I add information to content? 


Can you give me some advice to deal with the above?


Thanks~


Jiebo Chen


-----原始邮件-----
发件人:"Junxiao Shi" <shijunxiao at email.arizona.edu>
发送时间:2016-11-01 21:45:06 (星期二)
收件人: "cjb0725 at mail.ustc.edu.cn" <cjb0725 at mail.ustc.edu.cn>
抄送: ndnsim <ndnsim at lists.cs.ucla.edu>
主题: RE: How to Use Tag in ndnSIM 2.1


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
From: cjb0725 at mail.ustc.edu.cn
Sent: ‎11/‎1/‎2016 3:47
To: 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;
    }
    else{
      int tag = mytag_ptr->get();
      std::cout<<"forwarder: onIncomingData: mytag = "<<tag<<std::endl;
      if(tag > 0){
        mytag_ptr->decrement();  
        std::cout<<"forwarder: onIncomingData: after dec :mytag = "<<mytag_ptr->get()<<std::endl;


        if (m_csFromNdnSim == nullptr)
          m_cs.insert(*dataCopyWithoutPacket);
        else
          m_csFromNdnSim->Add(dataCopyWithoutPacket);
      }
      data.setTag(mytag_ptr);
    }
-------------------------------------------------------------------------------
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: 
App::OnData:/prefix/%FE%1D
------------------------------------------------------------------------------
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

--
陈劼博
中国科学技术大学自动化系
cjb0725 at mail.ustc.edu.cn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20161102/ce581af4/attachment.html>


More information about the ndnSIM mailing list