Re: How to force a nod to drop packets?

223 views
Skip to first unread message
Message has been deleted

Soulimane Mammar

unread,
Feb 18, 2022, 6:36:13 AM2/18/22
to ns-3-users
Hi,
On Friday, February 18, 2022 at 12:07:50 PM UTC+1 Nadia1899 wrote:

Hi,

I have the simulation attached in the file. A client 10.1.1.1 in LAN1 sending udpechoPackets to a server 10.1.10.1 in LAN10.

I added the trace source PhyRxDrop to visualize the packets dropped by the server. However I can't see any dropped packets as numdrop in my simulation is always 0 (even If I increase the number of packets sent). Can you please tell me how I can force the server to drop some packets?

Thank you.

Boumkheld Nadia

unread,
Feb 18, 2022, 10:01:51 AM2/18/22
to ns-3-...@googlegroups.com
Hi,

Thank you for your answer. And what if I want to add a droptailQueue to drop the packets when there is no space for them.

Thanks again



--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/54f7dcb4-8b4a-4e4f-9551-0414cb6cb23bn%40googlegroups.com.

Soulimane Mammar

unread,
Feb 18, 2022, 10:46:48 AM2/18/22
to ns-3-users
Hi,
You can always attach a Tx Queue to a netdevice. The queue can be a DropTailQueue a RedQueue or whatever you want.
This can be done as follows:

auto client_csma_interface = StaticCast<CsmaNetDevice>(LAN1devices.Get (0));
// The default mode of DropTailQueue is QUEUE_MODE_PACKETS  and MaxPackets == 100
Ptr<DropTailQueue> dtq = CreateObject<DropTailQueue>() ;
client_csma_interface.SetQueue(dtq)
// In case you want to change the Queue size, use the config system
// i refers to the node number in the scenario (not int the container)
Config::Set("/NodeList/[i]/DeviceList/[i]/$ns3::CsmaNetDevice/TxQueue/$ns3::DropTailQueue", UintegerValue(new_size))

Regards



Message has been deleted

Soulimane Mammar

unread,
Feb 18, 2022, 3:23:39 PM2/18/22
to ns-3-users
Hi,
Sorry, That was just a sketch not meant to be in real code
For recent implementation of DropTailQueue, the class is no more specific to packets, it is rather a template that we can specialize to Packet type.
Furthermore, there is no attribute MaxPackets for this template, it has been replaced by a more general attribute MaxSize 
So a working code looks like:

auto client_csma_interface = StaticCast<CsmaNetDevice>(LAN1devices.Get (0));
Ptr<DropTailQueue<Packet>> dtq = CreateObject<DropTailQueue<Packet>> ();
dtq->SetMaxSize(QueueSize (QueueSizeUnit::PACKETS, 3)); // setting the size of the queue to 3 packets
client_csma_interface->SetQueue (dtq);

Regards


On Friday, February 18, 2022 at 7:21:31 PM UTC+1 Nadia1899 wrote:
When I add this code for DroptailQueue in test2 File you attached. It generates some errors.

./scratch/test2.cc: In function ‘int main(int, char**)’:
../scratch/test2.cc:145:18: error: type/value mismatch at argument 1 in template parameter list for ‘template<class T> class ns3::Ptr’
  145 | Ptr<DropTailQueue> dtq = CreateObject<DropTailQueue> () ;
      |                  ^
../scratch/test2.cc:145:18: note:   expected a type, got ‘DropTailQueue’
../scratch/test2.cc:145:55: error: no matching function for call to ‘CreateObject<template<class Item> class ns3::DropTailQueue>()’
  145 | Ptr<DropTailQueue> dtq = CreateObject<DropTailQueue> () ;
      |                                                       ^
In file included from ./ns3/scheduler.h:25,
                 from ./ns3/calendar-scheduler.h:25,
                 from ./ns3/core-module.h:23,
                 from ../scratch/test2.cc:1:
./ns3/object.h:576:8: note: candidate: ‘template<class T, class ... Args> ns3::Ptr<T> ns3::CreateObject(Args&& ...)’
  576 | Ptr<T> CreateObject (Args&&... args)
      |        ^~~~~~~~~~~~
./ns3/object.h:576:8: note:   template argument deduction/substitution failed:
../scratch/test2.cc:146:23: error: ‘class ns3::Ptr<ns3::CsmaNetDevice>’ has no member named ‘SetQueue’
  146 | client_csma_interface.SetQueue(dtq)

Boumkheld Nadia

unread,
Feb 21, 2022, 5:48:38 AM2/21/22
to ns-3-...@googlegroups.com
Thank you. For some reason, even with the DroptailQueue I still can't see any packets dropped even if the client sends 1000 packets. In this case I don't use the Error Model.

Best.

Soulimane Mammar

unread,
Feb 22, 2022, 1:06:42 AM2/22/22
to ns-3-users
Hi,
You have to understand how things work.
You have a ppp link with a data rate of 10 Mbps and a client application that sends 1024 Bytes each 1ms
Using simple math, you can calculate the application data rate: (1024*8)/10^-3 = 8 Mbps which way less than 10 Mbps. In this case there no congestion and hence no packet will be dropped (considering a perfect link) even with no queue.
You have to create  a congestion situation (for instance sending 1024 Bytes each 0.5 ms) if you want to seed drops.
Don't forget, queues are good for bursty traffic not cbr
Regards

Boumkheld Nadia

unread,
Feb 22, 2022, 5:28:53 AM2/22/22
to ns-3-...@googlegroups.com
Ok thank you so much for your explanation.

All the best

Reply all
Reply to author
Forward
0 new messages