LinuxQuestions.org
Help answer threads with 0 replies.
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 07-06-2011, 07:24 AM   #1
saye_s
LQ Newbie
 
Registered: Jun 2011
Posts: 4

Rep: Reputation: Disabled
aqua sim in ns2 - DBR protocol


i am new to aqua sim. I want to write a tcl code which use DBR as a routing protocol. i searched for finding such codes but I couldn't find any. I would really appreciate it if you would be so kind as to guide me or send me one, please.

my email: saye_shamisa@yahoo.com
 
Old 07-07-2011, 04:10 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,606

Rep: Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960
Quote:
Originally Posted by saye_s View Post
i am new to aqua sim. I want to write a tcl code which use DBR as a routing protocol. i searched for finding such codes but I couldn't find any. I would really appreciate it if you would be so kind as to guide me or send me one, please.
Sorry, that's not the way things work. This is a community forum, not a place to come for free, personalized one-on-one tech support by email.

And not even the NS Wiki has anything on DBR (http://nsnam.isi.edu/nsnam/index.php/Main_Page)...there is DFR and DBF. If you mean the depth-based routing protocol, you will have to write "codes" yourself, it seems.
 
0 members found this post helpful.
Old 07-08-2011, 04:10 AM   #3
saye_s
LQ Newbie
 
Registered: Jun 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
Sorry, that's not the way things work. This is a community forum, not a place to come for free, personalized one-on-one tech support by email.

And not even the NS Wiki has anything on DBR (http://nsnam.isi.edu/nsnam/index.php/Main_Page)...there is DFR and DBF. If you mean the depth-based routing protocol, you will have to write "codes" yourself, it seems.


HI

Aqua-sim enable us to use ns for simulate underwater protocols. If you install the package then you have DBR and VBF and ... as a routing protocol. It doesn't need to write the codes your self.
 
0 members found this post helpful.
Old 07-08-2011, 10:13 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,606

Rep: Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960
Quote:
Originally Posted by saye_s View Post
HI
Aqua-sim enable us to use ns for simulate underwater protocols. If you install the package then you have DBR and VBF and ... as a routing protocol. It doesn't need to write the codes your self.
Right...so again, if you want "codes" for DBR, you will have to write them yourself, as there don't appear to be any pre-existing ones. But if you say it PROVIDES the codes, and then say you don't need to write them, what exactly is the point of your original question and follow-up???
 
Old 07-10-2011, 04:06 AM   #5
saye_s
LQ Newbie
 
Registered: Jun 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
Right...so again, if you want "codes" for DBR, you will have to write them yourself, as there don't appear to be any pre-existing ones. But if you say it PROVIDES the codes, and then say you don't need to write them, what exactly is the point of your original question and follow-up???
yes, DBR is a routing protocol and you can use it in tcl script as you can use for example AODV but I can't write such tcl script. I changed an example for vbf routing. the changhed example is as following:



set opt(chan) Channel/UnderwaterChannel
set opt(prop) Propagation/UnderwaterPropagation
set opt(netif) Phy/UnderwaterPhy
set opt(mac) Mac/UnderwaterMac/BroadcastMac
set opt(ifq) Queue/DropTail/PriQueue
set opt(ll) LL
set opt(energy) EnergyModel
set opt(txpower) 2.0
set opt(rxpower) 0.75
set opt(initialenergy) 10000
set opt(idlepower) 0.008
set opt(ant) Antenna/OmniAntenna
set opt(filters) GradientFilter ;# options can be one or more of
;# TPP/OPP/Gear/Rmst/SourceRoute/Log/TagFilter
set opt(minspeed) 0 ;#minimum speed of node
set opt(maxspeed) 3 ;#maximum speed of node
set opt(speed) 0.5 ;#speed of node
set opt(position_update_interval) 0.3 ;# the length of period to update node's position
set opt(packet_size) 50 ;#50 bytes
set opt(routing_control_packet_size) 20 ;#bytes

set opt(ifqlen) 50 ;# max queue length in if
set opt(nn) 6 ;# number of nodes
set opt(x) 1000 ;# X dimension of the topography
set opt(y) 10 ;# Y dimension of the topography
set opt(z) 10
set opt(seed) 11
set opt(stop) 500 ;# simulation time
set opt(prestop) 90 ;# time to prepare to stop
set opt(tr) "a.tr" ;# trace file
set opt(datafile) "a.data"
set opt(nam) "a.nam" ;# nam file
#*********************************Melease change next line***************
#set opt(adhocRouting) Vectorbasedforward
set opt(adhocRouting) DBR
#*********************************Me:width is for vbf and we didn't need it in dbr ***************
#set opt(width) 100
set opt(interval) 10.0
set opt(range) 100 ;#range of each node in meters

if { $argc > 0 } {
set opt(seed) [lindex $argv 0]
set opt(nn) [lindex $argv 1]
set opt(datafile) [lindex $argv 2]
}

puts "the file name is $opt(datafile)"
puts "the sending interval is $opt(interval)"

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

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 Z_ 0.05
Antenna/OmniAntenna set Gt_ 1.0
Antenna/OmniAntenna set Gr_ 1.0
#********************************* Melease omit the next line, you don't need it for dbr ***************
#Agent/Vectorbasedforward set hop_by_hop_ 0

Mac/UnderwaterMac set bit_rate_ 1.0e4 ;#10kbps
Mac/UnderwaterMac set encoding_efficiency_ 1
Mac/UnderwaterMac/BroadcastMac set packetheader_size_ 0 ;# #of bytes

# Initialize the SharedMedia interface with parameters to make
# it work like the 914MHz Lucent WaveLAN DSSS radio interface
Phy/UnderwaterPhy set CPThresh_ 10 ;#10.0
Phy/UnderwaterPhy set CSThresh_ 0 ;#1.559e-11
Phy/UnderwaterPhy set RXThresh_ 0 ;#3.652e-10
#Phy/WirelessPhy set Rb_ 2*1e6
Phy/UnderwaterPhy set Pt_ 0.2818
Phy/UnderwaterPhy set freq_ 25 ;# 25khz
Phy/UnderwaterPhy set K_ 2.0 ;# spherical spreading

# =================================================================
# Main Program
# =================================================================

#
# Initialize Global Variables
#
#set sink_ 1
set ns_ [new Simulator]
set topo [new Topography]

$topo load_cubicgrid $opt(x) $opt(y) $opt(z)
$ns_ use-newtrace
set tracefd [open $opt(tr) w]
$ns_ trace-all $tracefd

set nf [open $opt(nam) w]
$ns_ namtrace-all-wireless $nf $opt(x) $opt(y)


set data [open $opt(datafile) a]


set total_number [expr $opt(nn)-1]
set god_ [create-god $opt(nn)]


$ns_ at 0.0 "$god_ set_filename $opt(datafile)"


set chan_1_ [new $opt(chan)]


global defaultRNG
$defaultRNG seed $opt(seed)


$ns_ node-config -adhocRouting $opt(adhocRouting) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
#-channelType $opt(chan) \
-agentTrace OFF \
-routerTrace OFF \
-macTrace ON\
-topoInstance $topo\
-energyModel $opt(energy)\
-txPower $opt(txpower)\
-rxPower $opt(rxpower)\
-initialEnergy $opt(initialenergy)\
-idlePower $opt(idlepower)\
-channel $chan_1_

#********************************* Melease omit the next line, you don't need it for dbr ***************
#puts "Width=$opt(width)"


#Set the Sink node


set node_(0) [ $ns_ node 0]
$node_(0) set sinkStatus_ 1
$god_ new_node $node_(0)
$node_(0) set X_ 500
$node_(0) set Y_ 0
$node_(0) set Z_ 0
$node_(0) set passive 1

set rt [$node_(0) set ragent_]
$rt set control_packet_size $opt(routing_control_packet_size)

set a_(0) [new Agent/UWSink]
$ns_ attach-agent $node_(0) $a_(0)
#***********Me: see ns2.30/tcl/lib/ns-agent.tcl for more infrormation about UWSink and attach-vectorbasedforward.********
#***********Me: I have one question, shouldn't I add a function in ns-agent.tcl for depth of node for dbr usage?*************
#$a_(0) attach-vectorbasedforward $opt(width)
$a_(0) cmd set-range $opt(range)
$a_(0) cmd set-target-x -20
$a_(0) cmd set-target-y -10
$a_(0) cmd set-target-z -20
$a_(0) cmd set-filename $opt(datafile)
$a_(0) cmd set-packetsize $opt(packet_size) ;# # of bytes



set node_(1) [ $ns_ node 1]
$node_(1) set sinkStatus_ 1
$god_ new_node $node_(1)
$node_(1) set X_ 440
$node_(1) set Y_ 0
$node_(1) set Z_ 0
$node_(1) set passive 1

set rt [$node_(1) set ragent_]
$rt set control_packet_size $opt(routing_control_packet_size)
$node_(1) set max_speed $opt(maxspeed)
$node_(1) set min_speed $opt(minspeed)
$node_(1) set position_update_interval_ $opt(position_update_interval)
set a_(1) [new Agent/UWSink]
$ns_ attach-agent $node_(1) $a_(1)
#***********Me: see ns2.30/tcl/lib/ns-agent.tcl for more infrormation about UWSink and attach-vectorbasedforward.********
#***********Me: I have one question, shouldn't I add a function in ns-agent.tcl for depth of node for dbr usage?*************

#$a_(1) attach-vectorbasedforward $opt(width)
$a_(1) cmd set-range $opt(range)
$a_(1) cmd set-target-x -20
$a_(1) cmd set-target-y -10
$a_(1) cmd set-target-z -20
$a_(1) cmd set-filename $opt(datafile)
$a_(1) cmd set-packetsize $opt(packet_size) ;# # of bytes
#$node_(1) move

set node_(2) [ $ns_ node 2]
$node_(2) set sinkStatus_ 1
$node_(2) random-motion 1
$node_(2) set max_speed $opt(maxspeed)
$node_(2) set min_speed $opt(minspeed)
$node_(2) set position_update_interval_ $opt(position_update_interval)

$god_ new_node $node_(2)
$node_(2) set X_ 380
$node_(2) set Y_ 0
$node_(2) set Z_ 0
$node_(2) set passive 1

set rt [$node_(2) set ragent_]
$rt set control_packet_size $opt(routing_control_packet_size)

set a_(2) [new Agent/UWSink]
$ns_ attach-agent $node_(2) $a_(2)
#***********Me: see ns2.30/tcl/lib/ns-agent.tcl for more infrormation about UWSink and attach-vectorbasedforward.********
#***********Me: I have one question, shouldn't I add a function in ns-agent.tcl for depth of node for dbr usage?*************
#$a_(2) attach-vectorbasedforward $opt(width)
$a_(2) cmd set-range $opt(range)
$a_(2) cmd set-target-x -20
$a_(2) cmd set-target-y -10
$a_(2) cmd set-target-z -20
$a_(2) cmd set-filename $opt(datafile)
$a_(2) cmd set-packetsize $opt(packet_size) ;# # of bytes
#$node_(2) move


set node_(3) [ $ns_ node 3]
$node_(3) set sinkStatus_ 1
$node_(3) random-motion 1

$node_(3) set max_speed $opt(maxspeed)
$node_(3) set min_speed $opt(minspeed)
$node_(3) set position_update_interval_ $opt(position_update_interval)

$god_ new_node $node_(3)
$node_(3) set X_ 320
$node_(3) set Y_ 0
$node_(3) set Z_ 0
$node_(3) set passive 1

set rt [$node_(3) set ragent_]
$rt set control_packet_size $opt(routing_control_packet_size)

set a_(3) [new Agent/UWSink]
$ns_ attach-agent $node_(3) $a_(3)
#***********Me: see ns2.30/tcl/lib/ns-agent.tcl for more infrormation about UWSink and attach-vectorbasedforward.********
#***********Me: I have one question, shouldn't I add a function in ns-agent.tcl for depth of node for dbr usage?*************
#$a_(3) attach-vectorbasedforward $opt(width)
$a_(3) cmd set-range $opt(range)
$a_(3) cmd set-target-x -20
$a_(3) cmd set-target-y -10
$a_(3) cmd set-target-z -20
$a_(3) cmd set-filename $opt(datafile)
$a_(3) cmd set-packetsize $opt(packet_size) ;# # of bytes




set node_(4) [ $ns_ node 4]
$node_(4) set sinkStatus_ 1
$node_(4) random-motion 1

$node_(4) set max_speed $opt(maxspeed)
$node_(4) set min_speed $opt(minspeed)
$node_(4) set position_update_interval_ $opt(position_update_interval)

$god_ new_node $node_(4)
$node_(4) set X_ 260
$node_(4) set Y_ 0
$node_(4) set Z_ 0
$node_(4) set passive 1

set rt [$node_(4) set ragent_]
$rt set control_packet_size $opt(routing_control_packet_size)

set a_(4) [new Agent/UWSink]
$ns_ attach-agent $node_(4) $a_(4)
#***********Me: see ns2.30/tcl/lib/ns-agent.tcl for more infrormation about UWSink and attach-vectorbasedforward.********
#***********Me: I have one question, shouldn't I add a function in ns-agent.tcl for depth of node for dbr usage?*************
#$a_(4) attach-vectorbasedforward $opt(width)
$a_(4) cmd set-range $opt(range)
$a_(4) cmd set-target-x -20
$a_(4) cmd set-target-y -10
$a_(4) cmd set-target-z -20
$a_(4) cmd set-filename $opt(datafile)
$a_(4) cmd set-packetsize $opt(packet_size) ;# # of bytes




#Set the source node
set node_($total_number) [$ns_ node $total_number]
$god_ new_node $node_($total_number)

$node_($total_number) set sinkStatus_ 1

$node_($total_number) set X_ 200
$node_($total_number) set Y_ 0
$node_($total_number) set Z_ 0
$node_($total_number) set-cx 200
$node_($total_number) set-cy 0
$node_($total_number) set-cz 0
set rt [$node_($total_number) set ragent_]
$rt set control_packet_size $opt(routing_control_packet_size)


set a_($total_number) [new Agent/UWSink]
$ns_ attach-agent $node_($total_number) $a_($total_number)
#***********Me: see ns2.30/tcl/lib/ns-agent.tcl for more infrormation about UWSink and attach-vectorbasedforward.********
#***********Me: I have one question, shouldn't I add a function in ns-agent.tcl for depth of node for dbr usage?*************
#$a_($total_number) attach-vectorbasedforward $opt(width)
$a_($total_number) cmd set-range $opt(range)
$a_($total_number) cmd set-target-x 500
$a_($total_number) cmd set-target-y 0
$a_($total_number) cmd set-target-z 0
$a_($total_number) cmd set-filename $opt(datafile)
$a_($total_number) cmd set-packetsize $opt(packet_size) ;# # of bytes
$a_($total_number) set data_rate_ [expr 1.0/$opt(interval)]

# make nam workable
set node_size 10
for {set k 0} { $k<$opt(nn)} {incr k} {
$ns_ initial_node_pos $node_($k) $node_size
}


set opt(stop2) [expr $opt(stop)+200]


puts "Node $total_number is sending first!!"
$ns_ at 1.33 "$a_($total_number) cbr-start"
$ns_ at $opt(stop).001 "$a_($total_number) terminate"

$ns_ at $opt(stop2).002 "$a_(0) terminate"


$ns_ at $opt(stop2).003 "$god_ compute_energy"
$ns_ at $opt(stop2).004 "$ns_ nam-end-wireless $opt(stop)"
$ns_ at $opt(stop2).005 "puts \"NS EXISTING...\"; $ns_ halt"


puts $data "New simulation...."
#*********************************Me:width is for vbf and we didn't need it in dbr, please change the next line ***************
# puts $data "nodes = $opt(nn), maxspeed = $opt(maxspeed), minspeed = $opt(minspeed), random_seed = $opt(seed), sending_interval_=$opt(interval), width=$opt(width)"
puts $data "nodes = $opt(nn), maxspeed = $opt(maxspeed), minspeed = $opt(minspeed), random_seed = $opt(seed), sending_interval_=$opt(interval))"
puts $data "x= $opt(x) y= $opt(y) z= $opt(z)"
close $data
puts "starting Simulation..."
$ns_ run



but when I run it, it says:

the file name is a.data
the sending interval is 10.0
num_nodes is set 6
INITIALIZE THE LIST xListHead
Node 5 is sending first!!
starting Simulation...
GOD: the old file name istest.data
GOD: the new file name isa.data
Segmentation fault


I SAid I need an example of using DBR in tcl to compare with mine. I don't know why the segmentation fault occure. when I run the unchanged code, it runs without any problem.

if you need to see dbr.cc code or the others code just let me know please. Thanks in advance.

Last edited by saye_s; 07-10-2011 at 04:22 AM.
 
1 members found this post helpful.
Old 07-10-2011, 10:35 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,606

Rep: Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960
Quote:
Originally Posted by saye_s View Post
yes, DBR is a routing protocol and you can use it in tcl script as you can use for example AODV but I can't write such tcl script. I changed an example for vbf routing. the changhed example is as following:

I said I need an example of using DBR in tcl to compare with mine. I don't know why the segmentation fault occure. when I run the unchanged code, it runs without any problem.
Yes, and as I said, there don't appear to be any, and that you are going to have to write your own. The only way to make it work is for you to learn the language, and work through the errors, the same as everyone else would.
Quote:
if you need to see dbr.cc code or the others code just let me know please. Thanks in advance.
We will be glad to assist...is the code you posted above exactly like you've run it?

Last edited by TB0ne; 07-10-2011 at 10:40 AM.
 
Old 09-05-2011, 03:00 PM   #7
afsane
LQ Newbie
 
Registered: Aug 2011
Posts: 5

Rep: Reputation: Disabled
Hi,my question is about my DBR & VBF TCL script.when I run VBF it says
invalid command name "Agent/Vectorbasedforward"
while executing
"Agent/Vectorbasedforward set hop_by_hop_0"

And when I run DBR it says:
invalid command name "Mac/UnderwaterMac"
while executing
"Mac/UnderwaterMac set bit_rate_1.0e4"

I searched a lot but I could not find the problem,I will be thankful if you help me and tell me what should I do?
I have another request.I need TCL script for any underwater routing protocol.Thanks a lot for your help
 
Old 09-06-2011, 06:14 AM   #8
saye_s
LQ Newbie
 
Registered: Jun 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Hi

please write your code, I should take a look at it first.
 
Old 09-06-2011, 08:46 AM   #9
afsane
LQ Newbie
 
Registered: Aug 2011
Posts: 5

Rep: Reputation: Disabled
This is VBF tcl script:
set opt(chan) Channel/UnderwaterChannel
set opt(prop) Propagation/UnderwaterPropagation
set opt(netif) Phy/UnderwaterPhy
set opt(mac) Mac/UnderwaterMac/BroadcastMac
set opt(ifq) Queue/DropTail/PriQueue
set opt(ll) LL
set opt(energy) EnergyModel
set opt(txpower) 2.0
set opt(rxpower) 0.75
set opt(initialenergy) 10000
set opt(idlepower) 0.008
set opt(ant) Antenna/OmniAntenna
set opt(filters) GradientFilter ;# options can be one or more of
;# TPP/OPP/Gear/Rmst/SourceRoute/Log/TagFilter
set opt(minspeed) 0 ;#minimum speed of node
set opt(maxspeed) 3 ;#maximum speed of node
set opt(speed) 0.5 ;#speed of node
set opt(position_update_interval) 0.3 ;# the length of period to update node's position
set opt(packet_size) 50 ;#50 bytes
set opt(routing_control_packet_size) 20 ;#bytes

set opt(ifqlen) 50 ;# max queue length in if
set opt(nn) 6 ;# number of nodes
set opt(x) 1000 ;# X dimension of the topography
set opt(y) 10 ;# Y dimension of the topography
set opt(z) 10
set opt(seed) 11
set opt(stop) 500 ;# simulation time
set opt(prestop) 90 ;# time to prepare to stop
set opt(tr) "a.tr" ;# trace file
set opt(datafile) "a.data"
set opt(nam) "a.nam" ;# nam file
set opt(adhocRouting) Vectorbasedforward;
set opt(width) 100
set opt(interval) 10.0
set opt(range) 100 ;#range of each node in meters

if { $argc > 0 } {
set opt(seed) [lindex $argv 0]
set opt(nn) [lindex $argv 1]
set opt(datafile) [lindex $argv 2]
}

puts "the file name is $opt(datafile)"
puts "the sending interval is $opt(interval)"
# ==================================================================

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 Z_ 0.05
Antenna/OmniAntenna set Gt_ 1.0
Antenna/OmniAntenna set Gr_ 1.0
Agent/Vectorbasedforward set hop_by_hop_0

Mac/UnderwaterMac set bit_rate_ 1.0e4 ;#10kbps
Mac/UnderwaterMac set encoding_efficiency_ 1
Mac/UnderwaterMac/BroadcastMac set packetheader_size_ 0 ;# #of bytes

# Initialize the SharedMedia interface with parameters to make
# it work like the 914MHz Lucent WaveLAN DSSS radio interface
Phy/UnderwaterPhy set CPThresh_ 10 ;#10.0
Phy/UnderwaterPhy set CSThresh_ 0 ;#1.559e-11
Phy/UnderwaterPhy set RXThresh_ 0 ;#3.652e-10
#Phy/WirelessPhy set Rb_ 2*1e6
Phy/UnderwaterPhy set Pt_ 0.2818
Phy/UnderwaterPhy set freq_ 25 ;# 25khz
Phy/UnderwaterPhy set K_ 2.0 ;# spherical spreading

# =================================================================
# Main Program
# =================================================================

#
# Initialize Global Variables
#
#set sink_ 1
set ns_ [new Simulator]
set topo [new Topography]

$topo load_cubicgrid $opt(x) $opt(y) $opt(z)
$ns_ use-newtrace
set tracefd [open $opt(tr) w]
$ns_ trace-all $tracefd

set nf [open $opt(nam) w]
$ns_ namtrace-all-wireless $nf $opt(x) $opt(y)


set data [open $opt(datafile) a]


set total_number [expr $opt(nn)-1]
set god_ [create-god $opt(nn)]


$ns_ at 0.0 "$god_ set_filename $opt(datafile)"


set chan_1_ [new $opt(chan)]


global defaultRNG
$defaultRNG seed $opt(seed)


$ns_ node-config -adhocRouting $opt(adhocRouting) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
#-channelType $opt(chan) \
-agentTrace ON \
-routerTrace ON \
-macTrace ON\
-topoInstance $topo\
-energyModel $opt(energy)\
-txPower $opt(txpower)\
-rxPower $opt(rxpower)\
-initialEnergy $opt(initialenergy)\
-idlePower $opt(idlepower)\
-channel $chan_1_
puts "Width=$opt(width)"


#Set the Sink node


set node_(0) [ $ns_ node 0]
$node_(0) set sinkStatus_ 1
$god_ new_node $node_(0)
$node_(0) set X_ 500
$node_(0) set Y_ 0
$node_(0) set Z_ 0
$node_(0) set passive 1

set rt [$node_(0) set ragent_]
$rt set control_packet_size $opt(routing_control_packet_size)

set a_(0) [new Agent/UWSink]
$ns_ attach-agent $node_(0) $a_(0)
$a_(0) attach-vectorbasedforward $opt(width)
$a_(0) cmd set-range $opt(range)
$a_(0) cmd set-target-x -20
$a_(0) cmd set-target-y -10
$a_(0) cmd set-target-z -20
$a_(0) cmd set-filename $opt(datafile)
$a_(0) cmd set-packetsize $opt(packet_size) ;# # of bytes



set node_(1) [ $ns_ node 1]
$node_(1) set sinkStatus_ 1
$god_ new_node $node_(1)
$node_(1) set X_ 440
$node_(1) set Y_ 0
$node_(1) set Z_ 0
$node_(1) set passive 1

set rt [$node_(1) set ragent_]
$rt set control_packet_size $opt(routing_control_packet_size)
$node_(1) set max_speed $opt(maxspeed)
$node_(1) set min_speed $opt(minspeed)
$node_(1) set position_update_interval_ $opt(position_update_interval)
set a_(1) [new Agent/UWSink]
$ns_ attach-agent $node_(1) $a_(1)
$a_(1) attach-vectorbasedforward $opt(width)
$a_(1) cmd set-range $opt(range)
$a_(1) cmd set-target-x -20
$a_(1) cmd set-target-y -10
$a_(1) cmd set-target-z -20
$a_(1) cmd set-filename $opt(datafile)
$a_(1) cmd set-packetsize $opt(packet_size) ;# # of bytes
#$node_(1) move

set node_(2) [ $ns_ node 2]
$node_(2) set sinkStatus_ 1
$node_(2) random-motion 1
$node_(2) set max_speed $opt(maxspeed)
$node_(2) set min_speed $opt(minspeed)
$node_(2) set position_update_interval_ $opt(position_update_interval)

$god_ new_node $node_(2)
$node_(2) set X_ 380
$node_(2) set Y_ 0
$node_(2) set Z_ 0
$node_(2) set passive 1

set rt [$node_(2) set ragent_]
$rt set control_packet_size $opt(routing_control_packet_size)

set a_(2) [new Agent/UWSink]
$ns_ attach-agent $node_(2) $a_(2)
$a_(2) attach-vectorbasedforward $opt(width)
$a_(2) cmd set-range $opt(range)
$a_(2) cmd set-target-x -20
$a_(2) cmd set-target-y -10
$a_(2) cmd set-target-z -20
$a_(2) cmd set-filename $opt(datafile)
$a_(2) cmd set-packetsize $opt(packet_size) ;# # of bytes
#$node_(2) move


set node_(3) [ $ns_ node 3]
$node_(3) set sinkStatus_ 1
$node_(3) random-motion 1

$node_(3) set max_speed $opt(maxspeed)
$node_(3) set min_speed $opt(minspeed)
$node_(3) set position_update_interval_ $opt(position_update_interval)

$god_ new_node $node_(3)
$node_(3) set X_ 320
$node_(3) set Y_ 0
$node_(3) set Z_ 0
$node_(3) set passive 1

set rt [$node_(3) set ragent_]
$rt set control_packet_size $opt(routing_control_packet_size)

set a_(3) [new Agent/UWSink]
$ns_ attach-agent $node_(3) $a_(3)
$a_(3) attach-vectorbasedforward $opt(width)
$a_(3) cmd set-range $opt(range)
$a_(3) cmd set-target-x -20
$a_(3) cmd set-target-y -10
$a_(3) cmd set-target-z -20
$a_(3) cmd set-filename $opt(datafile)
$a_(3) cmd set-packetsize $opt(packet_size) ;# # of bytes




set node_(4) [ $ns_ node 4]
$node_(4) set sinkStatus_ 1
$node_(4) random-motion 1

$node_(4) set max_speed $opt(maxspeed)
$node_(4) set min_speed $opt(minspeed)
$node_(4) set position_update_interval_ $opt(position_update_interval)

$god_ new_node $node_(4)
$node_(4) set X_ 260
$node_(4) set Y_ 0
$node_(4) set Z_ 0
$node_(4) set passive 1

set rt [$node_(4) set ragent_]
$rt set control_packet_size $opt(routing_control_packet_size)

set a_(4) [new Agent/UWSink]
$ns_ attach-agent $node_(4) $a_(4)
$a_(4) attach-vectorbasedforward $opt(width)
$a_(4) cmd set-range $opt(range)
$a_(4) cmd set-target-x -20
$a_(4) cmd set-target-y -10
$a_(4) cmd set-target-z -20
$a_(4) cmd set-filename $opt(datafile)
$a_(4) cmd set-packetsize $opt(packet_size) ;# # of bytes




#Set the source node
set node_($total_number) [$ns_ node $total_number]
$god_ new_node $node_($total_number)

$node_($total_number) set sinkStatus_ 1

$node_($total_number) set X_ 200
$node_($total_number) set Y_ 0
$node_($total_number) set Z_ 0
$node_($total_number) set-cx 200
$node_($total_number) set-cy 0
$node_($total_number) set-cz 0
set rt [$node_($total_number) set ragent_]
$rt set control_packet_size $opt(routing_control_packet_size)


set a_($total_number) [new Agent/UWSink]
$ns_ attach-agent $node_($total_number) $a_($total_number)
$a_($total_number) attach-vectorbasedforward $opt(width)
$a_($total_number) cmd set-range $opt(range)
$a_($total_number) cmd set-target-x 500
$a_($total_number) cmd set-target-y 0
$a_($total_number) cmd set-target-z 0
$a_($total_number) cmd set-filename $opt(datafile)
$a_($total_number) cmd set-packetsize $opt(packet_size) ;# # of bytes
$a_($total_number) set data_rate_ [expr 1.0/$opt(interval)]

# make nam workable
set node_size 10
for {set k 0} { $k<$opt(nn)} {incr k} {
$ns_ initial_node_pos $node_($k) $node_size
}


set opt(stop2) [expr $opt(stop)+200]


puts "Node $total_number is sending first!!"
$ns_ at 1.33 "$a_($total_number) cbr-start"
$ns_ at $opt(stop).001 "$a_($total_number) terminate"

$ns_ at $opt(stop2).002 "$a_(0) terminate"


$ns_ at $opt(stop2).003 "$god_ compute_energy"
$ns_ at $opt(stop2).004 "$ns_ nam-end-wireless $opt(stop)"
$ns_ at $opt(stop2).005 "puts \"NS EXISTING...\"; $ns_ halt"


puts $data "New simulation...."
puts $data "nodes = $opt(nn), maxspeed = $opt(maxspeed), minspeed = $opt(minspeed), random_seed = $opt(seed), sending_interval_=$opt(interval), width=$opt(width)"
puts $data "nodes = $opt(nn), maxspeed = $opt(maxspeed), minspeed = $opt(minspeed), random_seed = $opt(seed), sending_interval_=$opt(interval))"
puts $data "x= $opt(x) y= $opt(y) z= $opt(z)"
close $data
puts "starting Simulation..."
$ns_ run


This is DBR tcl script:
set opt(chan) Channel/UnderwaterChannel
set opt(prop) Propagation/UnderwaterPropagation
set opt(netif) Phy/UnderwaterPhy
set opt(mac) Mac/UnderwaterMac/BroadcastMac
set opt(ifq) Queue/DropTail/PriQueue
set opt(ll) LL
set opt(energy) EnergyModel
set opt(txpower) 2.0
set opt(rxpower) 0.75
set opt(initialenergy) 10000
set opt(idlepower) 0.008
set opt(ant) Antenna/OmniAntenna
set opt(filters) GradientFilter ;# options can be one or more of
;# TPP/OPP/Gear/Rmst/SourceRoute/Log/TagFilter
set opt(minspeed) 0 ;#minimum speed of node
set opt(maxspeed) 3 ;#maximum speed of node
set opt(speed) 0.5 ;#speed of node
set opt(position_update_interval) 0.3 ;# the length of period to update node's position
set opt(packet_size) 50 ;#50 bytes
set opt(routing_control_packet_size) 20 ;#bytes

set opt(ifqlen) 50 ;# max queue length in if
set opt(nn) 6 ;# number of nodes
set opt(x) 1000 ;# X dimension of the topography
set opt(y) 10 ;# Y dimension of the topography
set opt(z) 10
set opt(seed) 11
set opt(stop) 500 ;# simulation time
set opt(prestop) 90 ;# time to prepare to stop
set opt(tr) "a.tr" ;# trace file
set opt(datafile) "a.data"
set opt(nam) "a.nam" ;# nam file
set opt(adhocRouting) DBR
set opt(interval) 10.0
set opt(range) 100 ;#range of each node in meters

if { $argc > 0 } {
set opt(seed) [lindex $argv 0]
set opt(nn) [lindex $argv 1]
set opt(datafile) [lindex $argv 2]
}

puts "the file name is $opt(datafile)"
puts "the sending interval is $opt(interval)"

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

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 Z_ 0.05
Antenna/OmniAntenna set Gt_ 1.0
Antenna/OmniAntenna set Gr_ 1.0

Mac/UnderwaterMac set bit_rate_ 1.0e4 ;#10kbps
Mac/UnderwaterMac set encoding_efficiency_ 1
Mac/UnderwaterMac/BroadcastMac set packetheader_size_ 0 ;# #of bytes

# Initialize the SharedMedia interface with parameters to make
# it work like the 914MHz Lucent WaveLAN DSSS radio interface
Phy/UnderwaterPhy set CPThresh_ 10 ;#10.0
Phy/UnderwaterPhy set CSThresh_ 0 ;#1.559e-11
Phy/UnderwaterPhy set RXThresh_ 0 ;#3.652e-10
#Phy/WirelessPhy set Rb_ 2*1e6
Phy/UnderwaterPhy set Pt_ 0.2818
Phy/UnderwaterPhy set freq_ 25 ;# 25khz
Phy/UnderwaterPhy set K_ 2.0 ;# spherical spreading

# =================================================================
# Main Program
# =================================================================

#
# Initialize Global Variables
#
#set sink_ 1
set ns_ [new Simulator]
set topo [new Topography]

$topo load_cubicgrid $opt(x) $opt(y) $opt(z)
$ns_ use-newtrace
set tracefd [open $opt(tr) w]
$ns_ trace-all $tracefd

set nf [open $opt(nam) w]
$ns_ namtrace-all-wireless $nf $opt(x) $opt(y)


set data [open $opt(datafile) a]


set total_number [expr $opt(nn)-1]
set god_ [create-god $opt(nn)]


$ns_ at 0.0 "$god_ set_filename $opt(datafile)"


set chan_1_ [new $opt(chan)]


global defaultRNG
$defaultRNG seed $opt(seed)


$ns_ node-config -adhocRouting $opt(adhocRouting) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
#-channelType $opt(chan) \
-agentTrace OFF \
-routerTrace OFF \
-macTrace ON\
-topoInstance $topo\
-energyModel $opt(energy)\
-txPower $opt(txpower)\
-rxPower $opt(rxpower)\
-initialEnergy $opt(initialenergy)\
-idlePower $opt(idlepower)\
-channel $chan_1_


#Set the Sink node


set node_(0) [ $ns_ node 0]
$node_(0) set sinkStatus_ 1
$god_ new_node $node_(0)
$node_(0) set X_ 500
$node_(0) set Y_ 0
$node_(0) set Z_ 0
$node_(0) set passive 1

set rt [$node_(0) set ragent_]
$rt set control_packet_size $opt(routing_control_packet_size)

set a_(0) [new Agent/UWSink]
$ns_ attach-agent $node_(0) $a_(0)
$a_(0) cmd set-range $opt(range)
$a_(0) cmd set-target-x -20
$a_(0) cmd set-target-y -10
$a_(0) cmd set-target-z -20
$a_(0) cmd set-filename $opt(datafile)
$a_(0) cmd set-packetsize $opt(packet_size) ;# # of bytes



set node_(1) [ $ns_ node 1]
$node_(1) set sinkStatus_ 1
$god_ new_node $node_(1)
$node_(1) set X_ 440
$node_(1) set Y_ 0
$node_(1) set Z_ 0
$node_(1) set passive 1

set rt [$node_(1) set ragent_]
$rt set control_packet_size $opt(routing_control_packet_size)
$node_(1) set max_speed $opt(maxspeed)
$node_(1) set min_speed $opt(minspeed)
$node_(1) set position_update_interval_ $opt(position_update_interval)
set a_(1) [new Agent/UWSink]
$ns_ attach-agent $node_(1) $a_(1)
$a_(1) cmd set-range $opt(range)
$a_(1) cmd set-target-x -20
$a_(1) cmd set-target-y -10
$a_(1) cmd set-target-z -20
$a_(1) cmd set-filename $opt(datafile)
$a_(1) cmd set-packetsize $opt(packet_size) ;# # of bytes
#$node_(1) move

set node_(2) [ $ns_ node 2]
$node_(2) set sinkStatus_ 1
$node_(2) random-motion 1
$node_(2) set max_speed $opt(maxspeed)
$node_(2) set min_speed $opt(minspeed)
$node_(2) set position_update_interval_ $opt(position_update_interval)

$god_ new_node $node_(2)
$node_(2) set X_ 380
$node_(2) set Y_ 0
$node_(2) set Z_ 0
$node_(2) set passive 1

set rt [$node_(2) set ragent_]
$rt set control_packet_size $opt(routing_control_packet_size)

set a_(2) [new Agent/UWSink]
$ns_ attach-agent $node_(2) $a_(2)
$a_(2) cmd set-range $opt(range)
$a_(2) cmd set-target-x -20
$a_(2) cmd set-target-y -10
$a_(2) cmd set-target-z -20
$a_(2) cmd set-filename $opt(datafile)
$a_(2) cmd set-packetsize $opt(packet_size) ;# # of bytes
#$node_(2) move


set node_(3) [ $ns_ node 3]
$node_(3) set sinkStatus_ 1
$node_(3) random-motion 1

$node_(3) set max_speed $opt(maxspeed)
$node_(3) set min_speed $opt(minspeed)
$node_(3) set position_update_interval_ $opt(position_update_interval)

$god_ new_node $node_(3)
$node_(3) set X_ 320
$node_(3) set Y_ 0
$node_(3) set Z_ 0
$node_(3) set passive 1

set rt [$node_(3) set ragent_]
$rt set control_packet_size $opt(routing_control_packet_size)

set a_(3) [new Agent/UWSink]
$ns_ attach-agent $node_(3) $a_(3)
$a_(3) cmd set-range $opt(range)
$a_(3) cmd set-target-x -20
$a_(3) cmd set-target-y -10
$a_(3) cmd set-target-z -20
$a_(3) cmd set-filename $opt(datafile)
$a_(3) cmd set-packetsize $opt(packet_size) ;# # of bytes




set node_(4) [ $ns_ node 4]
$node_(4) set sinkStatus_ 1
$node_(4) random-motion 1

$node_(4) set max_speed $opt(maxspeed)
$node_(4) set min_speed $opt(minspeed)
$node_(4) set position_update_interval_ $opt(position_update_interval)

$god_ new_node $node_(4)
$node_(4) set X_ 260
$node_(4) set Y_ 0
$node_(4) set Z_ 0
$node_(4) set passive 1

set rt [$node_(4) set ragent_]
$rt set control_packet_size $opt(routing_control_packet_size)

set a_(4) [new Agent/UWSink]
$ns_ attach-agent $node_(4) $a_(4)
$a_(4) cmd set-range $opt(range)
$a_(4) cmd set-target-x -20
$a_(4) cmd set-target-y -10
$a_(4) cmd set-target-z -20
$a_(4) cmd set-filename $opt(datafile)
$a_(4) cmd set-packetsize $opt(packet_size) ;# # of bytes




#Set the source node
set node_($total_number) [$ns_ node $total_number]
$god_ new_node $node_($total_number)

$node_($total_number) set sinkStatus_ 1

$node_($total_number) set X_ 200
$node_($total_number) set Y_ 0
$node_($total_number) set Z_ 0
$node_($total_number) set-cx 200
$node_($total_number) set-cy 0
$node_($total_number) set-cz 0
set rt [$node_($total_number) set ragent_]
$rt set control_packet_size $opt(routing_control_packet_size)


set a_($total_number) [new Agent/UWSink]
$ns_ attach-agent $node_($total_number) $a_($total_number)
$a_($total_number) cmd set-range $opt(range)
$a_($total_number) cmd set-target-x 500
$a_($total_number) cmd set-target-y 0
$a_($total_number) cmd set-target-z 0
$a_($total_number) cmd set-filename $opt(datafile)
$a_($total_number) cmd set-packetsize $opt(packet_size) ;# # of bytes
$a_($total_number) set data_rate_ [expr 1.0/$opt(interval)]

# make nam workable
set node_size 10
for {set k 0} { $k<$opt(nn)} {incr k} {
$ns_ initial_node_pos $node_($k) $node_size
}


set opt(stop2) [expr $opt(stop)+200]


puts "Node $total_number is sending first!!"
$ns_ at 1.33 "$a_($total_number) cbr-start"
$ns_ at $opt(stop).001 "$a_($total_number) terminate"

$ns_ at $opt(stop2).002 "$a_(0) terminate"


$ns_ at $opt(stop2).003 "$god_ compute_energy"
$ns_ at $opt(stop2).004 "$ns_ nam-end-wireless $opt(stop)"
$ns_ at $opt(stop2).005 "puts \"NS EXISTING...\"; $ns_ halt"


puts $data "New simulation...."
puts $data "nodes = $opt(nn), maxspeed = $opt(maxspeed), minspeed = $opt(minspeed), random_seed = $opt(seed), sending_interval_=$opt(interval))"
puts $data "x= $opt(x) y= $opt(y) z= $opt(z)"
close $data
puts "starting Simulation..."
$ns_ run


I use ns-allinone-2.28,can the problem caused because of its version?
Some sites recommended to add init_tk at the first of the line in which error occurred,but it could not help me at all.
Thanks for your attention.
 
Old 09-13-2011, 05:25 PM   #10
aram_2
LQ Newbie
 
Registered: Sep 2011
Posts: 2

Rep: Reputation: Disabled
Hello to all
I want to create a linear topology which every one send own traffic to sink
but i can't understand how can i define a sink and how can i say to nodes that send their packet to sink
set a_(4) [new Agent/UWSink]
set a_(3) [new Agent/UWSink]
set a_(2) [new Agent/UWSink]
,.......

another problem is how can i get total throughput of my scenario
thanks to all.
 
1 members found this post helpful.
Old 09-28-2011, 03:43 AM   #11
afsane
LQ Newbie
 
Registered: Aug 2011
Posts: 5

Rep: Reputation: Disabled
Hi,
my ns simulator does not have broadcastMac class,I will be thanksful if anyone can tell me that how can I add this class.
 
Old 10-07-2011, 07:19 AM   #12
afsane
LQ Newbie
 
Registered: Aug 2011
Posts: 5

Rep: Reputation: Disabled
Hi,
I have a question about ns2.30.I tried to install ns2.30 on windows (with cygwin).
when I want to make ns it gives me these erors:
configure:error:Installation of tcl seems incomplete or can not be found automatically.
Please correct the problem by telling configure where tcl is
using the argument --with-tcl=/path/to/package
<perhaps after installing it>,
or the package is not required, disable it with --with-tcl=no.
Makefile.in is newer than makefile.
You need to re-run configure.
false
make: *** [Makefile] Error 1
Makefile.in is newer than Makefile.
You need to re-run configure.
false
make: *** [Makefile] Error 1

I will be thankfull if anyone can help me.
 
Old 10-07-2011, 09:04 AM   #13
afsane
LQ Newbie
 
Registered: Aug 2011
Posts: 5

Rep: Reputation: Disabled
Hi,
now my problem is that my ns2.30 does not have makefile.I will be thankfull if anyone send me the makefile.
 
Old 10-07-2011, 10:58 AM   #14
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
Posts #9, #12 : Don't use color for a text, please edit.
Color is for a few words. And please edit the posts to use code tags:
Write [/code] at code end, and [code] at code text start. Like this :
Code:
cd ns-allinone-2.30/ && ./install
#12, #13 : ns-allinone-2.30 is a must for cygwin.
http://www.isi.edu/nsnam/dist/ > ns-allinone-2.30.tar.gz
> http://www.isi.edu/nsnam/dist/ns-allinone-2.30.tar.gz

A Makefile will be created, when you have tcl tk otcl tclcl in place.
That's what ns-allinone-2.30 takes care of : Installing the files in
locations inside ns-allinone-2.30, so ns etc. know where to find them.

An alien Makefile won't do : Only the one created on your OS will fit.

..
 
Old 12-03-2011, 01:50 PM   #15
ssohrab2003
LQ Newbie
 
Registered: Jul 2011
Posts: 5

Rep: Reputation: Disabled
Hi,

how can I download aquasim from a trusted website ? would you please introduce a download repository ?
 
0 members found this post helpful.
  


Reply

Tags
aquasim, dbr, ns2, vbf


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
codes for leach protocol in ns2 shaddrack yaw nusenu Linux - Newbie 4 09-14-2014 10:16 AM
installing a new protocol in ns2.34 MounaRM Linux - Networking 1 11-26-2010 07:45 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
sim messenger (msn protocol) shows every1 as offile. qwijibow Linux - Software 0 03-02-2004 10:53 AM

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

All times are GMT -5. The time now is 12:18 PM.

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