[ndnSIM] Adding new field to Interest packet

Spyridon (Spyros) Mastorakis mastorakis at cs.ucla.edu
Mon Oct 16 19:29:15 PDT 2017


Hi,

I would suggest that you add the new field as an NDNLP tag instead:

https://lo.calho.st/networks/adding-custom-packet-fields-to-packets-in-ndnsim-2-3-without-forking-the-entire-repository/

Thanks,

Spyridon (Spyros) Mastorakis
Personal Website: http://cs.ucla.edu/~mastorakis/ <http://cs.ucla.edu/~mastorakis/>
Internet Research Laboratory
Computer Science Department
UCLA

> On Oct 16, 2017, at 4:44 AM, Mateus Sousa <mateus.aluufc at gmail.com> wrote:
> 
> wireDEcode (before nonce): 
> 
>   ////////////////////////////////////////
>   // Mateus UFBA-Brazil-2017
>   ////////////////////////////////////////
>   // NextForwarder
>   m_nextForwarder = m_wire.get(tlv::NextForwarder);
>   m_lastForwarder = m_wire.get(tlv::LastForwarder);
> 
>   ////////////////////////////////////////
>   //          END MATEUS
>   ////////////////////////////////////////
> 
> wireEncode:
> 
>   //////////////////////////////////////////////////
>   // My modifications (Mateus)
>   //////////////////////////////////////////////////
>   getNextForwarder();
>   getLastForwarder();
>   totalLength += encoder.prependBlock(m_lastForwarder);
>   totalLength += encoder.prependBlock(m_nextForwarder);
>   //////////////////////////////////////////////////
> 
> I tried to copy the Nonce settings. 
> 
> Thanks,
> 
> 
> 
> 
> 2017-10-15 23:21 GMT-03:00 Spyridon (Spyros) Mastorakis <mastorakis at cs.ucla.edu <mailto:mastorakis at cs.ucla.edu>>:
> Hi,
> 
> have you modified the wireEncode and wireDecode methods to encode/decode the field to/from wire format?
> 
> Thanks,
> 
> Spyridon (Spyros) Mastorakis
> Personal Website: http://cs.ucla.edu/~mastorakis/ <http://cs.ucla.edu/~mastorakis/>
> Internet Research Laboratory
> Computer Science Department
> UCLA
> 
>> On Oct 15, 2017, at 4:28 PM, Mateus Sousa <mateus.aluufc at gmail.com <mailto:mateus.aluufc at gmail.com>> wrote:
>> 
>> Hi all,
>> 
>> I added a new field to Interest packet by following the discussions: http://www.lists.cs.ucla.edu/pipermail/ndnsim/2015-July/002044.html <http://www.lists.cs.ucla.edu/pipermail/ndnsim/2015-July/002044.html> and http://www.lists.cs.ucla.edu/pipermail/ndnsim/2017-March/003481.html <http://www.lists.cs.ucla.edu/pipermail/ndnsim/2017-March/003481.html>.
>> 
>> I created the field "NextForwarder" to point what node is the next forwarder to the interest. This field should be updated at every node (here is the problem). 
>> 
>> However, the alterations aren't persistent. The field value turns into "0" no matter what value I set.
>> 
>> Here goes my modifications:
>> 
>>     src/Interest.cpp: 
>>                 
>>     Interest&
>>     Interest::setNextForwarder(uint32_t next) {
>>            if (m_wire.hasWire() && m_nextForwarder.value_size() == sizeof(uint32_t)) {
>>             std::memcpy(const_cast<uint8_t*>(m_nextForwarder.value()), &next, sizeof(next));
>>   }
>>   else {
>>     m_nextForwarder = makeBinaryBlock(tlv::NextForwarder,
>>                               reinterpret_cast<const uint8_t*>(&next),
>>                               sizeof(next));
>>     m_wire.reset();
>>   }
>>   return *this;
>> }
>> 
>> uint32_t
>> Interest::getNextForwarder() const{
>>   if (!m_nextForwarder.hasWire())
>>     const_cast<Interest*>(this)->setNextForwarder(9999);
>> 
>>   if (m_nextForwarder.value_size() == sizeof(uint32_t))
>>     return *reinterpret_cast<const uint32_t*>(m_nextForwarder.value());
>>   else {
>>     return readNonNegativeInteger(m_nextForwarder);
>>   }
>> }
>> 
>> 
>>     encoding/tlv.h
>>           NextForwarder = 33, // X- Mateus
>> 
>> 
>> Thanks in advance.
>> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20171016/4c698ae7/attachment.html>


More information about the ndnSIM mailing list