#=== Input parameters =====================================
set val(nd) 5; #distance between nodes
set val(retx) 1; #retransmission attempt for repeater
set val(filename) try1; #for different output file name
set val(cwmin) 0; #Contention Window (mininum)
set val(cwmax) 8; #Contention Window (maximum)
set val(num) 250; #number of nodes
set val(random) 1; #random number for seed
set nodedist $val(nd);
set retransmission $val(retx);
set fn $val(filename);
set cwmin $val(cwmin);
set cwmax $val(cwmax);
set random $val(random);
$defaultRNG seed $random;#deterministic into Random
#=== Configure RF model parameters ========================
Antenna/OmniAntenna set Gt_ 1.0
Antenna/OmniAntenna set Gr_ 1.0
#=== Node configuration options ===========================
set val(chan) Channel/WirelessChannel;# channel type
set val(prop) Propagation/TwoRayGround;# radio-propagation model
set val(netif) Phy/WirelessPhyExt;# network interface type
set val(mac) Mac/802_11Ext;# MAC type
set val(ifq) Queue/DropTail/PriQueue;# interface queue type
set val(ll) LL;# link layer type
set val(ant) Antenna/OmniAntenna;# antenna model
set val(ifqlen) 20;# max packet in ifq
set val(nn) 250;#$val(num);# number of mobilenodes
set val(x) 2000;# X dimension of topography
set val(y) 200;# Y dimension of topography
set val(stop) 100;# time of simulation end
set val(rtg) DumbAgent;# routing protocol
#=== Create a ns simulator ================================
set ns_ [new Simulator]
#=== Setup topography object ==============================
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
set god_ [create-god $val(nn)]
$god_ off
#=== Open the NS trace file ===============================
set tracefile [open out_$
fn.tr w]
$ns_ use-newtrace
$ns_ trace-all $tracefile
#=== Open the NAM trace file ==============================
set namfile [open out_$fn.nam w]
$ns_ namtrace-all-wireless $namfile $val(x) $val(y)
#=== Configure the Nodes ==================================
set chan [new $val(chan)]
$ns_ node-config -adhocRouting $val(rtg)\
-llType $val(ll)\
-macType $val(mac)\
-ifqType $val(ifq)\
-ifqLen $val(ifqlen)\
-antType $val(ant)\
-propType $val(prop)\
-phyType $val(netif)\
-channel $chan\
-topoInstance $topo\
-agentTrace ON\
-routerTrace OFF\
-macTrace OFF\
-phyTrace OFF
set node_(0) [$ns_ node]
#=== Creating node objects ================================
for {set i 0} {$i<$val(nn)} {incr i} {
set ID_($i) $i
set node_($i) [$ns_ node]
$node_($i) set id_ $ID_($i)
$node_($i) set address_ $ID_($i)
$node_($i) set X_ [expr $i * $nodedist]
$node_($i) set Y_ 50
$node_($i) set Z_ 0.0
$node_($i) random-motion 0;# disable random motion
}
#=== PBC Agents Definition ================================
for {set i 0} {$i<1} {incr i} {
set agent_($i) [new Agent/PBC]
$ns_ attach-agent $node_($i) $agent_($i)
$agent_($i) set payloadSize 500
$agent_($i) set periodicBroadcastInterval 0.01
$agent_($i) set periodicBroadcastVariance 0.01
$agent_($i) set modulationScheme 1
$agent_($i) singleBroadcast
#packetType (0 = safety, 1 = service)
#Safety Type packet, set the channel number to -99
$agent_($i) set channel_ -99
$agent_($i) set type_dsrc_ 0
}
for {set i 1} {$i<$val(nn)} {incr i} {
set agent_($i) [new Agent/PBC]
$ns_ attach-agent $node_($i) $agent_($i)
$agent_($i) set payloadSize 500
$agent_($i) set periodicBroadcastInterval 0.5
$agent_($i) set periodicBroadcastVariance 0.05
#$agent_($i) set modulationScheme 1
$agent_($i) Repeater ON $retransmission
#packetType (0 = safety, 1 = service)
#Safety Type packet, set the channel number to -99
$agent_($i) set channel_ -99
$agent_($i) set type_dsrc_ 0
}
#=== Define node initial position in nam ==================
for {set i 0} {$i<$val(nn)} {incr i} {
$ns_ initial_node_pos $node_($i) 0
}
#=== Define a 'finish' procedure ==========================
proc finish {} {
global ns_ tracefile namfile
$ns_ flush-trace
close $tracefile
close $namfile
#exec nam scenario1.nam &
}
#=== Tell node to stop ====================================
for {set i 0} {$i < $val(nn) } { incr i } {
$ns_ at $val(stop).0 "$node_($i) reset";
}
$ns_ at $val(stop) "$ns_ nam-end-wireless $val(stop)"
$ns_ at $val(stop) "finish"
$ns_ at $val(stop).0002 "puts \"End Simulation\" ; $ns_ halt"
puts "Starting Simulation..."
$ns_ run
--------------------------------------------- it shows me this errors : ---------------------------------