<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Feb 9, 2016 at 2:34 AM, Alex Afanasyev <span dir="ltr"><<a href="mailto:aa@cs.ucla.edu" target="_blank">aa@cs.ucla.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class=""><br>
> On Feb 8, 2016, at 3:10 PM, Carl Zu <<a href="mailto:carlzu8@gmail.com">carlzu8@gmail.com</a>> wrote:<br>
><br>
</span><span class="">> I think lack of documentation is a problem...<br>
><br>
> 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.<br>
><br>
> 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...<br>
<br>
</span>Hi Carl,<br>
<br>
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.<br>
<br>
I will agree that there is limited documentation, but there are many examples of this encoding.<br>
<br></blockquote><div>Hi guys,</div><div><br></div><div>thanks a lot for your replies.</div><div><br></div><div>Alex, could you please mention more precisely to which examples you are referring?</div><div><br></div><div>Thank you.</div><div>C</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
add variable to keep your data (and getter/setter methods when needed):<br>
<br>
    char m_myValue[8];<br>
<br>
Add the following to the wireEncode (note that encoding is done in reverse order):<br>
<br>
    totalLength += encoder.prependByteArrayBlock(<YOUR_TYPE>, m_myValue, 8);<br>
<br>
And the following to the wireDecode:<br>
<br>
      val = m_wire.find(<YOUR_TYPE>);<br>
      if (val != m_wire.elements_end()) {<br>
         memcpy(m_myValue, val->value(), val->value_size());<br>
      else<br>
         memset(m_myValue, 0, 8);<br>
<br>
---<br>
Alex <br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">
><br>
> Can someone please give some guidance ???.<br>
><br>
> thanks and rgds.<br>
> C<br>
</span>> _______________________________________________<br>
> ndnSIM mailing list<br>
> <a href="mailto:ndnSIM@lists.cs.ucla.edu">ndnSIM@lists.cs.ucla.edu</a><br>
> <a href="http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim" rel="noreferrer" target="_blank">http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim</a><br>
<br>
</blockquote></div><br></div></div>