[ndnSIM] Find corresponding CS entry for the given data packet

Junxiao Shi shijunxiao at email.arizona.edu
Fri Jul 1 07:22:57 PDT 2016


Hi Qinchao

I understand your question as: given a ContentStore and a Data packet, determine whether the same Data packet already exists in the ContentStore.
This can be achieved as:

void
isDataInContentStore(const ndn::Data& data, const nfd::cs::Cs& cs,
                     std::function<void(bool)> cb)
{
  ndn::Name fullName = data.getFullName();
  ndn::Interest interest(fullName);
  cs.find(interest,
          bind([cb] { cb(true); }),
          bind([cb] { cb(false); }));
}

First we create an Interest that would match the specified Data packet if it exists in the CS; the Interest would not match any other Data packet because it contains the implicit digest. The CS is then queried with the Interest, and the result is returned asynchronously.

Yours, Junxiao

From: 潘庆超
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20160701/b40254a3/attachment.html>


More information about the ndnSIM mailing list