Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 09-14-2015, 03:35 PM   #1
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_ {
set ragent [$self create-dsdv-agent $node]
$self at 0.0 "$node start-dsr"
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) ;
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 w]
set f1 [open 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..."
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"
$ns_ run

Last edited by nertila; 09-14-2015 at 03:37 PM. Reason: i have to added the tcl script
Old 09-15-2015, 10:16 AM   #2
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156

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 )
'tests/', etc. ....
>> ns-2.27.code.tar.gz


Last edited by knudfl; 09-15-2015 at 10:28 AM.
Old 09-16-2015, 09:43 AM   #3
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, 5 views)

Last edited by nertila; 09-16-2015 at 01:51 PM.


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

All times are GMT -5. The time now is 10:01 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration