On 08/18/2015 04:14 PM, PN wrote:
> I'm trying to figure out how Simulator::Schedule() Method works. I was
> under the impression that if the following call is made:
>
> |
> Simulator::Schedule(t1,&func1);
> |
>
> then when the program execution reaches this line, it would increment
> the current value of time by t1 and make a call to func1().
The statement schedules func1 to execute after a delay t1 from the
current simulation time.
However, if
> that were true then after the following sequence of calls:
>
> |
> Simulator::Schedule(t1,&func1);
> Simulator::Schedule(t2,&func2);
> Simulator::Schedule(t3,&func3);
> |
>
> Time should be incremented by t1+t2+t3. However, it looks like the
> simulator sees t1, t2 and t3 as the actual values of time rather than
> increments (script is attached).
Not actual in the sense of absolute time, but in the sense of relative
time (delay) from the current simulation time reported by Simulator::Now().
Now assuming that the value of time
> given is an absolute value and not an increment, how does a call like
> the following work:
>
> |
> Simulator::Schedule(tEvent,&CsmaNetDevice::TransmitCompleteEvent,this);
> |
>
> where tEvent is the time it takes to complete the event? The above line
> is a part of CsmaNetDevice::TransmitStart().
TransmitCompleteEvent will execute tEvent time later than now.
>
> Also, what happens if there is this following set of calls:
>
> |
> Simulator::Schedule(t1,&func1);
> func2();
> Simulator::Schedule(t2,&func3);
> |
>
> will func2() get called before func1()? I know the answer is YES: you
> can see that through my script. I just want to know why.
Hopefully you can see now that func2() is executed now, func1() t1 from
now, and func3() t2 from now.
>
> I tried going through the Simulator::Schedule() script. However, there
> are more than one function calls involved and it was getting difficult
> for me to understand all of them. I guess that I'm facing the above
> questions due to my lack of knowledge on how ns 3 or a discrete event
> simulator works (what I know is sufficient to use and tweak/debug ns 3
> at a basic level but at an advance level, I get stuck with questions
> such as those mentioned above).
>
> If anyone can help me with this, it would be very much appreciated!
>
> Additionally, if you could point me to a document/book that helps
> understand the working of a discrete event simulator such as ns 3, that
> would be fantastic. I couldn't find a good one myself. The manual is a
> great reference, but at certain points, it looks like it is still being
> completed.
I'm not aware of any such books. You might want to look at the training
presentations or videos that the ns-3 Consortium has prepared.
https://www.nsnam.org/consortium/activities/training/
- Tom