LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 06-07-2013, 09:35 PM   #1
fualku1986@yahoo.com
LQ Newbie
 
Registered: Mar 2012
Posts: 3

Rep: Reputation: Disabled
update files in ns2


iam working with ns2 extension which support wireless sensor network, when i make some changes in sensorapp.cc file and compile the ns2 by make instruction ns2 did not take the changes
 
Old 06-08-2013, 04:27 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2020 CentOS6.10 CentOS7.7 + 50+ other Linux OS, for test only.
Posts: 17,393

Rep: Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607
Welcome to LQ.

Make sure that the object 'sensorapp.o' is present in the Makefile.in.

When / if you recompile for additional changes, the command is :
$ make clean && make


If you have further questions, some more information is required :
Ubuntu version, WSN patch name, ns2 version, files.tcl used to test WSN.
Any changes in sensorapp.cc must be shown. Or include a link to "instruction".
And please explain in details which changes you expected in WSN behavior
by editing sensorapp.cc.

-

Last edited by knudfl; 06-08-2013 at 04:38 AM.
 
Old 06-08-2013, 10:41 AM   #3
fualku1986@yahoo.com
LQ Newbie
 
Registered: Mar 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
thanks for replay

iam checked my makefile.in and i found the sensorapp.o
iam use the 10.04 LTS Lucid Lynx
ns-2.27 version which compatible with nrlsensorsim-2.27
the file sensorapp.cc has the following options

// set to true, if node color changes are unwanted
#define DISABLE_COLORS TRUE

// This is the size (in bytes) of the messages to send to the gateway, or data
// collection point, or whatever you want to call the sink node attached to this
// sensor node (over udp, for example)
#define MESG_SIZE 100

all these option you can change it and work with. i want to change the size of message to 32byte and any change but does not work
sorry to bother you
 
Old 06-08-2013, 11:13 AM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2020 CentOS6.10 CentOS7.7 + 50+ other Linux OS, for test only.
Posts: 17,393

Rep: Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607
# 3.
Quote:
any change but does not work
'Does not work' isn't telling what is happening. Or what you are doing.

Please show an example simulation, with 1) the "MESG_SIZE 100",
and 2) "MESG_SIZE 32".
And tell what you expected to happen, please.

-
 
Old 06-08-2013, 10:07 PM   #5
fualku1986@yahoo.com
LQ Newbie
 
Registered: Mar 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
replay

Quote:
Originally Posted by knudfl View Post
# 3.

'Does not work' isn't telling what is happening. Or what you are doing.

Please show an example simulation, with 1) the "MESG_SIZE 100",
and 2) "MESG_SIZE 32".
And tell what you expected to happen, please.

-
the following package sensorapp.cc contain many options, all i want to activate these options as you can see in the package. working with the nrl extension for ns2.27 for sensor network have default values like message size at the same time is able to change. therefore i want to change this default value.
AUTHORIZATION TO USE AND DISTRIBUTE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that:
*
* (1) source code distributions retain this paragraph in its entirety,
*
* (2) distributions including binary code include this paragraph in
* its entirety in the documentation or other materials provided
* with the distribution, and
*
* (3) all advertising materials mentioning features or use of this
* software display the following acknowledgment:
*
* "This product includes software written and developed
* by Brian Adamson, Joe Macker Justin Dean, and Ian Downard
* of the Naval Research Laboratory (NRL)."
*
* The name of NRL, the name(s) of NRL employee(s), or any entity
* of the United States Government may not be used to endorse or
* promote products derived from this software, nor does the
* inclusion of the NRL written and developed software directly or
* indirectly suggest NRL or United States Government endorsement
* of this product.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
********************************************************************/

/*

Class SensorApp defines the sensor application which describes what a sensor
node should do after it detects some phenomenon. This particular application
utilizes node color to show when the sensor detects some phenomenon.

Specifically, when a node does hear PHENOM packets, this application changes
the node color to red, activates an "alarm" public variable, and sends MESG_SIZE
bytes to the sink node of a UDP connection. When the node has not recieved a
PHENOM packet in the timeout period specified in SILENT_PHENOMENON, then the
node turns green (assuming node coloring has not been disabled; see
the customizable parameters, below).

*/

#include "sensornets-NRL/sensoragent.h"
#include "sensornets-NRL/sensorapp.h"
/********************** customizable parameters *******************************/

// seconds of quiessence required for a sensor to go off it's alarming state:
#define SILENT_PHENOMENON 0.2

// set to true, if node color changes are unwanted
#define DISABLE_COLORS TRUE

// This is the size (in bytes) of the messages to send to the gateway, or data
// collection point, or whatever you want to call the sink node attached to this
// sensor node (over udp, for example)
#define MESG_SIZE 26

// This is the frequency with which a sensor node triggered by PHENOM pkts
// will send a message to the gateway, or data collection point, or sink,
// or whatever you want to call the sink node attached to this sensor node
// (over udp, for example). Units are in seconds, so a message of size
// MESG_SIZE bytes will be transmitted to the gateway node once for every
// TRANSMIT_FREQ seconds in which the sensor node has recieved one or more
// PHENOM packets.
#define TRANSMIT_FREQ 1
#####above you can the options for message size and others this enable me to control and see the affect of change the message size on the energy consumption of sensor node.

there are many example like this example to see the energy consumption for the sensor node if i decrease the message size to 32bytes while its 100bytes as default.
# ======================================================================
# Define options
# ======================================================================
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) 2 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
set val(x) 400
set val(y) 400

Queue/DropTail/PriQueue set Prefer_Routing_Protocols 1

# specify the transmit power
# (see wireless-shadowing-vis-test.tcl for another example)
Phy/WirelessPhy set Pt_ 0.3

