[ndnSIM] error : assignment of member 'ndn::Interest::TSI ' in read only object

Alex Afanasyev aa at cs.fiu.edu
Sat Nov 26 07:47:43 PST 2022


It will not work the way you are trying to do it.  The variable you declared is just for the instance of the Interest on a specific simulated node.  As soon as you send this interest further, it is sent as wire encoded packet and there are no traces of your variable, unless you modified wire encoding/decoding procedures to include it.

There is, actually, already a hop count info that is associated with each Interest and Data packet.  You can simply access it to get the information you need:

  int hopCount = 0;
  auto hopCountTag = data->getTag<lp::HopCountTag>();
  if (hopCountTag != nullptr) { // e.g., packet came from local node's cache
    hopCount = *hopCountTag;
  }
  NS_LOG_DEBUG("Hop count: " << hopCount);

-
Alex


> On Nov 26, 2022, at 11:32 PM, SUBODH MISHRA via ndnSIM <ndnsim at lists.cs.ucla.edu> wrote:
> 
> Dear Researchers
> Greeting!
> I want to count the number  of intermediate nodes the interest packet  passes before reaching the producer.
> So, I declared the function IncrementTSI in Interest.hpp as follows
>                                     void IncrementTSI() const;
> I defined  this function in the Interest.cpp class to increment the private variable TSI of Interest class (TSI is initialized as 0 from the consumer application) .The definition of IncrementTSI  in Interest.cppis as follows;
>                              void Interest:: IncrementTSI() const
>                                {
>                                    TSI = TSI +1;
>                                 } 
> In the Forwarder::onIncomingInterest function I simply called this IncrementTSI () to increment the value of TSI  to record the number of nodes travelled by the Interest  packet before reaching the producer:-
>        
>   interest.IncrementTSI();
> 
> It throws the following error:-
> error: assignment of member 'ndn::Interest::TSI' in read-only object
> 399| TSI = TSI+1;
> 
> Please help me to remove this error
> 
> Thanks & Regards
> Subodh Mishra
> 
> Research Scholar (Ph.D),
> Department of Computer Science and Engineering,
> PDPM-Indian Institute of Information Technology, 
> Design and Manufacturing, Jabalpur
> 
> Email: 1911602 [at] iiitdmj [dot] ac [dot] in ,
>            subodhkmishra [at] gmail [dot] com
> _______________________________________________
> ndnSIM mailing list
> ndnSIM at lists.cs.ucla.edu
> https://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim

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


More information about the ndnSIM mailing list