How to create and add nodes dynamically

95 views
Skip to first unread message

琳琅

unread,
Oct 16, 2023, 3:54:14 AM10/16/23
to ns-3-users
In the example third.cc script, there are three mobile device nodes under one WiFi, which are specified in the third script and can only be there once the simulation starts.

I need to dynamically add nodes during the simulation run, such as adding a fourth mobile node to WiFi at some point in the simulation.

Is this feasible? How to achieve this dynamic creation and addition?

Thank you for your answers and help!

Tommaso Pecorella

unread,
Oct 16, 2023, 2:58:41 PM10/16/23
to ns-3-users
Even though theoretically it should be possible to create a node at run-time, I wouldn't suggest that. The reason is that far too many protocols are dependent on proper initialisation that is done automatically at the simulation start. Adding nodes later in the simulation is untested (at least by me).

What you can do is to create the nodes and position them far far away, and then move it in its "normal" position when you want it to become active.

Hope it helps,

T.

琳琅

unread,
Oct 18, 2023, 2:37:33 AM10/18/23
to ns-3-users
Ok, thank you for your help

Shorouk Raafat

unread,
Jan 8, 2025, 3:09:13 PM1/8/25
to ns-3-users
Does the same thing apply when simulating an LTE network?
As I tried to add the UEs after some time of the simulation start and it gave error that it cannot add new nodes after the simulation start. note even to create them and then "LTE attach" them after some time as well. so I followed your advice here.

Tommaso Pecorella

unread,
Jan 8, 2025, 4:29:28 PM1/8/25
to ns-3-users
> Does the same thing apply when simulating an LTE network?

Yes.

> note even to create them and then "LTE attach" them after some time as well. so I followed your advice here.

Sorry, but I can not figure out what you mean in the above sentence. 
Reply all
Reply to author
Forward
0 new messages