puts "This is a multi-channel sensor network test program."

# =====================================================================
# Main Program
# ======================================================================

#
# Initialize Global Variables
#

set ns_ [new Simulator]
set tracefd [open phenom05.tr w]
$ns_ trace-all $tracefd

set namtrace [open phenom05.nam w]
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)

# set up topography object
set topo [new Topography]

$topo load_flatgrid $val(x) $val(y)

#
# Create God
#
set god_ [create-god $val(nn)]
$god_ off
$god_ allow_to_stop
$god_ num_data_types 1

#configure phenomenon
set chan_1_ [new $val(chan)]
set chan_2_ [new $val(chan)]

# configure phenomenon node
set val(rp) PHENOM ;# PHENOM routing protocol
$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) \
-channel $chan_1_ \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace ON

set node_(0) [$ns_ node 0]
$node_(0) random-motion 0 ;# disable random motion
$god_ new_node $node_(0)
$node_(0) namattach $namtrace
$ns_ initial_node_pos $node_(0) 25
[$node_(0) set ragent_] pulserate .5 ;#configures PHENOM node
[$node_(0) set ragent_] phenomenon CO ;#configures PHENOM node

# configure wireless nodes

# configure dual-homed node (i.e. sensor node)
set val(rp) AODV ;# AODV routing protocol
$ns_ node-config \
-adhocRouting $val(rp) \
-channel $chan_2_ \
-energyModel EnergyModel \
-rxPower 0.175 \
-txPower 0.175 \
-sensePower 0.00000175 \
-idlePower 0.0 \
-initialEnergy 0.1 \
-PHENOMchannel $chan_1_ ;# adds the PHENOM iface

set node_(1) [$ns_ node 1]
$node_(1) random-motion 0 ;# disable random motion
$god_ new_node $node_(1)
$node_(1) namattach $namtrace
$ns_ initial_node_pos $node_(1) 25


# configure CBR sink. Not a sensor node. Eventually, may be a gateway for
# sensor alarms.
$ns_ node-config \
-channel $chan_2_ \
-PHENOMchannel "off"

set node_(2) [$ns_ node 2]
$node_(2) random-motion 0 ;# disable random motion
$god_ new_node $node_(2)
$node_(2) namattach $namtrace
$ns_ initial_node_pos $node_(2) 25


# output node object names for debugging
puts "node_(0) = $node_(0) node_(1) = $node_(1) node_(2) = $node_(2)"

#
# Provide initial (X,Y, for now Z=0) co-ordinates for mobilenodes
#
$node_(0) set X_ 1.0
$node_(0) set Y_ 1.0
$node_(1) set X_ 399.0
$node_(1) set Y_ 399.0
$node_(2) set X_ 360.0
$node_(2) set Y_ 300.0

$ns_ at 0.01 "$node_(0) setdest 300.0 300.0 150.0"
$ns_ at 0.01 "$node_(1) setdest 399.0 399.0 50.0"
$ns_ at 0.01 "$node_(2) setdest 360.0 300.0 50.0"

$ns_ at 4.0 "$node_(1) setdest 1.0 1.0 200.0"
$ns_ at 3.5 "$node_(2) setdest 100.0 100.0 200.0"

set src [new Agent/UDP]
set sink [new Agent/UDP]
$ns_ attach-agent $node_(1) $src
$ns_ attach-agent $node_(2) $sink
$ns_ connect $src $sink

set cbr [new Application/Traffic/CBR]
$cbr attach-agent $src
$cbr set packetSize_ 210
$cbr set rate_ 100k

#################################################################################################### #############################$ns_ at 5.0 "$cbr start"

###############################################################################
# Attach the sensor agent to the sensor node, and build a conduit thru which
# recieved PHENOM packets will reach the sensor agent's recv routine

# attach a Phenom Agent (i.e. sensor agent) to sensor node
set sensor01 [new Agent/SensorAgent]
puts "\tphenom05.tcl: sensor01 is object $sensor01"
$ns_ attach-agent $node_(1) $sensor01

# specify the sensor agent as the up-target for the sensor node's link layer
# configured on the PHENOM interface
[$node_(1) set ll_(1)] up-target $sensor01

$ns_ at 0.2 "$sensor01 start"

###############################################################################

#Tell nodes when the simulation ends
#
$ns_ at 10.0 "$node_(1) reset";
$ns_ at 10.0 "$node_(2) reset";

$ns_ at 10.0 "stop"
$ns_ at 10.01 "puts \"NS EXITING...\" ; $ns_ halt"

proc stop {} {
global ns_ tracefd namtrace
$ns_ flush-trace
close $tracefd
close $namtrace
}

#Begin command line parsing
puts "Starting Simulation..."
$ns_ run
 
Old 06-09-2013, 03:54 AM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2020 CentOS6.10 CentOS7.7 + 50+ other Linux OS, for test only.
Posts: 17,393

Rep: Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607
# 5 .

Please hit the ´Edit´ button in post #5, and then edit the text to 'code tags' around code
http://www.linuxquestions.org/questi...gs-4175464257/

Seems that you have copied something from two different files ?
Not readable as it is now.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
recompiling .h and .cc files in ns2 does not shows changes made to them Narges Linux - Newbie 5 02-28-2019 08:10 AM
NS2 Nam and Trace Files are always empty RSM_smile Linux - Newbie 36 08-15-2017 04:50 PM
how to link tcl file and C++ files together and run in ns2? tootz Linux - Software 3 07-25-2012 04:42 PM
RED-PD files in NS2 Gayathriharini Linux - Software 10 03-13-2011 02:25 PM
Is there any restriction in compiling the c++ files in ns2 library? shyan Linux - Newbie 1 12-12-2008 07:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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