[Energy] Relation between Rss/Prss and Energy consumption

361 views
Skip to first unread message

David

unread,
Sep 24, 2015, 12:52:55 PM9/24/15
to ns-3-users
Hi,
as far as I know, there is no relationship implemented so far on ns-3 between Rss and the energy consumed on transmission/reception in any of the batteries proposed (ideal, RV and li-ion). 

So my question is, is there any rule to increment/decrement the energy consumption on transmission/reception according to the Prss/Rss value? It would quite easy on the ideal model, just setting a new Rx/Tx current. But what about the other models? Could it be possible to add an element on the equations used to calculate the consumption?

Would it be like a simple rule of three or it is not that simple?.

Please advice. If any paper speaks about that, I would be glad to read it. The same for any website, document or whatever.

Thanks in advance,
David.

Tommaso Pecorella

unread,
Sep 24, 2015, 5:32:17 PM9/24/15
to ns-3-users
Hi David,

the received power doesn't change the energy used to receive a packet. Wi-Fi doesn't drain energy from the incoming signal. Moreover, the energy consumed by the Rx circuits is far more than the one received by the antenna.
On the opposite, the transmitted power does change the Tx consumed energy, but this should be already considered in the model.

Cheers,

T.

David

unread,
Sep 27, 2015, 3:16:02 AM9/27/15
to ns-3-users

Hello Tommaso,
thanks for the reply. My fault, I checked the code but I didn't realize there was a way already implemented to model it. I have one related-question regarding the way to configure it.

 I understand that a WifiTxCurrentModel pointer is needed:

Ptr<WifiTxCurrentModel> txCurrentModel;



And it needs to be attached to the WifiRadioEnergyModel:

radioEnergyHelper.Set("TxCurrentModel", PointerValue(txCurrentModel));


But how to set the Prss value before attach the model to the nodes? I mean: It is not possible by using helper as there is no access to the functions, so I thought a good idea would be to create an object and set the desired value:

    WifiRadioEnergyModel a;

    a.SetTxCurrentFromModel (Prss);



The problem I find is that I am using an object and a helper at the same time. The Wifi-Radio is installed on the nodes trough the helper (as below), but I don't find a way to set the Prss.

  DeviceEnergyModelContainer deviceModels = radioEnergyHelper.Install (devices, sources);



My question is: Can the Prss value be set without removing the helper? I find it quite handy and straightforward on energy model configurations.


Thanks in advance,
David.

Tommaso Pecorella

unread,
Sep 27, 2015, 4:47:14 AM9/27/15
to ns-3-users
Hi,

you missed a function in the helper: SetTxCurrentModel (..)

For an example, check examples/wireless/wifi-sleep.cc
  radioEnergyHelper.SetTxCurrentModel ("ns3::LinearWifiTxCurrentModel",
                                       
"Voltage", DoubleValue (voltage),
                                       
"IdleCurrent", DoubleValue (idleCurrent),
                                       
"Eta", DoubleValue (eta));

The params meaning are explained in the LinearWifiTxCurrentModel class.

Cheers,

T.

David

unread,
Sep 27, 2015, 7:44:50 AM9/27/15
to ns-3-users
Afternoon Tommaso, 

thanks for a sunday reply, I appreciate it. Your example gave me an idea, and I've been investigating about it. I made three approaches but non of them have been successful.

1- On the first place, I endep up adding the Prss value as an attribute of the TxCurrentModel, as it looked the easiest way. I created a "SetTxPowerDbm" function and also a "get" one. As prss was no longer needed when calling the function Calculate Tx Current from wifi Radio Energy Model (as it was already present on the TxCurrentModel as an attribute)  I removed it from here:

double

LinearWifiTxCurrentModel::CalcTxCurrent (void) const

{

  return DbmToW (m_txPowerDbm) / (m_voltage * m_eta) + m_idleCurrent;

}



To fit this modifications I had to edit wifi-radio-energy-model (.cc, .h), wifi-tx-current-model (.cc, .h) and also the bindings. In the end I got a callback error and I was asked to modify ns3module.cc. My c++ knowledge is so small that the idea of editing it never came to my mind (Nevertheless I had a look at it and I understood that the failure was somewhere else).


2- I tried to do something similar, a botched job. Doing the same as before but without removing the argument, simply ignoring it and using the one set as an attribute:

double

