Dear Users of NS2, I need to take some results regarding energy consumption of my protocol. I m wondering about the behaviour of Energy Model class in NS2. I set some initial energy for say X nodes. Some nodes are generating traffic and sending packets with dsdv protocol. But after some time, Although the traffic generating nodes consume much more energy than the silent nodes all the nodes loose thier energy at almost same time. I expect that only the traffic source nodes loose battery power not the silent nodes. It seems that all the nodes share the same energy and die at the same time. I my script, I have configure this parameters
Phy/WirelessPhy set CPThresh_ 10.0 Phy/WirelessPhy set CSThresh_ 1.559e-11 Phy/WirelessPhy set RXThresh_ 1.58e-10 ;#Sensibilidad: -98 dBm. Phy/WirelessPhy set Rb_ 2*1e6 Phy/WirelessPhy set Pt_ 0.00175 Phy/WirelessPhy set freq_ 916e+6 Phy/WirelessPhy set L_ 1.0 Phy/WirelessPhy set Pt_consume_ 0.002 ;# // power consumption for transmission (W) Phy/WirelessPhy set Pr_consume_ 0.002 ;# // power consumption for reception (W) Phy/WirelessPhy set P_idle_ 1.0; # // idle power consumption (W) Phy/WirelessPhy set P_sleep_ 0.00005; #// sleep power consumption (W) Also, I use energy model. Must I have to write something more in the code? My script is that one # ==================================================================== # Define Node Configuration paramaters #==================================================================== 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) 10 ;# number of mobilenodes set val(rp) DSDV ;# routing protocol set val(x) 500 ;# X dimension of the topography set val(y) 500 ;# Y dimension of the topography set val(rxPower) 0.00175 ;#Potencia recepción en W set val(txPower) 0.00175 ;#Potencia transmisión en W set val(energymodel) EnergyModel ; set val(initialenergy) 1000 ;# Initial energy in Joules set val(sleeppower) 0.00005 ;#sleep power W 15 uA P=I*I*R=11.25*10E-9 W set val(tp) 0.002 ;#transition powerpower consumption (Watt) in #;state transition from sleep to idle (active) set val(tt) 0.005 ;#transition time(second) use instate transition from sleep to idle (active) set val(ip) 1.0 ;#idle power 8 mA en modo activo.P=0.0032 #===================================================================== # Initialize trace file desctiptors #===================================================================== # *** Throughput Trace *** set f0 [open tiempo.tr w] set f1 [open rate.tr w] # *** Initialize Simulator *** set ns_ [new Simulator] # *** Initialize Trace file *** set tracefd [open trace2.tr w] $ns_ trace-all $tracefd # *** Initialize Network Animator *** set namtrace [open sim12.nam w] $ns_ namtrace-all-wireless $namtrace $val(x) $val(y) $ns_ use-newtrace # 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_ 1.58e-10 ;#Sensibilidad: -98 dBm. Phy/WirelessPhy set Rb_ 2*1e6 Phy/WirelessPhy set Pt_ 0.00175 Phy/WirelessPhy set freq_ 916e+6 Phy/WirelessPhy set L_ 1.0 Phy/WirelessPhy set Pt_consume_ 0.002 ;# // power consumption for transmission (W) Phy/WirelessPhy set Pr_consume_ 0.002 ;# // power consumption for reception (W) Phy/WirelessPhy set P_idle_ 1.0; # // idle power consumption (W) Phy/WirelessPhy set P_sleep_ 0.00005; #// sleep power consumption (W) #Frecuencia central de 868/916 MHz. #Número de canales: de 4 a 50. #Tasa de datos: 38.4 kbaudios. #Rango: 500 pies.--->155 m #// Assume AT&T's Wavelan PCMCIA card -- Chalermek # // Pt_ = 8.5872e-4; // For 40m transmission range. # // Pt_ = 7.214e-3; // For 100m transmission range. # // Pt_ = 0.2818; // For 250m transmission range. # // Pt_ = pow(10, 2.45) * 1e-3; // 24.5 dbm, ~ 281.8mw # *** set up topography object *** set topo [new Topography] $topo load_flatgrid 500 500 # Create General Operations Director (GOD) object. It is used to store global information about the state of the environment, network, or nodes that an # omniscent observer would have, but that should not be made known to any participant in the simulation. create-god $val(nn) # configure 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 $val(chan) \ -topoInstance $topo \ -agentTrace ON \ -routerTrace ON \ -macTrace OFF \ -movementTrace OFF \ -energyModel $val(energymodel) \ -idlePower $val(ip) \ -rxPower $val(rxPower) \ -txPower $val(txPower) \ -sleepPower $val(sleeppower)\ -transitionPower $val(tp) \ -transitionTime $val(tt)\ -initialEnergy $val(initialenergy)\ # Create Nodes for {set i 0} {$i < $val(nn) } {incr i} { set node_($i) [$ns_ node] $node_($i) random-motion 0 ;# disable random motion } # Initialize Node Coordinates set file [open nodosx.txt r] set file2 [open nodosy.txt r] for {set i 0} {$i < $val(nn) } { incr i } { gets $file linea $node_($i) set X_ $linea gets $file2 linea2 $node_($i) set Y_ $linea2 $node_($i) set Z_ 0 } close $file close $file2 set i [expr $val(nn)-1] $node_($i) set X_ [expr $linea + 5] $node_($i) set Y_ [expr $linea2 + 5] $node_($i) set Z_ 0 # Setup traffic flow between nodes # TCP connections between node_(0) and node_(1) # Create Constant four Bit Rate Traffic sources set agent1 [new Agent/UDP] ;# Create TCP Agent $agent1 set prio_ 0 ;# Set Its priority to 0 set sink [new Agent/LossMonitor] ;# Create Loss Monitor Sink in order to be able to trace the number obytes received $ns_ attach-agent $node_(0) $agent1 ;# Attach Agent to source node $ns_ attach-agent $node_($i) $sink ;# Attach Agent to sink node $ns_ connect $agent1 $sink ;# Connect the nodes set app1 [new Application/Traffic/CBR] ;# Create Constant Bit Rate application $app1 set packetSize_ 128 ;# Set Packet Size to 512 bytes $app1 set rate_ 38.4Kb ;# Set CBR rate to 400 Kbits/sec $app1 attach-agent $agent1 ;# Attach Application to agent # defines the node size in Network Animator for {set i 0} {$i < $val(nn)} {incr i} { $ns_ initial_node_pos $node_($i) 2 } # Initialize Flags set holdrate1 0 # Function To record Bit Rate proc record {} { global sink f0 holdrate1 set ns [Simulator instance] set time 0.9 ;#Set Sampling Time to 1 Sec set bw0 [$sink set bytes_] set now [$ns now] # Record Bit Rate in Trace Files # puts $f0 "$now"; #set kbs [expr (($bw0+$holdrate1 )*8)/($time*1000)];#kb/sec #puts $f1 " $kbs"; #puts $f0 "$now [expr (($bw0 ))/($time*512)]";#paquetes/sec # Reset Variables $sink set bytes_ 0 set holdrate1 $bw0 $ns at [expr $now+$time] "record" ;# Schedule Record after $time interval sec } # Start Recording at Time 0 $ns_ at 0.0 "record" $ns_ at 1.4 "$app1 start" ;# Start transmission at time t = 1.4 Sec # Stop Simulation at Time 100 sec $ns_ at 100 "stop" # Reset Nodes at time 100 sec for {set i 0} {$i < $val(nn) } {incr i} { $ns_ at 100 "$node_($i) reset"; } # Exit Simulatoion at Time 100.01 sec $ns_ at 100.01 "puts \"NS EXITING...\" ; $ns_ halt" proc stop {} { global ns_ tracefd f0 f4 f8 f1 # Close Trace Files close $f0 close $f1 # Plot Recorded Statistics # exec xgraph throughput.tr -geometry 800x400 & # Reset Trace File $ns_ flush-trace close $tracefd exit 0 } puts "Starting Simulation..." $ns_ run Thanks, Mikel --------------------------------- Sé un Mejor Amante del Cine ¿Quieres saber cómo? ¡Deja que otras personas te ayuden!.