LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   problem with running tcl script under ns 2.33 (https://www.linuxquestions.org/questions/linux-newbie-8/problem-with-running-tcl-script-under-ns-2-33-a-843581/)

manjunath11 11-11-2010 12:00 AM

problem with running tcl script under ns 2.33
 
i have installed ns 2.33 and added the patch mobiwan for supprting mobile ipv6. when i tried to run my tcl script , i got segmentation fault, can anybody just why we get segmentation fault when we run tcl
[code]
manju@manju-desktop:~/Desktop$ ns mytcl.tcl
num_nodes is set 7
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl (except for MobiWAN simulations)
INITIALIZE THE LIST xListHead

>-------------------- NS Addressing --------------------<
Domains (domain_num) : 4
Clusters (cluster_num) : 1 3 1 1
Nodes (nodes_num) : 1 1 2 1 1 1
>-------------------------------------------------------<

Segmentation fault
[\code]

knudfl 11-19-2010 12:52 AM

1) Code tags are [/code], not backslash like [\code].

2) I don't think anybody can answer your question,
when the code in "mytcl.tcl" is unknown.

Please attach the code.
..

zhouyaobin 11-21-2010 08:14 PM

I have the code and the same question
 
The code is:

# Basic Mobile IPv6 example without using ns-topoman
# Needs proc defined in file proc-mipv6-config.tcl
Phy/WirelessPhy set RXThresh 2.64161e-10

Agent/MIPv6/MN set bs_forwarding_ 0 ; # 1 if forwarding from previous BS
################################################################
proc log-mn-movement_no_topo { } {
global logtimer ns
Class LogTimer -superclass Timer
LogTimer instproc timeout {} {
global mobile_
$mobile_ log-movement
$self sched 1
}
set logtimer [new LogTimer]
$logtimer sched 1
}

################################################################
# Create Topology
################################################################
proc create-my-topo {} {
global ns opt topo mobile_ cn_ mnn_nodes_

# Create and define topography
set topo [new Topography]
# set prop [new $opt(prop)]
# $prop topography $topo
$topo load_flatgrid 1000 1000

# god is a necessary object when wireless is used
# set to a value equal to the number of mobile nodes
create-god 6

# Call node-config
$ns node-config \
-addressType hierarchical \
-agentTrace ON \
-routerTrace ON

# Set NS Addressing
AddrParams set domain_num_ 2
AddrParams set cluster_num_ {1 6}
AddrParams set nodes_num_ {1 1 3 1 1 1}

# Create Nodes
set cn_ [create-router 0.0.0]
$cn_ label "CN"
set router_ [create-router 1.0.0]
$router_ label "Router"
set bs1_ [create-base-station 1.1.0 1.0.0 200 200 0]
$bs1_ label "BS1"
set bs2_ [create-base-station 1.2.0 1.0.0 200 600 0]
$bs2_ label "BS2"
set bs3_ [create-base-station 1.3.0 1.0.0 600 200 0]
$bs1_ label "BS3"
set bs4_ [create-base-station 1.4.0 1.0.0 600 600 0]
$bs2_ label "BS4"
set bs5_ [create-base-station 1.5.0 1.0.0 700 700 0]
$bs1_ label "BS5"
set mobile_ [create-mobile 1.1.1 1.1.0 190 190 0 1 0.01]
$mobile_ label "MN"

# Create Links
$ns duplex-link $cn_ $router_ 100Mb 1.80ms DropTail
$ns duplex-link $router_ $bs1_ 100Mb 1.80ms DropTail
$ns duplex-link $router_ $bs2_ 100Mb 1.80ms DropTail
$ns duplex-link $router_ $bs3_ 100Mb 1.80ms DropTail
$ns duplex-link $router_ $bs4_ 100Mb 1.80ms DropTail
$ns duplex-link $router_ $bs5_ 100Mb 1.80ms DropTail

display_ns_addr_domain
}

