Commit 75f1f106 authored by Christopher Alfeld's avatar Christopher Alfeld

Did an ugly/interesting hack/method to find what variables the user is

storing the nodeids in and outputtng those as virtual node names instead
of the internal node names.
parent 8644f3ea
......@@ -4,7 +4,18 @@ Class link
# link src srcport dst dstport
link instproc print {file} {
puts $file [format "l[$self set id] [$self set src] [$self set srcport] \
[$self set dst] [$self set dstport] [$self set bw] [$self set bw] [$self set delay] [$self set delay]"]
global nodeid_map
if {[info exists nodeid_map([$self set src])]} {
set srcname $nodeid_map([$self set src])
} else {
set srcname [$self set src]
}
if {[info exists nodeid_map([$self set dst])]} {
set dstname $nodeid_map([$self set dst])
} else {
set dstname [$self set dst]
}
puts $file "l[$self set id] $srcname [$self set srcport] $dstname [$self set dstport] [$self set bw] [$self set bw] [$self set delay] [$self set delay]"
}
......@@ -4,17 +4,24 @@ Class node
# output format is: nodeID type link(s)
node instproc print {file} {
$self instvar nodelinks
puts -nonewline $file [format "n[$self set id] [$self set type]"]
foreach link $nodelinks {
puts -nonewline $file " $link"
}
#we have to add ". bandwidth delay" to delay nodes.
if [string match [$self set type] delay] {
puts -nonewline $file " . [$self set bw] [$self set delay]"
}
global nodeid_map
puts $file ""
if {[info exists nodeid_map(n[$self set id])]} {
set nodename $nodeid_map(n[$self set id])
} else {
set nodename n[$self set id]
}
$self instvar nodelinks
puts -nonewline $file "$nodename [$self set type]"
foreach link $nodelinks {
puts -nonewline $file " $link"
}
#we have to add ". bandwidth delay" to delay nodes.
if [string match [$self set type] delay] {
puts -nonewline $file " . [$self set bw] [$self set delay]"
}
puts $file ""
}
......
......@@ -11,6 +11,35 @@ source $libdir/node.tcl
source $libdir/link.tcl
source $libdir/event.tcl
###
# calfeld@cs.utah.edu
# This some ugly/interesting tcl hacking to figure out what variables the user
# stored the node ids in.
###
rename set real_set
set skipset 0
proc set {args} {
global skipset
global nodeid_map
if {! $skipset} {
real_set skipset 1
real_set var [lindex $args 0]
if {$var != "currnode"} {
if {[llength $args] > 1} {
real_set val [lindex $args 1]
if {[regexp {^n[0-9]+$} $val] != -1} {
if {![info exists nodeid_map($val)]} {
real_set nodeid_map($val) $var
}
}
}
}
real_set skipset 0
}
return [eval "uplevel real_set $args"]
}
###
#nop is used for unimplemented $ns instprocs that are supposed to
#return things. the instproc returns a nop, which users call in their
#ns input file.
......@@ -39,3 +68,4 @@ source $libdir/stubs.tcl
# argv[0] is the ns input file
source [lindex $argv 0]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment