LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-16-2013, 02:01 AM   #1
hsoft_project
LQ Newbie
 
Registered: Oct 2013
Posts: 2

Rep: Reputation: Disabled
ns2 ftp start Error


hello guys . i write a simple tcl code for ns 2.34 this code is

#Leach Nam Protocol (hamed.gh) ======================================================================
# Define options
# ======================================================================
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(ifqlen) 51
set val(nn) 51
set val(rp) DumbAgent
set val(en) EnergyModel/Battery
set val(x) 1000
set val(y) 1000
set val(stop) 150
set val(range) 100
set local(energy) 10.0
set trace(mac) ON
set val(start) 0.0
set val(stop) [expr $val(start) + 200.0]

set trace(router) ON

set trace(agent) ON

set trace(movement) ON
set val(LOOP) 0
#=====================================================================
#Main Program
#=====================================================================
#================================================
proc TwoRay { Pt Gt Gr ht hr L d lambda } {
set crossover_dist [expr (4 * 3.14159265359 * $ht * $hr) / $lambda]

if { $d < $crossover_dist } {
return [Friis $Pt $Gt $Gr $lambda $L $d]
} else {
return [expr $Pt * $Gt * $Gr * ($hr * $hr * $ht * $ht) / ($d * $d * $d * $d * $L)]
}
}
#===============================================
#============================================
#============calculate distance===================
proc calcDist { node_a node_b } {

set x1 [$node_a set X_]
set y1 [$node_a set Y_]

set x2 [$node_b set X_]
set y2 [$node_b set Y_]

set distance [ expr sqrt(($x2-$x1)*($x2-$x1)+($y2-$y1)*($y2-$y1)) ]
return $distance

}

#===================================================
#================wirless setting===================

proc setup_mica2 { antenna range } {

puts "Setting up mica 2 mote with $antenna and range = $range"

#Phy/WirelessPhy set CPThresh_ 10.0
#Phy/WirelessPhy set CSThresh_ 1.559e-11
#Phy/WirelessPhy set RXThresh_ 2.78869e-09 ; # 100 meters
#Phy/WirelessPhy set RXThresh_ 1.11548e-08 ; # 50 meters
#Phy/WirelessPhy set Rb_ 2*1e6

Phy/WirelessPhy set Pt_ 0.281838
Phy/WirelessPhy set freq_ 2.4e09
Phy/WirelessPhy set L_ 1.0
Phy/WirelessPhy set lambda_ 0.125
Phy/WirelessPhy set RXThresh_ [TwoRay 0.281838 [$antenna set Gt_] [$antenna set Gr_] 0.8 0.8 1.0 $range 0.125]
Phy/WirelessPhy set bandwidth_ 280.8*10e3 ;#28.8 kbps

Node/MobileNode/SensorNode set sensingPower_ 0.015
Node/MobileNode/SensorNode set processingPower 0.024
Node/MobileNode/SensorNode set instructionsPerSecond_ 8000000

}
#===============================================
#===============================random intigar
proc RandomInteger4 {min max} {
return [expr {int(rand()*($max-$min+1)+$min)}]
}
proc RandomInteger3 {min max} {
return [expr {rand()*($max-$min+1)+$min}]
}
#==============================================
## Creating node objects..
### Creating The WIRELESS NODES color

set a ""
set b ""
set c ""
set val(deployment) 0
#==============end of calculate distance==========
#=======================================================
#=============================create common node===========

