Bug 898 - Wrong example for Time ns3::Now (void)
Wrong example for Time ns3::Now (void)
Status: RESOLVED INVALID
Product: ns-3
Classification: Unclassified
Component: documentation
ns-3.7
All All
: P5 trivial
Assigned To: ns-bugs
http://www.nsnam.org/doxygen-release/...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-04-27 22:46 UTC by zhangbo2050
Modified: 2010-08-01 17:36 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zhangbo2050 2010-04-27 22:46:36 UTC
The example given for this function is :

It is typically used as shown below to schedule an event which expires at the absolute time "2 seconds":

 Simulator::Schedule (Seconds (2.0) - Now (), &my_function);



Which, if I'm correct, should really be:

  Simulator::Schedule (Seconds (2.0) + Now (), &my_function);

Probably just a typo, though.

Zhang Bo
Comment 1 Craig Dowell 2010-04-27 22:59:15 UTC
Unless I'm hallucinating:

  Simulator::Schedule (Seconds (2.0) + Now (), &my_function);

If Now() is 0 seconds, this schedules an event for 2 + 0 = 2 seconds in the future; at absoulute 0 + 2 = 2 seconds.

If Now() is 1 seconds, this schedules an event for 2 + 1 = 3 seconds in the future; at absoulte time 1 + 3 = 4 seconds.

If Now() is 2 seconds, this schedules an event for 2 + 2 = 4 seconds in the future; at absolute time 2 + 4 = 6 seconds.

However, in this case:

 Simulator::Schedule (Seconds (2.0) - Now (), &my_function);

If Now() is 0 seconds, this schedules an event for 2 - 0 = 2 seconds in the future; at absolute time 0 + 2 = 2 seconds.

If Now() is 1 seconds, this schedules an event for 2 - 1 = 1 seconds in the future; at absolute time 1 + 1 = 2 seconds.

If Now() is 2 seconds, this schedules an event for 2 - 2 = 0 seconds in the future; at absolute time 2 + 0 = 2 seconds.

It seems to me that the comment is correct.