LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Closed Thread
  Search this Thread
Old 04-16-2011, 02:57 AM   #211
salutrcmoi
LQ Newbie
 
Registered: Mar 2011
Posts: 16

Rep: Reputation: 0

can you tell me how I can change other parameters such as agent or paquet size ?
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 04-16-2011, 06:25 PM   #212
taransingh07
LQ Newbie
 
Registered: Apr 2011
Posts: 1

Rep: Reputation: 0
i have the tarik package for leach...i have ns2 2.34 on fedora 13..i need the steps to implement leach using this package...please reply its urgent...
 
Old 04-17-2011, 02:45 AM   #213
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
@taransingh07, post # 212.

LQ Member @unudior has repacked the (tarik)files + an installer + instructions.
Everything is referred in post # 210.

If it's urgent, how come you don't read the other posts ? ?
 
Old 04-19-2011, 05:55 AM   #214
keepwalking
Member
 
Registered: Oct 2010
Posts: 46

Rep: Reputation: 0
Im trying to simulate the LEACH protocol using this TCL but it give me errors. any one with a solution help me.############################################################################
#
# This code was developed as part of the MIT uAMPS project. (June, 2000)
#
############################################################################

global opt bs

source $env(RCA_LIBRARY)/ns-ranode.tcl
source $env(uAMPS_LIBRARY)/ns-bsapp.tcl
source $env(uAMPS_LIBRARY)/extras.tcl
#source $env(uAMPS_LIBRARY)/stats.tcl
#Uncomment these lines to use gdb to debug the c code
#source mit/uAMPS/ns-bsapp.tcl
#source mit/uAMPS/extras.tcl
source $env(uAMPS_LIBRARY)/stats.tcl
source $env(RCA_LIBRARY)/resources/ns-resource-manager.tcl
source $env(RCA_LIBRARY)/resources/ns-energy-resource.tcl
source $env(RCA_LIBRARY)/resources/ns-neighbor-resource.tcl

# ========================================================================
# Default Script Options
# ========================================================================

set opt(bsapp) "Application/BSApp" ;# BS application type
set opt(mtype) "" ;# No meta-data used
set opt(nn_**) [expr $opt(nn) - 1] ;# Number of non-BS nodes
set opt(bsID) $opt(nn_) ;# BS node number
set opt(bsCode) 0 ;# Spreading code for BS
set opt(quiet) 1 ;# 0=print info, 1=quiet

set opt(bw) 1e6 ;# 1 Mbps radio speed
set opt(delay) 1e-12 ;# Links delay
set opt(prop_speed) 3e8; ;# Meters per second
set opt(ll) RCALinkLayer ;# Arpless link-layer
set opt(mac) Mac/Sensor ;# Sensor mac protocol
set opt(ifq) Queue/DropTail ;# DropTail Q
set opt(ifqlen) 100 ;# Max packets in ifq
set opt(netif) Phy/WirelessPhy ;# Wireless channel
set opt(ant) Antenna/OmniAntenna ;# Omnidirectional antena

# Time required to transmit numbytes bytes of data
proc TxTime {numbytes} {
global opt
return [expr $numbytes*8/$opt(bw)]
}

set opt(hdr_size) 25 ;# Bytes for header
set opt(sig_size) 500 ;# Bytes for data signal
# Packet transmission time
set opt(slot_time) [expr [TxTime [expr $opt(sig_size)+$opt(hdr_size)]]]
# Spread-spectrum packet transmission time
set opt(ss_slot_time) [expr $opt(slot_time) * $opt(spreading)]
# Maximum TDMA frame time (if all nodes in one cluster)
set opt(frame_time) [expr $opt(ss_slot_time) * $opt(nn_)]

set opt(ch_change) [expr 10 * $opt(init_energy)] ;# Time for each round
set opt(check_energy) 10 ;# Time btwn energy traces

set opt(freq) 914e+6 ;# Carrier frequency
set opt(L) 1.0 ;# System (non-propogation) loss
set opt(Gt) 1.0 ;# Tx antenna gain
set opt(Gr) 1.0 ;# Rx antenna gain
set opt(ht) 1.5 ;# Antenna height
set opt(CSThresh) 1e-9 ;# Receive threshold is 1 nW
set opt(RXThresh) 6e-9 ;# Success threshold is 6 nW
set PI 3.1415926
set l [expr 3e8 / $opt(freq)] ;# Wavelength of carrier

############################################################################
#
# Energy Models
#
############################################################################

# Efriss_amp = RXThresh * (4pi)^2 / (Rb Gt Gr lambda^2)
set opt(Efriss_amp) [expr [expr 1.1 * $opt(RXThresh) * 16 * $PI * $PI] / \
[expr $opt(bw) * $opt(Gt) * $opt(Gr) * $l * $l]]
# Etwo_ray_amp = RXThresh / (Rb Gt Gr ht^2 hr^2)
set opt(Etwo_ray_amp) [expr 1.1 * $opt(RXThresh) / \
[expr $opt(bw) * $opt(Gt) * $opt(Gr) * \
$opt(ht) * $opt(ht) * $opt(ht) * $opt(ht)]]
set opt(EXcvr) 50e-9 ;# Energy for radio circuitry
set opt(e_bf) 5e-9 ;# Beamforming energy (J/bit)
set opt(Esense) 0 ;# Sensing energy (J/bit)
set opt(thresh_energy) 0.00 ;# Threshold for power adaptation
set opt(Pidle) 0 ;# Idle power (W)
set opt(Psleep) 0 ;# Sleep power (W)


# ===== Get rid of the warnings in bind ================================
Resource/Energy set energyLevel_ $opt(init_energy)
Resource/Energy set alarmLevel_ $opt(thresh_energy)
Resource/Energy set expended_ 0

Agent/RCAgent set sport_ 0
Agent/RCAgent set dport_ 0
Agent/RCAgent set packetMsg_ 0
Agent/RCAgent set distEst_ 0
Agent/RCAgent set packetSize_ 0
Agent/BSAgent set packetMsg_ 0
Agent/BSAgent set packetSize_ 0
Agent/BSAgent set recv_code_ 0

RCALinkLayer set delay_ 25us
RCALinkLayer set bandwidth_ 0
RCALinkLayer set off_prune_ 0
RCALinkLayer set off_CtrMcast_ 0
RCALinkLayer set macDA_ 0
RCALinkLayer set debug_ 0
RCALinkLayer set avoidReordering_ 0

Phy/WirelessPhy set bandwidth_ $opt(bw)
Phy/WirelessPhy set CSThresh_ $opt(CSThresh)
Phy/WirelessPhy set RXThresh_ $opt(RXThresh)
Phy/WirelessPhy set Efriss_amp_ $opt(Efriss_amp)
Phy/WirelessPhy set Etwo_ray_amp_ $opt(Etwo_ray_amp)
Phy/WirelessPhy set EXcvr_ $opt(EXcvr)
Phy/WirelessPhy set freq_ $opt(freq)
Phy/WirelessPhy set L_ $opt(L)
Phy/WirelessPhy set sleep_ 0
Phy/WirelessPhy set alive_ 1
Phy/WirelessPhy set ss_ $opt(spreading)
Phy/WirelessPhy set dist_ 0

Antenna/OmniAntenna set Gt_ $opt(Gt)
Antenna/OmniAntenna set Gr_ $opt(Gr)
Antenna/OmniAntenna set Z_ $opt(ht)

set MacTrace OFF
Mac set bandwidth_ $opt(bw)
Mac/Sensor set code_ 0
Mac/Sensor set node_num_ 0
Mac/Sensor set ss_ $opt(spreading)
Mac/Sensor set CHheard_ 0
Mac/Sensor set myADVnum_ 0

set bs[list $opt(bs_x) $opt(bs_y)]
set BS_NODE 1

set outf [open "$opt(dirname)/conditions.txt" a]
puts $outf "Simulation will stop after $opt(stop) seconds."
puts $outf "Base station at ($opt(bs_x), $opt(bs_y))"
if {$opt(eq_energy) == 1} {
puts $outf "Each node starting with $opt(init_energy) Joules of energy.\n"
}
puts $outf "Energy Model:"
puts $outf "\t\tRXThresh = $opt(RXThresh)"
puts $outf "\t\tCSThresh = $opt(CSThresh)"
puts $outf "\t\tRb = $opt(bw)"
puts $outf "\t\tExcvr = $opt(EXcvr)"
puts $outf "\t\tEfriss_amp = $opt(Efriss_amp)"
puts $outf "\t\tEtwo_ray_amp = $opt(Etwo_ray_amp)"
puts $outf "\t\tEbf = $opt(e_bf)"
puts $outf "\t\tPidle = $opt(Pidle)"
puts $outf "\t\tPsleep = $opt(Psleep)\n"
close $outf

set initialized 0
set rng_ [new RNG]

proc leach-create-mobile-node { id } {
global ns_ chan prop topo tracefd opt node_
global initialized BS_NODE rng_

if {$initialized == 0} {
sens_init
set initialized 1
}

# Create nodes.
if {$id != $opt(nn_)} {
puts -nonewline "$id "
set node_($id) [new MobileNode/ResourceAwareNode]
} else {
puts "($opt(nn_) == BS)"
set node_($id) [new MobileNode/ResourceAwareNode $BS_NODE]
}

set node $node_($id)
if {$id != $opt(nn_)} {
# Set initial node energy.
if {$opt(eq_energy) == 1} {
$node set-energy $opt(init_energy) $opt(thresh_energy)
} else {
#set E [$rng_ uniform $opt(lower_e) $opt(upper_e)]
#set rn [$rng_ uniform 0 1]
#if {$rn 0.1} {
# set E 200
#} else {
# set E 2
#}
set high_e_nodes[list 97 19 12 87 8 22 83 55 34 72]
if {[lsearch $high_e_nodes $id] == -1} {
set E 2
} else {
set E 200
}
$node set-energy $E $opt(thresh_energy)
set initf [open "$opt(dirname)/init.energy" a]
puts $initf "$id\t$E"
close $initf
}
} else {
# Base station has an infinite amount of energy.
$node set-energy 50000 $opt(thresh_energy)
}

# Disable random motion.
$node random-motion 0
$node topography $topo

if ![info exist inerrProc_] {
set inerrProc_ ""
}
if ![info exist outerrProc_] {
set outerrProc_ ""
}
if ![info exist FECProc_] {
set FECProc_ ""
}

# Connect the node to the channel.
$node add-interface $chan $prop $opt(ll) $opt(mac) \
$opt(ifq) $opt(ifqlen) $opt(netif) $opt(ant) \
$topo $inerrProc_ $outerrProc_ $FECProc_

# Set up the trace target.
set T [new Trace/Generic]
$T target [$ns_ set nullAgent_]
$T attach $tracefd
$T set src_ $id
$node log-target $T

$ns_ at 0.0 "$node_($id) start-app"
}

proc sens_init {} {

global ns_ opt ns

# The timer code has hard-coded the global variable ns to
# be the simulator.
set ns $ns_

# Remove old trace files.
catch "eval exec rm [glob -nocomplain $opt(dirname)/TDMAschedule.*.txt]"
catch "exec rm $opt(dirname)/$opt(filename).energy"
catch "exec rm $opt(dirname)/$opt(filename).data"
catch "exec rm $opt(dirname)/$opt(filename).alive"
catch "exec rm $opt(dirname)/startup.energy"
catch "exec rm $opt(dirname)/init.energy"

puts "Creating sensor nodes..."

sens_init_stats "$opt(dirname)/$opt(filename)"

$ns_ at $opt(stop) "sens_finish"
# Start logging simulation statistics.
$ns_ at $opt(check_energy) "sens_gather_stats"
}[B][B]
#################################################################################################### ########
resulting errors

Administrator@bayede-7e644b2d ~
$ cd ns-allinone-2.27

Administrator@bayede-7e644b2d ~/ns-allinone-2.27
$ ns em.tcl
invalid command name "Resource/Energy"
while executing
"Resource/Energy instproc setParams {args} {
$self instvar energyLevel_ alarmLevel_
set energyLevel_ [lindex $args 0]
set alarmLevel_ [lind..."
(file "../ns-allinone-2.27/ns-2.27/mit/rca/resources/ns-energy-resource.tcl"
line 11)
invoked from within
"source.orig ../ns-allinone-2.27/ns-2.27/mit/rca/resources/ns-energy-resource.tc
l"
("uplevel" body line 1)
invoked from within
"uplevel source.orig[list $fileName]"
invoked from within
"if [$instance_ is_http_url $fileName] {
set buffer [$instance_ read_url $fileName]
uplevel eval $buffer
} else {
uplevel source.orig[list $fileName]
..."
(procedure "source" line 8)
invoked from within
"source $env(RCA_LIBRARY)/resources/ns-energy-resource.tcl"
(file "em.tcl" line 18)

Administrator@bayede-7e644b2d ~/ns-allinone-2.27
$
 
Old 04-19-2011, 03:24 PM   #215
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
Post # 214, @keepwalking.

First : Please hit the 'Edit button' and 1) Shorten the long words :
I.e. the hash marks behave like a long word : #################################

2) Write [/code] at code end, and [code] at code text start.
http://www.linuxquestions.org/questions/misc.php?do=bbcode

Not possible to read the text, until you have done those edits.
 
Old 04-22-2011, 01:32 AM   #216
keepwalking
Member
 
Registered: Oct 2010
Posts: 46

Rep: Reputation: 0
Im trying to simulate the LEACH protocol using this TCL but it give me errors. any one with a solution help me.

Code:
#
 # This code was developed as part of the MIT uAMPS project. (June, 2000)
 #
 
 
global opt bs
 
source $env(RCA_LIBRARY)/ns-ranode.tcl
 source $env(uAMPS_LIBRARY)/ns-bsapp.tcl
 source $env(uAMPS_LIBRARY)/extras.tcl
 #source $env(uAMPS_LIBRARY)/stats.tcl
 #Uncomment these lines to use gdb to debug the c code
 #source mit/uAMPS/ns-bsapp.tcl
 #source mit/uAMPS/extras.tcl
 source $env(uAMPS_LIBRARY)/stats.tcl
 source $env(RCA_LIBRARY)/resources/ns-resource-manager.tcl
 source $env(RCA_LIBRARY)/resources/ns-energy-resource.tcl
 source $env(RCA_LIBRARY)/resources/ns-neighbor-resource.tcl
 
