[ns] Re: stop trace-callback

maillist ifiaas maillist.ifiaas at gmail.com
Thu Jun 30 23:43:38 PDT 2005


After looking at the code in ns/tcl/lib/ns-link.tcl, I add another
procedure in Simple link, as following (modification in
ns/tcl/lib/ns-link.tcl):

******
SimpleLink instproc trace-callback {ns cmd} {
    $self trace $ns {}
    foreach part {enqT_ deqT_ drpT_ rcvT_} {
        $self instvar $part
        set to [$self set $part]
        $to set callback_ 1
        $to proc handle a "$cmd \$a"
    }
}
# 
# Stop the callback function defined above.
#
SimpleLink instproc stop-trace-callback {ns} {
    foreach part {enqT_ deqT_ drpT_ rcvT_} {
        $self instvar $part
        set to [$self set $part]
        $to set callback_ 0
        $to proc handle a ""
    }
}
*****
Using stop-trace-callback could remove the callback function attached
previously.
After that we can switch to another callback function by calling
trace-callback function again.
Hope it's helpful to u too.

- gavin

On 7/1/05, maillist ifiaas <maillist.ifiaas at gmail.com> wrote:
> Hi, is there a way to stop trace-callback?
> 
> I am using a function to deal with the arriving packets. The function
> is attached to the link by:  $link trace-callback $ns mytrace-callback
> After a  while I want to change the function to another.
> Question is how can I detach mytrace-callback from the link? or just stop it?
> 
> Thank you!
> 
> gavin
>



More information about the Ns-users mailing list