Bug 2122 - Propagation loss models should use the correct frequency
Propagation loss models should use the correct frequency
Status: RESOLVED MOVED
Product: ns-3
Classification: Unclassified
Component: wifi
unspecified
All All
: P5 enhancement
Assigned To: sebastien.deronne
:
: 2648 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-05-20 16:17 EDT by sebastien.deronne
Modified: 2020-04-12 09:16 EDT (History)
6 users (show)

See Also:


Attachments
proposed patch (5.63 KB, patch)
2015-06-07 14:15 EDT, sebastien.deronne
Details | Diff
Proposed patch to change CalcRxPower API (57.49 KB, patch)
2018-08-07 13:31 EDT, Alexander Krotov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description sebastien.deronne 2015-05-20 16:17:04 EDT
By default, propagation loss models use the 5GHz frequency.

If the user considers a 802.11b/g/n scenario working at 2.4 GHz and do not specifically set the frequency in the propagation loss model, the obtain results will not be correct.

I propose to update the current implementation so that the correct frequency is used in propagation loss models without any intervention from the user.
Comment 1 sebastien.deronne 2015-06-07 07:14:34 EDT
IMO, the best way is to call CalcRxPower by specifying the frequency of the tx signal.
CalcRxPower thus needs to be extended for each model.

Indeed, we could imagine that both 2.4 and 5GHz signals are transmitted on the wireless channel. By calling CalcRxPower with the correct frequency, we are sure that the computed signal attenuation is done w.r.t. the signal frequency.
Comment 2 sebastien.deronne 2015-06-07 14:15:23 EDT
Created attachment 2061 [details]
proposed patch

I propose to set the correct frequency on the flight (when needed) directly in YansWifiChannel (see attached patch).

Good point:
-> since there is dependencies on propagation loss models, it avoids changes in other modules.
-> multiple type of signals can "share" the same channel.
-> users no longer need to explicitly set the frequency used in the simulation. Or even better, it avoids wrong results when users do not set the frequency in the propagation loss model!

Bad points:
-> computation at each reception.

Any idea of improvement?
Any objection?
Comment 3 sebastien.deronne 2015-06-08 10:34:05 EDT
Note that the proposed fix would no longer allow users to customize frequency-related parameters in the propagation model, but this is for a good reason.
I do not imagine a user would specify frequency Y while the wifi signal frequency would be X...
Comment 4 Matías Richart 2015-06-30 09:26:22 EDT
Hello Sebastien.

I have some comments and questions.

If I understand correctly you are setting the frequency at the Send function so as to allow devices using different frequencies to use the same channel and the same propagation model.
I think this is ok.

What I do not understand is why for the LogDistance models you do the calculation in the channel and not in the propagation model.
Do you think it generate to many changes to add a SetFrequency to those models?
My proposal is to add the SetFrequency function to these models, do the refLoss calculation in this new function and take out the attribute ReferenceLoss.

With your changes, if the user modify this attribute when creating the model we are overwriting it, so in either case I think we should remove it.
Comment 5 sebastien.deronne 2015-06-30 10:52:29 EDT
Matias,

Thanks for your comment.
I will check whether it can be done, it sounds indeed better.

The users will not be allowed to overwrite the frequency with my changes, but IMO it has no sense to set a different frequency for the propagation channel than the frequency being used by the propagating signal.
Comment 6 sebastien.deronne 2015-07-06 09:28:11 EDT
I agree that SetFrequency should be added to those models (or directly in the parent class?).

It may happen that the user want to specify different reference loss/distance values than the default one, and those values should not be overwritten in that case. 
They should be overwritten only if the user do not specify anything.

Is it ok to add a check like this?
if (m_foo != defaut_value)
  {
    ...
  }