################################################################
# End of Simulation
################################################################
proc finish { } {
global tracef ns namf opt mobile_ cn_

puts "Simulation finished"
# Dump the Binding Update List of MN and Binding Cache of HA
[[$mobile_ set ha_] set regagent_] dump
[$cn_ set regagent_] dump
[$mobile_ set regagent_] dump

$ns flush-trace
flush $tracef
close $tracef
close $namf
#puts "running nam with $opt(namfile) ... "
#exec nam $opt(namfile) &
exit 0
}


################################################################
# Main
################################################################
proc main { } {
global opt ns TOPOM namf n tracef mobile_ cn_
# Source Files
# source set-def-options.tcl
# set BASEDIR to your own correct path
source ~/fz/ns-allinone-2.33/ns-2.33/tcl/lib/proc-mipv6-config.tcl
source ~/fz/ns-allinone-2.33/ns-2.33/tcl/lib/proc-tools.tcl
source ~/fz/ns-allinone-2.33/ns-2.33/tcl/lib/proc-topo.tcl
source ~/fz/ns-allinone-2.33/ns-2.33/tcl/lib/ns-topoman.tcl
source ~/fz/ns-allinone-2.33/ns-2.33/tcl/lib/proc-mobi-global.tcl
source ~/fz/ns-allinone-2.33/ns-2.33/tcl/lib/proc-mobi-config.tcl
source ~/fz/ns-allinone-2.33/ns-2.33/tcl/mobility/timer.tcl

set NAMF out.nam
set TRACEF out.tr
set INFOF out.info

set opt(mactrace) ON
set opt(NAM) 1
set opt(namfile) $NAMF
set opt(stop) 100
set opt(tracefile) $TRACEF

#>--------------- Extract options from command line ---------------<
#Getopt ; # Get option from the command line
#DisplayCommandLine

#>---------------------- Simulator Settings ----------------------<
set ns [new Simulator]
#>------------------------ Open trace files ----------------------<
exec rm -f $opt(tracefile)
set tracef [open $opt(tracefile) w]
#... dump the file
$ns trace-all $tracef

set namf [open $opt(namfile) w]
$ns namtrace-all $namf

#>------------- Protocol and Topology Settings -------------------<
create-my-topo
log-mn-movement_no_topo

set-cbr
# set-ping-int 0.1 $cn_ $mobile_ 10 $opt(stop)




#>----------------------- Run Simulation -------------------------<
$ns at 40 "$mobile_ setdest 200.0 200.0 25.0"

$ns at 80 "$mobile_ setdest 200.0 600.0 25.0"

$ns at 120 "$mobile_ setdest 600.0 600.0 25.0"

$ns at 160 "$mobile_ setdest 600.0 200.0 25.0"

$ns at 180 "$mobile_ setdest 200.0 200.0 25.0"

$ns at 40 "$mobile_ setdest 700.0 700.0 25.0"

$ns at $opt(stop) "finish"
$ns run

$ns dump-topology $namf
close $namf
#puts "running nam with $opt(namfile) ... "
#exec nam $opt(namfile) &
}

proc set-cbr { } {
global ns cn_ mobile_
set udp [new Agent/UDP]
$ns attach-agent $cn_ $udp

set dst [new Agent/Null]
$ns attach-agent $mobile_ $dst
$ns connect $udp $dst

set src [new Application/Traffic/CBR]
$src set packetSize_ 1000
$src set rate_ 100k
$src set interval_ 0.05
$src attach-agent $udp
$ns at 20.0 "$src start"


}

main


thanks a lot!

manjunath11 11-22-2010 04:21 AM

this is the tcl file i tried to run. problem is when i run nam , it starts and then suddenly stops giving segmentation fault ,
Code:

