📄 init.tcl
字号:
####################################################################### ## range: Returns a numeric list from 'min' to 'max' ## ## min: the first element of the list ## max: the last element of the list ## #######################################################################proc range {min max} { set lst {} for {set i $min} {$i<=$max} {incr i} {lappend lst $i} return $lst}####################################################################### ## lessof: Returns a numeric list from 0 to 'max'-1 ## ## max: the last element of the list ## #######################################################################proc lessof {max} { set lst {} for {set i 0} {$i<$max} {incr i} {lappend lst $i} return $lst}####################################################################### ## calssify: Records some useful variables during the initialization ## phase ## ## node: the C++ class of this node ## n: the numeric index of the node ## name: the name of the node (a string) ## #######################################################################proc classify {node n name} { global obj nd macadd set obj(node,$n) $node set obj(mac,$n) [$node set mac_(0)] ;# The C++ Mac802_11 class set obj(ll,$n) [$node set ll_(0)] ;# The C++ LL class set obj(ifq,$n) [$node set ifq_(0)] ;# The C++ BS_DropTail class set obj(netif,$n) [$node set netif_(0)] ;# The C++ WirelessPhy class set obj(err,$n) [$node set inerr_(0)] ;# The C++ MyErrorModel class set nd($n) $name set macadd([$obj(mac,$n) id]) $name set nd([$node set mac_(0)]) $name}####################################################################### ## getopt: Reads the command line parameters ## ## argc: the number of tokens on the command line ## lst: the list of tokens ## VEC: the vector that will contain the parameters ## #######################################################################proc getopt {argc lst VEC} { upvar $VEC vec foreach i [lessof [llength $lst]] { set arg [lindex $lst $i] if {[string range $arg 0 0] != "-" || [string range $arg 1 1] == "1"} { continue } set name [string range $arg 1 end] set vec($name) [lindex $lst [expr $i+1]] }}####################################################################### ## save_par: Prints on the output file a list of the simulation ## parameters ## #######################################################################proc save_par {} { global file opt puts $file(finish) "#\n#\tUsing Parameters:\n#" set lst {} foreach par [array names opt] { lappend lst $par } set lst [lsort $lst] foreach par $lst { puts $file(finish) [format "#\t%20s%30s" $par $opt($par)] } puts $file(finish) "#"}####################################################################### ## MAC_set: Prints on the output file the value of some MAC variables ## ## name: the C++ Mac802_11 class ## index: the MAC Address of the node ## brate: basic transmission rate ## drate: data transmission rate ## difs: DCF Interframe Space (AIFS for 802.11e) ## eifs: Extended Interframe Space ## cwmin: minimum value of the Contention Window ## cwmax: maximum value of the Contention Window ## srl: Short Retry Limit ## lrl: Long retry Limit ## ## Called by mac-802_11.cc ## #######################################################################proc MAC_set {name index brate drate difs eifs cwmin cwmax srl lrl} { global file nd puts $file(finish) [format "#\t\t%5s %2d set rate %f %f, difs %f, eifs %f, cwmin %2d, cwmax %4d, maxrtx %d %d" \ $nd($name) $index $brate $drate $difs $eifs $cwmin $cwmax $srl $lrl]}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -