[Nfd-dev] NDNLPv2: create lp::packet and add content
Adhy Satya
adhysatya820 at gmail.com
Fri Aug 11 08:34:22 PDT 2017
Hi Junxiao,
Thanks for your comments. The info is not end-to-end.
I updated my NFD and ndn-cxx to version 0.5.1 as per the other email on
Ethernet broadcast face. Then I redid my steps above: defined
LpHeaderField. defined Tag, assigned a tag number, but with GeoTag instead,
which is I'm trying to accomplish.
Then I compile ndn-cxx with ./waf and ./waf install. Works perfectly!
The problem is when I modify my NFD LinkService to encode and decode the
new tag, I get the error "error: ‘GeoTag’ is not a member of
‘ndn::lp::tlv’". Complete error message attached.
How do I solve this?
For the remaining steps (encode/decode into LpHeaderField into Tag in
ndn-cxx), can I use the approach that was used in the ndnSIM Mobile
Simulation Package (
https://github.com/4th-ndn-hackathon/ndnSIM-Mobile-Simulation-Package/blob/master/ndn-cxx/src/lp/geo-tag.cpp
)?
Thanks
On Sun, Jul 30, 2017 at 12:58 AM, Junxiao Shi <shijunxiao at email.arizona.edu>
wrote:
> 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/20170811/e3e6b4e1/attachment-0001.html>
-------------- next part --------------
[ 97/164] Compiling daemon/face/generic-link-service.cpp
In file included from /usr/local/include/ndn-cxx/lp/packet.hpp:25:0,
from ../daemon/face/lp-fragmenter.hpp:31,
from ../daemon/face/generic-link-service.hpp:30,
from ../daemon/face/generic-link-service.cpp:26:
/usr/local/include/ndn-cxx/lp/fields.hpp:90:19: error: ‘GeoTag’ is not a member of ‘ndn::lp::tlv’
tlv::GeoTag> GeoTagField;
^
/usr/local/include/ndn-cxx/lp/fields.hpp:90:19: error: ‘GeoTag’ is not a member of ‘ndn::lp::tlv’
/usr/local/include/ndn-cxx/lp/fields.hpp:90:30: error: template argument 3 is invalid
tlv::GeoTag> GeoTagField;
^
In file included from /usr/local/include/ndn-cxx/lp/field-decl.hpp:25:0,
from /usr/local/include/ndn-cxx/lp/fields.hpp:25,
from /usr/local/include/ndn-cxx/lp/packet.hpp:25,
from ../daemon/face/lp-fragmenter.hpp:31,
from ../daemon/face/generic-link-service.hpp:30,
from ../daemon/face/generic-link-service.cpp:26:
/usr/local/include/ndn-cxx/lp/field.hpp: In instantiation of ‘struct ndn::lp::Field<int>’:
/usr/include/boost/concept/detail/has_constraints.hpp:32:62: required by substitution of ‘template<class Model> boost::concepts::detail::yes boost::concepts::detail::has_constraints_(Model*, boost::concepts::detail::wrap_constraints<Model, (& Model:: constraints)>*) [with Model = ndn::lp::Field<int>]’
/usr/include/boost/concept/detail/has_constraints.hpp:42:5: required from ‘const bool boost::concepts::not_satisfied<ndn::lp::Field<int> >::value’
/usr/include/boost/concept/detail/has_constraints.hpp:45:31: required from ‘struct boost::concepts::not_satisfied<ndn::lp::Field<int> >’
/usr/include/boost/mpl/if.hpp:67:11: required from ‘struct boost::mpl::if_<boost::concepts::not_satisfied<ndn::lp::Field<int> >, boost::concepts::constraint<ndn::lp::Field<int> >, boost::concepts::requirement<boost::concepts::failed************ ndn::lp::Field<int>::************> >’
/usr/include/boost/concept/detail/general.hpp:50:8: required from ‘struct boost::concepts::requirement_<void (*)(ndn::lp::Field<int>)>’
/usr/local/include/ndn-cxx/lp/fields.hpp:91:1: required from here
/usr/local/include/ndn-cxx/lp/field.hpp:62:1: error: ‘int’ is not a class, struct, or union type
{
^
/usr/local/include/ndn-cxx/lp/field.hpp:62:1: error: ‘int’ is not a class, struct, or union type
/usr/local/include/ndn-cxx/lp/field.hpp:62:1: error: ‘int’ is not a class, struct, or union type
/usr/local/include/ndn-cxx/lp/field.hpp:62:1: error: ‘int’ is not a class, struct, or union type
In file included from /usr/include/boost/concept/assert.hpp:35:0,
from /usr/include/boost/concept_check.hpp:20,
from /usr/local/include/ndn-cxx/common.hpp:124,
from /usr/local/include/ndn-cxx/meta-info.hpp:25,
from /usr/local/include/ndn-cxx/data.hpp:25,
from ./../core/common.hpp:59,
from <command-line>:0:
/usr/local/include/ndn-cxx/lp/field.hpp:66:3: error: ‘int’ is not a class, struct, or union type
NDN_CXX_ASSERT_DEFAULT_CONSTRUCTIBLE(typename X::ValueType);
^
/usr/local/include/ndn-cxx/lp/field.hpp:67:3: error: ‘int’ is not a class, struct, or union type
BOOST_CONCEPT_ASSERT((boost::CopyConstructible<typename X::ValueType>));
^
../daemon/face/generic-link-service.cpp: In member function ‘void nfd::face::GenericLinkService::encodeLpFields(const ndn::TagHost&, ndn::lp::Packet&)’:
../daemon/face/generic-link-service.cpp:134:42: error: no matching function for call to ‘ndn::lp::Packet::add(ndn::SimpleTag<long unsigned int, 1610612737>&)’
lpPacket.add<lp::GeoTagField>(*geoTag);
^
In file included from ../daemon/face/lp-fragmenter.hpp:31:0,
from ../daemon/face/generic-link-service.hpp:30,
from ../daemon/face/generic-link-service.cpp:26:
/usr/local/include/ndn-cxx/lp/packet.hpp:143:3: note: candidate: template<class FIELD> ndn::lp::Packet& ndn::lp::Packet::add(const typename FIELD::ValueType&)
add(const typename FIELD::ValueType& value)
^
/usr/local/include/ndn-cxx/lp/packet.hpp:143:3: note: template argument deduction/substitution failed:
/usr/local/include/ndn-cxx/lp/packet.hpp: In substitution of ‘template<class FIELD> ndn::lp::Packet& ndn::lp::Packet::add(const typename FIELD::ValueType&) [with FIELD = int]’:
../daemon/face/generic-link-service.cpp:134:42: required from here
/usr/local/include/ndn-cxx/lp/packet.hpp:143:3: error: ‘int’ is not a class, struct, or union type
../daemon/face/generic-link-service.cpp: In member function ‘void nfd::face::GenericLinkService::decodeInterest(const ndn::Block&, const ndn::lp::Packet&)’:
../daemon/face/generic-link-service.cpp:297:76: error: no matching function for call to ‘ndn::lp::Packet::get() const’
interest->setTag(make_shared<lp::GeoTag>(firstPkt.get<lp::GeoTagField>()));
^
In file included from ../daemon/face/lp-fragmenter.hpp:31:0,
from ../daemon/face/generic-link-service.hpp:30,
from ../daemon/face/generic-link-service.cpp:26:
/usr/local/include/ndn-cxx/lp/packet.hpp:91:3: note: candidate: template<class FIELD> typename FIELD::ValueType ndn::lp::Packet::get(size_t) const
get(size_t index = 0) const
^
/usr/local/include/ndn-cxx/lp/packet.hpp:91:3: note: template argument deduction/substitution failed:
/usr/local/include/ndn-cxx/lp/packet.hpp: In substitution of ‘template<class FIELD> typename FIELD::ValueType ndn::lp::Packet::get(size_t) const [with FIELD = int]’:
../daemon/face/generic-link-service.cpp:297:76: required from here
/usr/local/include/ndn-cxx/lp/packet.hpp:91:3: error: ‘int’ is not a class, struct, or union type
../daemon/face/generic-link-service.cpp: In member function ‘void nfd::face::GenericLinkService::decodeData(const ndn::Block&, const ndn::lp::Packet&)’:
../daemon/face/generic-link-service.cpp:339:72: error: no matching function for call to ‘ndn::lp::Packet::get() const’
data->setTag(make_shared<lp::GeoTag>(firstPkt.get<lp::GeoTagField>()));
^
In file included from ../daemon/face/lp-fragmenter.hpp:31:0,
from ../daemon/face/generic-link-service.hpp:30,
from ../daemon/face/generic-link-service.cpp:26:
/usr/local/include/ndn-cxx/lp/packet.hpp:91:3: note: candidate: template<class FIELD> typename FIELD::ValueType ndn::lp::Packet::get(size_t) const
get(size_t index = 0) const
^
/usr/local/include/ndn-cxx/lp/packet.hpp:91:3: note: template argument deduction/substitution failed:
/usr/local/include/ndn-cxx/lp/packet.hpp: In substitution of ‘template<class FIELD> typename FIELD::ValueType ndn::lp::Packet::get(size_t) const [with FIELD = int]’:
../daemon/face/generic-link-service.cpp:339:72: required from here
/usr/local/include/ndn-cxx/lp/packet.hpp:91:3: error: ‘int’ is not a class, struct, or union type
In file included from /usr/local/include/ndn-cxx/lp/field-decl.hpp:25:0,
from /usr/local/include/ndn-cxx/lp/fields.hpp:25,
from /usr/local/include/ndn-cxx/lp/packet.hpp:25,
from ../daemon/face/lp-fragmenter.hpp:31,
from ../daemon/face/generic-link-service.hpp:30,
from ../daemon/face/generic-link-service.cpp:26:
/usr/local/include/ndn-cxx/lp/field.hpp: In instantiation of ‘ndn::lp::Field<X>::~Field() [with X = int]’:
/usr/include/boost/concept/detail/general.hpp:38:28: required from ‘static void boost::concepts::requirement<boost::concepts::failed************ Model::************>::failed() [with Model = ndn::lp::Field<int>]’
/usr/local/include/ndn-cxx/lp/fields.hpp:91:1: required from here
/usr/local/include/ndn-cxx/lp/field.hpp:72:27: error: ‘int’ is not a class, struct, or union type
typename X::ValueType decoded = j.decode(wire);
^
/usr/local/include/ndn-cxx/lp/field.hpp:74:5: error: request for member ‘encode’ in ‘j’, which is of non-class type ‘int’
j.encode(enc, decoded);
^
/usr/local/include/ndn-cxx/lp/field.hpp:72:27: error: ‘int’ is not a class, struct, or union type
typename X::ValueType decoded = j.decode(wire);
^
In file included from ../daemon/face/lp-fragmenter.hpp:31:0,
from ../daemon/face/generic-link-service.hpp:30,
from ../daemon/face/generic-link-service.cpp:26:
/usr/local/include/ndn-cxx/lp/packet.hpp: In instantiation of ‘ndn::lp::Packet::count() const::<lambda(const ndn::Block&)> [with FIELD = int]’:
/usr/local/include/ndn-cxx/lp/packet.hpp:81:27: required from ‘struct ndn::lp::Packet::count() const [with FIELD = int; size_t = long unsigned int]::<lambda(const class ndn::Block&)>’
/usr/local/include/ndn-cxx/lp/packet.hpp:80:25: required from ‘size_t ndn::lp::Packet::count() const [with FIELD = int; size_t = long unsigned int]’
/usr/local/include/ndn-cxx/lp/packet.hpp:70:24: required from ‘bool ndn::lp::Packet::has() const [with FIELD = int]’
../daemon/face/generic-link-service.cpp:296:37: required from here
/usr/local/include/ndn-cxx/lp/packet.hpp:82:48: error: ‘int’ is not a class, struct, or union type
return block.type() == FIELD::TlvType::value; });
^
In file included from /usr/include/c++/5/algorithm:62:0,
from /usr/local/include/ndn-cxx/common.hpp:52,
from /usr/local/include/ndn-cxx/meta-info.hpp:25,
from /usr/local/include/ndn-cxx/data.hpp:25,
from ./../core/common.hpp:59,
from <command-line>:0:
/usr/include/c++/5/bits/stl_algo.h: At global scope:
/usr/include/c++/5/bits/stl_algo.h:3982:5: error: ‘typename std::iterator_traits<_Iterator>::difference_type std::count_if(_IIter, _IIter, _Predicate) [with _IIter = __gnu_cxx::__normal_iterator<const ndn::Block*, std::vector<ndn::Block> >; _Predicate = ndn::lp::Packet::count() const [with FIELD = int; size_t = long unsigned int]::<lambda(const ndn::Block&)>; typename std::iterator_traits<_Iterator>::difference_type = long int]’, declared using local type ‘ndn::lp::Packet::count() const [with FIELD = int; size_t = long unsigned int]::<lambda(const ndn::Block&)>’, is used but never defined [-fpermissive]
count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
^
Waf: Leaving directory `/home/adhy/NFD/build'
More information about the Nfd-dev
mailing list