[ns] how to set different energy level for each nodes

2015-06-12 Thread israe iken

Hi,
i want to set different energies for different nodes in the tcl file below:




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) 9  ;# number of mobilenodes
set val(rp) ENFAT  ;# routing protocol
set val(energymodel)   EnergyModel ;
set val(initialenergy)  100;
# ==
# Main Program
# ==


#
# Initialize Global Variables
#
set ns_ [new Simulator]
set tracefd [open simple.tr w]
$ns_ trace-all $tracefd
set Time [open time.tr w]
set cwnd1 [open cwnd1.tr w]
set b1 [open b1.tr w]

# set up topography object
set topo   [new Topography]
set namfile [open ENFAT.nam w]
$topo load_flatgrid 3000 1600
$ns_ namtrace-all $namfile
set wireless_tracefile [open ENFAT.trace w]
set topography [new Topography]
$ns_ trace-all $wireless_tracefile
$ns_ namtrace-all-wireless $namfile 500 500
#
# Create God
#
create-god $val(nn)
global TN
set TN 8
#
#  Create the specified number of mobilenodes [$val(nn)] and "attach" them
#  to the channel.
#  Here two nodes are created : node(0) and node(1)

# 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) \
 -channelType $val(chan) \
 -topoInstance $topo \
 -agentTrace ON \
 -routerTrace ON \
 -macTrace OFF \
 -movementTrace OFF \
 -energyModel $val(energymodel) \
 -initialEnergy $val(initialenergy) \
 -rxPower 35.28e-3 \
 -txPower 712e-6 \
 -sleepPower 144e-9

for {set i 0} {$i < $val(nn) } {incr i} {
set node_($i) [$ns_ node]
   $node_($i) random-motion 0 ;# disable random motion
}

for {set j 0} {$j < $TN} {incr j} {

set Tcp($j) [new Agent/TCP]
$ns_ attach-agent $node_($j) $Tcp($j)
$ns_ color 1 "black"
$Tcp($j) set fid_ $j
$Tcp($j) set packetSize_ 512
$Tcp($j) set window_ 20
$Tcp($j) set windowInit_ 1
$Tcp($j) set maxcwnd_ 0
#Set TCPSink
set TcpSink($j) [new Agent/TCPSink]
$ns_ attach-agent $node_($j) $TcpSink($j)
$TcpSink($j) set packetSize_ 210
#Set Trafic Source

set Ftp($j) [new Application/FTP]
$Ftp($j) attach-agent $Tcp($j)

}

#
# Provide initial (X,Y, for now Z=0) co-ordinates for mobilenodes
#
set x1 200
set y1 400
set x2 400
set y2 600
set x3 400
set y3 400
set x4 400
set y4 300
set x5 600
set y5 600
set x6 600
set y6 400
set x7 600
set y7 300
set x8 800
set y8 400
#Setting node position block
for {set i 0} {$i < $TN} {incr i} {
set node($i) [$ns_ node]
$node($i) random-motion 0
$ns_ at 0.0 "$node($i) label Node_($i)"
$ns_ initial_node_pos $node($i) 50.00
}
for {set j 0} {$j < $TN} {incr j} {

set Tcp($j) [new Agent/TCP]
$ns_ attach-agent $node($j) $Tcp($j)
$ns_ color 1 "black"
$Tcp($j) set fid_ $j
$Tcp($j) set packetSize_ 512
$Tcp($j) set window_ 20
$Tcp($j) set windowInit_ 1
$Tcp($j) set maxcwnd_ 0
#Set TCPSink
set TcpSink($j) [new Agent/TCPSink]
$ns_ attach-agent $node($j) $TcpSink($j)
$TcpSink($j) set packetSize_ 210
#Set Trafic Source

set Ftp($j) [new Application/FTP]
$Ftp($j) attach-agent $Tcp($j)
$Ftp($j) set maxpkts_ 2048
}


for {set j1 0} {$j1 < $TN} {incr j1 7} {
incr x1 0
incr y1 15
$node($j1) set X_ $x1
$node($j1) set Y_ $y1
$node($j1) set Z_ 0
$node($j1) color "blue"
$ns_ at 0.00 "$node($j1) setdest $x1 $y1 0.00"
}


for {set j2 1} {$j2 < $TN} {incr j2 7} {
incr x2 0
incr y2 14
$node($j2) set X_ $x2
$node($j2) set Y_ $y2
$node($j2) set Z_ 0
$node($j2) color "blue"
$ns_ at 0.00 "$node($j2) setdest $x2 $y2 0.00"
}



for {set j3 2} {$j3 < $TN} {incr j3 7} {
incr x3 0
incr y3 14
$node($j3) set X_ $x3
$node($j3) set Y_ $y3
$node($j3) set Z_ 0
$node($j3) color "red"
$ns_ at 0.00 "$node($j3) setdest $x3 $y3 0.00"
}


for {set j4 3} {$j4 < $TN} {incr j4 7} {
incr x4 0
inc

[ns] help to implement ENFAT-AODV protocol

2015-05-10 Thread israe iken

i have to implement enfat-aodv protocol using aodv packets,so i should add
the backup route. pllz tell me what does this function must contain


[ns] Help to add new protocol in ns2

2015-04-25 Thread israe iken

Hi every body
I have to implement  enfat-aodv protocol in ns2 for that i should add some
fonctions in files aodv.h and aodv.cc the thing that i don't know how to do

this is the example i'm working in, please help me and thanks in advance.



*set ns [new Simulator]*

*# Create a nam trace datafile.*

*set namfile [open AODV_final.nam w]*

*set Time [open time.tr  w]*

*#This Block Is For Congestion Window Trace file. Here 5 sample trace file*

*set cwnd1 [open cwnd1.tr  w]*

*set cwnd2 [open cwnd2.tr  w]*

*set cwnd3 [open cwnd3.tr  w]*

*set cwnd4 [open cwnd4.tr  w]*

*set cwnd5 [open cwnd5.tr  w]*

*#This Block Is For Bandwidth Calculation Trace file. Here 5 sample trace
file*

*set b1 [open b1.tr  w]*

*set b2 [open b2.tr  w]*

*set b3 [open b3.tr  w]*

*set b4 [open b4.tr  w]*

*set b5 [open b5.tr  w]*

*$ns namtrace-all $namfile*

*# - Setup wireless environment. *

*set wireless_tracefile [open AODV_final.trace w]*

*set topography [new Topography]*

*$ns trace-all $wireless_tracefile*

*$ns namtrace-all-wireless $namfile 3000  1600 *

*$topography load_flatgrid 3000  1600*

*#TN means Total number of  wireless node*

*global TN*

*set TN 21*

*set god_ [create-god $TN]*

*#global node setting*

*$ns node-config -adhocRouting AODV \*

* -llType LL \*

* -macType Mac/802_11\*

* -ifqLen 50 \*

* -ifqType Queue/DropTail/PriQueue \*

* -antType Antenna/OmniAntenna \*

* -propType Propagation/TwoRayGround \*

* -phyType Phy/WirelessPhy \*

* -channel [new Channel/WirelessChannel] \*

* -topoInstance $topography \*

* -agentTrace ON \*

* -routerTrace ON \*

* -macTrace ON \*

* -movementTrace ON*

*# Create wireless nodes.*

*#I have used few loop and to set in  diffrent position i have use few
defined value*

*#Here X and Y is the axix*

*set x1 150*

*set y1 150*

*set x2 150*

*set y2 250*

*set x3 150*

*set y3 350*

*set x4 150*

*set y4 450*

*set x5 350*

*set y5 150*

*set x6 350*

*set y6 250*

*set x7 350*

*set y7 350*

*set x8 350*

*set y8 450*

*set x9 550*

*set y9 150*

*set x10 550*

*set y10 250*

*set x11 550*

*set y11 350*

*set x12 550*

*set y12 450*

*set x13 750*

*set y13 150*

*set x14 750*

*set y14 250*

*set x15 750*

*set y15 350*

*set x16 750*

*set y16 450*

*set x17 950*

*set y17 150*

*set x18 950*

*set y18 250*

*set x19 950*
*set y19 350*

*set x20 950*

*set y20 450*

*set x21 1100*
*set y21 300*

*#Setting node position block*

*for {set i 0} {$i < $TN} {incr i} {*

*set node($i) [$ns node]*

*$node($i) random-motion 0*

*$ns at 0.0 "$node($i) label Node_($i)"*

*$ns initial_node_pos $node($i) 50.00*

*}*

*for {set j 0} {$j < $TN} {incr j} {*

* set Tcp($j) [new Agent/TCP]*

*$ns attach-agent $node($j) $Tcp($j)*

*$ns color 1 "black"*

*$Tcp($j) set fid_ $j*

*$Tcp($j) set packetSize_ 512*

*$Tcp($j) set window_ 20*

*$Tcp($j) set windowInit_ 1*

*$Tcp($j) set maxcwnd_ 0*

*#Set TCPSink*

*set TcpSink($j) [new Agent/TCPSink]*

*$ns attach-agent $node($j) $TcpSink($j)*

*$TcpSink($j) set packetSize_ 210*

*#Set Trafic Source*



*set Ftp($j) [new Application/FTP]*

*$Ftp($j) attach-agent $Tcp($j)*

*$Ftp($j) set maxpkts_ 2048*

*}*





* for {set j1 0} {$j1 < $TN} {incr j1 21} {*

* incr x1 0*

* incr y1 150*

* $node($j1) set X_ $x1*

* $node($j1) set Y_ $y1*

*$node($j1) set Z_ 0*

* $node($j1) color "green"*

*$ns at 0.00 "$node($j1) setdest $x1 $y1 0.00"*



* }*



* for {set j2 1} {$j2 < $TN} {incr j2 21} {*

* incr x2 0*

* incr y2 140*

* $node($j2) set X_ $x2*

* $node($j2) set Y_ $y2*

*$node($j2) set Z_ 0*

* $node($j2) color "blue"*

*$ns at 0.00 "$node($j2) setdest $x2 $y2 0.00"*

* }*




* for {set j3 2} {$j3 < $TN} {incr j3 21} {*

* incr x3 0*

* incr y3 140*

* $node($j3) set X_ $x3*

* $node($j3) set Y_ $y3*

*$node($j3) set Z_ 0*

* $node($j3) color "red"*

*$ns at 0.00 "$node($j3) setdest $x3 $y3 0.00"*

* }*



* for {set j4 3} {$j4 < $TN} {incr j4 21} {*

* incr x4 0*

* incr y4 150*

* $node($j4) set X_ $x4*

* $node($j4) set Y_ $y4*

*$node($j4) set Z_ 0*

* $node($j4) color "blue"*

*$ns at 0.00 "$node($j4) setdest $x4 $y4 0.00"*

* }*






* for {set j5 4} {$j5 < $TN} {incr j5 21} {*

* incr x5 0*

* incr y5 140*

* $node($j5) set X_ $x5*

* $node($j5) set Y_ $y5*

*$node($j5) set Z_ 0*

* $node($j5) color "black"*

*$ns at 0.00 "$node($j5) setdest $x5 $y5 0.00"*

* }*



* for {set j6 5} {$j6 < $TN} {incr

[ns] help to understand the code of all AODV protocole files

2015-03-25 Thread israe iken

i tryed hardly to understand it but it's so difficult and complicated
.please reply me becuase i need it soon.where can i found my question and
the replies.and also I am  beginner in ns2, and i want to learn it quickly
because i need it in my project.
 so i want to guide me what topics must i start reading? and i want to know
the steps to run any example in ns2 under windows 7 .
 i want to know how to run aodv and enfat-aodv, and show how it work in ns2
,because my project is to adjust some feauters in aodv and enfat-aodv
protocol.
please help me and reply me soon because i need it quickly.
thanks very much.
thanks very much.