Hi, all. Wish everyone a merry Christmas and a happy new year!

I was going through the source code of ns and got confused when I wanted to
find out how 'target_' of class agent, which is derived from class
connector, gets initialized? I know in Connector::command(), command
"target" is defined to do so. But where does this got invoked?
In function simulator's attach-agent{}, it calls node's attach{}. But in
attach "target" command is not invoked. Finally I find the target_ was
initialized after invoking Node's function:add-target { agent port }. But,
how? 
I don't understand the code of this function:

Node instproc add-target { agent port } {
        $self instvar ptnotif_
        # Replaces the following line from old ns (2.1b7 and earlier)
        #   $self add-target $agent $port
        foreach m [$self set ptnotif_] {
                $m attach $agent $port
        }
}

It seems that the expression "$m attach $agent $port" does not invoke the
function Node instproc attach { agent { port "" } }(Because I got it to
print information and if it is called it will print). What is this "attach"?
And how is target_ of agent finally got initialized?

Thanks.

HuangWei


Reply via email to