[ndnSIM] how to trace the self-defined element in ndnsim?
huyao0107 at gmail.com
Sun Apr 14 19:52:50 PDT 2013
I see. Thanks for your warning. At this stage, I just want to record and
print the values to cout or some file whenever some element changes.
Besides, I also saw that the output logging information does not include
the ID of the related node. I am not sure the output behavior information
is from which node. So is there a way to add such a node id information
before each logging information. I used
Ptr<ns3::Node> node = this->GetObject<ns3::Node> (); node->GetId(),
but it failed..
./ns3/ptr.h:410:7: error: invalid use of incomplete type ‘struct ns3::Node’
./ns3/ndn-face.h:37:7: error: forward declaration of ‘struct ns3::Node’
2013/4/15 Alex Afanasyev <alexander.afanasyev at ucla.edu>
> Hi huyao,
> **Do not** use NS_LOG to obtain metrics, as it is designed and is used
> only for debug purposes to output some helpful information. Most of the
> logging statements are disabled (and must be disabled) when you compile in
> optimized version (./waf configure -d optimized).
> Btw. Do you want periodically save values from your array to file, or save
> all the values whenever some element changes? The reason I'm asking is
> that solution could be completely different.
> On Apr 13, 2013, at 8:46 AM, yao hu <huyao0107 at gmail.com> wrote:
> Hi Alex,
> Thanks very much for your guidance.
> After I tried following your instruction, however, I still felt a little
> confused by the callback to the trace source. Simply speaking, I defined a
> uint32_t array in ndn-forwarding-strategy.cc which will continuously store
> the incoming faceid information when simulation runs. If I just want to
> record the values of each element in this array into a local file using ns3
> tracing, how should I select a simple way to do this? Just using NS_LOG or
> something is possible?
> Thanks a lot again~
> 2013/4/13 Alex Afanasyev <alexander.afanasyev at ucla.edu>
>> Hi huyao,
>> Technically, you have many options how to trace self-defined variables.
>> If you really want to, you can just directly dump the values to std::cout
>> or to some file.
>> If you want to go with NS-3-style tracing, you would need to use either
>> TraceSource, with which you explicitly notifying (somebody, who is
>> configured in the simulation scenario using Connect calls) before or after
>> you change the value.
>> There is also a TraceValue, which can automate some notification tasks,
>> if you're tracing just a value.
>> Both methods require a couple of things. For TraceSource, you need to
>> define a local TracedCallback (like this
>> and then define a way to connect to this variable in GetTypeId method (like
>> Afterwards, you just use the locally defined TracedCallback as if it is a
>> function (like this
>> For TracedValue, you need to define the variable that you want to trace
>> in a slightly different way (it is no longer a simple variable), like this
>> Then add a line into GetTypeId call, similar to this
>> To connect to variables, you need to use either
>> Config::Connect/Config::ConnectWithoutContext method, or Object's
>> TraceConnect (
>> Let us know if you have more questions. If you can give more specific
>> description of what you want to trace, then we may give more concrete
>> suggestion of what is the best way to do it.
>> On Apr 12, 2013, at 9:37 AM, yao hu <huyao0107 at gmail.com> wrote:
>> Hi Alex,
>> Maybe this is not related to ndnsim, just about ns3. Could you please
>> give a hint about how to trace or record the value of some self-defined
>> variable like each element in some array somewhere in ndnsim when
>> simulation runs?
>> Thanks a lot!!
>> ndnSIM mailing list
>> ndnSIM at lists.cs.ucla.edu
> ndnSIM mailing list
> ndnSIM at lists.cs.ucla.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ndnSIM