How to drop random packets

200 views
Skip to first unread message

Nicola Stocco

unread,
Apr 24, 2023, 6:48:27 AM4/24/23
to ns-3-users
Hi everyone, I'm new to ns3 and I'm working on a simple project.
I have a point-to-point link between a sender and a receiver using TCP. I need to randomly drop packets to simulate a simple path loss.
My intuition is to work on the SinkApp, however, I wasn't able to achieve anything so far.
I've tried to work on the HandleRead() without success.

Given a certain probability, I need the packet to be discarded before reaching the receiver.
Can someone suggest me a course of action? Maybe there is some documentation that I could look up to solve this problem.

Thank you in advance.

Tommaso Pecorella

unread,
Apr 24, 2023, 7:08:10 AM4/24/23
to ns-3-users
Smell like an assignment... but I'll give you an hint: check if the NetDevice you're using has a channel model that can have an error model associated.

Nicola Stocco

unread,
Apr 24, 2023, 7:33:29 AM4/24/23
to ns-3-users
Ahah, it's a project that will lead to my bachelor's thesis. The professor suggested we use this group as no one ever thought us how to use ns3 and we are just scrambling pieces together to make things work. The interesting part is the analysis of the data.

Oh please don't tell me that I just have to set it on SetReceiveErrorModel() in the point-to-point-net-device....
Thanks, I'll work on it.

faisal Lone

unread,
Apr 24, 2023, 7:45:00 AM4/24/23
to ns-3-...@googlegroups.com
Do you want to simulate blackhole attack?

--
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/753999a6-fe43-485f-9dca-9b707cc88cb6n%40googlegroups.com.

Nicola Stocco

unread,
Apr 24, 2023, 8:31:19 AM4/24/23
to ns-3-users
No, I need to simulate a basic TCP connection for a "Non-Terrestrial Network". In practice means two nodes with a very long propagation delay. I'll need to implement an evaluation of the channel's path loss to get a "drop probability", and drop packets with that probability.
I already implemented everything with an ideal channel but I'm wasting a lot of time to understand how I could drop packets. I'll try to follow Tommaso's suggestion, however, if you have more information or an example I'll gladly accept it :)

Nicola Stocco

unread,
Apr 25, 2023, 4:28:33 AM4/25/23
to ns-3-users
Thank you a lot!
Checking the NetDevice was just the hint that I needed.

Tommaso Pecorella

unread,
Apr 25, 2023, 7:45:15 AM4/25/23
to ns-3-users
If your tutor said to ask here (i.e., he/she is aware of it), we can help you a LOT more.

Yes, the easiest way is to set PointToPointNetDevice::SetReceiveErrorModel. Mind that it's a receiver error model, so if you want to simulate an asymmetric channel it's perfect.
However, if you need to simulate a symmetric (or a correlated) channel, such as the one of a terrestrial terminal with a satellite, you'll need to have an error model that can "tie" the receiver and sender error models. Think about a terminal under a tree - the terminal drops the packets, but the satellite drops them too. Hence, it would be more appropriate to use a CHANNEL error model, and not a receiver one.

Now, the P2P channel doesn't have such a facility, but you can create an error model acting a singleton, which drops packets based on an internal state (and leveraging the info contained in the packet). Not super easy, but can be done. Alternatively, you can use the same error model in both NetDevices.
Reply all
Reply to author
Forward
0 new messages