LinearWifiTxCurrentModel::CalcTxCurrent (double txPowerDbmconst

{

  return DbmToW (m_txPowerDbm) / (m_voltage * m_eta) + m_idleCurrent;

}


It didn't work either.


3- The third approach is the one I am working in now. I thought I could send the Prss as an attribute yes, but of the WifiRadioEnergyHelper:

radioEnergyHelper.Set("txPowerDbm", DoubleValue(-80));



The header file was modified:

    

    double GetTxPowerDbm (voidconst;

    void SetTxPowerDbm (double txPowerDbm);    

[...]

  double m_txPowerDbm;


Then edited the .cc file:

.AddAttribute ("txPowerDbm",

                   "Power transmission in dBm",

                   DoubleValue (-80))

                   MakeDoubleAccessor (&WifiRadioEnergyModel::SetTxPowerDbm,

                                       &WifiRadioEnergyModel::GetTxPowerDbm),

                   MakeDoubleChecker<double> ())


[...]

void

WifiRadioEnergyModel::SetTxPowerDbm (double txPowerDbm)

{

  NS_LOG_FUNCTION (this << txPowerDbm);

  m_txPowerDbm = txPowerDbm;

}

  

    

double

WifiRadioEnergyModel::GetTxPowerDbm (void) const

{

  NS_LOG_FUNCTION (this);

  return m_txPowerDbm;

}

   


[...] And tried this solution to set the new TxCurrent according to the value of the dBm: 

void

WifiRadioEnergyModel::SetTxCurrentFromModel (double m_txPowerDbm)

{

  if (m_txCurrentModel)

    {

      m_txCurrentA = m_txCurrentModel->CalcTxCurrent (m_txPowerDbm);

    }

}



To me, In hindsight this approach (3rd one) seems the easiest one. But I keep getting an error (No matching member function to call.....) that spreads into 5:

../src/energy/model/wifi-radio-energy-model.cc:85:6: error: no matching member function for call to 'AddAttribute'

    .AddAttribute ("txPowerDbm",

    ~^~~~~~~~~~~~

./ns3/type-id.h:292:10: note: candidate function not viable: requires 5 arguments, but 3 were provided

  TypeId AddAttribute (std::string name,

         ^

./ns3/type-id.h:318:10: note: candidate function not viable: requires 6 arguments, but 3 were provided

  TypeId AddAttribute (std::string name,

         ^

../src/energy/model/wifi-radio-energy-model.cc:39:3: error: function declared in block scope cannot have 'static' storage class

  static TypeId tid = TypeId ("ns3::WifiRadioEnergyModel")

  ^

../src/energy/model/wifi-radio-energy-model.cc:90:20: error: template specialization requires 'template<>'

                   MakeDoubleChecker<double> ())

                   ^                ~~~~~~~~

../src/energy/model/wifi-radio-energy-model.cc:90:20: error: no function template matches function template specialization 'MakeDoubleChecker'

./ns3/double.h:91:29: note: candidate template ignored: could not match 'Ptr<const ns3::AttributeChecker> ()' against 'ns3::TypeId ()'

Ptr<const AttributeChecker> MakeDoubleChecker (void)

                            ^

./ns3/double.h:99:29: note: candidate template ignored: could not match 'Ptr<const ns3::AttributeChecker> (double)' against 'ns3::TypeId ()'

Ptr<const AttributeChecker> MakeDoubleChecker (double min)

                            ^

./ns3/double.h:107:29: note: candidate template ignored: could not match 'Ptr<const ns3::AttributeChecker> (double, double)' against 'ns3::TypeId ()'

Ptr<const AttributeChecker> MakeDoubleChecker (double min, double max)

                            ^

../src/energy/model/wifi-radio-energy-model.cc:90:48: error: expected ';' at end of declaration

                   MakeDoubleChecker<double> ())

                                               ^

                                               ;

5 errors generated.



And I am stuck on it. The error keeps pointing the "Add Attribute" declaration but it looks ok for me. Any help or advice with this last option? Apologizes If it is too obvious.
Thanks in advance,

David.

Message has been deleted

David

unread,
Sep 27, 2015, 3:19:06 PM9/27/15
to ns-3-users
I leave the previous message just in case it helps anyone but I know the options are not right at all.

A) Double checking other files on the energy folder, I made another approach. I just edited the Wifi-Radio-Energy-Model.cc file and set the variable directly without using any "set" or "get" function, as it is no needed on the example:

    .AddAttribute ("txPowerDbm",

                   "Tx Power Transmission",

                   DoubleValue (-80),

                   MakeDoubleAccessor (&WifiRadioEnergyModel::m_txPowerDbm),

                   MakeDoubleChecker<double> ())


And also modified the function that sets the transmission current according to the value of the dBm attribute.

void

WifiRadioEnergyModel::SetTxCurrentFromModel (double txPowerDbm)

{

  if (m_txCurrentModel)

    {

      m_txCurrentA = m_txCurrentModel->CalcTxCurrent (m_txPowerDbm);

    }

}


My question is, if I only want to set the txPower dBm value for the whole simulation, when creating the radio energy source, are these lines right?:

    WifiRadioEnergyModelHelper radioEnergyHelper;

    radioEnergyHelper.SetTxCurrentModel ("ns3::LinearWifiTxCurrentModel");

    radioEnergyHelper.Set("txPowerDbm", DoubleValue(Prss));


B) Or, on the other hand, I have to forget all lines above, don't edit the function and create an object

