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

RE: dropped packet in nam



There was something wrong with Simulator::lossmodel{} (and other error
model installation methods in Link and SimpleLink), that they cannot
produce nam trace events in the right order. Following are patches to
ns-lib.tcl and ns-link.tcl. (They are against ns-lib.tcl version 1.139 and
ns-link version 1.40. If you failed to apply them, you can either try do
them manually using the context in them, or download the current
snapshot). 

- Haobo

* ns-lib.tcl:

--- ns-lib.tcl~ 1999/02/26 23:06:34     
+++ ns-lib.tcl  1999/03/02 20:22:00     
@@ -1049,11 +1049,7 @@
 ### to insert loss module to regular links in detailed Simulator
 Simulator instproc lossmodel {lossobj from to} {
        set link [$self link $from $to]
-       set head [$link head]
-       # puts "[[$head target] info class]"
-       $lossobj target [$head target]
-       $head target $lossobj
-       # puts "[[$head target] info class]"
+       $link errormodule $lossobj
 }
 
 Simulator instproc bw_parse { bspec } {


* ns-link.tcl:

--- ns-link.tcl~ 1998/10/28 19:26:49     
+++ ns-link.tcl  1999/03/02 20:22:00     
@@ -143,12 +143,6 @@
        }
 }
 
-Link instproc install-error {em} {
-       $self instvar link_
-       $em target [$link_ target]
-       $link_ target $em
-}
-
 Class SimpleLink -superclass Link
 
 SimpleLink instproc init { src dst bw delay q {lltype "DelayLink"} } {
@@ -464,8 +458,12 @@
 # insert an "error module" after the queue
 # point the em's drop-target to the drophead
 #
+# Must be inserted *RIGHT AFTER* the deqT_ (if present) or queue_,
because
+# nam can only visualize a packet drop if and only if it is on the link
or 
+# in the queue
+#
 SimpleLink instproc errormodule args {
-       $self instvar errmodule_ queue_ drophead_
+       $self instvar errmodule_ queue_ drophead_ deqT_ 
        if { $args == "" } {
                return $errmodule_
        }
@@ -473,7 +471,20 @@
        set em [lindex $args 0]
        set errmodule_ $em
 
-       $self add-to-head $em
+       #$self add-to-head $em
+        if [info exists deqT_] {
+                $em target [$deqT_ target]
+                $deqT_ target $em
+        } else {
+                $em target [$queue_ target]
+                $queue_ target $em
+        }
 
        $em drop-target $drophead_
+}
+
+# Simply to provide backward compatibility
+SimpleLink instproc install-error {em} {
+       puts "Obsolete interface. Please use errormodule{}"
+       $self errormodule $em
 }