# ========================================================================
 # Default Script Options
 # ========================================================================
 
set opt(bsapp) "Application/BSApp" ;# BS application type
 set opt(mtype) "" ;# No meta-data used 
set opt(nn_**) [expr $opt(nn) - 1] ;# Number of non-BS nodes
 set opt(bsID) $opt(nn_) ;# BS node number
 set opt(bsCode) 0 ;# Spreading code for BS
 set opt(quiet) 1 ;# 0=print info, 1=quiet
 
set opt(bw) 1e6 ;# 1 Mbps radio speed
 set opt(delay) 1e-12 ;# Links delay
 set opt(prop_speed) 3e8; ;# Meters per second
 set opt(ll) RCALinkLayer ;# Arpless link-layer
 set opt(mac) Mac/Sensor ;# Sensor mac protocol
 set opt(ifq) Queue/DropTail ;# DropTail Q
 set opt(ifqlen) 100 ;# Max packets in ifq
 set opt(netif) Phy/WirelessPhy ;# Wireless channel
 set opt(ant) Antenna/OmniAntenna ;# Omnidirectional antena
 
# Time required to transmit numbytes bytes of data
 proc TxTime {numbytes} {
 global opt
 return [expr $numbytes*8/$opt(bw)]
 }
 
set opt(hdr_size) 25 ;# Bytes for header
 set opt(sig_size) 500 ;# Bytes for data signal
 # Packet transmission time
 set opt(slot_time) [expr [TxTime [expr $opt(sig_size)+$opt(hdr_size)]]]
 # Spread-spectrum packet transmission time
 set opt(ss_slot_time) [expr $opt(slot_time) * $opt(spreading)]
 # Maximum TDMA frame time (if all nodes in one cluster)
 set opt(frame_time) [expr $opt(ss_slot_time) * $opt(nn_)]
 
set opt(ch_change) [expr 10 * $opt(init_energy)] ;# Time for each round
 set opt(check_energy) 10 ;# Time btwn energy traces 

set opt(freq) 914e+6 ;# Carrier frequency
 set opt(L) 1.0 ;# System (non-propogation) loss
 set opt(Gt) 1.0 ;# Tx antenna gain
 set opt(Gr) 1.0 ;# Rx antenna gain
 set opt(ht) 1.5 ;# Antenna height
 set opt(CSThresh) 1e-9 ;# Receive threshold is 1 nW
 set opt(RXThresh) 6e-9 ;# Success threshold is 6 nW
 set PI 3.1415926
 set l [expr 3e8 / $opt(freq)] ;# Wavelength of carrier
 

 #
 # Energy Models
 #

 
# Efriss_amp = RXThresh * (4pi)^2 / (Rb Gt Gr lambda^2)
 set opt(Efriss_amp) [expr [expr 1.1 * $opt(RXThresh) * 16 * $PI * $PI] / \
 [expr $opt(bw) * $opt(Gt) * $opt(Gr) * $l * $l]]
 # Etwo_ray_amp = RXThresh / (Rb Gt Gr ht^2 hr^2)
 set opt(Etwo_ray_amp) [expr 1.1 * $opt(RXThresh) / \
 [expr $opt(bw) * $opt(Gt) * $opt(Gr) * \
 $opt(ht) * $opt(ht) * $opt(ht) * $opt(ht)]]
 set opt(EXcvr) 50e-9 ;# Energy for radio circuitry
 set opt(e_bf) 5e-9 ;# Beamforming energy (J/bit)
 set opt(Esense) 0 ;# Sensing energy (J/bit)
 set opt(thresh_energy) 0.00 ;# Threshold for power adaptation
 set opt(Pidle) 0 ;# Idle power (W)
 set opt(Psleep) 0 ;# Sleep power (W)
 

# ===== Get rid of the warnings in bind ================================
 Resource/Energy set energyLevel_ $opt(init_energy)
 Resource/Energy set alarmLevel_ $opt(thresh_energy)
 Resource/Energy set expended_ 0
 
Agent/RCAgent set sport_ 0
 Agent/RCAgent set dport_ 0
 Agent/RCAgent set packetMsg_ 0
 Agent/RCAgent set distEst_ 0
 Agent/RCAgent set packetSize_ 0
 Agent/BSAgent set packetMsg_ 0
 Agent/BSAgent set packetSize_ 0
 Agent/BSAgent set recv_code_ 0
 
RCALinkLayer set delay_ 25us
 RCALinkLayer set bandwidth_ 0 