#============================================================
proc create_common_node {start stop reload} {
global val ns topo local trace claster1 claster2 claster3 node_ a b c


Node/MobileNode/SensorNode set sensingPower_ 10.015
Node/MobileNode/SensorNode set processingPower 0.024
Node/MobileNode/SensorNode set instructionsPerSecond_ 8000000





$ns node-config -sensorNode ON \
-adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-energyModel $val(en) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace $trace(agent) \
-routerTrace $trace(router) \
-macTrace $trace(mac) \
-rxPower 0.024 \
-txPower 0.036 \
-initialEnergy $local(energy) \
-movementTrace $trace(movement)

## comoon node energy coniguration
$ns node-config -energyModel EnergyModel \
-initialEnergy 20 \
-txPower 0.9 \
-rxPower 0.8 \
-idlePower 0.0 \
-sensePower 0.0175
#################################

if { $reload == "false"} {
for {set i 0} {$i < $val(nn) } { incr i } {
set node_($i) [$ns node]
}





## Provide initial location of mobilenodes..

if {$val(nn) >0} {
for {set i 1} {$i < $val(nn) } { incr i } {
if { $i <= 17 } {
set xx [RandomInteger3 0 600]
set yy [RandomInteger3 0 333.3333];
$node_($i) set X_ $xx
$node_($i) set Y_ $yy
}
if { $i > 17 && $i <= 34} {
set xx [RandomInteger3 600 1200]
set yy [RandomInteger3 333.3333 666.6666];
$node_($i) set X_ $xx
$node_($i) set Y_ $yy
}
if { $i > 34 && $i <= $val(nn)} {
set xx [RandomInteger3 1200 1800]
set yy [RandomInteger3 666.6666 1000];
$node_($i) set X_ $xx
$node_($i) set Y_ $yy
}
}
}
for {set i 0} {$i < $val(nn)} { incr i } {
# 30 defines the node size for nam..

$ns initial_node_pos $node_($i) 40


}

}
set claster1 [RandomInteger4 0 17]
set claster2 [RandomInteger4 18 34]
set claster3 [RandomInteger4 35 50]

set a $node_($claster1)
set b $node_($claster2)
set c $node_($claster3)
set xxx [expr int([$node_($claster2) set X_])]

#=============================================
#$ns at 0.1 "$node_($claster1) setdest $xxx [expr $xxx+1] 2.0"

puts "$claster1...$claster2.......$claster3"
for {set i 0} {$i <$val(nn)} {incr i} {
if {$i <=17} {
set udp($i) [$ns create-connection UDP $node_($claster1) Null $node_($i) 1]
$udp($i) set fid_ $i
set cbr($i) [$udp($i) attach-app Traffic/CBR]
$cbr($i) set packetSize_ 1000
$cbr($i) set interval_ .07
$ns at $start "$cbr($i) start"
$ns at $stop "$cbr($i) stop"

set c_($i) [calcDist $node_($claster1) $node_($i)]
#$node_($i) label $c_($i)
#$ns at $start "$node_($i) label $c_($i)"

}
if {$i >17 && $i <= 34} {
set udp($i) [$ns create-connection UDP $node_($claster2) Null $node_($i) 1]
$udp($i) set fid_ $i
set cbr($i) [$udp($i) attach-app Traffic/CBR]
$cbr($i) set packetSize_ 1000
$cbr($i) set interval_ .07
$ns at $start "$cbr($i) start"
$ns at $stop "$cbr($i) stop"
set c_($i) [calcDist $node_($claster2) $node_($i)]
#$node_($i) label $c_($i)
#$ns at $start "$node_($i) label $c_($i)"

}
if {$i > 34 && $i <=51} {
set udp($i) [$ns create-connection UDP $node_($claster3) Null $node_($i) 1]
$udp($i) set fid_ $i
set cbr($i) [$udp($i) attach-app Traffic/CBR]
$cbr($i) set packetSize_ 1000
$cbr($i) set interval_ .07
$ns at $start "$cbr($i) start"
$ns at $stop "$cbr($i) stop"
set c_($i) [calcDist $node_($claster3) $node_($i)]
#$node_($i) label $c_($i)
#$ns at $start "$node_($i) label $c_($i)"

}
}

for {set i 0} {$i < $val(nn)} {incr i} {
if {$i != $claster1 && $i != $claster2 && $i != $claster3} {
$node_($i) color darkgreen
$ns at $start "$node_($i) color darkgreen"
} else {
$node_($i) color cyan
$ns at $start "$node_($i) color cyan"
#$node_($i) shape box
#$ns at $start "$node_($i) shape box"


}
}
#set enrg [expr int([$node_($claster2) set $val(en))]

}
#============================end of create common node=================
#====================================================================
#============================Create Access Point======================

