[ndnSIM] Modify/Read payload content & Read the content in cache
Kanin Assantachai
kanin at inl.ics.keio.ac.jp
Sat May 16 09:22:44 PDT 2015
Dear Alex / Spyridon,
Currently I am working with various parts of the simulator (version 1.1)
related to its caching mechanism. I need your kind help for the
following questions.
1. I would like to modify the payload of packets sent by the producer
app. My current approach is to change this part of code in the
OnInterest() function of ndn-producer.cc:
Ptr<Data> data = Create<Data> (Create<Packet> (m_virtualPayloadSize));
to
std::string string = "Hello";
Ptr<Data> data = Create<Data> (Create<Packet> (reinterpret_cast<const
uint8_t*>(&string[0]), 5));
I want to firstly check if this simple way works. Even though the code
is compiled without an error, I have a difficulty checking whether the
payload of the packet really carries this string "Hello". So far, I add
this code to the OnData() function of ndn-consumer.cc to try to read the
content of the payload:
data->GetPayload ()->Print (std::cout);
It only outputs the size of the payload in the terminal. I have tried
reading this previous archive about reading the content of payload but
still cannot solve this problem:
http://www.lists.cs.ucla.edu/pipermail/ndnsim/2015-January/001501.html
In summary, my questions are whether my simple method in adding a
specific string to the payload works, and which function (or other
approach) can I use to really see the real content (string) of the payload?
2. I would like to get the latest content which has just been added to
the LRU cache. So in the file "lru-policy.h", after this line of code in
the insert() function:
policy_container::push_back (*item);
I tried adding this line of code to read the newly added content:
std::cout << "Item added: " << policy_container::end
()->payload()->GetName() << std::endl;
When I compile the file, I get an error saying that the compiler cannot
recognize the GetName() function. I wonder if I need to #include other
files. My reference is this archive:
http://www.lists.cs.ucla.edu/pipermail/ndnsim/2014-July/001329.html
Thank you for your help in advance.
Sincerely,
Kanin Assantachai
More information about the ndnSIM
mailing list