<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hi Saran,</div><div><br></div><div>Checking type of the packet is possible, but it should be done only for debug purposes.  To enable it, you need to call </div><div>Packet::EnableChecking ();</div><div>Packet::EnablePrinting ();</div><div><br></div><div>I'm not sure which one, but some of these two methods enable tracking of meta information alongside each packet.</div><div><br></div><div>But taking step back. If I were to track characteristic of interest/data traffic on different nodes, I would do it on a little bit higher lever: in forwarding strategy / forwarding strategy extension.  The reason is that forwarding strategy is the last one who actually knows if packet is Interest or Data.  Moreover, you can do it in non-intrusive manner (=without modifying ndnSIM code) by creating a custom strategy class and overriding a couple of methods:</div><div>- OnInterest to get hold on all received interests</div><div>- DidSendOutInterest to get hold on all forwarded interests</div><div>- OnData, DidSendOutData the same thing, but for data</div><div><br></div><div>Taking step forward :)  If you still want to observe packets on Face level, you can use helper method: ndn::HeaderHelper::GetNdnHeaderType(packet)  which will return <span style="background-color: rgb(252, 252, 252); font-family: monospace, fixed; font-size: 13px; line-height: 13px; text-indent: -53px; white-space: pre-wrap; ">INTEREST_NDNSIM (=2) or CONTENT_OBJECT_NDNSIM (=3).  However, if you want to know prefix after you discover the type, you would need to do something like this:</span></div><div><span style="background-color: rgb(252, 252, 252); font-family: monospace, fixed; font-size: 13px; line-height: 13px; text-indent: -53px; white-space: pre-wrap; "><br></span></div><div><span style="background-color: rgb(252, 252, 252); font-family: monospace, fixed; font-size: 13px; line-height: 13px; text-indent: -53px; white-space: pre-wrap; ">if (</span>ndn::HeaderHelper::GetNdnHeaderType(packet) == <span style="background-color: rgb(252, 252, 252); font-family: monospace, fixed; font-size: 13px; line-height: 13px; text-indent: -53px; white-space: pre-wrap; ">INTEREST_NDNSIM)</span></div><div><span style="background-color: rgb(252, 252, 252); font-family: monospace, fixed; font-size: 13px; line-height: 13px; text-indent: -53px; white-space: pre-wrap; ">{</span></div><div><span style="background-color: rgb(252, 252, 252); font-family: monospace, fixed; font-size: 13px; line-height: 13px; text-indent: -53px; white-space: pre-wrap; ">   Interest interest;</span></div><div><span style="background-color: rgb(252, 252, 252); font-family: monospace, fixed; font-size: 13px; line-height: 13px; text-indent: -53px; white-space: pre-wrap; ">   packet->PeekHeader (interest);</span></div><div><span style="background-color: rgb(252, 252, 252); font-family: monospace, fixed; font-size: 13px; line-height: 13px; text-indent: -53px; white-space: pre-wrap; "><br></span></div><div><span style="background-color: rgb(252, 252, 252); font-family: monospace, fixed; font-size: 13px; line-height: 13px; text-indent: -53px; white-space: pre-wrap; ">   cout << interest->GetName () << endl;</span></div><div><span style="background-color: rgb(252, 252, 252); font-family: monospace, fixed; font-size: 13px; line-height: 13px; text-indent: -53px; white-space: pre-wrap; ">   // or something else</span></div><div><span style="background-color: rgb(252, 252, 252); font-family: monospace, fixed; font-size: 13px; line-height: 13px; text-indent: -53px; white-space: pre-wrap; ">}</span></div><div><br></div><div>This would be unnecessary if you observe packets on strategy layer, since each event that I listed above will give you reference to parsed interest or data packet.</div><div><br></div><div>---</div><div>Alex</div><br><div><div>On May 30, 2013, at 12:15 AM, Saran Tarnoi <<a href="mailto:sarantarnoi@gmail.com">sarantarnoi@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">Dear All,<div><br></div><div>I just found that I should use the Interest and ContentObject <span style="font-family: 'Lucida Grande', Verdana, Geneva, Arial, sans-serif; font-size: 12px; line-height: 15px; ">Constructors to keep the header of a packet.</span></div>
<div>In addition, to check whether the considering packet is Interest or Data, I can simply check the packet's size.</div><div>However, If there is any more direct way to do so, please let me know.</div><div style="">Thanks a lot,</div>
<div style=""><br></div><div style="">Regards,</div><div style="">Saran Tarnoi</div><div><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Saran Tarnoi</b> <span dir="ltr"><<a href="mailto:sarantarnoi@gmail.com">sarantarnoi@gmail.com</a>></span><br>
Date: 2013/5/30<br>Subject: How to trace the interest accessing each node?<br>To: Alex Afanasyev <<a href="mailto:alexander.afanasyev@ucla.edu">alexander.afanasyev@ucla.edu</a>>, <a href="mailto:ndnsim@lists.cs.ucla.edu">ndnsim@lists.cs.ucla.edu</a><br>
<br><br><div dir="ltr">Dear Alex and All,<div><br></div><div>I would like to record the interests and their numbers that access each node.</div><div>Specifically, I want to study the characteristic of the interest traffic at different nodes.<br>

</div><div>I tried observing the received packets at each face in ndn:Face but I could neither get the header nor type of the packet.</div><div>I followed this code (<a href="http://polythinking.wordpress.com/2012/05/30/ns-3-network-simulator-how-to-find-a-specific-header-in-packet-in-ns-3/" target="_blank">http://polythinking.wordpress.com/2012/05/30/ns-3-network-simulator-how-to-find-a-specific-header-in-packet-in-ns-3/</a>) but it didn't work.</div>

<div><br></div><div>To add header to a packet, we can do:<br>packet->AddHeader (interestHeader);<br></div><div><br></div><div>Is there any way to do:</div><div>packet->GetContentName (); </div>
<div>packet->GetType ();</div><div>and get the output like:</div><div>"/prefix/0"</div><div>"Interest or Data"</div><div>?</div><div><br></div><div>Would you kindly tell me how can I get that information?</div>

<div>Thanks in advance for your time.</div><span class=""><font color="#888888"><div><br></div>-- <br>Regards,<div>Saran Tarnoi</div><div>Graduate Student</div><div>Department of Informatics</div><div>The Graduate University for Advanced Studies (Sokendai)</div>


<div>Tokyo, Japan</div>
</font></span></div>
</div><div><br></div>
</div></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>