proc accessPoint {start stop} {
global val ns topo local trace claster1 claster2 claster3 node_ a b c

#================================================================


#===============================================================
set accesp [$ns node]
set ac [$ns node]
$ac set X_ 1800
$ac set Y_ 0.0
$ac set Z_ 0.0
$accesp shape box
$ns at $start "$accesp shape box"
$accesp set X_ 1800
$accesp set Y_ 0.0
$accesp set Z_ 0.0
$ns at $start "$accesp label Sink"
$ns initial_node_pos $ac 20
$ns initial_node_pos $accesp 200
$ns duplex-link $accesp $ac 10Mb 10ms DropTail
set tcp1 [new Agent/TCP]
$tcp1 set class_ 2
set sink1 [new Agent/TCPSink]
$ns attach-agent $accesp $tcp1
$ns attach-agent $ac $sink1
$ns connect $tcp1 $sink1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
$ns at $start "$ftp1 start"

}
#===============================end of create access point============
# create new simulation
set ns [new Simulator]
# create topology
debug 1
# create nam animator simulation
set nam_trace [open a.nam w]
#create trace file
set all_trace [open a.trace w]


#================start finish function==============================
#function of finish simulation




## Creating node objects..
### Creating The WIRELESS NODES color


#=======================end of finish function=====================


$ns trace-all $all_trace
$ns namtrace-all-wireless $nam_trace $val(x) $val(y)

#define topology
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god [expr $val(nn)+3]
set chan_1_ [new $val(chan)]

#create god
set rng [new RNG]
$rng seed [clock seconds]
set secound [clock seconds]
#==============================================
#global node setting

#
#====================================================
$ns color 1 dodgerblue
$ns color 2 blue
$ns color 3 cyan
$ns color 4 green
$ns color 5 yellow
$ns color 6 black
$ns color 7 magenta
$ns color 8 gold
$ns color 9 red

$ns at 0.0 [create_common_node 0.0 1.0 "false"]
$ns at 1.25 [create_common_node 1.25 2.0 "true"]
$ns at 2.25 [create_common_node 2.25 3.0 "true"]
$ns at 3.25 [create_common_node 3.25 4.5 "true"]
$ns at 4.8 [create_common_node 4.8 5.8 "true"]
$ns at 6.0 [create_common_node 6.0 7.0 "true"]
$ns at 7.3 [create_common_node 7.3 8.5 "true"]
$ns at 8.8 [create_common_node 8.8 10.0 "true"]
#$ns at 10.2 [create_common_node 10.2 11.2 "true"]
$ns at 0.0 [accessPoint 0.0 1.3]
$ns at 0.0 "$ns trace-annotate \"Deploy Node In Panel\""
$ns at 0.3 "$ns trace-annotate \"select cluster head and send pakets\""
$ns at 200.0 "finish"

proc finish {} {
global ns nam_trace all_trace c_ val

$ns flush-trace
close $nam_trace
close $all_trace
#start nam application for graphic simulation
$ns halt
exec nam a.nam &
#exit simulation
exit 0

}

$ns run


and i run this code showen this error (ns: 1288: invalid command name "1288"
while executing
)

and i remove this line $ns at $start "$ftp1 start" in function accessPoint this code is run but not start ftp connection
please help me

Last edited by hsoft_project; 10-17-2013 at 10:38 AM.
 
Old 10-16-2013, 07:56 PM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,519

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Welcome to LQ.

Please do not use "php code tags".
Introduces some spaces, and missing back space's.
Plain "code tags" will work. Please edit post #1.

Your file works fairly OK here ( with the "php bugs" fixed ) :
Code:
$ ns-mannasim hsoft_project.tcl
warning: Script debugging disabled.  Reconfigure with --with-tcldebug, and recompile.             
num_nodes is set 54                              
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl                                 
INITIALIZE THE LIST xListHead                    
2...32.......36                                  
3...31.......48                                  
12...29.......39                                 
12...20.......45                                 
13...34.......45                                 
11...25.......42
7...22.......40
17...29.......40
ns: 1288: invalid command name "1288"
    while executing
"1288"
So you will have to find out which of your lines are generating "1288",
which is not a figure that appears in the file as the number "1288".
-
Attached Files
File Type: txt hsoft_project.tcl.txt (11.3 KB, 56 views)
 
Old 03-11-2014, 04:36 AM   #3
hd_uni_pro
Member
 
Registered: Mar 2014
Posts: 31

