Dear Hongsheng Lu,

Scheduler::instance().clock() has 9 decimal point accuracy, most of
the time it will be different.

Even you are calling it in the same file and in the same function, you
might end up completely different timings. You can either use a
debugger or simply printf statements to understand this.

For instance, assume you have a topology of two wireless nodes, T and
R where T transmits a data packet to R using 802.11 MAC.

Try to put a printf statement calling scheduler::instance().clock()
directly before send(p,h) at,

        if(hdr->direction() == hdr_cmn::DOWN) {
                send(p, h);
                return;
        }

and another printf statement directly after the IF loop.

in Mac802_11::recv function in mac-802_11.cc file

You will see completely different clock information as it is not a
systems time but simulated time. The first timing information related
when T sends a packet and the second timing information related when R
received a packet at the MAC layer which accounts a link delay among
other timing parameter.

By just shifting the printf statement couple of lines in the same
function you are already at a different node location.

Good Luck.

rgds
Saravanan K





On Sat, Aug 4, 2012 at 2:45 AM, Hongsheng Lu <h...@nd.edu> wrote:
>
> Hi there,
>
> I am a newer to NS2. Could anyone tells me
> how Scheduler::instance().clock() works? In particular,
> when Scheduler::instance().clock() are called at two different places in
> the program (might be in different methods or classes), how can I tell
> whether they return the same or different time? Thanks a lot.
>
> --
> Best Regards,
> Hongsheng Lu

Reply via email to