[Ns-bugs] [Bug 230] Simulator::Now() Updating and Simulator::Stop()
code@nsnam.ece.gatech.edu
code at nsnam.ece.gatech.edu
Tue Dec 9 23:25:02 PST 2008
http://www.nsnam.org/bugzilla/show_bug.cgi?id=230
--- Comment #1 from Mathieu Lacage <mathieu.lacage at sophia.inria.fr> 2008-12-10 02:25:02 EDT ---
(In reply to comment #0)
> Currently, when you use Simulator::Stop(), the simulator time is not updated at
> the end of the simulation. It remains at the time of the last event to be
> processed. For example, the following will print "0ns":
>
> Simulator::Stop(Seconds(4));
> Simulator::Run();
> std::cout << Simulator::Now() << std::endl;
>
> This is non-intuitive, and a potential annoyance for some add-on modules which
> do not necessarily know when the simulation script set the simulation to end.
> Example tasks affected by this include calculating partial traffic, updating
> final positions, etc. A potential workaround is the following, which will
> print the expected "4ns":
>
> Simulator::Schedule(Seconds(4), &Simulator::Stop);
> Simulator::Run();
> std::cout << Simulator::Now() << std::endl;
>
> But, this has the important downside of allowing some events scheduled at the
> same time to be executed before this event is processed.
>
> I believe the fix is as simple as setting m_currentTs to m_stopAt when the
> simulation ends because m_stopAt > NextTs(), but am not 100% convinced.
While the proposed change seems fairly intuitive, I am worried about potential
breakage in the case where you call Simulator::Run multiple times.
I have to ask, though, why does't Simulator::Stop (delay) not just schedule an
event to call Stop at the right time ? That would be even simpler and would
solve this problem.
Patch attached.
>
> Thx
>
--
Configure bugmail: http://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the Ns-bugs
mailing list