[ndnSIM] how to add private member variable in class Intererst

Spyridon (Spyros) Mastorakis mastorakis at CS.UCLA.EDU
Tue Mar 28 10:56:40 PDT 2017


Hi,

a step-by-step solution varies, therefore I can only help with some general guidelines:

1) Add the desired attribute to the Interest/Data class.

2) Encode and decode the attribute (modify the wireEncode and wireDecode classes respectively). The NDN packet encoding follows a TLV format that stands for Type Length Value, therefore, you have to use the API provided by ndn-cxx to:

	a) define a new type for the field you want to add: https://github.com/named-data-ndnSIM/ndn-cxx/blob/ndn-cxx-0.5.0-17-g99832d4-ndnSIM/src/encoding/tlv.hpp <https://github.com/named-data-ndnSIM/ndn-cxx/blob/ndn-cxx-0.5.0-17-g99832d4-ndnSIM/src/encoding/tlv.hpp>
	
	b) for the length and value fields, encode/decode your field using the appropriate format (non negative integer, string block, etc.). Use the block helpers to do that: https://github.com/named-data-ndnSIM/ndn-cxx/blob/ndn-cxx-0.5.0-17-g99832d4-ndnSIM/src/encoding/block-helpers.cpp <https://github.com/named-data-ndnSIM/ndn-cxx/blob/ndn-cxx-0.5.0-17-g99832d4-ndnSIM/src/encoding/block-helpers.cpp>

	c) Pointer to the NDN TLV packet format: http://named-data.net/doc/NDN-TLV/current/ <http://named-data.net/doc/NDN-TLV/current/>

3) If you want to modify a field on a hop by hop basis, the best way to do that would be to define a new Link Protocol (LP) field instead of directly modifying the Interest/Data classes. I have done that for the hopCount of data packets and the way to do that for any new LP field is similar:

https://github.com/named-data-ndnSIM/NFD/commit/d0abae38024a6aecf6f956f4bbea36f4a9ff6d6f <https://github.com/named-data-ndnSIM/NFD/commit/d0abae38024a6aecf6f956f4bbea36f4a9ff6d6f>
https://github.com/named-data-ndnSIM/ndn-cxx/commit/4692ba80cf1dcf07acbbaba8a134ea22481dd457 <https://github.com/named-data-ndnSIM/ndn-cxx/commit/4692ba80cf1dcf07acbbaba8a134ea22481dd457>
https://github.com/named-data-ndnSIM/ndn-cxx/commit/e53204419c51356dab70e0e5450ff5dcf587827a <https://github.com/named-data-ndnSIM/ndn-cxx/commit/e53204419c51356dab70e0e5450ff5dcf587827a>
https://github.com/named-data-ndnSIM/ndnSIM/commit/73df9f587e1c16c4f67a0053fe29b68f523ff138 <https://github.com/named-data-ndnSIM/ndnSIM/commit/73df9f587e1c16c4f67a0053fe29b68f523ff138>

Hope that this helps,

Spyridon (Spyros) Mastorakis
Personal Website: http://cs.ucla.edu/~mastorakis/ <http://cs.ucla.edu/~mastorakis/>
Internet Research Laboratory
Computer Science Department
UCLA

> On Mar 28, 2017, at 8:14 AM, 呂建德 <v0918732669 at gmail.com> wrote:
> 
> Hi
> 
> I also had the same problem , and happened that "TLV length doesn't match buffer length".
> 
> I add the length of my value to the "totallength" , and it pops up that messages.
> 
> Anyone knows how to fixed it step by step , I will appreciate very much 
> 
> 2017-03-28 17:19 GMT+08:00 lahmer ilyas <ilyaslahmer93 at gmail.com <mailto:ilyaslahmer93 at gmail.com>>:
> Hi, I had the same problem, but I added a string rather than int in the interest. My solution was to recreate the interest at each hop with the new string value. I don't know why but this fixed the problem.
> 
> 
> 
> Sent from BlueMail <http://www.bluemail.me/r>
> 
> On Mar 28, 2017, at 3:26 AM, gc199211 <gc199211 at mail.ustc.edu.cn <mailto:gc199211 at mail.ustc.edu.cn>> wrote:
>  
> Hi sir :
>      I find  out that my last email is incomplete in maillist, so I  finish it  and send again. 
>      I am  trying to add  hop information in Interest recently on ndnSIM 2.2. Here is my code.
> 1). I add a private member variable  which is named hop in ndnSIM/ndn-cxx/src/interest.h 
>             private:
>                           Name m_name;
>                                       ......
>                          mutable Block m_wire;
>                           int hop;           // a new private member variable                       
>                    
> 2). I increace the value of hop in the nfd::Forwarder::onOutgoingInterest(shared_ptr<pit::Entry> pitEntry, Face& outFace,bool  wantNewNonce),so as to caculate the hop .
>   
>                int tmpHop=interest->getHop();
>                tmpHop++;
>                interest->setHop(tmpHop);                
>  
> Here is my problem,It seems that the hop value is always 0 no matter how many nodes it is forwarded.How to solve the problem? I know there is a ns3::ndn::FwHopCountTag a to caculate the hop in ns3::ndn::NetDeviceLinkService ,But I want to caculate the hop value directly in Interest. If it works ,I can add other member variable in Interest  which is quite important for my research.Thank you very much .
>                                                                                                                                                                     !  &nb sp;                 
> 2016-12-20
> gc199211

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20170328/4a5ff8f3/attachment.html>


More information about the ndnSIM mailing list