LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 09-14-2015, 02:35 PM   #1
nertila
LQ Newbie
 
Registered: Sep 2015
Posts: 2

Rep: Reputation: Disabled
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
 
Old 09-15-2015, 09:16 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Bcast_Flood

Welcome to LQ.

Please edit post #1 to CODE TAGS : [code]error text[/code] and [code]tcl code text[/code]
* Editing post #1 : That's the 'Edit' button in post #1.


Your error : "" "for {set i 0} {$i <$val(nn) } {incr i} { "", line 92.
? Have you compared with the scripts in the 245MB folder "tests/" ?
( See the file README http://kunz-pc.sce.carleton.ca/Thesi...ME.ns2code.txt )
'tests/', etc. .... http://kunz-pc.sce.carleton.ca/Thesi...27.code.tar.gz
>> ns-2.27.code.tar.gz
Ref. http://www.sce.carleton.ca/wmc/code.html

-

Last edited by knudfl; 09-15-2015 at 09:28 AM.
 
Old 09-16-2015, 08:43 AM   #3
nertila
LQ Newbie
 
Registered: Sep 2015
Posts: 2

Original Poster
Rep: Reputation: Disabled
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/"?
Attached Files
File Type: txt Bcast_flood.txt (4.5 KB, 11 views)

Last edited by nertila; 09-16-2015 at 12:51 PM.
 
Old 05-17-2017, 11:32 AM   #4
ammal
LQ Newbie
 
Registered: Apr 2017
Posts: 7

Rep: Reputation: Disabled
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.
 
Old 05-17-2017, 11:57 AM   #5
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
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.

Else : No other sudo commands with ns2, please.


-

Last edited by knudfl; 05-17-2017 at 12:02 PM.
 
Old 05-17-2017, 12:11 PM   #6
ammal
LQ Newbie
 
Registered: Apr 2017
Posts: 7

Rep: Reputation: Disabled
Hello knudfl!

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.

Still learning! .
 
  


Reply

Tags
bcast_flood, ns2



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
Hello, How to add some fields in HELLO list in AODV protocol in NS2? jayashreemanoharan Linux - Newbie 1 10-26-2014 12:32 PM
how to add a simple protocol into ns2.34? huangguanglun Ubuntu 2 09-30-2014 09:55 AM
problem in running cbrp protocol in ns2.34 fbin Programming 0 07-12-2012 01:29 AM
i am using ubuntu as os. for NS2 to implement a routing protocol in ns2. sujovasu Programming 1 07-27-2010 01:44 AM
weight throwing protocol using ns2 code,diffusion based protocol using ns2 code rajrupa Linux - Networking 1 05-27-2010 03:39 AM

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

All times are GMT -5. The time now is 09:54 AM.

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
Open Source Consulting | Domain Registration