The previous section talked about error model, in this section we discuss how to use error models in ns over either wired networks or wireless ones.
To use an error model for wired networks, at first it has to be inserted into a SimpleLink object. Because a SimpleLink is a composite object (Chapter 6), an error model can be inserted to many places. Currently we provide the following methods to insert an error module into three different places.
rX
SimpleLink::errormodule args & When an error model is given
as a parameter, it inserts the error module into the simple link,
right after the queue module, and set the drop-target of the error
model to be the drop trace object of the simple link. Note that
this requires the following configuration order:
ns namtrace-all
followed by link configurations, followed by error
model insertion. When no argument is given, it returns the current
error model in the link, if there's any. This method is defined in
ns/tcl/lib/ns-link.tcl
Simulator::lossmodel em src dst & Call SimpleLink::errormodule to insert the given error module into the simple link (src, dst). It's simply a wrapper for the above method. This method is defined in ns/tcl/lib/ns-lib.tcl.
rX
SimpleLink::insert-linkloss args & This method's behavior
is identical to that of SimpleLink::errormodule, except
that it inserts an error module immediately after the queue
object. It's defined in ns/tcl/lib/ns-link.tcl
Simulator::link-lossmodel em src dst & This is a wrapper for SimpleLink::insert-linkloss. It's defined in ns/tcl/lib/ns-lib.tcl
The nam traces generated by error models inserted using these two methods do not require special treatment and can be visualized using an older version of nam.
To add an error model over wireless networks, each node can insert a given statistical error model either over outgoing or incoming wireless channels. Precisely, the instanciated error model would be stuck between mac and netif modules depicted in Figure 16.2. For the outgoing link, the error module would be pointed by downtarget_ of the above mac module while for the incoming link it would be linked by uptaget_ pointer of the below netif module. And in each case the target_ of the error module points to either the netif or the mac respectively. The difference of placing over the two different locations is that the outgoing causes all the receivers to receive the packet suffering the same degree of errors since the error is determined before wireless channel module copies the packet. On the other hand, the incoming error module lets each receiver get the packet corrupted with different degree of error since the error is independently computed in each error module.
The insertion into the wireless protocol stack can be done by calling node-config command explained in Section 5.3 with the two options IncomingErrrProc and OutgoingErrProc. We can use these two options at the same time or each one separately. The argument of the two option is the name of the global procedure which creates an error model object, feeds it with necessary initial values appropriate for the new error module, and finally returns the object pointer. The following shows a simple TCL example script to add an error module into the wireless protocol stack.
$ns node-config -IncomingErrProc UniformErr -OutgoingErrProc UniformErr proc UniformErr {} { set err [new ErrorModel] $err unit packet return $err }
Tom Henderson 2011-11-05