# FIRST SCENARIO WITHOUT BUFFER
# Basic Mobile IPv6 example without using ns-topoman
# Needs proc defined in file proc-mipv6-config.tcl
Agent/MIPv6/MN set bs_forwarding_ 0 ; # 1 if forwarding from previous BS
################################################################
proc log-mn-movement_no_topo { } {
global logtimer ns
Class LogTimer -superclass Timer
LogTimer instproc timeout {} {
global mobile_
$mobile_ log-movement
$self sched 1
}
set logtimer [new LogTimer]
$logtimer sched 1
}
################################################################
# Create Topology
################################################################
proc create-my-topo {} {
global ns opt topo mobile_ cn_ mnn_nodes_
# Create and define topography
set topo [new Topography]
# set prop [new $opt(prop)]
# $prop topography $topo
$topo load_flatgrid 800 800
# god is a necessary object when wireless is used
# set to a value equal to the number of mobile nodes
create-god 5
# Call node-config
$ns node-config \
-addressType hierarchical \
-agentTrace On \
-routerTrace Off\
# Set NS Addressing
AddrParams set domain_num_ 2
AddrParams set cluster_num_ {1 3}
AddrParams set nodes_num_ {1 1 2 1}
# Create Nodes
set cn_ [create-router 0.0.0]
set router_ [create-router 1.0.0]
set bs1_ [create-base-station 1.1.0 1.0.0 100 100 0]
set bs2_ [create-base-station 1.2.0 1.0.0 100 550 0]
set mobile_ [create-mobile 1.1.1 1.1.0 230 100 0 0 0.01]
# Create Links
$ns simplex-link $cn_ $router_ 10Mb 2.0ms DropTail
$ns duplex-link $router_ $bs1_ 10Mb 2.0ms DropTail
$ns duplex-link $router_ $bs2_ 10Mb 2.0ms DropTail
display_ns_addr_domain
}
################################################################
# End of Simulation
################################################################
proc finish { } {
global tracef ns namf opt mobile_ cn_
puts "Simulation finished"
# Dump the Binding Update List of MN and Binding Cache of HA
[[$mobile_ set ha_] set regagent_] dump
[$cn_ set regagent_] dump
[$mobile_ set regagent_] dump
$ns flush-trace
flush $tracef
close $tracef
close $namf
puts "running nam with $opt(namfile) ... "
#exec nam $opt(namfile) &
exit 0
}
################################################################
# Main
################################################################
proc main { } {
global opt ns TOPOM namf n tracef mobile_ cn_
# Source Files
# source set-def-options.tcl
# set home/salim to your own correct path

#source /home/manju/Desktop//ns-allinone-2.33/ns-2.33/tcl/lib/proc-mipv6-config.tcl
 #  source /home/manju/Desktop//ns-allinone-2.33/ns-2.33/tcl/lib/proc-tools.tcl
 #  source /home/manju/Desktop//ns-allinone-2.33/ns-2.33/tcl/lib/proc-topo.tcl
  # source /home/manju/Desktop//ns-allinone-2.33/ns-2.33/tcl/lib/ns-topoman.tcl
 #  source /home/manju/Desktop//ns-allinone-2.33/ns-2.33/tcl/lib/proc-mobi-global.tcl
  # source /home/manju/Desktop//ns-allinone-2.33/ns-2.33/tcl/lib/proc-mobi-config.tcl
 #  source /home/manju/Desktop//ns-allinone-2.33/ns-2.33/tcl/mobility/timer.tcl
source /home/manju/Desktop//ns-allinone-2.33/ns-2.33/tcl/lib/proc-mipv6-config.tcl
source /home/manju/Desktop//ns-allinone-2.33/ns-2.33/tcl/lib/proc-tools.tcl
source /home/manju/Desktop//ns-allinone-2.33/ns-2.33/tcl/lib/proc-topo.tcl
source /home/manju/Desktop//ns-allinone-2.33/ns-2.33/tcl/lib/ns-topoman.tcl

source /home/manju/Desktop//ns-allinone-2.33/ns-2.33/tcl/lib/proc-mobi-global.tcl
source /home/manju/Desktop//ns-allinone-2.33/ns-2.33/tcl/lib/proc-mobi-config.tcl
source /home/manju/Desktop//ns-allinone-2.33/ns-2.33/tcl/mobility/timer.tcl
set NAMF out.nam
set TRACEF out.tr
set INFOF out.info
set opt(mactrace) ON
set opt(NAM) 1
set opt(namfile) $NAMF
set opt(stop) 100
set opt(tracefile) $TRACEF
#>--------------- Extract options from command line ---------------<
#Getopt
; # Get option from the command line
#DisplayCommandLine
#>---------------------- Simulator Settings ----------------------<
set ns [new Simulator]
#>------------------------ Open trace files ----------------------<
exec rm -f $opt(tracefile)
set tracef [open $opt(tracefile) w]
#... dump the file
#set new trace file for wireless
$ns use-newtrace
$ns trace-all $tracef
set namf [open $opt(namfile) w]
$ns namtrace-all $namf
#>------------- Protocol and Topology Settings -------------------<
create-my-topo
log-mn-movement_no_topo
#############
set-cbr
# set-ping-int 0.1 $cn_ $mobile_ 10 $opt(stop)
#start movement to pos(x,y) with velocity v
#$ns at 10.0 "$mobile_ setdest 700 400 10"
#MN move again to BS2#####
$ns at 2.0 "$mobile_ setdest 230 500 10"
#>----------------------- Run Simulation -------------------------<
$ns at $opt(stop) "finish"
$ns run
$ns dump-topology $namf
close $namf
puts "running nam with $opt(namfile) ... "
exec nam $opt(namfile) &
}
proc set-cbr { } {
global ns cn_ mobile_
set udp [new Agent/UDP]
$ns attach-agent $cn_ $udp
set dst [new Agent/Null]
$ns attach-agent $mobile_ $dst
$ns connect $udp $dst
set src [new Application/Traffic/CBR]
$src set packetSize_ 160
$src set rate_ 64k
$src set interval_ 0.05
$src attach-agent $udp
$ns at 10.0 "$src start"
$ns at 15.0 "$src stop"
}
main

