[ndnSIM] How to add a new variable

Alex Afanasyev aa at CS.UCLA.EDU
Fri Feb 10 09:24:31 PST 2017

My guess that you have missed two more steps while modifying data.cpp. You also need to properly encode and decode your new string to/from wire format.

However, I'm kind of unsure what the problem you referring about receiving trash. The producer app is controlling what is put into the content and in which format.  If you want to publish just a string, you just need to encode and decode it from the content.  If you want to include more content (e.g., to inflate packet size), you can define a small structure on how content part is encoded.


> On Feb 10, 2017, at 4:06 AM, 呂建德 <v0918732669 at gmail.com> wrote:
> Dear all
> I want to add a new variable in data.hpp and  create get&set functions.
> Then , in ndn-producer.cpp::oninterest , i use set functions like below.
> data->setString(str);
> //std::cout << data->getString() << std::endl;
> I make sure that the str was set.
> but , in ndn-consumer.cpp::ondata , i use get functions like below.
> std::cout << data->getString() << std::endl;
> there is something wrong, str is empty!
> why i want to do that is the content may be encoded , 
> and the consumer will receive some trash that i dont need.
> can someone help me to solve this questions
> I need some steps or tips.
> _______________________________________________
> 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