is it not possible to use WiFi helpers to instantiate new WiFi stations during simulation?

41 views
Skip to first unread message

Sebastian Lindner

unread,
May 14, 2024, 10:22:02 AMMay 14
to ns-3-users
I want to dynamically add WiFi stations during simulation. I use Simulator::Schedule to schedule an appropriate event to call a function that instantiates a new user, i.e. it instantiates an ns3::Ptr<ns3::Node> object, installs the WiFi PHY and MAC layers, assigns IP, and so on. The same function works fine to instantiate stations before calling Simulator::Run. But when this is done during simulation, it *sometimes* crashes with a segmentation fault. The debugger is of no help, the culprit-caller tends to change depending on how I'm trying to find the right source of the error.

Is there something fundamentally wrong with instantiating users during simulation? Would I be better off instantiating everything before simulation start, and letting them become active by setting application-layer start times?

Tommaso Pecorella

unread,
May 14, 2024, 4:45:47 PMMay 14
to ns-3-users
Usually nodes aren't created while the simulation is running. It's not forbidden (what's forbidden is to destroy them), but for sure it's... unusual.

What can be a bit wobbly in creating the nodes at run-time is in the initialization phase of each layer. Still, even if it's not theoretically illegal, for sure it's something we don't test. Hence, I can't exclude that there aren't code issues when you try to do it.

Instantiating the nodes before Run is for sure the best option. If you need them to be completely "silent", just move them to the Far Far Away Kingdom (usually 2Km apart from any other node does the trick). When it's their time to "show up" just move them where they should be.

Sebastian Lindner

unread,
May 16, 2024, 3:22:15 AMMay 16
to ns-3-users
Thanks for your insights, Tommaso! I've implemented your suggestions and it seems to work fine.
Reply all
Reply to author
Forward
0 new messages