Search code examples
tclns2wifi

dsrc vanet ns2 tcl scipt not working


i ve been working for weeks to run this tcl script (NOT written by me )for dsrc but i never succeeded. please i need ur help. the error is:

invalid command name "10"
    while executing
"$val(payload)"
    invoked from within
"set payload [$val(payload)]"
    (file "singleBroadcast.tcl" line 7)

so in order not to make the thgs very complicated, i will parse here a part of the code which i think there s a mistake:

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 $val(payload)
set modulationIndex $val(modIndex)  

#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 yi          [expr $pi*4]
set yi2         [expr $yi*[$val(comRange)]]
set M          [expr $lambda/$yi2];
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)"

please correct me, i think there s 5 args, so to run it, i must type i.e : ns test.tcl 10 12 4 10 2

the problem is in the comRange.

1- am i thinking in the correct way, is it correct how i m running it?

2- can u help me correct it ?

Thank you so much your help is much appreciate it


Solution

  • Not sure why your error looks like this but there is a mistake on line 14. You need to change:

    set yi2 [expr $yi*[$val(comRange)]]
    

    to something like:

    set yi2 [expr { $yi*$val(comRange) }]
    

    Unless $val(comRange) is supposed to be a valid Tcl command provided in argv.