LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 03-08-2014, 12:19 PM   #1
mudas
LQ Newbie
 
Registered: Mar 2014
Location: Chennai, India
Posts: 4

Rep: Reputation: Disabled
Hello there. What is "segmentation Faullt" and how to rectify it ?


Hi. I am new to NS2 and I ahve been trying this tcl script from a long time but can't get the NAM. Shows error in Ns2.34 and Ns2.35. Please help me with the following two scripts and the commands/procedure to run them. And also please tell me how to call/load files to the current file.

SINGLE BROADCAST

set val(modIndex) [lindex $argv 0]
set val(ncars) [lindex $argv 1]
set val(payload) [lindex $argv 2]
set val(comRange) [lindex $argv 3] ;#"intended" Communication Range
set val(vseed) [lindex $argv 4]

set payload [expr - $val(payload)]
set modulationIndex [expr $val(modIndex)]
# In 802.11p
#modIndex = 0 (BPSK and 1/2 coding rate): 3Mbps
#modIndex = 1 (QPSK and 1/2 coding rate): 6Mbps
#modIndex = 2 (QAM16 and 1/2 coding rate): 12Mbps
#modIndex = 3 (QAM 64 and 2/3 coding rate): 24Mbps
#=====================================================================
#Calculate the needed Transmission power corresponding to the intended Communication Range
set lambda [expr 3e+8/5.9e+9] ;# lambda = c / f
set PI 3.1415926535897931
set M [expr $lambda / [expr 4 * $PI * $val(comRange)]];
set Pr2Pt [expr [expr 5.118 * 5.118 * $M * $M ] / 1];
set Pt [expr 3.162e-12 / $Pr2Pt]
set PtmW [expr $Pt * 1000]
puts "mod Index is $val(modIndex)"
puts "# of cars is $val(ncars)"
puts "TCL Payload Size is: $val(payload) bytes"
puts "comRange is: $val(comRange) meters"
puts "Used Transmission Power is: $PtmW mW"
# =====================================================================

set val(chan) Channel/WirelessChannel
set val(prop) Propagation/Nakagami

set val(netif) Phy/WirelessPhyExt
set val(mac) Mac/802_11Ext
set val(ifq) Queue/DSRC ;#DropTail/PriQueue
set val(ll) LL
set val(ant) Antenna/OmniAntenna
set val(x) 1100 ;# X dimension of the topography
set val(y) 20 ;# Y dimension of the topography
set val(ifqlen) 20 ;# max packet in ifq
set val(nn) $val(ncars) ;# how many nodes are simulated
set val(rtg) DumbAgent
set val(stop) 5 ;# simulation time in seconds


# 802.11p Paramters
#**************************************************
set val(sc) 802.11p.tcl
source $val(sc) ;# load 802.11p configuration file

# =====================================================================
# Main Program
# ======================================================================

#
# Initialize Global Variables
#

global defaultRNG
$defaultRNG seed $val(vseed)

set ns_ [new Simulator]
set topo [new Topography]
set tracefd [open tracefile.txt w]
$ns_ trace-all $tracefd
#$ns_ use-newtrace

$topo load_flatgrid $val(x) $val(y)
set god_ [create-god $val(nn)]
$god_ off

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 ON \
-phyTrace ON

set lane 4 ;#number of lanes in the scenario

#set channel_ [new RandomVariable/Normal]
#$channel_ set max_ 6
#$channel_ set min_ 0

for {set counter 0} {$counter < $lane} {incr counter} {
for {set i 0} {$i < [expr $val(ncars) / $lane] } {incr i} {
set index [expr $i + [expr $counter * [expr $val(ncars) / $lane]]]
set ID_($index) $index
set vehicle_($index) [$ns_ node]
$vehicle_($index) set id_ $ID_($index)
$vehicle_($index) set address_ $ID_($index)
$vehicle_($index) set X_ [expr $i * 10]
$vehicle_($index) set Y_ [expr $counter * 5 ]
$vehicle_($index) set Z_ 0
$vehicle_($index) nodeid $ID_($index)

set agent_($index) [new Agent/DSRCApp]
$ns_ attach-agent $vehicle_($index) $agent_($index)
$agent_($index) set modulationScheme_ $val(modIndex)
$agent_($index) set interval_ 0.1
$agent_($index) set packetSize_ $val(payload)

$ns_ at $val(stop).0 "$vehicle_($index) reset";
#puts "$index [expr $i * 5] [expr $counter * 5 ]";
}
}

