Bugzilla – Bug 898
Wrong example for Time ns3::Now (void)
Last modified: 2010-08-01 17:36:07 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
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.