RCALinkLayer set off_prune_ 0 
RCALinkLayer set off_CtrMcast_ 0 
RCALinkLayer set macDA_ 0 
RCALinkLayer set debug_ 0 
RCALinkLayer set avoidReordering_ 0 

Phy/WirelessPhy set bandwidth_ $opt(bw)
 Phy/WirelessPhy set CSThresh_ $opt(CSThresh)
 Phy/WirelessPhy set RXThresh_ $opt(RXThresh)
 Phy/WirelessPhy set Efriss_amp_ $opt(Efriss_amp)
 Phy/WirelessPhy set Etwo_ray_amp_ $opt(Etwo_ray_amp)
 Phy/WirelessPhy set EXcvr_ $opt(EXcvr)
 Phy/WirelessPhy set freq_ $opt(freq)
 Phy/WirelessPhy set L_ $opt(L)
 Phy/WirelessPhy set sleep_ 0
 Phy/WirelessPhy set alive_ 1
 Phy/WirelessPhy set ss_ $opt(spreading)
 Phy/WirelessPhy set dist_ 0
 
Antenna/OmniAntenna set Gt_ $opt(Gt)
 Antenna/OmniAntenna set Gr_ $opt(Gr)
 Antenna/OmniAntenna set Z_ $opt(ht)
 
set MacTrace OFF
 Mac set bandwidth_ $opt(bw)
 Mac/Sensor set code_ 0
 Mac/Sensor set node_num_ 0
 Mac/Sensor set ss_ $opt(spreading) 
Mac/Sensor set CHheard_ 0
 Mac/Sensor set myADVnum_ 0
 
set bs[list $opt(bs_x) $opt(bs_y)]
 set BS_NODE 1
 
set outf [open "$opt(dirname)/conditions.txt" a]
 puts $outf "Simulation will stop after $opt(stop) seconds."
 puts $outf "Base station at ($opt(bs_x), $opt(bs_y))"
 if {$opt(eq_energy) == 1} {
 puts $outf "Each node starting with $opt(init_energy) Joules of energy.\n"
 }
 puts $outf "Energy Model:"
 puts $outf "\t\tRXThresh = $opt(RXThresh)"
 puts $outf "\t\tCSThresh = $opt(CSThresh)"
 puts $outf "\t\tRb = $opt(bw)"
 puts $outf "\t\tExcvr = $opt(EXcvr)"
 puts $outf "\t\tEfriss_amp = $opt(Efriss_amp)"
 puts $outf "\t\tEtwo_ray_amp = $opt(Etwo_ray_amp)"
 puts $outf "\t\tEbf = $opt(e_bf)"
 puts $outf "\t\tPidle = $opt(Pidle)"
 puts $outf "\t\tPsleep = $opt(Psleep)\n"
 close $outf
 
set initialized 0
 set rng_ [new RNG]
 
proc leach-create-mobile-node { id } {
 global ns_ chan prop topo tracefd opt node_ 
global initialized BS_NODE rng_
 
if {$initialized == 0} {
 sens_init
 set initialized 1
 }
 
# Create nodes.
 if {$id != $opt(nn_)} {
 puts -nonewline "$id "
 set node_($id) [new MobileNode/ResourceAwareNode]
 } else {
 puts "($opt(nn_) == BS)"
 set node_($id) [new MobileNode/ResourceAwareNode $BS_NODE]
 }
 
set node $node_($id)
 if {$id != $opt(nn_)} {
 # Set initial node energy.
 if {$opt(eq_energy) == 1} {
 $node set-energy $opt(init_energy) $opt(thresh_energy)
 } else {
 #set E [$rng_ uniform $opt(lower_e) $opt(upper_e)]
 #set rn [$rng_ uniform 0 1]
 #if {$rn 0.1} {
 # set E 200
 #} else {
 # set E 2
 #}
 set high_e_nodes[list 97 19 12 87 8 22 83 55 34 72]
 if {[lsearch $high_e_nodes $id] == -1} {
 set E 2
 } else {
 set E 200
 }
 $node set-energy $E $opt(thresh_energy)
 set initf [open "$opt(dirname)/init.energy" a]
 puts $initf "$id\t$E"
 close $initf
 }
 } else {
 # Base station has an infinite amount of energy.
 $node set-energy 50000 $opt(thresh_energy)
 }
 
# Disable random motion.
 $node random-motion 0 
$node topography $topo
 
if ![info exist inerrProc_] {
 set inerrProc_ ""
 }
 if ![info exist outerrProc_] {
 set outerrProc_ ""
 }
 if ![info exist FECProc_] {
 set FECProc_ ""
 }
 
# Connect the node to the channel.
 $node add-interface $chan $prop $opt(ll) $opt(mac) \
 $opt(ifq) $opt(ifqlen) $opt(netif) $opt(ant) \
 $topo $inerrProc_ $outerrProc_ $FECProc_
 
# Set up the trace target.
 set T [new Trace/Generic]
 $T target [$ns_ set nullAgent_]
 $T attach $tracefd
 $T set src_ $id
 $node log-target $T
 
$ns_ at 0.0 "$node_($id) start-app"
 }
 
