[ndnSIM] adding new field to data packet

Samar Alduayji samarduayji at gmail.com
Wed Jan 1 06:49:52 PST 2020

Thanks for your quick reply,

Would that works if this value is linked to the producer type? Let's say
I've two types of producers( Type A &B) that can be used as many as we need
in the simulation.

Creating a data packet would be similar except for the freshness value
which will be interpreted, in the CS lookup process, in different ways
depending in the producer type.


On Wed, Jan 1, 2020 at 5:28 PM Junxiao Shi <shijunxiao at email.arizona.edu>

> Hi Samar
> You can't add new packet fields. Instead, place the field as part of the
> payload.
> Example:
> // sender
> uint64_t myNumber = 2020;
> ndn::Data data;
> data.setContent(reinterpret_cast<const uint_t*>(&myNumber),
> sizeof(myNumber));
> // receiver
> uint64_t readNumber;
> auto payload = data.getContent();
> if (payload.value_size() == sizeof(readNumber)) {
>   std::copy(payload.value_begin(), payload.value_end(),
> reinterpret_cast<uint8_t*>(&readNumber));
> }
> Note: sender and receiver must use same endianness. This requirement is
> met in ns-3.
> Yours, Junxiao
> On Wed, Jan 1, 2020, 09:14 Samar Alduayji via ndnSIM <
> ndnsim at lists.cs.ucla.edu> wrote:
>> Dear all,
>> I'm trying to add a new field( type is uint32_t) to data packet so the
>> producer can set this field while creating the packet. I modified tlv,
>> tags, and fields header files to include a new tag for it. I also edited
>> generic-link-service.cpp file
>> I declared the field in the producer.hpp file and in the producer.cpp
>> file I added the field using .addAttribute(....), and tried to set it using
>> data->setTag<fieldName>(std::make_shared<fieldName>(m_field));
>> but I got an errors while compiling the OnInterest method:
>> 1-that this new field was not declared in this scope.
>> 2- the value is not usable in a constant expression and was not declared
>> constexp.
>> 3- no matching function for call to make_shared(uint32_t)
>> Does the setTag is not applicable to be used here? Should I write
>> specific set and get function in the data.cpp file? what other
>> modifications shall I add to be able to set this field and use it?
>> Your help is really appreciated
>> Regards,
>> Samar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20200101/1a26df2c/attachment-0001.html>

More information about the ndnSIM mailing list