Setting Maximum queue size in a CsmaNetDevice

1,171 views
Skip to first unread message

Dani Camps

unread,
May 4, 2010, 11:09:35 AM5/4/10
to ns-3-users

Dear all,

I am struggling with configuring a DropTailQueue of a certain size in
a CsmaNetDevice, and would appreciate any help. I have tried different
methods:

1- Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue
(50));
CsmaHelper csma;
NetDeviceContainer devices = csma.Install (nodes);

Expecting that by default a DropTailQueue of 50 packets would be
installed in the devices. However, the previous does not work.

2- I tried with the SetQueue method of the CsmaHelper class.
CsmaHelper csma;

csma.SetQueue(std::string("DropTailQueue"),std::string("MaxPackets"),IntegerValue(50));
NetDeviceContainer devices = csma.Install (nodes);

However, the previous does not work either, I get compilation errors
complaining about an incorrect TypeID, basically I do not seem to be
able to pass the correct parameters to the method SetQueue() and I
have not found any example in the existing code.

3- I try to set the queues manually:
NetDeviceContainer devices = csma.Install (nodes);
Ptr<CsmaNetDevice> csma_device_aux = devices.Get(0)-
>GetObject<CsmaNetDevice> ();
csma_device_aux->SetQueue (CreateObject<DropTailQueue> ());
Ptr<DropTailQueue> dtq = csma_device_aux->GetQueue()-
>GetObject<DropTailQueue> ();
dtq->SetAttribute("MaxPackets", UintegerValue (60));

The previous does compile, but when I run my experiment I see that the
queue is not yet limited to 50 packets. Actually, th experiment I run
seems to have unbounded queues (?).

The way I capture the queue size is by tracing the Enqueue and Dequeue
events defined in the Queue class:
QueueMonitor QMon;
Ptr<CsmaNetDevice> csma_device = devices.Get(0)-
>GetObject<CsmaNetDevice> ();
csma_device->GetQueue()->TraceConnectWithoutContext ("Enqueue",
MakeCallback(&QueueMonitor::TraceEnqueue, &QMon));
csma_device->GetQueue()->TraceConnectWithoutContext ("Dequeue",
MakeCallback(&QueueMonitor::TraceDequeue, &QMon));

It could also be that I am making a mistake there.

Thanks in advance for your advice!

Best Regadrs

Daniel

--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To post to this group, send email to ns-3-...@googlegroups.com.
To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.

Craig Dowell

unread,
May 4, 2010, 1:27:50 PM5/4/10
to ns-3-...@googlegroups.com
> I am struggling with configuring a DropTailQueue of a certain size in
> a CsmaNetDevice, and would appreciate any help. I have tried different
> methods:
>
> 1- Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue
> (50));
> CsmaHelper csma;
> NetDeviceContainer devices = csma.Install (nodes);
>
> Expecting that by default a DropTailQueue of 50 packets would be
> installed in the devices. However, the previous does not work.

This works for me. Try doing

NS_LOG=DropTailQueue

and see what is printed with respect to queue occupancy. I took
examples/csma/csma-bridge.cc, added the line,

Config::SetDefault("ns3::DropTailQueue::MaxPackets", UintegerValue
(1));

and changed the datarate to 5 kbps to slow everything down

csma.SetChannelAttribute ("DataRate", DataRateValue (5000));

and got the expected drops.

> 2- I tried with the SetQueue method of the CsmaHelper class.
> CsmaHelper csma;
>
> csma.SetQueue(std::string("DropTailQueue"),std::string("MaxPackets"),IntegerValue(50));
> NetDeviceContainer devices = csma.Install (nodes);
>
> However, the previous does not work either, I get compilation errors
> complaining about an incorrect TypeID, basically I do not seem to be
> able to pass the correct parameters to the method SetQueue() and I
> have not found any example in the existing code.

I also tried the following code in csma-bridge.cc and got the same
expected results:

csma.SetQueue ("ns3::DropTailQueue", "MaxPackets", UintegerValue(1));

Note the parameter is a UintegerValue not an Integervalue.

> 3- I try to set the queues manually:
> NetDeviceContainer devices = csma.Install (nodes);
> Ptr<CsmaNetDevice> csma_device_aux = devices.Get(0)-
> >GetObject<CsmaNetDevice> ();
> csma_device_aux->SetQueue (CreateObject<DropTailQueue> ());
> Ptr<DropTailQueue> dtq = csma_device_aux->GetQueue()-
> >GetObject<DropTailQueue> ();
> dtq->SetAttribute("MaxPackets", UintegerValue (60));
>
> The previous does compile, but when I run my experiment I see that the
> queue is not yet limited to 50 packets. Actually, th experiment I run
> seems to have unbounded queues (?).

I tried to set the queue size manually (in a long one-liner):

link.Get (j)->GetObject<CsmaNetDevice> ()->GetQueue
()->GetObject<DropTailQueue> ()->SetAttribute ("MaxPackets", Uinteger\
Value (1));

And it works as expected.

> The way I capture the queue size is by tracing the Enqueue and Dequeue
> events defined in the Queue class:
> QueueMonitor QMon;
> Ptr<CsmaNetDevice> csma_device = devices.Get(0)-
> >GetObject<CsmaNetDevice> ();
> csma_device->GetQueue()->TraceConnectWithoutContext ("Enqueue",
> MakeCallback(&QueueMonitor::TraceEnqueue, &QMon));
> csma_device->GetQueue()->TraceConnectWithoutContext ("Dequeue",
> MakeCallback(&QueueMonitor::TraceDequeue, &QMon));
>
> It could also be that I am making a mistake there.

Pick any of the approaches you have above. I would then use
NS_LOG=DropTailQueue to watch the queue occupancy change directly:

xx.xxxs DropTailQueue:DoEnqueue(): Number packets 1

Dani Camps

unread,
May 11, 2010, 11:24:00 AM5/11/10
to ns-3-...@googlegroups.com

Dear Craig,

Thanks again for your accurate response. I checked your method and it works, the problem must be related with my traces.

Best Regards

Daniel

Which would be the easiest way to trace the queue
Reply all
Reply to author
Forward
0 new messages