#set repetition 1; #How many time each packet is repeated

#for {set i 0} {$i < $repetition} {incr i} {
# for {set j 0} {$j < [expr $val(ncars)] } {incr j} {
# set rand [expr rand() * 0.05]
#$ns_ at $rand "$agent_($j) send"
#$ns_ at 0.02 "$agent_($j) send"
# }
#}

# When sending a packet, you need to specify the packetType (0 = safety, 1 = service)
# If it is a Service Type packet, you need to specify the channel number (0 to 5)
# If it is a Safety Type packet, you have to set the channel number to -99.


for {set i 0} {$i < $val(ncars)} {incr i} {
set txtime_ [new RandomVariable/Uniform]
$txtime_ set max_ 0.1
$txtime_ set min_ 0

$agent_($i) set channel_ -99
$agent_($i) set type_dsrc_ 0
$ns_ at [$txtime_ value] "$agent_($i) send"
}

$ns_ at $val(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt"
$ns_ at $val(stop).0003 "$ns_ flush-trace"
puts "Starting Simulation..."
$ns_ run


BROADCASTING

set val(seed) [lindex $argv 0]

Mac/802_11 set CWMin_ 15
Mac/802_11 set CWMax_ 1023
Mac/802_11 set SlotTime_ 0.000009
Mac/802_11 set SIFS_ 0.000016
Mac/802_11 set ShortRetryLimit_ 7
Mac/802_11 set LongRetryLimit_ 4
Mac/802_11 set PreambleLength_ 60
Mac/802_11 set PLCPHeaderLength_ 60
Mac/802_11 set PLCPDataRate_ 6.0e6
Mac/802_11 set RTSThreshold_ 2000
Mac/802_11 set basicRate_ 6.0e6
Mac/802_11 set dataRate_ 6.0e6

Mac/802_11Ext set CWMin_ 15
Mac/802_11Ext set CWMax_ 1023
Mac/802_11Ext set SlotTime_ 0.000009
Mac/802_11Ext set SIFS_ 0.000016
Mac/802_11Ext set ShortRetryLimit_ 7
Mac/802_11Ext set LongRetryLimit_ 4
Mac/802_11Ext set HeaderDuration_ 0.000020
Mac/802_11Ext set SymbolDuration_ 0.000004
Mac/802_11Ext set BasicModulationScheme_ 0
Mac/802_11Ext set use_802_11a_flag_ true
Mac/802_11Ext set RTSThreshold_ 2000
Mac/802_11Ext set MAC_DBG 0

Phy/WirelessPhy set CSThresh_ 6.30957e-12
Phy/WirelessPhy set Pt_ 0.001
Phy/WirelessPhy set freq_ 5.18e9
Phy/WirelessPhy set L_ 1.0
Phy/WirelessPhy set RXThresh_ 3.652e-10
Phy/WirelessPhy set bandwidth_ 20e6
Phy/WirelessPhy set CPThresh_ 10.0

Phy/WirelessPhyExt set CSThresh_ 6.30957e-12
Phy/WirelessPhyExt set Pt_ 0.001
Phy/WirelessPhyExt set freq_ 5.18e9
Phy/WirelessPhyExt set noise_floor_ 2.51189e-13
Phy/WirelessPhyExt set L_ 1.0
Phy/WirelessPhyExt set PowerMonitorThresh_ 2.10319e-12
Phy/WirelessPhyExt set HeaderDuration_ 0.000020
Phy/WirelessPhyExt set BasicModulationScheme_ 0
Phy/WirelessPhyExt set PreambleCaptureSwitch_ 1
Phy/WirelessPhyExt set DataCaptureSwitch_ 0
Phy/WirelessPhyExt set SINR_PreambleCapture_ 2.5118
Phy/WirelessPhyExt set SINR_DataCapture_ 100.0
Phy/WirelessPhyExt set trace_dist_ 1e6
Phy/WirelessPhyExt set PHY_DBG_ 0
Phy/WirelessPhyExt set CPThresh_ 0 ;# not used at the moment
Phy/WirelessPhyExt set RXThresh_ 0 ;# not used at the moment


#=====================================================================

#configure RF model parameters
Antenna/OmniAntenna set Gt_ 1.0
Antenna/OmniAntenna set Gr_ 1.0

Propagation/Nakagami set use_nakagami_dist_ false
Propagation/Nakagami set gamma0_ 2.0
Propagation/Nakagami set gamma1_ 2.0
Propagation/Nakagami set gamma2_ 2.0

Propagation/Nakagami set d0_gamma_ 200
Propagation/Nakagami set d1_gamma_ 500

Propagation/Nakagami set m0_ 1.0
Propagation/Nakagami set m1_ 1.0
Propagation/Nakagami set m2_ 1.0

Propagation/Nakagami set d0_m_ 80
Propagation/Nakagami set d1_m_ 200

#=======================================================================


set val(chan) Channel/WirelessChannel
set val(prop) Propagation/TwoRayGround

set val(netif) Phy/WirelessPhyExt
set val(mac) Mac/802_11Ext
set val(ifq) Queue/DropTail/PriQueue
set val(ll) LL
set val(ant) Antenna/OmniAntenna
set val(x) 1100 ;# X dimension of the topography
set val(y) 20 ;# Y dimension of the topography
set val(ifqlen) 20 ;# max packet in ifq
set val(nn) 200 ;# how many nodes are simulated
set val(rtg) DumbAgent
set val(stop) 5 ;# simulation time
# =====================================================================
# Main Program
# ======================================================================

#
# Initialize Global Variables
#

global defaultRNG
$defaultRNG seed $val(seed)

set ns_ [new Simulator]
set topo [new Topography]
set namtrace [open wireless.nam w]
set tracefd stdout
$ns_ trace-all $tracefd
#$ns_ use-newtrace

$topo load_flatgrid $val(x) $val(y)
set god_ [create-god $val(nn)]
$god_ off

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

for {set i 0} {$i < 200 } {incr i} {
set ID_($i) $i
set vehicle_($i) [$ns_ node]
$vehicle_($i) set id_ $ID_($i)
$vehicle_($i) set address_ $ID_($i)
$vehicle_($i) set X_ [expr $i * 5]
$vehicle_($i) set Y_ 10
$vehicle_($i) set Z_ 0
$vehicle_($i) nodeid $ID_($i)

set agent_($i) [new Agent/PBC]
$ns_ attach-agent $vehicle_($i) $agent_($i)
$agent_($i) set Pt_ 1e-4
$agent_($i) set payloadSize 1000
$agent_($i) set peroidcaBroadcastInterval 0.2
$agent_($i) set peroidcaBroadcastVariance 0.05
$agent_($i) set modulationScheme 1
$agent_($i) PeriodicBroadcast ON
$ns_ at $val(stop).0 "$vehicle_($i) reset";

}


$ns_ at $val(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt"
$ns_ at $val(stop).0003 "$ns_ flush-trace"
puts "Starting Simulation..."
proc stop {} {
global ns_ tracefd namtrace
$ns_ flush-trace
close $tracefd
close $namtrace
exec nam wireless.nam &
exit 0
}
$ns_ run
 
Old 03-09-2014, 04:34 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate of http://www.linuxquestions.org/questi...it-4175497506/
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"netstat -l" gives "segmentation fault" Earwig Linux - Newbie 2 03-31-2010 05:12 PM
sunbird 0.3 does not start, error: Segmentation fault : "$prog" ${1+"$@"} polemon Ubuntu 8 01-08-2007 05:22 AM
Segmentation Faults with "ls" and "mount" Mark007 Slackware 11 03-02-2005 10:45 AM
why iam getting problems like "...too many files opened" or "segmentation fault" naren_0101bits Linux - Newbie 2 07-19-2004 01:20 PM
"segmentation error" when issuing "useradd" command through terminal with RH 9.0 kaihuang Linux - General 0 10-22-2003 12:47 AM


All times are GMT -5. The time now is 05:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration