LinuxQuestions.org
Review your favorite Linux distribution.
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


Reply
  Search this Thread
Old 04-10-2017, 07:44 AM   #1
desuwa
LQ Newbie
 
Registered: Jan 2017
Posts: 2

Rep: Reputation: Disabled
ns235 myevalvid wireless simulation error


Hello everyone,

I am trying to run wireless video transmission analysis using myevalvid on ns2.35 using the Fedora virtual machine made by Smallko for my thesis.

The ns2.35 along with the myevalvid agent is preinstalled on the virtual machine. The scripts for the simulation is also there, so I suppose I should be able to run it without any edit.

I ran the wired simulation (file name wired.tcl) without modifications again and again, it always ran fine and gives the right result.

But when I tried to run the wireless simulation, it always result in this error:

Code:
[ns235@localhost myevalvid]$ ns wireless.tcl

can't read "opt(0)": no such element in array

    while executing

"set loss_model  $opt(0)"

    (file "wireless.tcl" line 12)

This is the script:

Code:
proc getopt {argc argv} {
	global opt
        lappend optlist nn
        for {set i 0} {$i < $argc} {incr i} {
		set opt($i) [lindex $argv $i]
	}
}

getopt $argc $argv

#loss_model: 0 for uniform distribution, 1 for GE model
set loss_model  $opt(0)
set pGG $opt(1)
set pBB $opt(2)
set pG $opt(3)
set pB $opt(4)


#===================================
#     Simulation parameters setup
#===================================
set val(chan)   Channel/WirelessChannel    ;# channel type
set val(prop)   Propagation/TwoRayGround   ;# radio-propagation model
set val(netif)  Phy/WirelessPhy            ;# network interface type
set val(mac)    Mac/802_11                ;# 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) 50                         ;# max packet in ifq
set val(nn)     2                          ;# number of mobilenodes
set val(rp)     AODV                       ;# routing protocol
set val(x)      500                        ;# X dimension of topography
set val(y)      500                        ;# Y dimension of topography
set val(stop)   50.0                       ;# time of simulation end
Mac/802_11 set dataRate_  2Mb
Mac/802_11 set basicRate_ 1Mb 

#===================================
#        Initialization        
#===================================
#Create a ns simulator
set ns [new Simulator]

#Setup topography object
set topo       [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)

#Open the NS trace file
set tracefile [open out.tr w]
$ns trace-all $tracefile

set chan [new $val(chan)];#Create wireless channel

#===================================
#     Mobile node parameter setup
#===================================
$ns node-config -adhocRouting  $val(rp) \
                -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 \
                -movementTrace OFF

#===================================
#        Nodes Definition        
#===================================
#Create 3 nodes
set n0 [$ns node]
$n0 set X_ 200
$n0 set Y_ 400
$n0 set Z_ 0.0
$ns initial_node_pos $n0 20
set n1 [$ns node]
$n1 set X_ 300
$n1 set Y_ 400
$n1 set Z_ 0.0
$ns initial_node_pos $n1 20


set n0if_ [$n0 set netif_(0)]
$n0if_ set-error-level $pGG $pBB $pG $pB $loss_model

set n1if_ [$n1 set netif_(0)]
$n1if_ set-error-level $pGG $pBB $pG $pB $loss_model

#===================================================
set max_fragmented_size 1024
#8 bytes:UDP header, 12 bytes: RTP header
set packetSize [expr $max_fragmented_size+20]  

set src_udp1 [new Agent/my_UDP]
$src_udp1 set packetSize_ $packetSize
$src_udp1 set_filename wireless_sd
set dst_udp1 [new Agent/myEvalvid_Sink]
$ns attach-agent $n0 $src_udp1
$ns attach-agent $n1 $dst_udp1
$ns connect $src_udp1 $dst_udp1
$dst_udp1 set_filename wireless_rd


set original_file_name foreman_qcif.st
set trace_file_name video1.dat
set original_file_id [open $original_file_name r]
set trace_file_id [open $trace_file_name w]

set pre_time 0

while {[eof $original_file_id] == 0} {
    gets $original_file_id current_line
    scan $current_line "%d%s%d%d%f" no_ frametype_ length_ tmp1_ tmp2_
    set time [expr int(($tmp2_ - $pre_time)*1000000.0)]

    if { $frametype_ == "I" } {
        set type_v 1
        set prio_p 0
    }  

    if { $frametype_ == "P" } {
        set type_v 2
        set prio_p 0
    }  

    if { $frametype_ == "B" } {
        set type_v 3
        set prio_p 0
    }  

    if { $frametype_ == "H" } {
        set type_v 1
        set prio_p 0
    }

    puts  $trace_file_id "$time $length_ $type_v $prio_p $max_fragmented_size"
    set pre_time $tmp2_
}

close $original_file_id
close $trace_file_id
set end_sim_time $tmp2_
puts "$end_sim_time"

set trace_file [new Tracefile]
$trace_file filename $trace_file_name
set video1 [new Application/Traffic/myEvalvid]
$video1 attach-agent $src_udp1
$video1 attach-tracefile $trace_file

$ns at 0.5  "$video1 start"
$ns at 30.0 "$video1 stop"

#===================================
#        Termination        
#===================================
#Define a 'finish' procedure
proc finish {} {
    global ns tracefile namfile src_udp1 dst_udp1
    $ns flush-trace
    close $tracefile
    $src_udp1 closefile
    $dst_udp1 closefile
    puts "simulation completed"
    exit 0
}
for {set i 0} {$i < $val(nn) } { incr i } {
    $ns at $val(stop) "\$n$i reset"
}
$ns at $val(stop) "finish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run
I have looked everywhere and the suggested solution for similar problem is to reduce the number of nodes by 1. I have tried it and it doesn't solve the error.

Please help me with solving this. I'm a newbie to both coding and NS but I am willing to learn.

Thank you.
 
Old 04-15-2017, 04:08 PM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2019 CentOS6.10 CentOS7.7 + 50+ other Linux OS, for test only.
Posts: 17,267

Rep: Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568
I have tried comparing your "wireless.tcl" with other wireless scripts.
( Please use a new name for your file, already plenty of wireless.tcl ).

And I edited your file .... No luck.

But please have a look into the existing "wireless-***.tcl" →
all_tcl-examples-2.tar.gz : ~2000 files.tcl
Link https://drive.google.com/file/d/0B7S...ew?usp=sharing

cd 000-All-examples/ && ls | grep wireless
... there are 93 "wireless" examples.

-
 
Old 04-16-2017, 09:34 AM   #3
desuwa
LQ Newbie
 
Registered: Jan 2017
Posts: 2

Original Poster
Rep: Reputation: Disabled
Dear knudfl,

Thank you for your reply. I will look at the examples you gave me.

In the meantime, is there any other info I should provide you which might help you find what is wrong with the script?


Thank you.
 
Old 04-16-2017, 10:46 AM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2019 CentOS6.10 CentOS7.7 + 50+ other Linux OS, for test only.
Posts: 17,267

Rep: Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568
Re #3.

No. I hope you can edit the script yourself. I already did some edits ... in vain.
 
  


Reply

Tags
myevalvid2, ns2


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
live video streaming in p2p network with ns235 zaina Linux - Newbie 10 01-13-2016 01:35 PM
error install myevalvid video transmission nguyenmy1203 Linux - Software 5 05-03-2015 08:45 PM
ns2 Wireless simulation Help md_imranullah Programming 1 06-13-2012 02:19 AM
wireless simulation tootz Linux - Software 2 03-22-2011 12:19 AM
wireless network simulation using ns2 berry123 Linux - Newbie 1 03-10-2011 02:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:45 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