Bug 2946

Summary: GetNDevices is not initialized in MultiModelSpectrumChannel
Product: ns-3 Reporter: Gabriel Arrobo <gab.arrobo>
Component: spectrumAssignee: Nicola Baldo <nicola>
Status: NEW ---    
Severity: normal CC: gab.arrobo, ns-bugs
Priority: P3    
Version: ns-3-dev   
Hardware: PC   
OS: Linux   
Attachments: Modified script from examples/wireless/wifi-spectrum-per-example.cc
Proposed patch for initializing m_numDevices

Description Gabriel Arrobo 2018-07-09 21:16:44 EDT
Created attachment 3127 [details]
Modified script from examples/wireless/wifi-spectrum-per-example.cc

Hello,
I was working with the LTE module (MultiModelSpectrumChannel) and I was trying to get the number of devices connected to the channel using (GetNDevices) and I obtained some unreasonable numbers. So, I ran another test using a modified version of a script from the examples/wireless folder (wifi-spectrum-per-example.cc).

My modified script is attached (wifi-multi-model.cc) and when I run it, I get the following output:
distance: 50m; time: 10; TxPower: 1 dBm (1.3 mW)
index   MCS  Rate (Mb/s) Tput (Mb/s) Received Signal (dBm) Noise (dBm) SNR (dB)
    0     0      6.50        5.77    7414      -79.74      -93.97       14.22
Devices: 139641248762746
    1     1     13.00       11.58   14892      -79.74      -93.97       14.22
Devices: 67
    2     2     19.50       17.38   22357      -79.74      -93.97       14.22
Devices: 34

The number of devices (GetNDevices) should be 2. However, as you can see above, Devices (GetNDevices) has different numbers. I saw this issue in ns-3.28 and I also checked whether this has been addressed in ns-3-dev but it has not. I ran my test using Ubuntu 16.04.4 and gcc/g++ 5.4.0


By initializing m_numDevices (0) in the constructor, I obtained what it is expected (2 devices), as shown below.
 distance: 50m; time: 10; TxPower: 1 dBm (1.3 mW)
index   MCS  Rate (Mb/s) Tput (Mb/s) Received Signal (dBm) Noise (dBm) SNR (dB)
    0     0      6.50        5.77    7414      -79.74      -93.97       14.22
Devices: 2
    1     1     13.00       11.58   14892      -79.74      -93.97       14.22
Devices: 2
    2     2     19.50       17.38   22357      -79.74      -93.97       14.22
Devices: 2

Thanks!
Comment 1 Gabriel Arrobo 2018-07-09 22:41:27 EDT
Created attachment 3128 [details]
Proposed patch for initializing m_numDevices

Attached is a patch to initialize m_numDevices. So, GetNDevices returns the correct value.
Thanks!