Rep: Reputation: Disabled
Thumbs down why this error for all code's

hi freind . i write this code's and run in nam(((---->cygwin in window 7 ))) ( code is copy here :C:\cygwin-ori\usr\local\ns-allinone-2.29\ns-2.29\aodv))
code's download from here :
=================================================================================================
Code:
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(stop)           100                            ;# time of simulation end
set val(x)              500                            ;# X dimension of topography
set val(y)              400                            ;# Y dimension of topography
set ns_ [new Simulator]
set tracefd [open wireless2node1.tr w]
$ns_ trace-all $tracefd
set namtrace [open wireless2node1.nam w]
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
#create-god $val(nn)
set god_ [create-god $val(nn)]
# configure the nodes
$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) \
		-channelType [new $val(chan)] \
		-topoInstance $topo \
		-agentTrace ON \
		-routerTrace ON \
		-macTrace ON \
		-movementTrace OFF

#############################
for {set i 0} {$i < $val(nn) } {incr i} {
         set node_($i) [$ns_ node]
         $ns_ initial_node_pos $node_($i) 20.0
         $node_($i) random-motion 0
}
#########################
$node_(0) set X_ 5.0
$node_(0) set Y_ 10.0
$node_(0) set Z_ 0.0
$ns_  at 0.0 "$node_(0) setdest 5.0 10.0 0.0"
$node_(1) set X_ 400.0
$node_(1) set y_ 300.0
$node_(1) set Z_ 0.0

$ns_ at 1.0 "$node_(1) setdest 24.01 20.01 15.1" 
$ns_  at 0.0 "$node_(1) setdest 400.0 300.0 0.0"
$ns_ at 2.0 "$node_(0) setdest 155.0 110.0 55.0"
$ns_ at 5.0 "$node_(1) setdest 105.0 110.0 21.0"
$ns_ at 10.0 "$node_(0) setdest 185.0 260.0 45.0"
$ns_ at 40.0 "$node_(0) setdest 105.0 140.0 33.0"
$ns_ at 45.0 "$node_(1) setdest 125.0 210.0 33.0"
$ns_ at 50.0 "$node_(0) setdest 115.0 230.0 60.0"
$ns_ at 100.0 "$node_(1) setdest 200.0 280.0 10.0"
$ns_ at 130.0 "$node_(0) setdest 250.0 380.0 22.0"
proc stop {} {	
	global ns_ tracefd namtrace
	$ns_ flush-trace
	close $tracefd
	close $namtrace
	exit 0
}
set tcp [new Agent/TCP]
$ns_ attach-agent $node_(0) $tcp
set sink [new Agent/TCPSink]
$ns_ attach-agent $node_(1) $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns_ connect $tcp $sink
$ns_ at 0.0.050000 "$ftp start"
$ns_ at 150.0.050000 "stop"
puts "Starting Simulation for you.."
$ns_ run
and
Code:
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) 25 ;# 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(cstop) 451 ;# time of connections end
#####
set val(stop) 100.0 ;# time of simulation end
set val(t1) 0.0 ;
set val(t2) 0.0 ;
set val(cp)"scen-25-nodes"
set val(cc) "cbr"
#######===================================
####### Initialization
#######===================================
#######Create a ns simulator
set ns_ [new Simulator]
#######Setup topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
set god_[God instance]
source $val(cp)
#######Open the NS trace file
set tracefile [open out.tr w]
$ns_ trace-all $tracefile
#######Open the NAM trace file
set namfile [open out.nam w]
$ns_ namtrace-all $namfile
$ns_ namtrace-all-wireless $namfile $val(x) $val(y)
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) \
		 -channelType $chan \
		 -topoInstance $topo \
		 -agentTrace ON \
		 -routerTrace ON \
		 -macTrace ON \
		 -movementTrace ON
