<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hi huyao,</div><div><br></div><div>I see.  You can just print to std::cout (or some predefined file) for now, but ideally it should be something like TraceSource, which is configured during the runtime (in a specific scenario).</div><div><br></div><div>To solve your error of obtaining node id, you need to write slightly differently, since "Face" object (I'm assuming you're calling from some method of Face object) is not aggregated to Node and to get node, you just need simply call GetNode () method.  Something like this:</div><div><br></div><div>std::cout << this->GetNode ()->GetId ();</div><div><br></div><div>One more note.  If you need this logging just for debug purposes, then you can simply output the desired values with NS_LOG* methods, which will output node ID as part of the output (when enabled with NS_LOG environmental variable).</div><div><br></div><div>---</div><div>Alex</div><br><div><div>On Apr 14, 2013, at 7:52 PM, yao hu <<a href="mailto:huyao0107@gmail.com">huyao0107@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">Hi Alex,<div><br></div><div style="">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. </div><div style=""><br></div><div style="">
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 </div>
<div style="">Ptr<ns3::Node> node = this->GetObject<ns3::Node> (); node->GetId(), </div><div style=""><br></div><div style="">but it failed..</div><div style=""><br></div><div style=""><div>./ns3/ptr.h:410:7: error: invalid use of incomplete type ‘struct ns3::Node’</div>
<div>./ns3/ndn-face.h:37:7: error: forward declaration of ‘struct ns3::Node’</div></div><div style=""><br></div><div style="">Regards,</div><div style="">huyao</div><div style=""><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
2013/4/15 Alex Afanasyev <span dir="ltr"><<a href="mailto:alexander.afanasyev@ucla.edu" target="_blank">alexander.afanasyev@ucla.edu</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div>Hi huyao,</div><div><br></div><div>**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).</div>
<div><br></div><div>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.</div>
<div><br></div><div>---</div><div>Alex</div><div><div class="h5"><br><div><div>On Apr 13, 2013, at 8:46 AM, yao hu <<a href="mailto:huyao0107@gmail.com" target="_blank">huyao0107@gmail.com</a>> wrote:</div><br><blockquote type="cite">
<div dir="ltr">Hi Alex,<div><br></div><div>Thanks very much for your guidance. </div><div>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?<br>

</div><div><br></div><div>Thanks a lot again~</div><div><br></div><div>Regards,</div><div>huyao</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/4/13 Alex Afanasyev <span dir="ltr"><<a href="mailto:alexander.afanasyev@ucla.edu" target="_blank">alexander.afanasyev@ucla.edu</a>></span><br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Hi huyao,</div><div>
<br></div><div>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.</div>
<div><br></div><div>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.</div>

<div><br></div><div>There is also a TraceValue, which can automate some notification tasks, if you're tracing just a value.  </div><div><br></div><div>Both methods require a couple of things.  For TraceSource, you need to define a local TracedCallback (like this <a href="https://github.com/NDN-Routing/ndnSIM/blob/master/model/fw/ndn-forwarding-strategy.h#L482" target="_blank">https://github.com/NDN-Routing/ndnSIM/blob/master/model/fw/ndn-forwarding-strategy.h#L482</a>) and then define a way to connect to this variable in GetTypeId method (like this <a href="https://github.com/NDN-Routing/ndnSIM/blob/master/model/fw/ndn-forwarding-strategy.cc#L71" target="_blank">https://github.com/NDN-Routing/ndnSIM/blob/master/model/fw/ndn-forwarding-strategy.cc#L71</a>).  Afterwards, you just use the locally defined TracedCallback as if it is a function (like this <a href="https://github.com/NDN-Routing/ndnSIM/blob/master/model/fw/ndn-forwarding-strategy.cc#L586" target="_blank">https://github.com/NDN-Routing/ndnSIM/blob/master/model/fw/ndn-forwarding-strategy.cc#L586</a>).</div>

<div><br></div><div>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 <a href="https://github.com/NDN-Routing/ndnSIM/blob/master/apps/ndn-consumer-window.h#L98" target="_blank">https://github.com/NDN-Routing/ndnSIM/blob/master/apps/ndn-consumer-window.h#L98</a>.  Then add a line into GetTypeId call, similar to this <a href="https://github.com/NDN-Routing/ndnSIM/blob/master/apps/ndn-consumer-window.cc#L65" target="_blank">https://github.com/NDN-Routing/ndnSIM/blob/master/apps/ndn-consumer-window.cc#L65</a>.</div>

<div><br></div><div>To connect to variables, you need to use either Config::Connect/Config::ConnectWithoutContext method, or Object's TraceConnect (<a href="http://www.nsnam.org/doxygen-release/classns3_1_1_object_base.html#ada3a45b34bc23114a25e0ab19188276e" target="_blank">http://www.nsnam.org/doxygen-release/classns3_1_1_object_base.html#ada3a45b34bc23114a25e0ab19188276e</a>).</div>

<div><br></div><div><br></div><div>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.</div>

<div><br></div><div>---</div><div>Alex</div><br><div><div><div><div>On Apr 12, 2013, at 9:37 AM, yao hu <<a href="mailto:huyao0107@gmail.com" target="_blank">huyao0107@gmail.com</a>> wrote:</div><br></div>
</div><blockquote type="cite"><div><div dir="ltr">Hi Alex,<div><br></div><div>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?</div>


<div><br></div><div>Thanks a lot!!</div><div><br></div><div>Regards,</div><div>huyao</div></div></div>
_______________________________________________<br>ndnSIM mailing list<br><a href="mailto:ndnSIM@lists.cs.ucla.edu" target="_blank">ndnSIM@lists.cs.ucla.edu</a><br><a href="http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim" target="_blank">http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim</a><br>

</blockquote></div><br></div></blockquote></div><br></div>
_______________________________________________<br>ndnSIM mailing list<br><a href="mailto:ndnSIM@lists.cs.ucla.edu" target="_blank">ndnSIM@lists.cs.ucla.edu</a><br><a href="http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim" target="_blank">http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim</a><br>
</blockquote></div><br></div></div></div></blockquote></div><br></div>
_______________________________________________<br>ndnSIM mailing list<br><a href="mailto:ndnSIM@lists.cs.ucla.edu">ndnSIM@lists.cs.ucla.edu</a><br>http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim<br></blockquote></div><br></body></html>