proc sens_init {} {
 
global ns_ opt ns
 
# The timer code has hard-coded the global variable ns to
 # be the simulator.
 set ns $ns_
 
# Remove old trace files.
 catch "eval exec rm [glob -nocomplain $opt(dirname)/TDMAschedule.*.txt]"
 catch "exec rm $opt(dirname)/$opt(filename).energy"
 catch "exec rm $opt(dirname)/$opt(filename).data"
 catch "exec rm $opt(dirname)/$opt(filename).alive"
 catch "exec rm $opt(dirname)/startup.energy"
 catch "exec rm $opt(dirname)/init.energy"
 
puts "Creating sensor nodes..."

 sens_init_stats "$opt(dirname)/$opt(filename)"
 
$ns_ at $opt(stop) "sens_finish"
 # Start logging simulation statistics.
 $ns_ at $opt(check_energy) "sens_gather_stats"
 }
Im not sure where there I have done a changeis that were required from me but I still find the same error

Last edited by keepwalking; 05-23-2011 at 07:41 AM.
 
Old 04-22-2011, 03:31 AM   #217
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
keepwalking, posts # 214, # 216 :

No answers until you have used the 'Edit button' and done the required changes.

See post # 215.
 
Old 05-15-2011, 07:59 AM   #218
chethantm
LQ Newbie
 
Registered: May 2011
Posts: 1

Rep: Reputation: 0
Hello friends
If anybody has written a code for "An Efficient N-to-1 Multipath Routing Protocol in Wireless Sensor Networks" could you please send me the source code to my mail id chethan.atkit@gmail.com.
i will be very thankful to you if you send me the code
friends please help me


with regards
chethan
 
Old 07-04-2011, 05:40 AM   #219
keepwalking
Member
 
Registered: Oct 2010
Posts: 46

Rep: Reputation: 0
hello every one

I need to evaluate LEACH and LEAH-C but my TCl script want to run it give me the following errors, I need some one who can help me to solve this problem, I need to check delay of leader election , routing cost, number of hops taken.


Code:
luuh@ubuntu:~$ cd ns-allinone-2.34/ns-2.34/mit/
luuh@ubuntu:~/ns-allinone-2.34/ns-2.34/mit$ ns leacttcl.tcl
syntax error in expression "$i  $argc": extra tokens at end of expression
    ("for" test expression)
    while compiling
"for {set i 0} {$i  $argc} {incr i} {
		set arg [lindex $argv $i]
		if {[string range $arg 0 0] != "-"} continue

		set name [string range $arg 1 end]
..."
    (compiling body of proc "getopt", line 5)
    invoked from within
"getopt $argc $argv"
    (file "leacttcl.tcl" line 180)
luuh@ubuntu:~/ns-allinone-2.34/ns-2.34/mit$
this my TCL script
Code:
# Copyright (c) 1997 Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
#    must display the following acknowledgement:
#      This product includes software developed by the Computer Systems
#      Engineering Group at Lawrence Berkeley Laboratory.
# 4. Neither the name of the University nor of the Laboratory may be used
#    to endorse or promote products derived from this software without
#    specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $Header: /usr/src/mash/repository/vint/ns-2/tcl/ex/wireless.tcl,v 1.2 1999/02/24 23:27:34 haldar Exp $
#
# Ported from CMU/Monarch's code, nov'98 -Padma.

# ======================================================================
# Default Script Options
# ======================================================================
set opt(chan)		Channel/WirelessChannel
set opt(prop)		Propagation/TwoRayGround
#set opt(netif)		NetIf/SharedMedia
set opt(netif)		Phy/WirelessPhy
#set opt(mac)		Mac/802_11
set opt(mac)		Mac/802_11
set opt(ifq)		Queue/DropTail/PriQueue
set opt(ll)		LL
set opt(ant)            Antenna/OmniAntenna

set opt(x)		0	;# X dimension of the topography
set opt(y)		0		;# Y dimension of the topography
#set opt(cp)		"../mobility/scene/cbr-50-20-4-512" ;# connection pattern file
set opt(cp)		""
set opt(sc)		"../mobility/scene/scen-670x670-50-600-20-2" ;# scenario file


set opt(ifqlen)		50		;# max packet in ifq
set opt(nn)		51		;# number of nodes
set opt(seed)		0.0
set opt(stop)		10.0		;# simulation time
set opt(tr)		out.tr		;# trace file
set opt(rp)             dsdv            ;# routing protocol script
set opt(lm)             "on"           ;# log movement

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

set AgentTrace			ON
set RouterTrace			ON
set MacTrace			OFF

