how to integrate the "Resource/Energy" leach class into NS-2.34?
Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have corrected that error conform to deepa but when i hit again "make":
Code:
./common/packet.h:398: warning: deprecated conversion from string constant to ‘char*’
trace/cmu-trace.cc: In member function ‘void CMUTrace::format_rca(Packet*, int)’:
trace/cmu-trace.cc:1531: error: ‘ADV_CHAR’ was not declared in this scope
trace/cmu-trace.cc:1535: error: ‘REQ_CHAR’ was not declared in this scope
trace/cmu-trace.cc:1539: error: ‘DATA_CHAR’ was not declared in this scope
make: *** [trace/cmu-trace.o] Error 1
root@ubuntu:/opt/ns-allinone-2.34/ns-2.34#
I have corrected that error conform to deepa but when i hit again "make":
Code:
./common/packet.h:398: warning: deprecated conversion from string constant to ‘char*’
trace/cmu-trace.cc: In member function ‘void CMUTrace::format_rca(Packet*, int)’:
trace/cmu-trace.cc:1531: error: ‘ADV_CHAR’ was not declared in this scope
trace/cmu-trace.cc:1535: error: ‘REQ_CHAR’ was not declared in this scope
trace/cmu-trace.cc:1539: error: ‘DATA_CHAR’ was not declared in this scope
make: *** [trace/cmu-trace.o] Error 1
root@ubuntu:/opt/ns-allinone-2.34/ns-2.34#
Are there any files in leach_sims ? for example, leach.err ?
What do you mean by "and I reached leach.out" ???
And did you made a folder called "ns-234-leach". If so, have u modified the leach_test file (line that says dirname="mit/leach_sims") accordingly?
Quote:
Originally Posted by leminh1009
Hi everyone,
As previous, when I've been running ./test and I reached leach.out as following path: /root/ns-allinone-2.34/ns-2.34/ns-234-leach/mit/leach_sims but no result in it.
deepa_2111 i added what you told me. So, my cmu-trace.h file is :
Code:
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*-
*
* 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: /cvsroot/nsnam/ns-2/trace/cmu-trace.h,v 1.28 2009/01/15 06:23:49 tom_henderson Exp $
*/
/* Ported from CMU/Monarch's code, nov'98 -Padma.*/
#ifndef __cmu_trace__
#define __cmu_trace__
#include "trace.h"
#include "god.h"
#ifndef __PRETTY_FUNCTION__
#define __PRETTY_FUNCTION__ ("")
#endif /* !__PRETTY_FUNCTION__ */
/* ======================================================================
Global Defines
====================================================================== */
#define DROP 'D'
#define RECV 'r'
#define SEND 's'
#define FWRD 'f'
// change wrt Mike's code
#define EOT 'x'
#define TR_ROUTER 0x01
#define TR_MAC 0x02
#define TR_IFQ 0x04
#define TR_AGENT 0x08
#define TR_PHY 0x10
#define DROP_END_OF_SIMULATION "END"
#define DROP_MAC_COLLISION "COL"
#define DROP_MAC_DUPLICATE "DUP"
#define DROP_MAC_PACKET_ERROR "ERR"
#define DROP_MAC_RETRY_COUNT_EXCEEDED "RET"
#define DROP_MAC_INVALID_STATE "STA"
#define DROP_MAC_BUSY "BSY"
#define DROP_MAC_INVALID_DST "DST"
#define DROP_MAC_SLEEP "SLP" // smac sleep state
#define DROP_RTR_NO_ROUTE "NRTE" // no route
#define DROP_RTR_ROUTE_LOOP "LOOP" // routing loop
#define DROP_RTR_TTL "TTL" // ttl reached zero
#define DROP_RTR_QFULL "IFQ" // queue full
#define DROP_RTR_QTIMEOUT "TOUT" // packet expired
#define DROP_RTR_MAC_CALLBACK "CBK" // MAC callback
#define DROP_RTR_SALVAGE "SAL"
#define DROP_IFQ_QFULL "IFQ" // no buffer space in IFQ
#define DROP_IFQ_ARP_FULL "ARP" // dropped by ARP
#define DROP_IFQ_FILTER "FIL"
#define DROP_OUTSIDE_SUBNET "OUT" // dropped by base stations if received rtg updates from nodes outside its domain.
#define MAX_ID_LEN 3
#define MAX_NODE 4096
/**
* This class allows a dynamic library to define the tracing format
* for newly defined packet types
*
*/
class PacketTracer
{
public:
PacketTracer();
virtual ~PacketTracer();
void setNext(PacketTracer *next);
PacketTracer *getNext();
int format_unknow(Packet *p, int offset, BaseTrace *pt_, int newtrace);
protected:
virtual int format(Packet *p, int offset, BaseTrace *pt_, int newtrace) = 0; //return 0 if the packet is unknown
PacketTracer *next_;
};
class CMUTrace : public Trace {
public:
CMUTrace(const char *s, char t);
void recv(Packet *p, Handler *h);
void recv(Packet *p, const char* why);
static void addPacketTracer(PacketTracer *pt);
private:
char tracename[MAX_ID_LEN + 1];
int nodeColor[MAX_NODE];
int tracetype;
MobileNode *node_;
int newtrace_;
//<zheng: ns 2.27 removed the following part, but we need it to control the broadcast radius>
static double bradius;
static double radius_scaling_factor_;
static double duration_scaling_factor_;
static void calculate_broadcast_parameters();
//</zheng>
int initialized() { return node_ && 1; }
int node_energy();
int command(int argc, const char*const* argv);
void format(Packet *p, const char *why);
void nam_format(Packet *p, int offset);
void format_phy(Packet *p, int offset);
void format_mac_common(Packet *p, const char *why, int offset);
void format_mac(Packet *p, int offset);
void format_smac(Packet *p, int offset);
void format_ip(Packet *p, int offset);
void format_arp(Packet *p, int offset);
void format_hdlc(Packet *p, int offset);
void format_dsr(Packet *p, int offset);
void format_msg(Packet *p, int offset);
void format_tcp(Packet *p, int offset);
void format_sctp(Packet *p, int offset);
void format_rtp(Packet *p, int offset);
void format_tora(Packet *p, int offset);
void format_imep(Packet *p, int offset);
void format_aodv(Packet *p, int offset);
void format_aomdv(Packet *p, int offset);
#ifdef MIT_uAMPS
void format_rca(Packet *p, int offset);
#define ADV_CHAR 'A'
#define REQ_CHAR 'R'
#define DATA_CHAR 'D'
#endif
// This holds all the tracers added at run-time
static PacketTracer *pktTrc_;
};
#endif
IS ok?
I ask this because when i run .test something it's working but I have some warning:
Code:
/test
num_nodes is set 3
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
warning: no class variable Phy/WirelessPhy::alive_
see tcl-object.tcl in tclcl for info about this warning.
warning: no class variable Phy/WirelessPhy::Efriss_amp_
warning: no class variable Phy/WirelessPhy::Etwo_ray_amp_
warning: no class variable Phy/WirelessPhy::EXcvr_
warning: no class variable Phy/WirelessPhy::sleep_
warning: no class variable Phy/WirelessPhy::ss_
warning: no class variable Phy/WirelessPhy::dist_
INITIALIZE THE LIST xListHead
warning: no class variable Phy/WirelessPhy::alive_
see tcl-object.tcl in tclcl for info about this warning.
warning: no class variable Phy/WirelessPhy::Efriss_amp_
warning: no class variable Phy/WirelessPhy::Etwo_ray_amp_
warning: no class variable Phy/WirelessPhy::EXcvr_
warning: no class variable Phy/WirelessPhy::sleep_
warning: no class variable Phy/WirelessPhy::ss_
warning: no class variable Phy/WirelessPhy::dist_
warning: no class variable Phy/WirelessPhy::alive_
see tcl-object.tcl in tclcl for info about this warning.
warning: no class variable Phy/WirelessPhy::Efriss_amp_
warning: no class variable Phy/WirelessPhy::Etwo_ray_amp_
warning: no class variable Phy/WirelessPhy::EXcvr_
warning: no class variable Phy/WirelessPhy::sleep_
warning: no class variable Phy/WirelessPhy::ss_
warning: no class variable Phy/WirelessPhy::dist_
Loading connection pattern...
Loading scenario file...
Starting Simulation...
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5, distCST_ = 89.8
SORTING LISTS ...DONE!
NS EXITING...
In /opt/ns-allinone-2.34/ns-2.34/ns-234-leach/mit/leach_sims# nano leach.err I Have:
Code:
INITIALIZE THE LIST xListHead
SORTING LISTS ...DONE!
Congrats ! You have got it working. Whats you see in leach.err is not a warning/error. It is a status message that appears if your simulation is running.
The warnings you see are ok. But if you want to remove them, in uamps.tcl, added the last paragraph i.e.
Code:
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
so that lines 98 - 131 in uamps.tcl are ::
Code:
# ===== 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
Quote:
Originally Posted by helyos
deepa_2111 i added what you told me. So, my cmu-trace.h file is :
IS ok?
I ask this because when i run .test something it's working but I have some warning:
Code:
/test
num_nodes is set 3
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
warning: no class variable Phy/WirelessPhy::alive_
see tcl-object.tcl in tclcl for info about this warning.
warning: no class variable Phy/WirelessPhy::Efriss_amp_
warning: no class variable Phy/WirelessPhy::Etwo_ray_amp_
warning: no class variable Phy/WirelessPhy::EXcvr_
warning: no class variable Phy/WirelessPhy::sleep_
warning: no class variable Phy/WirelessPhy::ss_
warning: no class variable Phy/WirelessPhy::dist_
INITIALIZE THE LIST xListHead
warning: no class variable Phy/WirelessPhy::alive_
see tcl-object.tcl in tclcl for info about this warning.
warning: no class variable Phy/WirelessPhy::Efriss_amp_
warning: no class variable Phy/WirelessPhy::Etwo_ray_amp_
warning: no class variable Phy/WirelessPhy::EXcvr_
warning: no class variable Phy/WirelessPhy::sleep_
warning: no class variable Phy/WirelessPhy::ss_
warning: no class variable Phy/WirelessPhy::dist_
warning: no class variable Phy/WirelessPhy::alive_
see tcl-object.tcl in tclcl for info about this warning.
warning: no class variable Phy/WirelessPhy::Efriss_amp_
warning: no class variable Phy/WirelessPhy::Etwo_ray_amp_
warning: no class variable Phy/WirelessPhy::EXcvr_
warning: no class variable Phy/WirelessPhy::sleep_
warning: no class variable Phy/WirelessPhy::ss_
warning: no class variable Phy/WirelessPhy::dist_
Loading connection pattern...
Loading scenario file...
Starting Simulation...
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5, distCST_ = 89.8
SORTING LISTS ...DONE!
NS EXITING...
In /opt/ns-allinone-2.34/ns-2.34/ns-234-leach/mit/leach_sims# nano leach.err I Have:
Code:
INITIALIZE THE LIST xListHead
SORTING LISTS ...DONE!
As I can see i have two uamps.tcl :
/opt/ns-allinone-2.34/ns-2.34/mit/uAMPS/sims/uamps.tcl
/opt/ns-allinone-2.34/ns-2.34/ns-234-leach/mit/uAMPS/sims/uamps.tcl
The strange thing is that the files are exactly the same and they already have this code added. This is how they look:
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 mit/uAMPS/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"
}
It should be modified into another file? Thank you in advance.
I suggest you delete the folder /opt/ns-allinone-2.34/ns-2.34/ns-234-leach/ and all its contents.
Then, modify the uamps.tcl in the /opt/ns-allinone-2.34/ns-2.34/mit/uAMPS/sims/ folder.
Quote:
Originally Posted by helyos
@deepa_2111
As I can see i have two uamps.tcl :
/opt/ns-allinone-2.34/ns-2.34/mit/uAMPS/sims/uamps.tcl
/opt/ns-allinone-2.34/ns-2.34/ns-234-leach/mit/uAMPS/sims/uamps.tcl
The strange thing is that the files are exactly the same and they already have this code added. This is how they look:
It should be modified into another file? Thank you in advance.
Hmmmm actually i think leach is not working. I deleted the folder /opt/ns-allinone-2.34/ns-2.34/ns-234-leach/ and all its contents.
Then i saw that actually leach.out has nothing in it.
/opt/ns-allinone-2.34/ns-2.34/mit/leach_sims/leach.err has this:
Code:
can't read "env(RCA_LIBRARY)": no such variable
while executing
"source $env(RCA_LIBRARY)/ns-ranode.tcl"
(file "mit/uAMPS/sims/uamps.tcl" line 9)
invoked from within
"source.orig mit/uAMPS/sims/uamps.tcl"
("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 mit/uAMPS/sims/uamps.tcl"
(file "tcl/mobility/leach.tcl" line 18)
invoked from within
"source.orig tcl/mobility/leach.tcl"
("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 tcl/mobility/$opt(rp).tcl"
(file "tcl/ex/wireless.tcl" line 187)
When i run ./test no errors but i still have that warnings and uamps.tcl is with modifications from above . Please help me
test script is :
Code:
#!/bin/bash
cd tcl/ex
ns wireless-demo-csci694.tcl
sleep 2
cd ../../
./leach_test
here is my problem :nothing to be done for 'all'.Anyone help?thank you ~
for i in indep-utils/cmu-scen-gen/setdest indep-utils/webtrace-conv/dec indep-utils/webtrace-conv/epa indep-utils/webtrace-conv/nlanr indep-utils/webtrace-conv/ucb; do ( cd $i; make all; ) done
make[1]: Entering directory `/home/liuqingwei/ns2/ns-allinone-2.34/ns-2.34/indep-utils/cmu-scen-gen/setdest'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/liuqingwei/ns2/ns-allinone-2.34/ns-2.34/indep-utils/cmu-scen-gen/setdest'
make[1]: Entering directory `/home/liuqingwei/ns2/ns-allinone-2.34/ns-2.34/indep-utils/webtrace-conv/dec'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/liuqingwei/ns2/ns-allinone-2.34/ns-2.34/indep-utils/webtrace-conv/dec'
make[1]: Entering directory `/home/liuqingwei/ns2/ns-allinone-2.34/ns-2.34/indep-utils/webtrace-conv/epa'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/liuqingwei/ns2/ns-allinone-2.34/ns-2.34/indep-utils/webtrace-conv/epa'
make[1]: Entering directory `/home/liuqingwei/ns2/ns-allinone-2.34/ns-2.34/indep-utils/webtrace-conv/nlanr'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/liuqingwei/ns2/ns-allinone-2.34/ns-2.34/indep-utils/webtrace-conv/nlanr'
make[1]: Entering directory `/home/liuqingwei/ns2/ns-allinone-2.34/ns-2.34/indep-utils/webtrace-conv/ucb'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/liuqingwei/ns2/ns-allinone-2.34/ns-2.34/indep-utils/webtrace-conv/ucb'
when i do this : root@ubuntu:~/ns2/ns-allinone-2.34/ns-2.34# ./test
it shows the same problem with @helyos at #53
Today i have set up after your instructions n2.34 with leach on ubuntu 9.04 but i have EXACTLY the same error as helyos.
I beg you to tell me how to resolve this error. In two days i need this simulation!!!
Code:
can't read "env(RCA_LIBRARY)": no such variable
while executing
"source $env(RCA_LIBRARY)/ns-ranode.tcl"
(file "mit/uAMPS/sims/uamps.tcl" line 9)
invoked from within
"source.orig mit/uAMPS/sims/uamps.tcl"
("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 mit/uAMPS/sims/uamps.tcl"
(file "tcl/mobility/leach.tcl" line 18)
invoked from within
"source.orig tcl/mobility/leach.tcl"
("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 tcl/mobility/$opt(rp).tcl"
(file "tcl/ex/wireless.tcl" line 187)
Helyos if you figure out pleeeeeeaseeeee tell me cause I am disperate
The problem is in your path. What I did was modify all the paths in uamps.tcl. You can see my modified code below the commented out lines (lines beginning with '#') ::
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 /usr/local/ns-allinone-2.35-RC4/ns-2.35/mit/rca/ns-ranode.tcl
#source $env(uAMPS_LIBRARY)/ns-bsapp.tcl
source /usr/local/ns-allinone-2.35-RC4/ns-2.35/mit/uAMPS/ns-bsapp.tcl
#source $env(uAMPS_LIBRARY)/extras.tcl
source /usr/local/ns-allinone-2.35-RC4/ns-2.35/mit/uAMPS/extras.tcl
#source $env(uAMPS_LIBRARY)/stats.tcl
source /usr/local/ns-allinone-2.35-RC4/ns-2.35/mit/uAMPS/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 mit/uAMPS/stats.tcl
#source $env(RCA_LIBRARY)/resources/ns-resource-manager.tcl
source /usr/local/ns-allinone-2.35-RC4/ns-2.35/mit/rca/resources/ns-resource-manager.tcl
#source $env(RCA_LIBRARY)/resources/ns-energy-resource.tcl
source /usr/local/ns-allinone-2.35-RC4/ns-2.35/mit/rca/resources/ns-energy-resource.tcl
#source $env(RCA_LIBRARY)/resources/ns-neighbor-resource.tcl
source /usr/local/ns-allinone-2.35-RC4/ns-2.35/mit/rca/resources/ns-neighbor-resource.tcl
Yey !!! deepa_2111 thank,thank you so much deepa_2111 now leach is working i have no error on leach.err and leach.out is generated.
Only one thing and i will not bother you. Those warnings are still there and now this is the content of my uamps.tcl. There are the "Get rid of the warnings in bind" additions.
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 /opt/ns-allinone-2.34/ns-2.34/mit/rca/ns-ranode.tcl
#source $env(uAMPS_LIBRARY)/ns-bsapp.tcl
source /opt/ns-allinone-2.34/ns-2.34/mit/uAMPS/ns-bsapp.tcl
#source $env(uAMPS_LIBRARY)/extras.tcl
source /opt/ns-allinone-2.34/ns-2.34/mit/uAMPS/extras.tcl
#source $env(uAMPS_LIBRARY)/stats.tcl
source /opt/ns-allinone-2.34/ns-2.34/mit/uAMPS/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 mit/uAMPS/stats.tcl
#source $env(RCA_LIBRARY)/resources/ns-resource-manager.tcl
source /opt/ns-allinone-2.34/ns-2.34/mit/rca/resources/ns-resource-manager.tcl
#source $env(RCA_LIBRARY)/resources/ns-energy-resource.tcl
source /opt/ns-allinone-2.34/ns-2.34/mit/rca/resources/ns-energy-resource.tcl
#source $env(RCA_LIBRARY)/resources/ns-neighbor-resource.tcl
source /opt/ns-allinone-2.34/ns-2.34/mit/rca/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"
}
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.