hi. i want to add a new protocol in ns2.35 .i have problem with tclscript
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
hi. i want to add a new protocol in ns2.35 .i have problem with tclscript
I have added my protocol in ns2.35 but i have this problem with tcl script.
num_nodes is set 500
(_o15 cmd line 1)
invoked from within
"_o15 cmd addr"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o15" line 2)
(SplitObject unknown line 2)
invoked from within
"_o15 addr"
("eval" body line 1)
invoked from within
"eval $node addr $args"
("default" arm line 2)
invoked from within
"switch -exact $routingAgent_ {
DSDV {
set ragent [$self create-dsdv-agent $node]
}
DSR {
$self at 0.0 "$node start-dsr"
}
AODV {
set ragent [$self cre..."
(procedure "_o3" line 14)
(Simulator create-wireless-node line 14)
invoked from within
"_o3 create-wireless-node"
("eval" body line 1)
invoked from within
"eval $self create-wireless-node $args"
(procedure "_o3" line 23)
(Simulator node line 23)
invoked from within
"$ns_ node"
("for" body line 2)
invoked from within
"for {set i 0} {$i <$val(nn) } {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0 ;# disable random motion
$node_($i) attach-dummy
$ns_ ..."
(file "Bcast_flood.tcl" line 92)
my tcl script is
set val(chan) Channel/WirelessChannel
set val(prop) Propagation/TwoRayGround
set val(netif) Phy/WirelessPhy
set val(mac) Mac/802_11
set val(ifq) Queue/DropTail/PriQueue
set val(ll) LL
set val(ant) Antenna/OmniAntenna
set val(x) 3000 ;# X dimension of the topography
set val(y) 3000 ;# Y dimension of the topography
set val(sc) "./Broadcast/scenario-500-test"
set val(nn) 500 ;# number of nodes
set val(stop) 500.0 ;# simulation time
set val(tr) tempElection.tr ;
set val(lm) "off" ;# log movement
set val(energymodel) EnergyModel ;
set val(initialenergy) 500 ;# Initial energy in Joules
set val(cp) "./Broadcast/scenario/scenario-500-test"
set val(seed) 0.0
set val(rp) Bcast_flood
set val(ifqlen) 50
set val(idlepower) 0
LL set mindelay_ 50us
LL set delay_ 25us
LL set bandwidth_ 0 ;# not used
Queue/DropTail/PriQueue set Prefer_Routing_Protocols 1
# unity gain, omni-directional antennas
# set up the antennas to be centered in the node and 1.5 meters above it
Antenna/OmniAntenna set X_ 0
Antenna/OmniAntenna set Y_ 0
Antenna/OmniAntenna set Z_ 1.5
Antenna/OmniAntenna set Gt_ 1.0
Antenna/OmniAntenna set Gr_ 1.0
# Initialize the SharedMedia interface with parameters to make
# it work like the 914MHz Lucent WaveLAN DSSS radio interface
Phy/WirelessPhy set CPThresh_ 10.0
Phy/WirelessPhy set CSThresh_ 1.559e-11
Phy/WirelessPhy set RXThresh_ 3.652e-10
Phy/WirelessPhy set Rb_ 2*1e6
Phy/WirelessPhy set Pt_ 0.58183815
Phy/WirelessPhy set freq_ 914e+6
Phy/WirelessPhy set L_ 1.0
proc finish {} {
global ns_ quiet val nf
$ns_ flush-trace
set tracefd [open $val(tr) r]
close $tracefd
close $nf
close $f0
close $f1
puts "finish.."
exit 0
}
# Initialize Global Variables
set ns_ [new Simulator]
set topo [new Topography]
set tracefd [open $val(tr) w]
set f0 [open packets.tr w]
set f1 [open packets_risp.tr w]
$ns_ trace-all $tracefd
set nf [open bcastout.nam w]
$ns_ namtrace-all-wireless $nf $val(x) $val(y)
set curr ""
$topo load_flatgrid $val(x) $val(y)
puts $tracefd "M 0.0 nn:$val(nn) x:$val(x) y:$val(y) energy:$val(initialenergy) "
puts $tracefd "M 0.0 sc:$val(sc) cp:$val(cp) seed:$val(seed)"
puts $tracefd "M 0.0 prop:$val(prop) ant:$val(ant)"
set god_ [create-god $val(nn)]
set chan_1_ [new $val(chan)]
set chan_2_ [new $val(chan)]
# configure node
$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_1_ \
-topoInstance $topo \
-energyModel $val(energymodel) \
-initialEnergy $val(initialenergy) \
-routerTrace OFF \
-macTrace OFF \
-agentTrace ON \
-energyTrace OFF \
-movementTrace OFF \
-rxPower 35.28e-3 \
-txPower 31.32e-3 \
-idlePower $val(idlepower) \
for {set i 0} {$i <$val(nn) } {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0 ;# disable random motion
$node_($i) attach-dummy
$ns_ initial_node_pos $node_($i) 250
$node_($i) color red
$ns_ at 0.01 "$node_($i) color red"
}
for {set i 0} {$i < $val(nn)} {incr i} {
set den_($i) [new Agent/Bcast_flood [$node_($i) id]]
$node_($i) attach $den_($i) 900
}
Agent/Bcast_flood hello_period 20
Agent/Bcast_flood hello_delay 5
Agent/Bcast_flood hello_prob 0.6
Agent/Bcast_flood hello_num 4
Agent/Bcast_flood instproc received {from packet} {
global ns_ t f0
$self instvar node_
set id [$node_ id]
puts " node $id received an hello packet from $from whose id is $packet"
puts $f0 " node $id received an hello packet from $from whose id is $packet"
global node_
}
Agent/Bcast_flood instproc rejected {packet} {
global ns_ t f1
$self instvar node_
set id [$node_ id]
puts $f1 " node $id do not send an hello packet with probability $packet"
global node_
}
proc outSendHello {me num} {
puts "$me sent his hello con id $num"}
proc prova {time rit} {
puts "Current time $time; Delay $rit"}
proc probability {prob} {
puts "Sent hello with probability $prob"}
proc number_packets {num} {
puts "Il numero di pacchetti da spedire è $num" }
puts "Sto caricando lo scenario...."
source $val(sc)
puts "Load complete..."
#STOP
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at $val(stop).000000001 "$node_($i) reset";
}
$ns_ at $val(stop).0001 "finish"
$ns_ at 10 "$den_(0) startHello"
#RUN
$ns_ run
Last edited by nertila; 09-14-2015 at 02:37 PM.
Reason: i have to added the tcl script
Thank you for your reply but my protocol is not like bcast and flood .He is protocol based in gossip algorithm .I have added it successfuly in ns2.35 and there is been created Bcast_flood.o .But i have problem with tcl script ,and yes my problem is "" "for {set i 0} {$i <$val(nn) } {incr i} { "", line 92.How to compare it with the scripts in the 254MB folder "tests/"?
Error : "_o15 cmd addr" while trying to add new protocol in ns2.
Hi All,
Not sure how much helpful it will be to the people encountering this type of error after they have successfully added files they generated for their new protocol but I have observed, while I am trying to add and test my own protocol in ns2, that even after placing the files in ../ns-allinone-2.xx/ns-2.xx (2.35 in my case) and successfully executing the command:
../ns-allinone-2.xx$ sudo ./install (you may not need sudo)
which created the object files of my newer protocol, ns2 was not able to create the routing agent (ragent) according to newly added protocol. Infact, in the proc create-wireless-node in ns~/tcl/lib/ns-lib.tcl, it is not picking the lines that I added for my new protocol "create-myprotocol-agent" in the block "switch -exact -routingAgent_{.." and is rather moving to "default" condition of that "switch" statement provided in the end of the switch case. So, as a hit and trial, I executed commands
> ../ns-allinone-2.xx/ns-2.xx$ sudo make clean
> ../ns-allinone-2.xx/ns-2.xx$ sudo make
> ../ns-allinone-2.xx/ns-2.xx$ sudo make install
which helped and the changes were now visible to ns.
Don't know if it will be relevant or not in your case but I just want to suggest that if you are seeing similar error then try running the "make" commands above even after successfull execution of "./install" command. Please excuse my limited knowledge if it is too obvious.
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,492
Rep:
Re #4, @ammal.
If "_o15 cmd addr" is supposed to be your question, then all required information is missing.
? What is the command causing "_o15 cmd addr" ?
And which files did you edit ?
Maybe missing edits of e.g. tcl/lib/{ns-default.tcl, ns-mobilenode.tcl, ns-agent.tcl}
'sudo' can only be used for 'sudo make install' in ns-2.35/
And also in ns-2.35/, for 'sudo cp ns-my.agent /usr/local/bin/.
I.e. it's a good idea to have ns with a new name, to be sure another ns isn't used for a specific new protocol.
I.e. i.e. at simulation time, 'ns-[any-name] file.tcl' always works OK.
All the important points noted. Thanks!!
I have added the protocol info to relevant files. Actually, I posted the previous reply just to draw attention of people, who are struggling due to the error similar to the one posted in this thread, that not executing "$ sudo make install" after "./install" may be the source of their error and they might have missed it, as I did.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.