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

[ns] introduce error for LAN



Hello, all,
   My Q is how to add error model to a LAN, 

when I use make-lan to create a Lan made of several nodes..
how to add loss into the LAN?? when I do something like 
"set loss_module [new ErrorModel/Expo $rate $unit]
$ns lossmodel $loss_module $src $dst" as suggested in ns Doc, I got the
error: 
-----------------
invalid command name ""
    while executing
"$link errormodule $lossobj"
    (procedure "_o4" line 11)
    (Simulator lossmodel line 11)
    invoked from within
"$ns lossmodel $loss_module $src $dst"
----------------------

I tracked down the ns-lib.tcl code, found out that $link is null since the
nodes are making a LAN, not simplx or duplex link, therefore there is not
link between the nodes in the LAN. That is the problem.
 
in tcl/ex/snoop/snoop.tcl, it uses LAN, it sets error model for each
direction between pairs of the nodes, it has something like:

                set e1 [new ErrorModel/Expo $rate $unit]
                set e2 [new ErrorModel/Expo $rate $unit]
		
		add-error $lan $src $dst $e1
                add-error $lan $dst $src $e2

in "add-error" function, they add filter to introduce error:

proc add-error {lan src dst errmodel} {
        $lan instvar lanIface_

        set nif $lanIface_([$dst id])
        set filter [new Filter/Field]
        $nif add-receive-filter $filter
        $filter filter-target $errmodel
        $errmodel target [$filter target]
        $filter set offset_ [PktHdr_offset PacketHeader/Mac macSA_]
        $filter set match_ [$src node-addr] # will not work with hier. routing
}

My Question is:
DOes it have to be so complex to introduce an error to LAN?

btw, I did not see any filter related documentation, I am wodnering is
Fileter an obsolete interface, not recommendated to use any more?

THANKS in advance!
yan