[Nfd-dev] NDNLPv2: create lp::packet and add content

Junxiao Shi shijunxiao at email.arizona.edu
Sat Jul 29 21:58:44 PDT 2017


Hi Adhy

You have:
* define the LpHeaderField
* define the Tag
* encode Tag into LpHeaderField in NFD LinkService

You are missing:
* encode Tag into LpHeaderField in ndn-cxx client face (look at ndn-cxx
face.cpp and face-impl.hpp)
* decode LpHeaderField into Tag in ndn-cxx client face
* decode LpHeaderField into Tag in NFD LinkService
* copy Tag from incoming packet to outgoing packet (probably no code change
is needed for now, but keep in mind that NDNLP is a single-hop protocol and
the forwarding plane is not onligated to preserve tags)

If the information is end-to-end, you shouldn't be using NDNLP header
field. Put it in the Interest name or Data payload instead.

Yours, Junxiao

On Thu, Jul 27, 2017 at 13:47 Adhy Satya <adhysatya820 at gmail.com> wrote:

>
> I was able to create a new field in the NDNLP packet.
>>
>> I changed the following files:
>> "ndn-cxx/src/lp/fields.hpp"
>>
>>     typedef detail::FieldDecl<field_location_tags::Header,
>>                                             uint64_t,
>>                                             tlv::CustomTag>
>> CustomTagField;
>>     BOOST_CONCEPT_ASSERT((Field<CustomTagField>));
>>
>>     CustomTagField
>>      > FieldSet;
>>
>>
>> "ndn-cxx/src/lp/tags.hpp"
>>
>> typedef SimpleTag<uint64_t, 0x60000001> CustomTag;
>>
>>
>> "ndn-cxx/src/lp/tlv.hpp"
>>
>> CustomTag= 901
>>
>> compiled with ./waf
>>
>> "NFD/daemon/face/generic-link-service.cpp"
>>
>> void
>> GenericLinkService::encodeLocalFields(const ndn::TagHost& netPkt,
>> lp::Packet& lpPacket)
>> {
>>   shared_ptr<lp::IncomingFaceIdTag> incomingFaceIdTag =
>> netPkt.getTag<lp::IncomingFaceIdTag>();
>>   if (incomingFaceIdTag != nullptr) {
>>     lpPacket.add<lp::IncomingFaceIdField>(*incomingFaceIdTag);
>>   }
>>
>>   shared_ptr<lp::CustomTag> customTag = netPkt.getTag<lp::CustomTag>();
>>   if (customTag != nullptr) {
>>     lpPacket.add<lp::CustomTagField>(*customTag);
>>   }
>> }
>>
>>
>> compiled with ./waf
>>
>> "ndn-cxx/examples/consumer.cpp"
>>
>>     // Insert Packet Tag
>>     interest.setTag(std::make_shared<lp::CustomTag>(54321));
>>     std::cout << "Tag value: " << interest.getTag<lp::CustomTag>() <<
>> std::endl;
>>
>>     m_face.expressInterest(interest,
>>                            bind(&Consumer::onData, this,  _1, _2),
>>                            bind(&Consumer::onTimeout, this, _1));
>>
>>
>> and finally, on the producer app
>> "ndn-cxx/examples/producer.cpp"
>>
>> onInterest(const InterestFilter& filter, const Interest& interest)
>>   {
>>     std::cout << "<< I: " << interest << std::endl;
>>
>>     // Read Packet Tag
>>     std::shared_ptr<lp::CustomTag> tag = interest.getTag<lp::CustomTag>();
>>     std::cerr << "Tag from Consumer: " << tag << std::endl;
>>
>>
>> compiled with ./waf
>> and ran the applications, but the tag doesn't arrive at the producer:
>>
>> << I:
>> /example/testApp/randomData?ndn.MustBeFresh=1&ndn.InterestLifetime=1000&ndn.Nonce=1547038398
>> Tag from Consumer: 0
>>
>>
>>
>> Is there anything missing?
>>
>>
>> Thank you
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/nfd-dev/attachments/20170730/24f48d9a/attachment.html>


More information about the Nfd-dev mailing list