LL set mindelay_		50us
LL set delay_			25us
LL set bandwidth_		0	;# not used
LL set off_prune_		0	;# not used
LL set off_CtrMcast_		0	;# not used

Agent/Null set sport_		0
Agent/Null set dport_		0

Agent/CBR set sport_		0
Agent/CBR set dport_		0

Agent/TCPSink set sport_	0
Agent/TCPSink set dport_	0

Agent/TCP set sport_		0
Agent/TCP set dport_		0
Agent/TCP set packetSize_	1460

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

# 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_ 3.652e-10
Phy/WirelessPhy set Rb_ 2*1e6
Phy/WirelessPhy set Pt_ 0.2818
Phy/WirelessPhy set freq_ 914e+6 
Phy/WirelessPhy set L_ 1.0

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

proc usage { argv0 }  {
	puts "Usage: $argv0"
	puts "\tmandatory arguments:"
	puts "\t\t\[-x MAXX\] \[-y MAXY\]"
	puts "\toptional arguments:"
	puts "\t\t\[-cp conn pattern\] \[-sc scenario\] \[-nn nodes\]"
	puts "\t\t\[-seed seed\] \[-stop sec\] \[-tr tracefile\]\n"
}


proc getopt {argc argv} {
	global opt
	lappend optlist cp nn seed sc stop tr x y

	for {set i 0} {$i  $argc} {incr i} {
		set arg [lindex $argv $i]
		if {[string range $arg 0 0] != "-"} continue

		set name [string range $arg 1 end]
		set opt($name) [lindex $argv [expr $i+1]]
	}
}


proc cmu-trace { ttype atype node } {
	global ns_ tracefd

	if { $tracefd == "" } {
		return ""
	}
	set T [new CMUTrace/$ttype $atype]
	$T target [$ns_ set nullAgent_]
	$T attach $tracefd
        $T set src_ [$node id]

        $T node $node

	return $T
}


proc create-god { nodes } {
	global ns_ god_ tracefd

	set god_ [new God]
	$god_ num_nodes $nodes
}

proc log-movement {} {
    global logtimer ns_ ns

    set ns $ns_
    source tcl/mobility/timer.tcl
    Class LogTimer -superclass Timer
    LogTimer instproc timeout {} {
	global opt node_;
	for {set i 0} {$i  $opt(nn)} {incr i} {
	    $node_($i) log-movement
	}
	$self sched 0.1
    }

    set logtimer [new LogTimer]
    $logtimer sched 0.1
}

# ======================================================================
# Main Program
# ======================================================================
getopt $argc $argv

#
# Source External TCL Scripts
#
source tcl/lib/ns-mobilenode.tcl

#if { $opt(rp) != "" } {
	source tcl/mobility/$opt(rp).tcl
	#} elseif { [catch { set env(NS_PROTO_SCRIPT) } ] == 1 } {
	#puts "\nenvironment variable NS_PROTO_SCRIPT not set!\n"
	#exit
#} else {
	#puts "\n*** using script $env(NS_PROTO_SCRIPT)\n\n";
        #source $env(NS_PROTO_SCRIPT)
#}
source tcl/lib/ns-cmutrace.tcl

# do the get opt again incase the routing protocol file added some more
# options to look for
getopt $argc $argv

if { $opt(x) == 0 || $opt(y) == 0 } {
	usage $argv0
	exit 1
}

if {$opt(seed) > 0} {
	puts "Seeding Random number generator with $opt(seed)\n"
	ns-random $opt(seed)
}

#
# Initialize Global Variables
#
set ns_		[new Simulator]
set chan	[new $opt(chan)]
set prop	[new $opt(prop)]
set topo	[new Topography]
set tracefd	[open $opt(tr) w]

$topo load_flatgrid $opt(x) $opt(y)

$prop topography $topo

#
# Create God
#
create-god $opt(nn)


#
# log the mobile nodes movements if desired
#
if { $opt(lm) == "on" } {
    log-movement
}

#
#  Create the specified number of nodes $opt(nn) and "attach" them
#  the channel.
#  Each routing protocol script is expected to have defined a proc
#  create-mobile-node that builds a mobile node and inserts it into the
#  array global $node_($i)
#

if { [string compare $opt(rp) "dsr"] == 0} { 
	for {set i 0} {$i  $opt(nn) } {incr i} {
		dsr-create-mobile-node $i
	}
} elseif { [string compare $opt(rp) "dsdv"] == 0} { 
	for {set i 0} {$i  $opt(nn) } {incr i} {
		dsdv-create-mobile-node $i
	}
} elseif { [string compare $opt(rp) "leach"] == 0} { 
	for {set i 0} {$i  $opt(nn) } {incr i} {
		leach-create-mobile-node $i
	}
} elseif { [string compare $opt(rp) "leach-c"] == 0} { 
	for {set i 0} {$i  $opt(nn) } {incr i} {
		leach-create-mobile-node $i
	}
} elseif { [string compare $opt(rp) "stat-clus"] == 0} { 
	for {set i 0} {$i  $opt(nn) } {incr i} {
		leach-create-mobile-node $i
	}
} elseif { [string compare $opt(rp) "mte"] == 0} { 
	for {set i 0} {$i  $opt(nn) } {incr i} {
		leach-create-mobile-node $i
	}
}