Comment 7 Matías Richart 2015-07-06 17:26:37 EDT
(In reply to sebastien.deronne from comment #6)
> I agree that SetFrequency should be added to those models (or directly in
> the parent class?).
We should consider that there could be models that don't use the frequency for the calculation.
> 
> It may happen that the user want to specify different reference
> loss/distance values than the default one, and those values should not be
> overwritten in that case. 
> They should be overwritten only if the user do not specify anything.
> 
> Is it ok to add a check like this?
> if (m_foo != defaut_value)
>   {
>     ...
>   }

I don't completely understand what you are comparing.
The problem I see is that the default reference loss value depends on the frequency and the distance.
Comment 8 sebastien.deronne 2015-07-07 03:12:26 EDT
(In reply to Matías Richart from comment #7)
> (In reply to sebastien.deronne from comment #6)
> > I agree that SetFrequency should be added to those models (or directly in
> > the parent class?).
> We should consider that there could be models that don't use the frequency
> for the calculation.

Indeed, but in that case it should just be ignored.
The good point to have SetFrequency() defined in the parent class is that we can have this simple call in YansWifiChannel:
m_loss->SetFrequency (...)

Otherwise, you need to get the model(s) that are attached to the channel, and then set the frequency separately for each of them if needed.

> > 
> > It may happen that the user want to specify different reference
> > loss/distance values than the default one, and those values should not be
> > overwritten in that case. 
> > They should be overwritten only if the user do not specify anything.
> > 
> > Is it ok to add a check like this?
> > if (m_foo != defaut_value)
> >   {
> >     ...
> >   }
> 
> I don't completely understand what you are comparing.
> The problem I see is that the default reference loss value depends on the
> frequency and the distance.

Indeed, that is why we need to be sure that the user is aware of this.

If the user intentionally tuned the reference loss/distance, we need to not overwrite it (it is at his own risk, and will be used even if different signals are propagating).

On the contrary, if the user did not set those values, it should be overwritten with the correct frequency.

So, in order to know whether the user did overwrite the value(s), I suggest to add a check like this:

if (m_foo != defaut_value)
  {
    ...
  }
Comment 9 Matías Richart 2015-07-07 09:33:09 EDT
(In reply to sebastien.deronne from comment #8)
> (In reply to Matías Richart from comment #7)
> > (In reply to sebastien.deronne from comment #6)
> > > I agree that SetFrequency should be added to those models (or directly in
> > > the parent class?).
> > We should consider that there could be models that don't use the frequency
> > for the calculation.
> 
> Indeed, but in that case it should just be ignored.
> The good point to have SetFrequency() defined in the parent class is that we
> can have this simple call in YansWifiChannel:
> m_loss->SetFrequency (...)
> 
> Otherwise, you need to get the model(s) that are attached to the channel,
> and then set the frequency separately for each of them if needed.

Good point. I agree.
> 
> > > 
> > > It may happen that the user want to specify different reference
> > > loss/distance values than the default one, and those values should not be
> > > overwritten in that case. 
> > > They should be overwritten only if the user do not specify anything.
> > > 
> > > Is it ok to add a check like this?
> > > if (m_foo != defaut_value)
> > >   {
> > >     ...
> > >   }
> > 
> > I don't completely understand what you are comparing.
> > The problem I see is that the default reference loss value depends on the
> > frequency and the distance.
> 
> Indeed, that is why we need to be sure that the user is aware of this.
> 
> If the user intentionally tuned the reference loss/distance, we need to not
> overwrite it (it is at his own risk, and will be used even if different
> signals are propagating).
> 
> On the contrary, if the user did not set those values, it should be
> overwritten with the correct frequency.
> 
> So, in order to know whether the user did overwrite the value(s), I suggest
> to add a check like this:
> 
> if (m_foo != defaut_value)
>   {
>     ...
>   }

Ok, I understand. What do you say to do if the user only tune the distance? Should we calculate the "correct" reference loss?
Comment 10 sebastien.deronne 2015-07-07 09:36:09 EDT
(In reply to Matías Richart from comment #9)
> (In reply to sebastien.deronne from comment #8)
> > (In reply to Matías Richart from comment #7)
> > > (In reply to sebastien.deronne from comment #6)
> > > > I agree that SetFrequency should be added to those models (or directly in
> > > > the parent class?).
> > > We should consider that there could be models that don't use the frequency
> > > for the calculation.
> > 
> > Indeed, but in that case it should just be ignored.
> > The good point to have SetFrequency() defined in the parent class is that we
> > can have this simple call in YansWifiChannel:
> > m_loss->SetFrequency (...)
> > 
> > Otherwise, you need to get the model(s) that are attached to the channel,
> > and then set the frequency separately for each of them if needed.
> 
> Good point. I agree.
> > 
> > > > 
> > > > It may happen that the user want to specify different reference
> > > > loss/distance values than the default one, and those values should not be
> > > > overwritten in that case. 
> > > > They should be overwritten only if the user do not specify anything.
> > > > 
> > > > Is it ok to add a check like this?
> > > > if (m_foo != defaut_value)
> > > >   {
> > > >     ...
> > > >   }
> > > 
> > > I don't completely understand what you are comparing.
> > > The problem I see is that the default reference loss value depends on the
> > > frequency and the distance.
> > 
> > Indeed, that is why we need to be sure that the user is aware of this.
> > 
> > If the user intentionally tuned the reference loss/distance, we need to not
> > overwrite it (it is at his own risk, and will be used even if different
> > signals are propagating).
> > 
> > On the contrary, if the user did not set those values, it should be
> > overwritten with the correct frequency.
> > 
> > So, in order to know whether the user did overwrite the value(s), I suggest
> > to add a check like this:
> > 
> > if (m_foo != defaut_value)
> >   {
> >     ...
> >   }
> 
> Ok, I understand. What do you say to do if the user only tune the distance?
> Should we calculate the "correct" reference loss?

Yes, it is what I suggest.
This should also be made clear in the documentation then.
Comment 11 Tom Henderson 2015-07-07 10:29:02 EDT
I'm not in favor of making YansWifiChannel have to be aware of the type of loss model, as in:

+  if (m_loss->GetObject<FriisPropagationLossModel> () != 0)
+    {
+      m_loss->GetObject<FriisPropagationLossModel> ()->SetFrequency(frequency * 1000000);

this approach will break over time.  I'd rather see that the loss model is passed the frequency as an argument to CalcRxPower().

also, 
> Is it ok to add a check like this?
> if (m_foo != defaut_value)
>   {
>    ...
>  }

I don't think we have any facility to remember whether the user touched a default value as in Config::SetDefault(..).  If you are checking whether the instance value matches the current default value, that could be done.  But it makes me wonder whether the need to do this is an indication that the overall design is not correct...
Comment 12 sebastien.deronne 2015-07-08 02:36:44 EDT
(In reply to Tom Henderson from comment #11)
> I'm not in favor of making YansWifiChannel have to be aware of the type of
> loss model, as in:
> 
> +  if (m_loss->GetObject<FriisPropagationLossModel> () != 0)
> +    {
> +      m_loss->GetObject<FriisPropagationLossModel>
> ()->SetFrequency(frequency * 1000000);
> 
> this approach will break over time.  I'd rather see that the loss model is
> passed the frequency as an argument to CalcRxPower().

This could indeed be a good option.
Does this seem cleaner than adding a SetFrequency in the parent class?

> 
> also, 
> > Is it ok to add a check like this?
> > if (m_foo != defaut_value)
> >   {
> >    ...
> >  }
> 
> I don't think we have any facility to remember whether the user touched a
> default value as in Config::SetDefault(..).  If you are checking whether the
> instance value matches the current default value, that could be done.  But
> it makes me wonder whether the need to do this is an indication that the
> overall design is not correct...

Unfortunately, I do not see any other option for the moment.
Comment 13 Junling Bu 2015-07-15 03:19:41 EDT
Hi,

I agree that it would be better to have SetFrequency method in parent class.
All subclasses should decide how to deal with frequency property by themselves.
Some may ignore this if they do not need this.
Some shall do calculation further with this property.
So the SetReference and SetReferenceLoss in the proposed patch will become private in the different classes.
Besides that, it can also make YansWifiChannel::Send method implemented easier than current proposed path.

Junling
Comment 14 sebastien.deronne 2017-02-04 09:13:56 EST
*** Bug 2648 has been marked as a duplicate of this bug. ***
Comment 15 sebastien.deronne 2017-03-02 15:26:24 EST
I would like to handle this one in the coming weeks.
Some new wifi standards are using different frequency bands (1 GHz, 60 GHz, ...), so this will become more and more critical.
Comment 16 Alexander Krotov 2018-08-02 06:06:21 EDT
I would really like to make changes to "propagation" module instead and change its API to accept frequency each time. And also change "spectrum" module to use propagation loss models from the "propagation" model. Currently we have friis-spectrum-propagation-loss.cc simply because "propagation" API is bad, and each time I need to use some propagation loss model with the spectrum channel, I have to copy it from propagation module and adopt it similarly to friis-spectrum-propagation-loss.cc, with lots of duplicate code.

Besides that, proposed patch does a lot of GetObject calls inside the Send that are expensive. And adding a new propagation loss model requires adding another "if" branch.

I think breaking API is worth it in this case.
Comment 17 Tom Henderson 2018-08-03 17:55:27 EDT
(In reply to Alexander Krotov from comment #16)
> 
> I think breaking API is worth it in this case.

I agree; do you have any cycles to work on a new patch?
Comment 18 Tom Henderson 2018-08-03 17:57:58 EDT
I suggest to keep the existing API and Frequency attributes (and Set/GetFrequency) for a release cycle or two with NS_DEPRECATED and add the new API taking frequency argument.
Comment 19 Alexander Krotov 2018-08-06 13:28:28 EDT
I started implementing it, but it seems we need to deal with https://www.nsnam.org/bugzilla/show_bug.cgi?id=2001 first.
Comment 20 Alexander Krotov 2018-08-07 13:31:58 EDT
Created attachment 3157 [details]
Proposed patch to change CalcRxPower API
Comment 21 sebastien.deronne 2018-08-08 15:32:55 EDT
I think your idea is indeed better.
I see you made changes to the propagation module, do you plan to also adapt wifi and other wireless modules?
Comment 22 Alexander Krotov 2018-08-09 04:34:31 EDT
> I see you made changes to the propagation module, do you plan to also adapt wifi and other wireless modules?

The patch is not finished yet.

I need to make changes to everything else: spectrum model (remove m_propagationLoss from MultiModelSpectrumChannel, make a template wrapper for normal propagation loss models), change wi-fi etc.

> I suggest to keep the existing API and Frequency attributes (and Set/GetFrequency) for a release cycle or two with NS_DEPRECATED and add the new API taking frequency argument.

I am trying to do it, but there will be incompatibilities anyway, because I will have to change channel models.
Comment 23 sebastien.deronne 2020-04-12 09:16:29 EDT
Moved to https://gitlab.com/nsnam/ns-3-dev/-/issues/174