[ndnSIM] regarding block.hpp

Carl Zu carlzu8 at gmail.com
Tue Feb 9 09:24:48 PST 2016


On Tue, Feb 9, 2016 at 2:34 AM, Alex Afanasyev <aa at cs.ucla.edu> wrote:

>
> > On Feb 8, 2016, at 3:10 PM, Carl Zu <carlzu8 at gmail.com> wrote:
> >
> > I think lack of documentation is a problem...
> >
> > I wanted to write some bytes in the interest message in ndnSIM. In ns3,
> thanks to their documentation, one can easily understand that in order to
> write some bytes, he should serialize a header.
> >
> > For doing the same thing in ndnSIM, I have had the impression that I
> should use "block". Moreover, It looks as though an interest message is a
> set of TLVs (based on the explanation in the NDN project website). So
> probably if I like to write eight bytes as four pieces of two-byte data, I
> should write four TLVs. But indeed, there are many constructors in
> block.hpp, and it's just about looking at one code after another to
> understand each of them due to lack of documentation...
>
> Hi Carl,
>
> I think you're looking into a slightly wrong place.  If you want to extend
> Interest, you need first define your own TLV (which type to use and
> specific content).  For simple things you don't need to define your own
> class, you can simply store the actual value in some standard type, say
> char[8].  After doing so, the only part remain is to update
> serialization/deserialization methods of interest.cpp which are called
> wireEncode and wireDecode.
>
> I will agree that there is limited documentation, but there are many
> examples of this encoding.
>
> Hi guys,

thanks a lot for your replies.

Alex, could you please mention more precisely to which examples you are
referring?

Thank you.
C

> add variable to keep your data (and getter/setter methods when needed):
>
>     char m_myValue[8];
>
> Add the following to the wireEncode (note that encoding is done in reverse
> order):
>
>     totalLength += encoder.prependByteArrayBlock(<YOUR_TYPE>, m_myValue,
> 8);
>
> And the following to the wireDecode:
>
>       val = m_wire.find(<YOUR_TYPE>);
>       if (val != m_wire.elements_end()) {
>          memcpy(m_myValue, val->value(), val->value_size());
>       else
>          memset(m_myValue, 0, 8);
>
> ---
> Alex
>
>
> > Can someone please give some guidance ???.
> >
> > thanks and rgds.
> > C
> > _______________________________________________
> > ndnSIM mailing list
> > ndnSIM at lists.cs.ucla.edu
> > http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20160209/31c12c72/attachment.html>


More information about the ndnSIM mailing list