Ptr<WifiRadioEnergyModel> txdBm;

txdBm->SetTxCurrentFromModel (Prss);


And then, somehow install it here?

 DeviceEnergyModelContainer deviceModels = radioEnergyHelper.Install (devices, sources);


Thanks in advance,
David.



Tommaso Pecorella

unread,
Sep 27, 2015, 5:39:10 PM9/27/15
to ns-3-users
Hi,

to be honest I don't understand the problem you're trying to address.
If the issue is to have the radio consuming a fixed energy quantity when transmitting, why don't you fix the Tx power ?
Please describe the problem before the solutions. Sometimes you have to stop coding and do some ideas reordering.

Cheers,

T.
Message has been deleted

David

unread,
Sep 29, 2015, 3:02:07 PM9/29/15
to ns-3-users
Good evening Tommaso and everybody,

I am stuck on implementing the TxCurrentModel so I decided to try by setting the TxCurrent value manually as you suggested. I kindly ask for advise with one detail. As said, I will implement the CalcTxCurrent function manually. The formula used is:

(  ( TxPowerDbm  (converted into Watts)) / (voltage * eta)  ) + idle_current. 

Checking here I see and understand the Power in watts for each state and the equivalence in amperes (with a voltage of 3V) using the formula I (amps) = P(w) / V (volts). But when using that power value in Watts (1,14Watts for Ptx) on the formula above ( Txpower / (voltage*eta) + idle_current and doing the numbers on a sheet of paper I get wrong results (Too far from Itx= 0.380amperes). 

So my main question is: Which value should I use on the formula above? I traced the TxPowerDbm variable and I ended up on the WifiPhyListener, where is says:
"txPowerDbm - the nominal tx power in dBm"

But I can't go further. 

My goal is: If for a rss value of rss = -80; // dBm. (Power value of the signal on the reception side according to this)  the TxCurrent is = 0.380 amperes then for a rss value of = -70, the TxCurrent should be (for example) = 0.540 amperes. That's what I am trying to manually model, beforehand, on paper. Then I would directly set the TxCurrent to the appropriate value on the set up (radioEnergyHelper.Set ("TxCurrentA", DoubleValue (0.540));).

So, from the deepest of my heart, I kindly ask for any help that can be provided, I am really looking forward to solve this issue but I can't find any solution. I am stuck on it and this is the last remaining doubt on my energy investigation.

Thank you so much in advance,
David.







Tommaso Pecorella

unread,
Sep 29, 2015, 3:47:34 PM9/29/15
to ns-3-users
Hi David,

now I think I got your problem. You're looking in the opposite direction as "normal" (which isn't wrong per-se).
Most probably what you are missing from the formulas is the propagation loss.
The Rx power is given by the Tx power minus the propagation loss and the Rx / Tx antenna gains. As a consequence, the Tx power is always higher than the Rx power.

Check in YansWifiChannel::Send
          double rxPowerDbm = m_loss->CalcRxPower (txPowerDbm, senderMobility, receiverMobility);

The propagation loss is dependent on the nodes position and (of course) the propagation loss model(s) <- plural, you can chain 'em up.
HOWEVER... in YansWifiPhy::StartReceivePreambleAndHeader
  rxPowerDbm += m_rxGainDb;
 
double rxPowerW = DbmToW (rxPowerDbm);
you must add the Rx gain :P

Note that you must set the Tx gain as well... also in YansWifiPhy:
  m_channel->Send (this, packet, GetPowerDbm (txVector.GetTxPowerLevel ()) + m_txGainDb, txVector, preamble, aMpdu, txDuration);

Basically you have that the Rx (effective) power is (TxPower + TxGain + RxGain - PropagationLoss) [dBW]
But the energy spent is just for the TxPower, the other parts are "passive", i.e., they don't consume energy.

Moreover, I'd like to stress you that -80 dBm received are not really meaningful. You could have the same value for a very powerful and far transmitter or for one very near and low power. The energy required by the transmitter doesn't really tell you much, unless you fix the propagation loss and the node positions.