this is what i got when tried to run nam
Code:

manju@manju-desktop:~/Desktop$ nam out.nam
Segmentation fault


knudfl 11-22-2010 05:46 AM

@ zhouyaobin, post # 3 : Welcome to LQ.

Please edit post #3 to use 'code tags'.
I.e. [/code] after the code, and [code] at code start.
http://www.linuxquestions.org/questi....php?do=bbcode

The code you show, is "simple_mobileipv6.tcl"
It is explained in post #2 here, how to use it ..
http://www.linuxquestions.org/questi...an_1-a-842686/
..

May be " ~ " isn't working for the path.
The full path /home/<name>/ , etc. should be preferred.
..

knudfl 11-22-2010 07:52 AM

3 Attachment(s)
Post #4 manjunath11 : I edited the code to my path, and the output is
Code:

[knudfl@localhost ns-2.33]$ ./ns _mob.tcl.txt
num_nodes is set 5
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl (except for MobiWAN simulations)
INITIALIZE THE LIST xListHead

  >-------------------- NS Addressing --------------------<
  Domains (domain_num) : 2
  Clusters (cluster_num) : 1 3
  Nodes (nodes_num) :  1 1 2 1
  >-------------------------------------------------------<

channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5,  distCST_ = 550.0
SORTING LISTS ...DONE!
26.3025 get_coa for BS 1.2.0:4198400
Simulation finished

|Binding Cache for node 1.1.0 at 100 --------------------------------------- |
|Node          COA            Type    Info    Flag    Last    Time            Life    Expire          Nb|
|1.1.1          1.2.4          7      MN      1      13      91.3087        10      0              13 |


|Binding Update List for node 1.1.1 at 100 --------------------------------------- |
|Node          COA            Type    Info    Flag    Last    Time            Life    Expire          Nb|
|1.1.0          1.2.4          3      HA      1      13      91.3025        10      2.68435e+08            14 |


