Bug 2820

Summary: segmentation fault when Rrpaa wifi manager is used
Product: ns-3 Reporter: sebastien.deronne
Component: wifiAssignee: Matías Richart <matis18>
Status: RESOLVED FIXED    
Severity: normal CC: ns-bugs
Priority: P3    
Version: ns-3.27   
Hardware: All   
OS: All   
Attachments: Correct power levels bug
Correct power levels bug

Description sebastien.deronne 2017-11-13 15:38:53 UTC
If I run wifi-hidden-terminal example with Rrpaa wifi manager, simulation is crashing.
A quick investigation seems to point to an out of bound access to station->m_pdTable.
Comment 1 sebastien.deronne 2017-11-13 15:39:47 UTC
Matias, since you wrote this class, could you please have a look?
Comment 2 Matías Richart 2017-11-14 09:13:38 UTC
(In reply to sebastien.deronne from comment #1)
> Matias, since you wrote this class, could you please have a look?

Ok, I'll have a look as soon as possible.
Comment 3 Matías Richart 2017-11-17 14:48:35 UTC
There was an issue when the node only has 1 power available.
I attach a patch.
Comment 4 Matías Richart 2017-11-17 14:51:26 UTC
Created attachment 2960 [details]
Correct power levels bug
Comment 5 sebastien.deronne 2017-11-18 05:41:19 UTC
Matias, thanks I will give a try. Any reason you need to use - 1 everwhere?
Comment 6 Matías Richart 2017-11-20 10:38:40 UTC
(In reply to sebastien.deronne from comment #5)
> Matias, thanks I will give a try. Any reason you need to use - 1 everwhere?

Sorry I didn't explain the problem better.
The problem was that the code considered GetTxPowerStart() and GetTxPowerEnd() as the maximum and minimum power levels but this functions return the max and min powers in dbm.

The power levels are the steps between the the max and min powers and are always between 0 and the number of power levels -1.

The problem appears when the max and min powers do not match the power levels. For example when max and min powers are the same.

I attach a new patch with a clearer code.
Comment 7 Matías Richart 2017-11-20 10:42:29 UTC
Created attachment 2962 [details]
Correct power levels bug
Comment 8 sebastien.deronne 2017-11-20 16:22:08 UTC
Thanks, it is clearer now.
I still have a question about initialization:

station->m_prevPowerLevel = m_maxPowerLevel;
station->m_powerLevel = m_maxPowerLevel;

Why is it initialized to max and not to min?
Comment 9 Matías Richart 2017-12-26 10:32:40 UTC
(In reply to sebastien.deronne from comment #8)
> Thanks, it is clearer now.
> I still have a question about initialization:
> 
> station->m_prevPowerLevel = m_maxPowerLevel;
> station->m_powerLevel = m_maxPowerLevel;
> 
> Why is it initialized to max and not to min?

It is a design decision.

Initializing at max power guarantees better reception when the algorithm starts.

The algorithm starts at max power and min rate so as to start at the most robust configuration and then, if it is, possible it decrease power and increase rate.
Comment 10 sebastien.deronne 2017-12-27 03:18:36 UTC
Matias, thanks, I will push this patch.
Comment 11 sebastien.deronne 2017-12-27 03:26:19 UTC
Fixed in changeset 13233:d1ed8ca3b295