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

Anil Jangam anilj.mailing at gmail.com
Sun May 8 23:46:56 PDT 2016


Alex,

The reason I was trying to find an alternative because this 'wireEncode()'
code path is one of the major memory consumer in ndnSIM. Although there are
optimizations provided by caching the block size after first encode(), it
appears that memory is not freed after first encode.

==9587== 100,926,144 bytes in 73,852 blocks are still reachable in loss
record 1,226 of 1,228
==9587==    at 0x4C2B0E0: operator new(unsigned long) (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==9587==    by 0x69A08DF: allocate (new_allocator.h:104)
==9587==    by 0x69A08DF: _M_allocate (stl_vector.h:168)
==9587==    by 0x69A08DF: void std::vector<ndn::Block,
std::allocator<ndn::Block> >::_M_emplace_back_aux<ndn::Block>(ndn::Block&&)
(vector.tcc:404)
==9587==    by 0x699C79C: emplace_back<ndn::Block> (vector.tcc:101)
==9587==    by 0x699C79C: push_back (stl_vector.h:920)
==9587==    by 0x699C79C: ndn::Block::parse() const (block.cpp:347)
==9587==    by 0x6A1F5A8: ndn::Name::wireEncode() const (name.cpp:102)
==9587==    by 0x6B4619F: nfd::DeadNonceList::makeEntry(ndn::Name const&,
unsigned int) (dead-nonce-list.cpp:108)
==9587==    by 0x6B4621D: nfd::DeadNonceList::has(ndn::Name const&,
unsigned int) const (dead-nonce-list.cpp:92)
==9587==    by 0x6B25A42: nfd::Forwarder::onIncomingInterest(nfd::Face&,
ndn::Interest const&) (forwarder.cpp:86)
==9587==    by 0x69B066A: operator() (functional:2471)
==9587==    by 0x69B066A: operator() (signal-signal.hpp:241)
==9587==    by 0x69B066A: operator() (signal-signal.hpp:255)
==9587==    by 0x69B066A: emit_onReceiveInterest<ndn::Interest,
ndn::util::signal::DummyExtraArg> (face.hpp:194)
==9587==    by 0x69B066A:
ndn::Face::Impl::asyncExpressInterest(std::shared_ptr<ndn::Interest const>
const&, std::function<void (ndn::Interest const&, ndn::Data&)> const&,
std::function<void (ndn::Interest const&)> const&) (face-impl.hpp:170)
==9587==    by 0x69AD13B: operator() (face.cpp:69)
==9587==    by 0x69AD13B: std::_Function_handler<void (),
ndn::Face::expressInterest(ndn::Interest const&, std::function<void
(ndn::Interest const&, ndn::Data&)> const&, std::function<void
(ndn::Interest const&)> const&)::{lambda()#1}>::_M_invoke(std::_Any_data
const&) (functional:2071)
==9587==    by 0xB84EC6C: ns3::DefaultSimulatorImpl::ProcessOneEvent()
(default-simulator-impl.cc:149)


/anil.


On Thu, May 5, 2016 at 2:29 PM, Alex Afanasyev <aa at cs.ucla.edu> wrote:

>
> > 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.
>
> --
> Alex
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20160508/bae62c39/attachment.html>


More information about the ndnSIM mailing list