|Base Station List for node 1.1.1 at 100 --------------------------------------- |
|Node          COA            Type    Info    Flag    Last    Time            Life    Expire          Nb|
|1.2.0          1.2.4          8      BS      1      -1      99.6504        1      0              149 |

running nam with out.nam ...

But it doesn't run the 330 kB nam.out right away.
( 'nam.out' is 21,9 kB gzipped. Attached as out.nam__mob_tcl_.gz.txt ).
'nam nam.out' works. But almost freezes the OS, when the play button is used.
And the nam GUI will also close down.
May be the file is too huge for nam to handle ?
..

Elenka 12-20-2010 07:37 PM

Hello,

I have installed ns-2.33 and mobiwan patch succesfully according to Nicta web page (O.Mehani).
But when running the first, simple-mipv6.tcl script i get error regarding Agent/MIPv6/MN set bs_forwarding_ 0, as the Agent doesnt exist.
Any thoughts about this issue? Am I missing something? Some extra configurations of certain files? Or, any manual or examples of scripts using Mobiwan patch and mipv6 in ns-2.33?

Would appreciate any help a lot.

kindest regards,
Elena

knudfl 12-21-2010 08:06 AM

@ Elenka, post # 7 : Welcome to LQ.

Please read post # 5 and the connected link :

http://www.linuxquestions.org/questi...an_1-a-842686/
... where post #2 shows how to write your personal path in lines 93 .. 99.
...

Elenka 12-21-2010 08:40 PM

@Knudfl: Thank you!
Anyway, I ve just seen your reply... I will read the previous posts today as referred
and I will give you my feedback afterward.

Regards,
Elena

Elenka 12-22-2010 06:53 PM

Although I have changed the source paths in the script, I keep on getting this message:

invalid command name "Agent/MIPv6/MN"
while executing
"Agent/MIPv6/MN set bs_forwarding_ 0 "
(file "simple-mipv6.tcl" line 4)

My script is the same mentioned in the previous posts, with correct paths (referring where they really are like: source /home/elena/NetSim/ns-allinone-2.33/ns-2.33/tcl/mobility/timer.tcl). Thats is the only change I ve made in this simple script.

Anyway, just after pure installation of ns-2.33 on Ubuntu 9.10, I have applied
the following patch (http://www.nicta.com.au/people/mehanio/nsmisc- Mobiwan patch for ns-2.33).
And afterward a list of all files that have been patched was shown using this command (patch -p0 <ns-233-mobiwan-1.patch).

Is it the same patch mentioned in previous posts? Or am I still missing something in my configuration? :-(

I really hope I will get some help, or at least some instructions.

BR,
Elena

knudfl 01-06-2011 06:33 AM

Post # 10.

Suggest : Read the other "mobiwan threads" at LQ.
May be, you will find some hints.

LQ Search , Tag = mobiwan

..

Elenka 01-08-2011 04:58 AM

Thanks Knudfl:-)
Actually i forgot to write you that i managed to resolve my issue:-)

Thank you for your previous posts and time once again!;-)

Best regards!

Elena

rochd 01-25-2011 04:07 PM

how you could solve this problem please?

invalid command name "Agent/MIPv6/MN"
while executing
"Agent/MIPv6/MN set bs_forwarding_ 0 "
(file "simple-mipv6.tcl" line 4)

knudfl 01-26-2011 04:50 AM

Post # 13, @ rochd : Welcome to LQ.

May be read posts #10 - #11.

Or ask @Elenka, if she has some other solution.

Good luck !
..

rochd 01-26-2011 06:10 AM

thanks Knudf
@Elenka
how you could solve this problem please?

invalid command name "Agent/MIPv6/MN"
while executing
"Agent/MIPv6/MN set bs_forwarding_ 0 "
(file "simple-mipv6.tcl" line 4)


All times are GMT -5. The time now is 07:38 AM.