puts "Creating nodes..."
for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0 ;#######disable random motion
}
puts "Loading random movement pattern..."
set god_ [God instance]
source $val(cp)
####### CBR Connections generated by cbrgen
source $val(cc)
####### Define initial node position
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ initial_node_pos $node_($i) 30
}
####### CBR connections stops
for {set i 0} {$i < 3 } {incr i} {
$ns_ at $val(cstop) "$cbr_($i) stop"
}
####### Tell all nodes when the simulation ends
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at $val(stop).000000001 "$node_($i) reset";
}
#######===================================
####### Termination
#######===================================
#######Define a 'finish' procedure
proc finish {} {
global ns tracefile namfile
$ns_ flush-trace
close $tracefile
close $namfile
exec nam out.nam &
exit 0
}
for {set i 0} {$i < $val(nn) } { incr i } {
$ns_ at $val(stop) "\$node_($i) reset"
}
$ns_ at $val(stop) "$ns_ nam-end-wireless $val(stop)"
$ns_ at $val(stop) "finish"
$ns_ at $val(stop) "puts \"done\" ; $ns_ halt"
$ns_ run
and code hsoft_project.tcl fronm this forum

but all of code's display one error (why and how solution ))
$ ns wireless4_1node.tcl
invalid command name "i>>?set"
while executing
"i>>?set val(prop) propagation/TwoRayGround "
(file "wireless4_1node.tcl" line1)

please help me for solution error .!!!!!!
thx

Last edited by hd_uni_pro; 03-15-2014 at 03:30 AM.
 
Old 03-13-2014, 01:21 AM   #4
hd_uni_pro
Member
 
Registered: Mar 2014
Posts: 31

Rep: Reputation: Disabled
!!!!!!!!!
 
Old 03-13-2014, 08:21 AM   #5
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,519

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
# 3 .

What to say. Your error { invalid command name "i>>?set" } doesn't appear in a Linux OS,
by testing your files.
Your ns-2.29 modifications are unknown : Show a link, please.

This is a Linux Forum / a Linux + ns2 thread :
Do not expect precise answers for anything Cygwin related.
→ You might try asking in a Cygwin Forum.
Or : * http://network-simulator-ns-2.7690.n7.nabble.com/
* https://groups.google.com/forum/?fro...forum/ns-users


""code is copy here :C:\cygwin-ori\usr\local\ns-allinone-2.29\ns-2.29\aodv))"" : Missing link.
""and code hsoft_project.tcl fronm this forum"" : A link, please.


-

Last edited by knudfl; 03-13-2014 at 08:27 AM.
 
Old 03-15-2014, 02:32 AM   #6
hd_uni_pro
Member
 
Registered: Mar 2014
Posts: 31

Rep: Reputation: Disabled
hello
thank you for answer .
my error :
invalid command name "i>>?set"
while executing
"i>>?set val(prop) propagation/TwoRayGround "
(file "wireless4_1node.tcl" line1)

and I do not know how to fix it
also Thank you have to introduce forum
 
Old 03-15-2014, 02:36 AM   #7
hd_uni_pro
Member
 
Registered: Mar 2014
Posts: 31

Rep: Reputation: Disabled
Quote:
Originally Posted by knudfl View Post
# 3 .




""code is copy here :C:\cygwin-ori\usr\local\ns-allinone-2.29\ns-2.29\aodv))"" : Missing link.


-
I want to know why the error is caused by the file not being copied correctly or not.
 
Old 03-15-2014, 02:38 AM   #8
hd_uni_pro
Member
 
Registered: Mar 2014
Posts: 31

Rep: Reputation: Disabled
Exclamation ک م ک

Quote:
Originally Posted by knudfl View Post
# 3 .

""code is copy here :C:\cygwin-ori\usr\local\ns-allinone-2.29\ns-2.29\aodv))"" : Missing link.

-
I want to know why the error is caused by the file not being copied correctly or not.
 
Old 03-15-2014, 02:43 AM   #9
hd_uni_pro
Member
 
Registered: Mar 2014
Posts: 31

Rep: Reputation: Disabled
Exclamation ک م ک

Quote:
Originally Posted by knudfl View Post
Welcome to LQ.

Please do not use "php code tags".
Introduces some spaces, and missing back space's.
Plain "code tags" will work. Please edit post #1.

Your file works fairly OK here ( with the "php bugs" fixed ) :
Code:
$ ns-mannasim hsoft_project.tcl
warning: Script debugging disabled.  Reconfigure with --with-tcldebug, and recompile.             
num_nodes is set 54                              
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl                                 
INITIALIZE THE LIST xListHead                    
2...32.......36                                  
3...31.......48                                  
12...29.......39                                 
12...20.......45                                 
13...34.......45                                 
11...25.......42
7...22.......40
17...29.......40
ns: 1288: invalid command name "1288"
    while executing
