Try now, it will work
# Some constants
set area_width 100
set area_height 100
set stop_time 20
# MAC stuff
Mac/802_11 set dataRate_ 2.0e6
Mac/802_11 set RTSThreshold_ 3000
# Define the simulator
set simulator [new Simulator]
set trace_file [open out.tr w]
$simulator trace-all $trace_file
#Open the NAM trace file
set nam_file [open out.nam w]
$simulator namtrace-all-wireless $nam_file $area_width $area_height
#Adjusting the topography
set topography [new Topography]
$topography load_flatgrid $area_width $area_height
# General Operations Director
create-god 2
# Some configuration just as same as the expamle 'ex6sta.tcl'
$simulator node-config -adhocRouting DumbAgent \
-llType LL \
-macType Mac/802_11 \
-ifqType Queue/DropTail/PriQueue \
-ifqLen 50 \
-antType Antenna/OmniAntenna \
-propType Propagation/FreeSpace \
-phyType Phy/WirelessPhy \
-channelType Channel/WirelessChannel \
-topoInstance $topography \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace ON
set host(1) [ $simulator node ]
set host(2) [ $simulator node ]
$host(1) set X_ 20
$host(1) set Y_ 20
$host(1) set Z_ 0.0
$host(2) set X_ 70
$host(2) set Y_ 70
$host(2) set Z_ 0.0
$simulator initial_node_pos $host(1) 30
$simulator initial_node_pos $host(2) 30
# Connection 1 UDP
set udp [new Agent/UDP]
$simulator attach-agent $host(1) $udp
set sink [new Agent/Null]
$simulator attach-agent $host(2) $sink
$simulator connect $udp $sink
set cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 1000
$cbr set interval_ 0.005
$cbr attach-agent $udp
$simulator at 5.0 "$cbr start"
# invoking finish procedure
$simulator at $stop_time "finish"
proc finish {} {
global simulator host cbr nam_file trace_file
$host(1) reset
$host(2) reset
$cbr stop
$simulator flush-trace
close $nam_file
close $trace_file
$simulator halt
puts "Finished"
}
puts "Starting Simulation..."
$simulator run