1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
|
#
# Copyright (c) 1996-1998 Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the MASH Research
# Group at the University of California Berkeley.
# 4. Neither the name of the University nor of the Research Group may be
# used to endorse or promote products derived from this software
# without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $Header: /cvsroot/nsnam/ns-2/tcl/mobility/com.tcl,v 1.9 2003/02/19 22:22:28 haldar Exp $
#
# These procedures are all obsolete and has been replaced by the newer node
# configuration. See test-suite-WL-tutorial.tcl for details.
proc create-base-station-node {address } {
puts "Method create-base-station-node is now obsolete. Use methods in ~ns/tcl/test/test-suite-WLtutorial.tcl to create base-station nodes\n\n"
exit 0
# global topo tracefd opt node node_ ns_
# set ns_ [Simulator instance]
# if [Simulator set mobile_ip_] {
# Simulator set node_factory_ MobileNode/MIPBS
# } else {
# Simulator set node_factory_ Node/MobileNode/BaseStationNode
# }
# set node [$ns_ node $address]
# set id [$node id]
# $node random-motion 0 ;# disable random motion
# $node topography $topo
# #
# # This Trace Target is used to log changes in direction
# # and velocity for the mobile node.
# #
# set T [new Trace/Generic]
# $T target [$ns_ set nullAgent_]
# $T attach $tracefd
# $T set src_ $id
# $node log-target $T
# $node base-station [AddrParams addr2id [$node node-addr]]
# create-$opt(rp)-bs-node $node $id
# Simulator set node_factory_ Node ;# default value
# return $node
}
proc create-dsdv-bs-node {node id} {
puts "Method create-dsdv-bs-node is now obsolete. Use methods in ~ns/tcl/test/test-suite-WLtutorial.tcl to create base-station nodes\n\n"
exit 0
# global ns_ chan prop opt node_
# $node instvar regagent_ ragent_
#
# $node add-interface $chan $prop $opt(ll) $opt(mac) \
# $opt(ifq) $opt(ifqlen) $opt(netif) \
# $opt(ant)
#
# create-$opt(rp)-routing-agent $node $id
#
# if [info exists regagent_] {
# $regagent_ ragent $ragent_
# }
# if { $opt(pos) == "Box" } {
# #
# # Box Configuration
# #
# set spacing 200
# set maxrow 7
# set col [expr ($id - 1) % $maxrow]
# set row [expr ($id - 1) / $maxrow]
# $node set X_ [expr $col * $spacing]
# $node set Y_ [expr $row * $spacing]
# $node set Z_ 0.0
# $node set speed_ 0.0
#
# $ns_ at 0.0 "$node_($id) start"
# }
}
proc create-dsr-bs-node {node id} {
puts "Method create-dsr-bs-node is now obsolete. Use methods in ~ns/tcl/test/test-suite-WLtutorial.tcl to create base-station nodes\n\n"
exit 0
# global ns_ chan prop opt
# $node instvar regagent_ ragent_
#
# $node add-interface $chan $prop $opt(ll) $opt(mac) \
# $opt(ifq) $opt(ifqlen) $opt(netif) \
# $opt(ant)
#
# create-$opt(rp)-routing-agent $node $id
# $node create-xtra-interface
#
# if [info exists regagent_] {
# $regagent_ ragent $ragent_
# }
#
# $ns_ at 0.0 "$node start-dsr"
}
proc create-dsr-routing-agent { node id } {
puts "Method create-dsr-routing-agent is now obsolete. Use methods in ~ns/tcl/test/test-suite-WLtutorial.tcl to create base-station nodes\n\n"
exit 0
# global ns_ ragent_ tracefd opt
#
# #
# # Create routing agent and attach it to port 255
# #
# set ragent_($id) [new Agent/DSRAgent/BS_DSRAgent]
# set ragent $ragent_($id)
#
# # setup address (supports hier-addr) for dsdv agent
# set address [$node node-addr]
# $ragent addr $address
# $ragent node $node
# if [Simulator set mobile_ip_] {
# $ragent port-dmux [$node set dmux_]
# }
#
# $node addr $address
# $node set ragent_ $ragent
#
# set dmux [$node set dmux_]
# if {$dmux == "" } {
# set dmux [new Classifier/Hash/Dest 32]
# $dmux set mask_ [AddrParams PortMask]
# $dmux set shift_ [AddrParams PortShift]
# #
# # point the node's routing entry to itself
# # at the port demuxer (if there is one)
# #
# $node add-route $address $ragent
# $node set dmux_ $dmux
# }
# set level [AddrParams hlevel]
#
# if { [Simulator set RouterTrace_] == "ON" } {
# #
# Recv Target
#
# set rcvT [cmu-trace Recv "RTR" $node]
# $rcvT target $ragent
# for {set i 1} {$i <= $level} {incr i} {
# [$node set classifiers_($i)] defaulttarget $rcvT
# [$node set classifiers_($i)] bcast-receiver $rcvT
# }
# } else {
#
# for {set i 1} {$i <= $level} {incr i} {
# [$node set classifiers_($i)] defaulttarget $ragent
# [$node set classifiers_($i)] bcast-receiver $ragent
# }
# }
#
# Drop Target (always on regardless of other tracing)
#
# set drpT [cmu-trace Drop "RTR" $node]
# $ragent drop-target $drpT
#
#
# Log Target
#
#set T [new Trace/Generic]
#$T target [$ns_ set nullAgent_]
#$T attach $tracefd
#$T set src_ [$node id]
#$ragent log-target $T
# $ragent target $dmux
# packets to the DSR port should be handed over to ragent_
# since all pkts now donot go thru ragent
# $dmux install $opt(rt_port) $ragent
}
Node/MobileNode/BaseStationNode instproc create-xtra-interface { } {
global ns_ opt
$self instvar ragent_ ll_ mac_ ifq_
$ragent_ mac-addr [$mac_(0) id]
if { [Simulator set RouterTrace_] == "ON" } {
# Send Target
set sndT [cmu-trace Send "RTR" $self]
$sndT target $ll_(0)
$ragent_ add-ll $sndT $ifq_(0)
} else {
# Send Target
$ragent_ add-ll $ll_(0) $ifq_(0)
}
# setup promiscuous tap into mac layer
$ragent_ install-tap $mac_(0)
}
Node/MobileNode/BaseStationNode instproc start-dsr {} {
$self instvar ragent_
global opt;
$ragent_ startdsr
if {$opt(cc) == "on"} {checkcache $dsr_agent_}
}
Node/MobileNode/BaseStationNode instproc reset args {
$self instvar ragent_
eval $self next $args
$ragent_ reset
}
#Class God
#God instproc init {args} {
# eval $self next $args
#}
proc create-god { nodes } {
#global ns_ god_ tracefd
set god [God info instances]
if { $god == "" } {
set god [new God]
}
$god num_nodes $nodes
return $god
}
God proc instance {} {
set god [God info instances]
if { $god != "" } {
return $god
}
error "Cannot find instance of god"
}
proc cmu-trace { ttype atype node } {
global ns_ tracefd
if { $tracefd == "" } {
return ""
}
set T [new CMUTrace/$ttype $atype]
$T target [$ns_ set nullAgent_]
$T attach $tracefd
$T set src_ [$node id]
$T node $node
return $T
}
proc log-movement {} {
global logtimer ns_ ns
set ns $ns_
source ../mobility/timer.tcl
Class LogTimer -superclass Timer
LogTimer instproc timeout {} {
global opt node_;
for {set i 0} {$i < $opt(nn)} {incr i} {
$node_($i) log-movement
}
$self sched 0.1
}
set logtimer [new LogTimer]
$logtimer sched 0.1
}
proc set-wireless-traces { args } {
set len [llength $args]
if { $len <= 0 || [expr $len%2] } {
error "Incorrect number of parameters"
}
for {set n 0} {$n < $len} {incr n 2} {
if {[string compare [lindex $args $n] "-AgentTrace"] == 0 } {
Simulator set AgentTrace_ [lindex $args [expr $n+1]]
} elseif {[string compare [lindex $args $n] "-RouterTrace"] == 0 } {
Simulator set RouterTrace_ [lindex $args [expr $n+1]]
} elseif {[string compare [lindex $args $n] "-MacTrace"] == 0 } {
Simulator set MacTrace_ [lindex $args [expr $n+1]]
} else {
error "Unknown wireless trace type: [lindex $args $n]"
}
}
}
|