[ndnSIM] How to calculate size of Interest/Data packet

Alex Afanasyev aa at CS.UCLA.EDU
Thu May 5 14:29:03 PDT 2016

> On May 4, 2016, at 4:05 PM, Anil Jangam <anilj.mailing at gmail.com> wrote:
> Hi.
> Calculating the size of Interest/Data packet wire, L3 tracer is done using the wireEncode() API.
> https://github.com/named-data-ndnSIM/ndnSIM/blob/master/utils/tracers/ndn-l3-rate-tracer.cpp#L294
> if (interest.hasWire()) {
>     std::get<1>(m_stats[face.shared_from_this()]).m_outInterests +=
>     interest.wireEncode().size();
> }
> In the implementation of wireEncode() also, the same check is being done.
> https://github.com/named-data-ndnSIM/ndn-cxx/blob/36ec104e23ba5395a8b4df411b776cdbef9c5cd4/src/interest.cpp#L279
> const Block&
> Interest::wireEncode() const
> {
>     if (m_wire.hasWire())
>     return m_wire;
>     ...
> }
> Perhaps this is a redundant check inside L3 tracer. But, is this the only way to know the size of data being transferred over or received from the face?
> /anil.

To know the size of the packet, one need to create the wire encoding of the packet.  "wireEncode()" method doesn't encode all the time, but rather encodes once and caches the encoding for future reuse.  Exception here are cases when some fields of the Interest are modified, in which case the cached version of the wire encoding is removed.

The guard in interest.cpp, is to simply return the cached version of wire if it exists (not to encode again).

The guard in L3Tracer serves an optimization different role for ndnSIM-native apps (ndn::Consumer*).  When interest/data are exchanged between these apps and L3 stack, the wire format is not created at all.  It gets created only when packet is moved through the actual wire ("Channel").  This optimization does not apply for apps that are based on ndn-cxx Face emulation.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20160505/21e657ca/attachment.bin>

More information about the ndnSIM mailing list