Energy Consumption Issue

137 views
Skip to first unread message

Christian Nikolai Rabaya

unread,
Apr 20, 2025, 8:53:50 AM4/20/25
to ns-3-users
Hello!

I want to ask help regarding my issue with the energy consumption. In the example I'm using (leach-example.cc), the nodes are consuming energy for the first 11 seconds of the simulation but then stop consuming right after. My guess is that it might be because of the custom application (wsn-application.cc) or the wrong installation of the energy consumption model.

Please help. Thank you very much.

note: code is not mine, im trying to modify image_2025-04-20_205127635.pngold code

wsn-application.cc
leach-example.cc

Alberto Gallegos

unread,
Apr 23, 2025, 11:25:36 PM4/23/25
to ns-3-users
Christian,

There are just incomplete pieces of code here.  I cannot compile your wsn-application/leach because you did not include all the necessary files.
Even if you provide the files, I am also guessing this is for an old version of ns-3. A combination of this things makes it very hard to find your issue.

That being said, I recommend the following:

a) Always use the latest ns-3 version, we might have already patched the problem you are having.
b) Turn on the logs for the BasicEnergySource and/or the WiFiRadioEnergyModel, you might be able to catch an odd behavior looking at the outputs.
c) Try to reproduce the problem in a script that does not involve a lot of original generated content. If you provide such script I can run it and look more
into it.

Christian Nikolai Rabaya

unread,
Apr 24, 2025, 11:09:45 AM4/24/25
to ns-3-users
Hello!

Thank you for the advice. I'm actually running the example on ns-3.43. I modified some of the scripts a bit so that it can run on the latest version since the original was from around 8 years ago. Here's the link to the leach module if you'd like to try it out: LINK

So far, I've been unable to replicate the error in other scripts and I'm pretty new to ns-3 (and C++ unfortunately) so I'm trying my best to find the root cause. My intuition tells me it's because of the wsn-application model so if you could try and compile it, it would really mean a lot. For now I'll try turning on the logs as you said.

I would really appreciate any form of help you can provide. Thank you very much.

Alberto Gallegos

unread,
May 1, 2025, 9:26:50 PM5/1/25
to ns-3-...@googlegroups.com
Christian,

I am still checking the issue but it might take me some time as I haven't be able to spend so much time with your code.
However, I was able to reproduce the issue but it is yet to be determined if it is an issue caused by you or recent changes
in the code base. I will reply here asap.

Al.

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/gWH-Xexe68o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ns-3-users/cac74816-7dd2-40ed-a1b8-84bc6fe4d73en%40googlegroups.com.


--
"ITS BETTER TO BURN OUT , THAN TO FADE AWAY"

Christian Nikolai Rabaya

unread,
May 3, 2025, 6:52:45 AM5/3/25
to ns-3-users
Hello,

I was able to replicate the error using the dsdv-manet.cc example from the DSDV module of ns-3. I simply added the SetupEnergyModel() function (found in dsdv-manet-energy.cc) and I got the same behavior as I previously mentioned.
Based on the logs, my guess is that the PHY state of the Wifi Radio Energy Consumption Model turns off at a certain threshold that is dependent on the current draw values. The node consumption models turn off slowly (only in selected nodes, then all nodes except sink, then sink also turns off). In my tests, I changed the Tx current draw values and it turns out that the higher the Tx current draw, the earlier the Wifi Radio Energy Consumption Model stops consuming energy from a Basic Energy Source. 
energyerror7.png
dsdv-manet-energy.cpp
energyerror8.png
Reply all
Reply to author
Forward
0 new messages