Hope this helps,

T.

David

unread,
Sep 29, 2015, 4:56:44 PM9/29/15
to ns-3-users
Night Tommaso,

thank you so much for replying. As per your last phrase, I will try to give more details as I think it can help on the resolution of this big problem I have on my hands: The scenario is 2 nodes, fixed position (E.g. 400m) under a FriisPropagationLossModel. With that distance the prss value is -80 dBm and the TxCurrent is 0,380 mA.

Then what I have to try is to separate the nodes to another fix position (E.g. 2000m). Due to that distance, unless I change the prss to -70 the packets won't be received. Ok, as the nodes are far away in a fixed position, the transmission power is higher, and it should be served with an increase of the TxCurrent up to.....? mA.

I only need to model that. As said, I will do it on paper and will simply set the value on the simulation (that's a trick, but I don't need anything more elaborated and coding would be a chaos). To do that, do I need to go deep deep in the code as your advice? When checking the propagation loss model as per your advice, I found the friis space formula (Pic attached). 

double numerator = m_lambda * m_lambda;
double denominator = 16 * M_PI * M_PI * distance * distance * m_systemLoss;
double lossDb = -10 * log10 (numerator / denominator);
return txPowerDbm - std::max (lossDb, m_minLoss); (m_minLoss is 0 by default).

Could I simply use that formula (rx = tx - lossDb, or the one you gave me before:  Rx (effective) = TxPower + TxGain ( always 1?) + RxGain(-10) - PropagationLoss) calculated there to set the TxPowerDbm (aka tx) on the formula below? (I would know the distance, the Rss (aka Rx) and all the rest of variables):

LinearWifiTxCurrentModel::CalcTxCurrent (double txPowerDbm)
          return DbmToW (txPowerDbm) / (m_voltage * m_eta) + m_idleCurrent;


Think we are talking about the same, but to confirm it.

THANK YOU SO MUCH again one thousand times,
David.
1.jpg

Tommaso Pecorella

unread,
Sep 29, 2015, 6:30:41 PM9/29/15
to ns-3-users, Sébastien Deronne, Tom Henderson
Hi,

more or less it should be all correct.
I'd double check the TxGain and RxGain (mind, they're ADDED in the code, not multiplied). By default they're both set to 1, but I haven't checked if they are not changed in some setup function.
About the propagation loss, the formula in the docs includes the two gains, but they're already considered elsewhere, so they're not computed in the propagation model.

The formulas (I haven't checked, but I'm mostly sure) should be:

1) You use txPowerDbm power to transmit.
2) You can calculate the used energy as "DbmToW (txPowerDbm) / (m_voltage * m_eta) + m_idleCurrent;"
3) The receiver will receive a power of Rx (effective) = TxPower + TxGain + RxGain - PropagationLoss

Cheers,

T.

David

unread,
Sep 30, 2015, 8:32:24 AM9/30/15
to ns-3-users, sebastie...@gmail.com, to...@tomh.org

Hi Tommaso, as always, thanks for your time and explanations.

With all the info provided, I decided to check the default values given (taken from Demystifying 802.11n Power Consumption). What it is proposed is that the PTx is 1,14 watts. To get the TxCurrent the equation is simple, divide between the voltage (3V). So TxCurrent =  PTx / Voltage = 1.14 w / 3 v = 0.38 amperes. Using 2) from your post, to get the same results I had to change eta to 1.077 as per the last formula detailed here

Under a Friis scenario of 2 nodes at 400m,  I calculate PTx from Friis. I get that PRx=1.10^-11w=-80dBm then -> PTx(w)=0.08507=19dBm. With that now I can calculate TXcurrent using 2). But, which eta should I use? Can't calculate it as before as TXcurrent is unknown (In fact, it is what I am looking for!). 

Under the same scenario as before but based on a known PTx (1.14w = 30dBm) instead a known PRx, when trying to calculate TXcurrent I am under the same problematic.


If leave eta as default (0.10) on both scenarios, the results are:

A) PRx is known. PRx = 1.10^-11w = -80dBm.
PTx = 0.08507w = 19dBm.
TxCurrent (eta = 0.1) = 0.2599 amperes.

B) PTx is known. PTx = 1.14w  = 30dBm.
PRx = 1.34^-10w = - 68 dBm.
TxCurrent (eta = 0.1) = 3.48 amperes!!.

 Is that an appropiate approach? Are the result coherent? Or otherwise should I use another eta?

Thanks a lot,
David.
Reply all
Reply to author
Forward
0 new messages