Change Node State To Sleep

620 views
Skip to first unread message

Jack Higgins

unread,
Oct 18, 2016, 5:03:41 AM10/18/16
to ns-3-users


Dear all,

I was wondering , is it possible to force node to go to sleep mode? 
Of course, the objective is to save energy from Idle times when  X  conditions happen inside  a routing  protocol (duty cycling mechanism).

Since  Im trying to send  the instruction of sleeping node from inside the protocol , I thought I could use something similar as the way the BasicEnergySource info is obtained  in https://groups.google.com/forum/#!topic/ns-3-users/S-Z9m3wLf60



Ptr<Node> thisNode = m_ipv4->GetObject<Node>();  //as in the first line of aodv-routing-protocol.cc
        Ptr<EnergySourceContainer> EnergySourceContrainerOnNode = thisNode->GetObject<EnergySourceContainer> ();
Ptr<DeviceEnergyModelContainer> thisDeviceEnergyContainer = thisNode->GetObject<DeviceEnergyModelContainer>();
Ptr<DeviceEnergyModel> thisDeviceEnergyModel = DynamicCast<DeviceEnergyModel> (thisDeviceEnergyContainer->Get(0));
thisDeviceEnergyModel->ChangeState(**SleepState here**);


Im getting a /ns3/object.h:465:50: error: ‘GetTypeId’ is not a member of ‘ns3::DeviceEnergyModelContainer’ , I think that this is because  DeviceEnergyModelContainer is not meant to be accessed by  "getObject".
Or even worst, Im not even able to manually change states from the deviceEnergyModel.   

Is there any way I can change the state (between Sleep,Idle) of the node so I can implement a duty cycling mechanism inside my  L3 routing protocol?


I see some posts related to this , but not a straight answer, most of the post are either ignored or go in a different direction.

Any Guidance would be much appreciated

Regards,

Jack 

Jack Higgins

unread,
Oct 19, 2016, 2:14:43 AM10/19/16
to ns-3-users

I have not made enough testing but , apparently my mistake was to try to manipulate directly the sleep state from the energy Module.

Apparently, it should be accessed from the Wifi-Phy.
So in order to put a node to  sleep a node and to wake up a node from inside a routing protocol it should be done similar to this:
        Ptr<Node> thisNode = m_ipv4->GetObject<Node>();
Ptr<YansWifiPhy> thisNodePhy = thisNode->GetObject< YansWifiPhy >();

thisNodePhy->SetSleepMode();  //sleep node
thisNodePhy->ResumeFromSleep();   //wake up node

Cant confirm it yet, but I hope it helps somebody else with the same question.

Regards,

Jack

Jack Higgins

unread,
Oct 19, 2016, 5:13:04 AM10/19/16
to ns-3-users

Further investigation in the forums showed this:

Since there is no turn off mechanism, is still necessary to setDown() the interface and set the consumption values to 0 to effectively simulate a sleep mode of the WifiRadio?
The post is from 2014, is this still true for 2016?

Tommaso Pecorella

unread,
Oct 21, 2016, 5:59:33 AM10/21/16
to ns-3-users
Hi,

shortly put: yes. There wasn't any progress so far on a node-wide sleep (or stop) functionality.

Cheers,

T.

Jack Higgins

unread,
Oct 23, 2016, 11:40:33 PM10/23/16
to ns-3-users

Thank you  Tommaso  for your reply,

 I I will proceed with the  interface down + and set the consumption values to 0 approach then.

Best Regards

Bao Trinh

unread,
Nov 3, 2016, 10:28:09 AM11/3/16
to ns-3-users
Hi Jack. Can I ask you one question ? So after you change the state of wifi net sevice to sleep mode, does the application at higher layer will stop ?

Thank you very much

Jack Higgins

unread,
Nov 15, 2016, 2:22:35 AM11/15/16
to ns-3-users

I have not implemented this just yet. 
However, the changes merely stop packets delivery ( interface down) and stop energy consumption ( rx,tx, idle =0).

The application is not aware of this, so it is logical to assume that  there will be a error for trying to send a packet to an interface that is currently down or the packet will be dropped. (dont know yet)

Whichever is the case , it must be handle. If I have time I will report my results later.

Regards,
Jack 

Jack Higgins

unread,
Nov 21, 2016, 2:36:31 AM11/21/16
to ns-3-users

For anyone Interested,  a way to simulate a node "sleeping is the following:
       //Setting wifiRadio consumption to 0
       Ptr<Node> thisNode = m_ipv4->GetObject<Node>();
       Ptr<EnergySourceContainer> EnergySourceContrainerOnNode = thisNode->GetObject<EnergySourceContainer> ();
       Ptr<BasicEnergySource> basicSourcePtr = DynamicCast<BasicEnergySource> (EnergySourceContrainerOnNode->Get(0));
       Ptr<DeviceEnergyModel> basicRadioModelPtr = basicSourcePtr->FindDeviceEnergyModels ("ns3::WifiRadioEnergyModel").Get (0);
       basicRadioModelPtr->SetAttribute("RxCurrentA", DoubleValue (0.0));
       basicRadioModelPtr->SetAttribute("TxCurrentA", DoubleValue (0.0));
       basicRadioModelPtr->SetAttribute("IdleCurrentA", DoubleValue (0.0));
       basicRadioModelPtr->SetAttribute("CcaBusyCurrentA", DoubleValue (0.0));
       //Set Interface DOWN
       m_ipv4->SetDown(1);

The wake up function is similar, just need to set the interface up and restore the current values.

As for , what would happen if the interface is down and you attempt to send a packet from the node the answer is:
Drop Packet reason 4  ( Drop by Interface down) .












Reply all
Reply to author
Forward
Message has been deleted
0 new messages