LinuxQuestions.org
Visit Jeremy's Blog.
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 06-14-2020, 09:56 AM   #1
abdullahezz
LQ Newbie
 
Registered: Jun 2020
Posts: 1

Rep: Reputation: Disabled
i am running a ns2 simulation regarding how to minimze the energy of the nodes using DSR protocol


i am running a ns2 simulation regarding how to minimze the energy of the nodes using DSR protocol
problems :
1- does this code do the function ? and if no how could I implement it.
2- when I run the code this error appears
num_nodes is set 6
Node Configuration Started here...
-channel Channel/WirelessChannel
-adhocRouting DSR
-llType LL
-macType Mac/802_11
-ifqType Queue/DropTail/PriQueue
-ifqLen 5
-antType Antenna/OmniAntenna
-propType Propagation/TwoRayGround
-phyType Phy/WirelessPhy

warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
INITIALIZE THE LIST xListHead
end simulation
---------------------
MY 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) 5 ;# max packet in ifq
set val(nn) 6 ;# number of mobilenodes
set val(rp) DSR ;# routing protocol
set val(x) 750 ;# X dimension of topography
set val(y) 550 ;# Y dimension of topography
set val(stop) 18.0 ;# time of simulation end
## Create a simulator object(nothing but, a scheduler's object)..
set ns [new Simulator]
## Create a trace file and nam file..
set tracefd [open wireless1.tr w]
set namtrace [open wireless1.nam w]
## Trace the nam and trace details from the main simulation..
$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)
## set up topography object..
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
set god_ [create-god $val(nn)]
## Color Descriptions..
$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

# Setting The Distance Variables..
# For model 'TwoRayGround'
set dist(5m) 7.69113e-06
set dist(9m) 2.37381e-06
set dist(10m) 1.92278e-06
set dist(11m) 1.58908e-06
set dist(12m) 1.33527e-06
set dist(13m) 1.13774e-06
set dist(14m) 9.81011e-07
set dist(15m) 8.54570e-07
set dist(16m) 7.51087e-07
set dist(20m) 4.80696e-07
set dist(25m) 3.07645e-07
set dist(30m) 2.13643e-07
set dist(35m) 1.56962e-07
set dist(40m) 1.56962e-10
set dist(45m) 1.56962e-11
set dist(50m) 1.20174e-13
#Phy/WirelessPhy set CSThresh_ $dist(50m)
#Phy/WirelessPhy set RXThresh_ $dist(50m)
## Setting node config event with set of inputs..
puts "Node Configuration Started here...\n \
-channel $val(chan) \n \
-adhocRouting $val(rp) \n \
-llType $val(ll) \n \
-macType $val(mac) \n \
-ifqType $val(ifq) \n \
-ifqLen $val(ifqlen) \n \
-antType $val(ant) \n \
-propType $val(prop) \n \
-phyType $val(netif) \n"

$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 $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace ON
# Energy model
$ns node-config -energyModel EnergyModel \
-initialEnergy 20 \
-txPower 0.9 \
-rxPower 0.8 \
-idlePower 0.0 \
-sensePower 0.0175
## Creating node objects..
for {set i 0} {$i < $val(nn) } { incr i } {
set node_($i) [$ns node]
}
for {set i 0} {$i < $val(nn)} {incr i} {
$node_($i) color darkgreen
$ns at 0.0 "$node_($i) color darkgreen"
}
## Provide initial location of mobilenodes..

if {$val(nn) >0} {
for {set i 1} {$i < $val(nn) } { incr i } {
set xx [expr rand()*600]
set yy [expr rand()*500];
$node_($i) set X_ $xx
$node_($i) set Y_ $yy
}
}
## set god distance..
$god_ set-dist 0 1 2
$god_ set-dist 0 2 2
$god_ set-dist 0 3 2
$god_ set-dist 0 4 1
$god_ set-dist 0 5 2
$god_ set-dist 1 2 3
$god_ set-dist 1 3 3

## Define node initial position in nam..
for {set i 0} {$i < $val(nn)} { incr i } {
# 30 defines the node size for nam..
$ns initial_node_pos $node_($i) 30
}
## Telling nodes when the simulation ends..
for {set i 0} {$i < $val(nn) } { incr i } {
$ns at $val(stop) "$node_($i) reset";
}
## Ending nam and the simulation..
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "stop"
$ns at 16.01 "puts "end simulation" " ;# $ns halt

## Stop procedure..
proc stop {} {
global ns tracefd namtrace
$ns flush-trace
close $tracefd
close $namtrace
exec nam wireless1.nam &
exit 0
}
$ns run
 
  


Reply

Tags
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
Running SPAN protocol on ns2 !! errors !! Hi, I am trying to SPAN protocol on ns2.28 using cygwin on windows 10 phyotay3 Linux - Wireless Networking 2 10-23-2019 08:11 AM
Energy efficient DSR in ns2 hellome Linux - Newbie 0 03-04-2016 05:46 PM
Energy.awk required to compute remaing energy of nodes. Aska123 Linux - Wireless Networking 2 02-02-2014 02:31 AM
I've made changes to DSR in NS2 , but when I run the simulation nothing has changed farzane Linux - Wireless Networking 0 06-26-2012 12:50 AM

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

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