usleep() in ns-3

29 views
Skip to first unread message

Harald Ott

unread,
Jul 29, 2016, 3:52:30 PM7/29/16
to ns-3-users
It seems like such a banal question, but how is it possible to just sleep() in an ns-3 script so that virtual time passes?
I would just need the C++ usleep() equivalent...
I've look all over and couldn't find anything...

Tommaso Pecorella

unread,
Jul 30, 2016, 9:33:14 AM7/30/16
to ns-3-users
Hi,

there's no µsleep or sleep equivalent simply because the virtual time is handled differently in discrete event simulators.
In a DE simulator like ns-3, "now" is when an event is handled. The event handling is performed in a (virtually) null time (i.e., negligible) and then the control is passed back to the event scheduler. If you need to "wait" some time, you need to schedule another event.

Hope this helps,

T.

Matt Anonyme

unread,
Jul 30, 2016, 10:32:12 AM7/30/16
to ns-3-users
There is a patch to provide per node clock which should allow in the future to achieve this https://groups.google.com/forum/#!topic/ns-3-reviews/CqvQurXzX2E but a simpler way would be to have your own per node variable that decals scheduling times.
Reply all
Reply to author
Forward
0 new messages