How to set queue size for point-to-point devices

3,447 views
Skip to first unread message

محمود النعانعة

unread,
Jan 6, 2016, 10:32:54 AM1/6/16
to ns-3-users
I have three connected nodes n0---------n1-----------n2.
The link speed between n0,n1 is 100kbps and between n1,n2 is 50kbps.
I set the queue size to 10 packets using the code.
...
uint32_t queueSize = 10;
...
p2pHelper01.SetQueue("ns3::DropTailQueue",  "MaxPackets",UintegerValue(queueSize));
...
p2pHelper12.SetQueue("ns3::DropTailQueue",  "MaxPackets",UintegerValue(queueSize));

Node 1 is supposed to transmit 200 packets and node 2 is supposed to transmitt about 110 packet, but only 10 packets are shown in all nodes in the pcap file. Also 10 packets are successfully transmitted in the flow monitor file.

What do you think is the problem.

I think that the code will set the queue size for all devices (Rx, and Tx) . How can I set Rx/TX queue size for specific device only.

I have attached my code.

myCode1.cc

Tommaso Pecorella

unread,
Jan 6, 2016, 5:06:52 PM1/6/16
to ns-3-users
Hi,

the queue is only on the Tx part, the Rx part doesn't have one. Theoretically there could be a queue also in Rx, but its effect are usually neglected, as its effects (in real nodes) are evident only in very particular cases.

About how to set the queue size for specific devices, you can use a direct method, e.g.:
 NetDeviceContainer devices01;
 devices01
= p2pHelper01.Install (nodes01);
 
Ptr<DropTailQueue> queue = DynamicCast<DropTailQueue> (DynamicCast<PointToPointNetDevice> (devices01.Get (0))->GetQueue ());
 queue
->SetAttribute ("MaxPackets", UintegerValue (250));

However, the problem isn't there.
The problem is that you didn't triple check your own code, and the script is just doing what it is supposed to do: transmit 10 packets on the channel. All the other packets are discarded, trashed, dropped in the bin.
Just check (again) what you wrote and you'll find why.

Have fun,

T.

محمود النعانعة

unread,
Jan 7, 2016, 7:34:39 AM1/7/16
to ns-3-users
Thank you Tommaso, in my simulation node 1 is a router and it has limited receiving buffer size (10 packets). and because output link speed is halve the input link then about half of the packets should be dropped.

It seems that "MaxPackets" attribute means something else other than buffer size...

How could I implement input buffer size ... as in this ns2 code

set r [$ns node]
set d [$ns node]
$ns duplex­link $s1 $r 2Mb 10ms DropTail
$ns duplex­link $s2 $r 2Mb 10ms DropTail
$ns duplex­link $r $d 1.7Mb 20ms DropTail


# setting queue limit
$ns queue­limit $r $d 10 


Tommaso Pecorella

unread,
Jan 7, 2016, 8:27:47 AM1/7/16
to ns-3-users
Hi,

I don't know about ns2, but in ns-3 MaxPackets have an exact meaning: the number of packets that a queue can store before starting dropping stuff.
I could explain why your simulation behaves like it does, but it would be too easy. Instead, I'll give you an hint: packets are not dropped by the intermediate node, they're dropped by the source.
As I said, triple check your code. You did a mistake, and a pretty huge one. If you really can't find it I'll tell you. 

T.

محمود النعانعة

unread,
Jan 7, 2016, 10:13:52 AM1/7/16
to ns-3-users
I don't want to set the queue size of node 0 transmit device , I want to set the queue size of n1 receiving device.

Also ,I want packets to be dropped by the intermediate node (which represents a router).

How could I do that.

I am confused about the way NS3 behave and the results does not comply with the expected ones.

Tommaso Pecorella

unread,
Jan 7, 2016, 11:26:25 AM1/7/16
to ns-3-users
Hi,

in my opinion you should re-read the tutorial. Still, here's the explanation.

 PointToPointHelper p2pHelper01;
 p2pHelper01
.SetChannelAttribute ("Delay", StringValue ("0ms"));

 p2pHelper01
.SetQueue("ns3::DropTailQueue",  "MaxPackets",UintegerValue(queueSize));

 p2pHelper01
.SetDeviceAttribute ("DataRate", StringValue ("100kbps"));
The above piece of code sets an helper. When you'll use it, it will install a couple of NetDevices on the nodes you'll pass as arguments.
Since it's a PointToPoint, only 2 devices will be created, each one on a different node.
Both devices will share the same properties, i.e., the ones defined in the helper.

Note that you have 4 PointToPoint NetDevices: one in Node 0, one in Node 2 and TWO in Node 1.
The one in Node 0 (your source node) does have a data rate, but it also have a maximum number of packets.

Summarizing, you have 2 queues between node 0 and node 2, one in node 0 and the other one in node 1 (remember, no queues on reception). Moreover, all the queues are finite, with 10 packets size.

Problem is... you haven't found the thing I was trying to point to. The big mistake in not in the queues (not only there), it's in the following lines:
 Time interPacketInterval = Seconds (0.0);

 
...

 
UdpClientHelper client (serverAddress, port);
 client
.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
 client
.SetAttribute ("Interval", TimeValue (interPacketInterval)); // Default is 1 s
 client
.SetAttribute ("PacketSize", UintegerValue (MaxPacketSize));
 apps
= client.Install (nodes01.Get (0));
 apps
.Start (Seconds (2.0));
 apps
.Stop (Seconds (20.0));

Since interPacketInterval is zero, all the packets will be generated at the same time, filling the sender's queue. It's not an unexpected behaviour, and ns2 would have had the very same behaviour, if configured in the same way.

Got it now ?
Your sender node is generating packets with a data rate much greater than the link data rate (infinite to be precise), and you have set a finite queue in the sender node. This will always end up in packet being dropped at the source.

Pretty logical once you know where the problem is, right ?

T.
Reply all
Reply to author
Forward
0 new messages