#
# Source the Connection and Movement scripts
#
if { $opt(cp) == "" } {
	puts "*** NOTE: no connection pattern specified."
        set opt(cp) "none"
} else {
	puts "Loading connection pattern..."
	source $opt(cp)
}


#
# Tell all the nodes when the simulation ends
#
for {set i 0} {$i  $opt(nn) } {incr i} {
    $ns_ at $opt(stop).000000001 "$node_($i) reset";
}
$ns_ at $opt(stop).00000001 "puts \"NS EXITING...\" ; $ns_ halt"


if { $opt(sc) == "" } {
	puts "*** NOTE: no scenario file specified."
        set opt(sc) "none"
} else {
	puts "Loading scenario file..."
	source $opt(sc)
	puts "Load complete..."
}

puts $tracefd "M 0.0 nn $opt(nn) x $opt(x) y $opt(y) rp $opt(rp)"
puts $tracefd "M 0.0 sc $opt(sc) cp $opt(cp) seed $opt(seed)"
puts $tracefd "M 0.0 prop $opt(prop) ant $opt(ant)"

puts "Starting Simulation..."
$ns_ run
 
Old 08-05-2011, 09:28 AM   #220
monazEssam
LQ Newbie
 
Registered: Aug 2011
Posts: 22

Rep: Reputation: Disabled
Quote:
Originally Posted by knudfl View Post
@ maunik : Click my name, send an email, and I will attach
mit.tar.gz + LEACH-Makefile-org to a return mail. ( 580 kB.)

.....
Dear knudfl,
can you send them (mit.tar.gz + LEACH-Makefil)to me too, my email is monaz.essam@gmail.com
i need them badly

Last edited by monazEssam; 08-05-2011 at 09:30 AM.
 
Old 08-05-2011, 09:34 AM   #221
monazEssam
LQ Newbie
 
Registered: Aug 2011
Posts: 22

Rep: Reputation: Disabled
needed urgently

Dears,
I'm a new member and i need to install the leach on NS2 for my masters, but i can't get Leach mit.tar.gz neither the make file? so can any one help me and send me them on my Email? Monaz.essam@gmail.com
thanks in advance
 
Old 08-05-2011, 11:18 AM   #222
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 #220, #221 @monazEssam : Welcome to LQ. .. .. ..

Please read all the above posts, there may be some info, you need.
That's where I also found the references to these links :


Ns-2.27, Leach download links (from Google Docs), post # 3 here
http://www.linuxquestions.org/questi...each-862835/#4

Ns-2.34 , Leach instructions and files, post # 5 here
http://www.linuxquestions.org/questi...34-a-870368/#5


More info : LQ Search, Tag = leach

Good luck !
..

Last edited by knudfl; 08-05-2011 at 11:30 AM.
 
Old 08-23-2011, 03:11 AM   #223
keepwalking
Member
 
Registered: Oct 2010
Posts: 46

Rep: Reputation: 0
how to write a sending method on c++ the sends a packet with remaining energy on ns2
 
Old 09-27-2011, 01:17 AM   #224
narendra kumar patel
LQ Newbie
 
Registered: Sep 2011
Posts: 2

Rep: Reputation: Disabled
mit leach in ns2.34

I have ns2.34 installed in ubuntu 9.10. Now I want to run and work on mit LEACH protocol in ns2.34. I have installed ns-leach2.34, i m not able to run it.Can anyone plz tell me entire process of run mit leach in ns2.34.
thanks ........
 
Old 09-28-2011, 03:49 PM   #225
monazEssam
LQ Newbie
 
Registered: Aug 2011
Posts: 22

Rep: Reputation: Disabled
Dears,
I want to know what's the traffic model of LEACH, i mean what is its connection pattern?and in which file it is defined?

please replay me ASAP
 
  


Closed Thread

Tags
leach, leach-ns227, ns2, ns227



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in simulating Black Hole Attack in AODV Protocol through NS2 in FC8 shyan Linux - Newbie 3 02-17-2015 03:21 PM
NS2 installation ds_priyaa Fedora 2 05-28-2008 02:23 AM
NS2 installation eby83 Linux - Newbie 2 06-11-2007 01:08 AM
ns2 installation pranoti Linux - Software 2 06-11-2007 12:45 AM
LXer: Interview with Bernard Leach (iPodLinux) LXer Syndicated Linux News 0 10-31-2006 11:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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