"1288"
So you will have to find out which of your lines are generating "1288",
which is not a figure that appears in the file as the number "1288".
-
Here is a link taking you.
Where do I need to run his store
attach files------>>>hsoft_project.tcl

Last edited by hd_uni_pro; 03-15-2014 at 02:56 AM.
 
Old 03-15-2014, 05:04 AM   #10
hd_uni_pro
Member
 
Registered: Mar 2014
Posts: 31

Rep: Reputation: Disabled
Exclamation resault

Quote:
Originally Posted by hsoft_project View Post
hello guys . i write a simple tcl code for ns 2.34 this code is

#Leach Nam Protocol (hamed.gh) ======================================================================
# Define options
# ======================================================================
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(ifqlen) 51
set val(nn) 51
set val(rp) DumbAgent
set val(en) EnergyModel/Battery
set val(x) 1000
set val(y) 1000
set val(stop) 150
set val(range) 100
set local(energy) 10.0
set trace(mac) ON
set val(start) 0.0
set val(stop) [expr $val(start) + 200.0]

set trace(router) ON

set trace(agent) ON

set trace(movement) ON
set val(LOOP) 0
#=====================================================================
#Main Program
#=====================================================================
#================================================
proc TwoRay { Pt Gt Gr ht hr L d lambda } {
set crossover_dist [expr (4 * 3.14159265359 * $ht * $hr) / $lambda]

if { $d < $crossover_dist } {
return [Friis $Pt $Gt $Gr $lambda $L $d]
} else {
return [expr $Pt * $Gt * $Gr * ($hr * $hr * $ht * $ht) / ($d * $d * $d * $d * $L)]
}
}
#===============================================
#============================================
#============calculate distance===================
proc calcDist { node_a node_b } {

set x1 [$node_a set X_]
set y1 [$node_a set Y_]

set x2 [$node_b set X_]
set y2 [$node_b set Y_]

set distance [ expr sqrt(($x2-$x1)*($x2-$x1)+($y2-$y1)*($y2-$y1)) ]
return $distance

}

#===================================================
#================wirless setting===================

proc setup_mica2 { antenna range } {

puts "Setting up mica 2 mote with $antenna and range = $range"

#Phy/WirelessPhy set CPThresh_ 10.0
#Phy/WirelessPhy set CSThresh_ 1.559e-11
#Phy/WirelessPhy set RXThresh_ 2.78869e-09 ; # 100 meters
#Phy/WirelessPhy set RXThresh_ 1.11548e-08 ; # 50 meters
#Phy/WirelessPhy set Rb_ 2*1e6

Phy/WirelessPhy set Pt_ 0.281838
Phy/WirelessPhy set freq_ 2.4e09
Phy/WirelessPhy set L_ 1.0
Phy/WirelessPhy set lambda_ 0.125
Phy/WirelessPhy set RXThresh_ [TwoRay 0.281838 [$antenna set Gt_] [$antenna set Gr_] 0.8 0.8 1.0 $range 0.125]
Phy/WirelessPhy set bandwidth_ 280.8*10e3 ;#28.8 kbps

Node/MobileNode/SensorNode set sensingPower_ 0.015
Node/MobileNode/SensorNode set processingPower 0.024
Node/MobileNode/SensorNode set instructionsPerSecond_ 8000000

}
#===============================================
#===============================random intigar
proc RandomInteger4 {min max} {
return [expr {int(rand()*($max-$min+1)+$min)}]
}
proc RandomInteger3 {min max} {
return [expr {rand()*($max-$min+1)+$min}]
}
#==============================================
## Creating node objects..
### Creating The WIRELESS NODES color

set a ""
set b ""
set c ""
set val(deployment) 0
#==============end of calculate distance==========
#=======================================================
#=============================create common node===========

