egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

802.11p sample script not working

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
andrewhajj
Voice


Joined: 09 Jun 2013
Posts: 3

PostPosted: Sun Jun 09, 2013 4:32 pm    Post subject: 802.11p sample script not working Reply with quote

Hello, I have been working the whole day to test the following script for 802.11p on ns2 but it failed. do u think it s related to ns2 since many test failed or an error in the tcl script.

here is the script and error i got
please i need ur help
Code:

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

error:
Quote:

syntax error in expression "- ": premature end of expression
while executing
"expr - $val(payload)"
invoked from within
"set payload [expr - $val(payload)]"
(file "singleBroadcast.tcl" line 7)
Back to top
View user's profile Send private message
heartbroken
Op


Joined: 23 Jun 2011
Posts: 106
Location: somewhere out there

PostPosted: Sun Jun 09, 2013 4:48 pm    Post subject: Reply with quote

this is looks like "pure tcl" not for an eggdrop ... eggdrop tcl lil bit different than pure tcl.... probably this one Cisco IOS tcl scripting or something like that.
_________________
Life iS Just a dReaM oN tHE wAy to DeaTh


Last edited by heartbroken on Sun Jun 09, 2013 4:54 pm; edited 1 time in total
Back to top
View user's profile Send private message
andrewhajj
Voice


Joined: 09 Jun 2013
Posts: 3

PostPosted: Sun Jun 09, 2013 4:52 pm    Post subject: Reply with quote

yes it is not an eggdrop :S
cant u help ?
Back to top
View user's profile Send private message
heartbroken
Op


Joined: 23 Jun 2011
Posts: 106
Location: somewhere out there

PostPosted: Sun Jun 09, 2013 4:56 pm    Post subject: Reply with quote

well you can find some help for about this kinda code @ Freenode's #tcl channel ...this is not a place for that sorry...
_________________
Life iS Just a dReaM oN tHE wAy to DeaTh
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sun Jun 09, 2013 5:07 pm    Post subject: Reply with quote

Code:
set payload [expr - $val(payload)]
set modulationIndex [expr $val(modIndex)]


Did you mean?
Code:
set payload $val(payload)
set modulationIndex $val(modIndex)


Because the - that starts that first [expr] is your problem. You can't subtract from thin-air.
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
andrewhajj
Voice


Joined: 09 Jun 2013
Posts: 3

PostPosted: Sun Jun 09, 2013 5:09 pm    Post subject: Reply with quote

thank u Smile
sorry if i posted in the wrong place

dear speechles

i did as u advised, now i m getting:
syntax error in expression "4 * 3.1415926535897931 * ": premature end of expression
while executing
"expr 4 * $PI * $val(comRange)"
invoked from within
"expr $lambda / [expr 4 * $PI * $val(comRange)]"
invoked from within
"set M [expr $lambda / [expr 4 * $PI * $val(comRange)]]"
(file "singleBroadcast2.tcl" line 19)
Back to top
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Sun Jun 09, 2013 8:04 pm    Post subject: Reply with quote

Well its obvious $val(comRange) is getting a null result so you have to have a number there (if im not mistaken)
_________________
https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber