[ndnSIM] OnInterest/OnData functions : access to an output queue

Alex Afanasyev alexander.afanasyev at ucla.edu
Wed Dec 12 15:31:36 PST 2012


Quick thing. Don't forget to check that netDeviceFace returned by DynamicCast is no 0, otherwise you'll get in trouble with segfaults.

As for the queue. There are two options.  ns-3 style and c++-style.

(1) ns-3 style
==============
ns-3 allows you to access to many internal variables using so called attributes, without accessing implementation class.  For netdevice example, you can access to queue using the following:

PointerValue txQueueAttribute;
nd->GetAttribute ("TxQueue", txQueueAttribute); 
/** // or this, more safer way
 * bool ok = nd->GetAttributeFailSafe ("TxQueue", txQueueAttribute);
 * if (!ok) { /* something wrong */ }
**/

Ptr<Queue> txQueue = txQueueAttribute.Get<Queue> ();
if (txQueue == 0) { /*something wrong*/ }

...

(2) c++ style
Alternative and more C++ way is to make another dynamic cast on NetDevice object:

Ptr<PointToPointNetDevice> p2pNd = DynamicCast<PointToPointNetDevice> (nd);
...
and do the rest. 

The small disadvantage of the second approach is that it requires exact knowledge of the class you're casting to, that is, you need to include "point-to-point-net-device.h" header.


---
Alex

On Dec 12, 2012, at 2:43 PM, Natalya Rozhnova <natalya.rozhnova at lip6.fr> wrote:

> Hi Alex!
>  
> Thanks for your reply!
> That's what I thought to do, but one thing was disturbing me.
> I tried so this :
> Ptr<NetDeviceFace> netDeviceFace = DynamicCast<NetDeviceFace> (inFace);
> Ptr<NetDevice> nd = netDeviceFace->GetNetDevice ();
>  
> Then, I presume to use the function GetQueue() which is in PointToPointNetDevice class and not virtual function of base NetDevice object.
>  So I'm just confused how to get the p2p device after getting the NetDevice object...
>  
> Thanks,
> Natalya
>  
> 13.12.2012, 04:55, "Alex Afanasyev" <alexander.afanasyev at ucla.edu>:
>> Hi, Natalya!
>> 
>> It is easy, but would take a couple of steps. 
>> 
>> First, you need to figure out what from which type of face you have received a packet (as it could be an application face, which doesn't have a queue).  This could be done using DynamicCast call, like in https://github.com/NDN-Routing/ndnSIM/blob/master/model/ndn-l3-protocol.cc#L229.
>> 
>> Second, you will need to get netdevice pointer from the NetDeviceFace using GetNetDevice method (http://ndnsim.net/doxygen/classns3_1_1ndn_1_1_net_device_face.html#ae5ee510df5ba24c4a1aa94343302bb46).
>> 
>> Finally, you can access queue and other NetDevice attributes in a standard NS-3 way.
>> 
>> ---
>> Alex
>> 
>> On Dec 12, 2012, at 1:46 PM, Natalya Rozhnova <natalya.rozhnova at lip6.fr> wrote:
>> 
>>  Hi everyone,
>> 
>>  I'm trying to access to the output queue from m_forwardingStrategy::OnInterest(...) and OnData(...) functions. I need to access to the output queue installed on the interface from where the router just received a packet.
>>  Like:
>>  +-----+
>>  | R     |->out
>>  |        |
>>  +-----+<-in
>> 
>>  What I'm actually trying to do is : when the router receives an Interest (or Data) packet on the Interface "in", I'd like to access to the queue instaled on interface "out" and to put there some values.
>>  How I could access to this queue correctly?
>> 
>>  Thanks in advance!
>>  Best,
>>  Natalya
>>  
> _______________________________________________
> ndnSIM mailing list
> ndnSIM at lists.cs.ucla.edu
> http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim





More information about the ndnSIM mailing list