#============================================================
proc create_common_node {start stop reload} {
global val ns topo local trace claster1 claster2 claster3 node_ a b c


Node/MobileNode/SensorNode set sensingPower_ 10.015
Node/MobileNode/SensorNode set processingPower 0.024
Node/MobileNode/SensorNode set instructionsPerSecond_ 8000000





$ns node-config -sensorNode ON \
-adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-energyModel $val(en) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace $trace(agent) \
-routerTrace $trace(router) \
-macTrace $trace(mac) \
-rxPower 0.024 \
-txPower 0.036 \
-initialEnergy $local(energy) \
-movementTrace $trace(movement)

## comoon node energy coniguration
$ns node-config -energyModel EnergyModel \
-initialEnergy 20 \
-txPower 0.9 \
-rxPower 0.8 \
-idlePower 0.0 \
-sensePower 0.0175
#################################

if { $reload == "false"} {
for {set i 0} {$i < $val(nn) } { incr i } {
set node_($i) [$ns node]
}





## Provide initial location of mobilenodes..

if {$val(nn) >0} {
for {set i 1} {$i < $val(nn) } { incr i } {
if { $i <= 17 } {
set xx [RandomInteger3 0 600]
set yy [RandomInteger3 0 333.3333];
$node_($i) set X_ $xx
$node_($i) set Y_ $yy
}
if { $i > 17 && $i <= 34} {
set xx [RandomInteger3 600 1200]
set yy [RandomInteger3 333.3333 666.6666];
$node_($i) set X_ $xx
$node_($i) set Y_ $yy
}
if { $i > 34 && $i <= $val(nn)} {
set xx [RandomInteger3 1200 1800]
set yy [RandomInteger3 666.6666 1000];
$node_($i) set X_ $xx
$node_($i) set Y_ $yy
}
}
}
for {set i 0} {$i < $val(nn)} { incr i } {
# 30 defines the node size for nam..

$ns initial_node_pos $node_($i) 40


}

}
set claster1 [RandomInteger4 0 17]
set claster2 [RandomInteger4 18 34]
set claster3 [RandomInteger4 35 50]

set a $node_($claster1)
set b $node_($claster2)
set c $node_($claster3)
set xxx [expr int([$node_($claster2) set X_])]

#=============================================
#$ns at 0.1 "$node_($claster1) setdest $xxx [expr $xxx+1] 2.0"

puts "$claster1...$claster2.......$claster3"
for {set i 0} {$i <$val(nn)} {incr i} {
if {$i <=17} {
set udp($i) [$ns create-connection UDP $node_($claster1) Null $node_($i) 1]
$udp($i) set fid_ $i
set cbr($i) [$udp($i) attach-app Traffic/CBR]
$cbr($i) set packetSize_ 1000
$cbr($i) set interval_ .07
$ns at $start "$cbr($i) start"
$ns at $stop "$cbr($i) stop"

set c_($i) [calcDist $node_($claster1) $node_($i)]
#$node_($i) label $c_($i)
#$ns at $start "$node_($i) label $c_($i)"

}
if {$i >17 && $i <= 34} {
set udp($i) [$ns create-connection UDP $node_($claster2) Null $node_($i) 1]
$udp($i) set fid_ $i
set cbr($i) [$udp($i) attach-app Traffic/CBR]
$cbr($i) set packetSize_ 1000
$cbr($i) set interval_ .07
$ns at $start "$cbr($i) start"
$ns at $stop "$cbr($i) stop"
set c_($i) [calcDist $node_($claster2) $node_($i)]
#$node_($i) label $c_($i)
#$ns at $start "$node_($i) label $c_($i)"

}
if {$i > 34 && $i <=51} {
set udp($i) [$ns create-connection UDP $node_($claster3) Null $node_($i) 1]
$udp($i) set fid_ $i
set cbr($i) [$udp($i) attach-app Traffic/CBR]
$cbr($i) set packetSize_ 1000
$cbr($i) set interval_ .07
$ns at $start "$cbr($i) start"
$ns at $stop "$cbr($i) stop"
set c_($i) [calcDist $node_($claster3) $node_($i)]
#$node_($i) label $c_($i)
#$ns at $start "$node_($i) label $c_($i)"

}
}

for {set i 0} {$i < $val(nn)} {incr i} {
if {$i != $claster1 && $i != $claster2 && $i != $claster3} {
$node_($i) color darkgreen
$ns at $start "$node_($i) color darkgreen"
} else {
$node_($i) color cyan
$ns at $start "$node_($i) color cyan"
#$node_($i) shape box
#$ns at $start "$node_($i) shape box"


}
}
#set enrg [expr int([$node_($claster2) set $val(en))]

}
#============================end of create common node=================
#====================================================================
#============================Create Access Point======================

proc accessPoint {start stop} {
global val ns topo local trace claster1 claster2 claster3 node_ a b c

#================================================================


#===============================================================
set accesp [$ns node]
set ac [$ns node]
$ac set X_ 1800
$ac set Y_ 0.0
$ac set Z_ 0.0
$accesp shape box
$ns at $start "$accesp shape box"
$accesp set X_ 1800
$accesp set Y_ 0.0
$accesp set Z_ 0.0
$ns at $start "$accesp label Sink"
$ns initial_node_pos $ac 20
$ns initial_node_pos $accesp 200
$ns duplex-link $accesp $ac 10Mb 10ms DropTail
set tcp1 [new Agent/TCP]
$tcp1 set class_ 2
set sink1 [new Agent/TCPSink]
$ns attach-agent $accesp $tcp1
$ns attach-agent $ac $sink1
$ns connect $tcp1 $sink1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
$ns at $start "$ftp1 start"

}
#===============================end of create access point============
# create new simulation
set ns [new Simulator]
# create topology
debug 1
# create nam animator simulation
set nam_trace [open a.nam w]
#create trace file
set all_trace [open a.trace w]


#================start finish function==============================
#function of finish simulation




## Creating node objects..
### Creating The WIRELESS NODES color


#=======================end of finish function=====================


$ns trace-all $all_trace
$ns namtrace-all-wireless $nam_trace $val(x) $val(y)

#define topology
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god [expr $val(nn)+3]
set chan_1_ [new $val(chan)]

#create god
set rng [new RNG]
$rng seed [clock seconds]
set secound [clock seconds]
#==============================================
#global node setting

#
#====================================================
$ns color 1 dodgerblue
$ns color 2 blue
$ns color 3 cyan
$ns color 4 green
$ns color 5 yellow
$ns color 6 black
$ns color 7 magenta
$ns color 8 gold
$ns color 9 red

$ns at 0.0 [create_common_node 0.0 1.0 "false"]
$ns at 1.25 [create_common_node 1.25 2.0 "true"]
$ns at 2.25 [create_common_node 2.25 3.0 "true"]
$ns at 3.25 [create_common_node 3.25 4.5 "true"]
$ns at 4.8 [create_common_node 4.8 5.8 "true"]
$ns at 6.0 [create_common_node 6.0 7.0 "true"]
$ns at 7.3 [create_common_node 7.3 8.5 "true"]
$ns at 8.8 [create_common_node 8.8 10.0 "true"]
#$ns at 10.2 [create_common_node 10.2 11.2 "true"]
$ns at 0.0 [accessPoint 0.0 1.3]
$ns at 0.0 "$ns trace-annotate \"Deploy Node In Panel\""
$ns at 0.3 "$ns trace-annotate \"select cluster head and send pakets\""
$ns at 200.0 "finish"

proc finish {} {
global ns nam_trace all_trace c_ val

$ns flush-trace
close $nam_trace
close $all_trace
#start nam application for graphic simulation
$ns halt
exec nam a.nam &
#exit simulation
exit 0

}

$ns run


and i run this code showen this error (ns: 1288: invalid command name "1288"
while executing
)

and i remove this line $ns at $start "$ftp1 start" in function accessPoint this code is run but not start ftp connection
please help me
hello and don't be tired .
You did result
 
  


Reply


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
NS2: Cygwin error "couldn't create signal error, win32 error 161" bhartideswal General 2 05-04-2013 03:22 AM
Can we control FTP rate in ns2 as wat we did for CBR? bsyew Linux - Networking 0 08-03-2012 04:03 AM
how to start writing codes in ns2? ziajustin Linux - Newbie 3 03-25-2012 02:55 PM
active and passive modes of FTP in ns2 birdbn@yahoo.com Linux - Software 0 06-27-2011 06:13 AM
How to configure the FTP rate in NS2.28 under Fedora platform? alloiatry Linux - Software 0 12-24-2010 10:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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