how to set sleep and wakeup for nodes in ns2 in aodv
#1

How to make a node uninterested or in sleep mode. We have done few changes in mac.cc file but dono which command to use in tcl script.
Reply
#2
how to set sleep and wakeup for nodes in ns2 in aodv

public:
AODV();
void CLUSTERING();
...
AODV.cc :
void AODV::CLUSTERING(){
if(current_){
while(numberofNodes){
// Selecting clusters
}
}
}
Now we know how the mechanism of ns2 works.so let's get started with sleep nodes.
First of all there is 4 functions in ns2 for turning a node to 'off', 'on', 'sleep', 'idle'. The difference between these are not so big.
As you know the 'off' function turns a node to off but it still broadcasts something based on your protocol.
$ns_ at 7.0 "$node(2) off"
And you can turn it on like :

$ns_ at 7.0 "$node(2) on"
The base is :

$simulator at $time "$Node_($number) off"
I don't know how to set a node to sleep in scenario.tcl but you can do that in your protocol's codes.
Now, to set a node to sleep we could do several things...

setting nodes to sleep from energy model
setting nodes to sleep from wireless physics
First we'll try energymodel.cc and if it didn't work we'll use the other one.
To set a node to sleep from energymodel.cc we can use this code in void Mac802_11::recv function in ns-2.35/mac/mac-802_11.cc :

if(index_ == myNode){
EnergyModel *em = netif_->node()->energy_model();
if (em && em->sleep()) {
em->set_node_sleep(1);
//em->set_node_state(EnergyModel::INROUTE);
}
}
Replace myNode with the number of the interface you want to set it to off.
If you are not using MultiInterface for your simulation so the number of interfaces will be equal to the number of your nodes.

example :
Normal :

node ---- > interface ----> channel
MultiInterface :


---- > interface[0] -----|
| ---------|
| v
node -------|---- > interface[1] --------- > channel
| ^
| ----------|
---- > interface[2] -----|
Open a terminal and cd to your ns2 directory, for example if you have ns-allinone-2.35, cd to /ns-allinone-2.35/ns-2.35/ and now type make and inter. After it finished try to simulate your scenario.tcl.

Now if your simulation start and you see the nam file, when the nodes get the first packet, the shape of them must change from balck circle to black circle blue hexagon.
From then on the nodes must not send or receive any data packet.

If this way didn't work now it's the time to use the other option.
Go to /ns-2.35/mac/ and open wireless-phy.cc.
You'll see that at the end of the file it contains our 4 function that we need.
we can simply use those function on the wireless-phy.cc to set a node to sleep or off by just calling those functions.But we may need to use them in another layer like in mac.
To use those functions in mac-802_11.cc simply use the below code anywhere you want in mac-802_11.cc and add wireless-phy.cc to your mac headers:

#include "wireless-phy.h" // at the header of mac-802_11.cc
/*
* Use the below code in any function you want in mac
*/
Phy *p;
p=netif_;
((WirelessPhy *)p)->node_sleep();
And to use another one of those 4 function just change the function's name like ->node_sleep(); to ->node_wakeup();.
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: ns2 code to create static nodes in wireless sensor networks, nodes disjoints code in ns2, sleep training and, ns2 code to create 10 nodes in wsn, a mobile ad hoc network manet is a collection of wireless nodes that can dynamically set up anywhere without using pre specif, how to integrate wireless and satellite nodes in ns2, ns2 source code compromise nodes,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
Shocked how to set diesel pump timing on mahindra bolero 3 1,206 20-11-2017, 11:47 AM
Last Post: jaseela123d
Thumbs Up online catering management system on php with report and source code and ppt 4 8,718 29-04-2017, 10:59 AM
Last Post: jaseela123d
  tcl source code for genetic algorithm to find the shortest path in ns2 2 811 21-07-2016, 03:04 PM
Last Post: dhanabhagya
  how to hack mtn network and free airtime and data 2 1,302 16-07-2016, 04:17 PM
Last Post: jaseela123d
  matlab rough set clustering code 1 659 14-07-2016, 12:40 PM
Last Post: jaseela123d
  ant colony optimization source code in ns2 2 754 12-07-2016, 11:26 AM
Last Post: jaseela123d
  source code of intrusion detection system in manet using ns2 2 816 09-07-2016, 03:18 PM
Last Post: seminar report asees
  download enhanced aodv code free 1 500 04-07-2016, 10:33 AM
Last Post: visalakshik
  pso algorithm ns2 code 1 535 02-07-2016, 10:47 AM
Last Post: visalakshik
  how to hack mtn network and free airtime and data 1 1,062 07-06-2016, 04:05 PM
Last Post: dhanabhagya

Forum Jump: