Tmac
Tmac
set opt(dz) 10
set opt(ifqlen) 50 ;# max packet in ifq
set opt(nn) 10 ;# number of nodes in each layer
set opt(layers) 1
set opt(x) 100 ;# X dimension of the topography
set opt(y) 100 ;# Y dimension of the topography
set opt(z) 0
set opt(seed) 55
set opt(stop) 100 ;# simulation time
set opt(prestop) 60 ;# time to prepare to stop
set opt(tr) "out.tr" ;# trace file
set opt(nam) "out.nam" ;# nam file
set opt(rp) DumbAgent ;# routing protocol
set opt(width) 20
set opt(adj) 10
set opt(interval) 0.001
# ==================================================================
# ==================================================================
# Main Program
# =================================================================
#
# Initialize Global Variables
#
#set sink_ 1
set ns_ [new Simulator]
set topo [new Topography]
#===================================
# Nodes Definition
#===================================
#Create 5 nodes
for {set i 0} {$i < $opt(nn) } {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0 ;# disable random motion
$ns_ initial_node_pos $node_($i) 20 ;#size of the node
}
#===================================
# Agents Definition
#===================================
#Setup a UDP connection
set udp0 [new Agent/UDP]
$ns_ attach-agent $node_(0) $udp0
set null1 [new Agent/Null]
$ns_ attach-agent $node_(9) $null1
$ns_ connect $udp0 $null1
$udp0 set packetSize_ 512
#===================================
# Applications Definition
#===================================
#Setup a CBR Application over UDP connection
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0
$cbr0 set packetSize_ 512
$cbr0 set rate_ 1.0Mb
$cbr0 set random_ null
$ns_ at 1.0 "$cbr0 start"
$ns_ at 2.0 "$cbr0 stop"
#===================================
# Termination
#===================================
#Define a 'finish' procedure
proc finish {} {
global ns tracefile namfile
$ns_ flush-trace
close $tracefile
close $namfile
exec nam out.nam &
exit 0
}
for {set i 0} {$i < $val(nn) } { incr i } {
$ns_ at $val(stop) "\$node_($i) reset"
}
$ns_ at $val(stop) "$ns_ nam-end-wireless $val(stop)"
$ns_ at $val(stop) "finish"
$ns_ at $val(stop) "puts \"done\" ; $ns_ halt"
$ns_ run