#=== Input parameters =====================================
set val(nd) [lindex $argv 0]; #distance between nodes
set val(retx) [lindex $argv 1]; #retransmission attempt for repeater
set val(filename) [lindex $argv 2]; #for different output file name
set val(cwmin) [lindex $argv 3]; #Contention Window (mininum)
set val(cwmax) [lindex $argv 4]; #Contention Window (maximum)
set val(num) [lindex $argv 5]; #number of nodes
set val(random) [lindex $argv 6]; #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
#=== 802.11p default parameters ===========================
#~/ns-allinone-2.35/ns-2.35/tcl/ex/802.11/IEEE802-11p.tcl
Phy/WirelessPhyExt set CSThresh_ 3.162e-12 ;#-85 dBm Wireless interface sensitivity (sensitivity defined in the standard)
Phy/WirelessPhyExt set Pt_ 0.0003108 ;#0.00000051 for distCST_ 80.0 mts range
Phy/WirelessPhyExt set freq_ 5.9e+9
Phy/WirelessPhyExt set noise_floor_ 1.26e-13 ;#-99 dBm for 10MHz band-width
Phy/WirelessPhyExt set L_ 1.0 ;#default radio circuit gain/loss
Phy/WirelessPhyExt set PowerMonitorThresh_ 6.310e-14 ;#-102dBm power moni-tor sensitivity
Phy/WirelessPhyExt set HeaderDuration_ 0.000040 ;#40 us
Phy/WirelessPhyExt set BasicModulationScheme_ 0
Phy/WirelessPhyExt set PreambleCaptureSwitch_ 1
Phy/WirelessPhyExt set DataCaptureSwitch_ 0
Phy/WirelessPhyExt set SINR_PreambleCapture_ 2.5118; ;# 4 dB
Phy/WirelessPhyExt set SINR_DataCapture_ 100.0; ;# 10 dB
Phy/WirelessPhyExt set trace_dist_ 1e6 ;# PHY trace until distance of 1 Mio. km ("infinty")
Phy/WirelessPhyExt set PHY_DBG_ 0
Mac/802_11Ext set CWMin_ $cwmin
Mac/802_11Ext set CWMax_ $cwmax
Mac/802_11Ext set SlotTime_ 0.000013
Mac/802_11Ext set SIFS_ 0.000032
Mac/802_11Ext set ShortRetryLimit_ 7
Mac/802_11Ext set LongRetryLimit_ 4
Mac/802_11Ext set HeaderDuration_ 0.000040
Mac/802_11Ext set SymbolDuration_ 0.000008
Mac/802_11Ext set BasicModulationScheme_ 0
Mac/802_11Ext set use_802_11a_flag_ true
Mac/802_11Ext set RTSThreshold_ 2346
Mac/802_11Ext set MAC_DBG 0
#=== 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) $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..."
--
You received this message because you are subscribed to the Google Groups "Network Simulator 2 (NS2)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-users+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-users/cfed40b5-8406-4489-b473-ccee7937d0b5n%40googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/ns-users/529cc641-f6f6-4820-829d-8bdbdd00002fn%40googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/ns-users/5622f75b-2961-47bd-82ec-fba9e3b04508n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-users/1af4a7fd-5310-48b2-b073-3c1324da42bdn%40googlegroups.com.