Bugzilla – Bug 104
Maximum simulation time
Last modified: 2008-07-01 13:32:20 UTC
It is quite common for me to need a way to get the maximum possible simulation time in my time-calculation algorithms. I have added in my local ns-3 copy a method named MaxSeconds is nstime.h: Time MaxSeconds (void); implemented as such: Time MaxSeconds (void) { return Timestep (0x7fffffffffffffffLL); } The big tricky thing here is that the internal time can be up to 0xffffffffffffffffLL: note the high bit which is set to 1 here because the internal time is an unsigned 64 bit quantity. However, the Time class is a signed quantity so, the Simulator::Now () method actually returns the internal unsigned time as a signed time. I think that this means that we should be very careful in our simulator.cc code to check this condition and make sure that it never happens, that is, that the simulation time never goes beyond 0x7ffff.... The other issue is how the MaxSeconds function should be named: should it be named MaxTime instead ? Is there a better alternative to name it ?
Actually, in simulator.cc line 208, we ensure that no event will be scheduled with a timestamp bigger than 0x7fff.... because we check for the negativity of the input end time. I have added a test for that case to ensure that the check is correct and pushed it to ns-3-dev.
changeset 50fa1ca3b26c