[ndnSIM] How to get a node's neighbour

Alex Afanasyev alexander.afanasyev at ucla.edu
Mon Mar 11 13:22:03 PDT 2013


Hi Pan,

Let me ask you one clarification question.  What is the intended use of getting the node for the requested item? If it is to collect content store performance, then I would recommend to use content store trace helper (http://ndnsim.net/metric.html#example-of-content-store-trace-helper) or a modified version of this trace helper.

Normally, Node is not directly accessible from lru_policy_traits, as these traits define a general replacement policy.  If you really need it, you can write a specialized policy that has access to node, similar but not exactly as freshness-policy.h and lifetime-stats-policy.h.  If needed, I can try to give you some more examples.  Would you mind giving a high-level idea what you want to implement, so I can give a better suggestion?

---
Alex

On Mar 11, 2013, at 8:24 AM, panhgshine at 163.com wrote:

> Hi Alex,
> 
> Thank you very much! 
> You let me understand much better to the problem.
> By the way, how can I get the request node.
> In cache replacement policy, such as: lru_policy_traits, freshness_policy_traits, I don't know how to get which node request the *item data. Can you help me? And my thoughts is wrong or not?
> 
> Thank you!
> 
> Pan 
> 
> 
> 
> 
> At 2013-03-11 02:33:22,"Alex Afanasyev" <alexander.afanasyev at ucla.edu> wrote:
> >Hi Pan,
> >
> >In general, as in real system, you would need to implement some kind of a resource discovery protocol to discover all node's neighbors.  At the same time, in NS-3, since it is a simulation, it is technically possible to "discover" neighbors directly:
> >
> >In NS-3 in general, you would enumerate all NetDevice's on a particular Node object (http://www.nsnam.org/doxygen/classns3_1_1_node.html):
> >
> >for (uint32_t deviceId = 0; deviceId < node->GetNDevices (); deviceId ++)
> >{
> >    Ptr<NetDevice> device = node->GetDevice (deviceId);
> >
> >    # get channel, to which device is connected (a "wire")
> >    Ptr<Channel> channel = device->GetChannel ();
> >
> >    for (uint32_t channelDeviceId = 0; channelDeviceId < channel->GetNDevices (); channelDeviceId ++)
> >    {
> >        Ptr<NetDevice> channelDevice = channel->GetDevice (channelDeviceId);
> >        if (channelDevice == device)
> >            continue;
> >
> >        # channelDevice is a "neighbor"
> >    }
> >}
> >
> >---
> >Alex
> >
> >On Mar 10, 2013, at 5:53 AM, panhgshine at 163.com wrote:
> >
> >> Hi All,
> >> 
> >> I'm a beginner of NS3 and ndnSIM. Recently, I have read the cache replacement policy code.
> >> Now, I want to get a node's all neighbour. 
> >> Is there anyone can give me some advice or hint?
> >> 
> >> Thank you in advance.
> >> 
> >> Pan





More information about the ndnSIM mailing list