[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ErrorModel Help needed



> Hi,
> 
> 	Anyone has a sample script of how to use 
> 	ErrorModel. I have been trying to use the install-error
> 	in tcl/lan/ns-lan.tcl and no luck. Either I am doing
> 	something wrong or install-error is really not operational
> 	as non of the debugger does not show any calls to the
> 	ErrorModel methods such as recv, corrupt...etc.
> 
> 	Currently, I am trying this with NS2.1B2. Things were working
> 	for me in NS2.0 without much trouble. Since I upgraded to
> 	NS2.1B2, I had this problem.
> 
> 	A help would be appreciated in:
> 
> 	o A sample script for the user of ErrorModel.
> 
> 	o A hint if the install-error or create-error in tcl/lan/ns-lan.tcl
> 	   are operational or not. I can not guess if the code would be
> 	   generated without being backward compatible.
> 
> 	
> 
	Dear Emad

We've had similar problems. It seems from your description of the problem that the error model is not properly installed on the link since the debugger never goes into it, right?

Try this, perhaps it helps you out, it sure helped us to get started (thanx to mr Haobo Yu):

SimpleLink instproc putLossOnLink { ns em } {
    $self instvar queue_ head_ link_ isLossy_ deqT_ lossModule_

    # set em between a queue and a DelayLink
    $em onlink

    if [info exists deqT_] {
        $em target [$deqT_ target]
        $deqT_ target $em
    } else {
        $em target [$queue_ target]
        $queue_ target $em
    }

    set lossModule_ $em
}

Simulator instproc insert-loss { n1 n2 em} {
    $self instvar link_

    set lnk $link_([$n1 id]:[$n2 id])

    set trace [$self get-ns-traceall]
    if {$trace != ""} {
        set drpT [$self create-trace Drop $trace $n1 $n2]
        set trace [$self get-nam-traceall]
        if {$trace != ""} {
            $drpT namattach $trace
        }
        $drpT target [$em drop-target]
        $em drop-target $drpT
    } else {
        set trace [$self get-nam-traceall]
        if {$trace != ""} {
            set drpT [$self create-trace Drop $trace $n1 $n2 nam]
            $drpT target [$em drop-target]
            $em drop-target $drpT
        }
    }

    $lnk putLossOnLink $self $em
    puts "Lossy link ([$n1 id]:[$n2 id]) added"
}

set data_em [new ErrorModel]

$data_em drop-target [$ns create-trace Drop $f $n0 $n1]

# insert loss on link 0->1
$ns insert-loss $n0 $n1 $data_em

Also, take a look in the ns manual page 37 to make sure you understand where the error model is inserted. 

Hope this helps.

-wesa & johan