Bug 2492

Summary: RxGain in uan-phy-gen.cc not functional
Product: ns-3 Reporter: Randall Plate <r-pl8>
Component: uanAssignee: Randall Plate <r-pl8>
Status: RESOLVED FIXED    
Severity: normal CC: fedwar82, ns-bugs, tomh
Priority: P5    
Version: pre-release   
Hardware: PC   
OS: Linux   
Attachments: proposed patch.
Moves RxGain calculation to uan-transducer-hd
updated patch

Description Randall Plate 2016-09-06 17:47:38 UTC
The RxGain attribute in the UanPhyGen class does not appear to be used anywhere.  It does not ever affect the received power level, as it should.  My suggestion would be to add a line such as "rxPowerDb += m_rxGainDb;" either in UanPhyGen::StartRxPacket or someplace else?
Comment 1 Federico Guerra 2016-09-07 05:55:15 UTC
there seems to be two issue here. 
m_rxGainDb seems to have been copied from Yans wifi phy... and guess what, it's not being used even in that model.

Issue 1) yans wifi phy (tom/tommaso any hint here?)

Issue 2) (current ticket) UAN phy

I agree that the sum should be done in ::StartRxPacket.

I can't be done anywhere else since:
- transducer should have its own gain
- m_rxGainDb is related to PHY (maybe due to emulation of equalizer etc...)
- it will be also used by PHY for SINR calculations
Comment 2 Tom Henderson 2016-09-07 10:58:03 UTC
(In reply to Federico Guerra from comment #1)
> there seems to be two issue here. 
> m_rxGainDb seems to have been copied from Yans wifi phy... and guess what,
> it's not being used even in that model.
> 
> Issue 1) yans wifi phy (tom/tommaso any hint here?)

It is used in both SpectrumWifiPhy and YansWifiPhy models.
Comment 3 Federico Guerra 2016-09-07 10:59:55 UTC
(In reply to Tom Henderson from comment #2)
> (In reply to Federico Guerra from comment #1)
> > there seems to be two issue here. 
> > m_rxGainDb seems to have been copied from Yans wifi phy... and guess what,
> > it's not being used even in that model.
> > 
> > Issue 1) yans wifi phy (tom/tommaso any hint here?)
> 
> It is used in both SpectrumWifiPhy and YansWifiPhy models.

Actively used or only set and get action? Thanks I'll re check the code then ASAP
Comment 4 Federico Guerra 2016-10-04 09:25:53 UTC
Created attachment 2603 [details]
proposed patch.
Comment 5 Federico Guerra 2016-10-04 09:26:43 UTC
hello, 
proposed patch attached.
Randall, let me know if this is OK with you.

thanks

Federico
Comment 6 Randall Plate 2016-10-04 17:53:11 UTC
Fine by me.  I implemented this and it seems to work OK.
Comment 7 Federico Guerra 2016-10-05 03:41:43 UTC
thanks Randall.

Tom, the patch is all yours :)
Comment 8 Tom Henderson 2016-10-06 09:36:58 UTC
What does the last 'db re uPa' string mean in this log message?  Could you make it more clear?

NS_LOG_DEBUG ("PHY " << m_mac->GetAddress () << ": rx power after RX gain = " << rxPowerDb << " db re uPa");
Comment 9 Federico Guerra 2016-10-06 09:40:44 UTC
Hi Tom, it's official nomenclature of the underwater acoustic power measurement unit, used in the whole model. it means "dB relative to micro Pascal", hence dB re(lative) to u(micro, it should the greek "mu" actually, but with ascii you usually use "u")Pa(scal)". 
when you say db in underwater acoustic you really mean db re uPa.
Comment 10 Tom Henderson 2016-10-07 02:07:03 UTC
pushed in 12365:1ff7fc1e6ba7
Comment 11 Randall Plate 2017-04-20 19:01:05 UTC
Created attachment 2834 [details]
Moves RxGain calculation to uan-transducer-hd

In doing some more testing on this, I believe our previous patch was an incorrect fix.  This applied the gain only to the packet being received, but to all other arrivals (at least when using uan-transducer-hd), the gain was not applied, resulting in incorrect interference calculations.  I have attached a second proposed patch which moves the RX gain to be added in uan-transducer-hd instead.  This way, it gets applied to ALL arrivals, not just the packet actively being received.  I have attached a new patch.
Comment 12 Federico Guerra 2017-04-26 09:15:57 UTC
(In reply to Randall Plate from comment #11)
> Created attachment 2834 [details]
> Moves RxGain calculation to uan-transducer-hd
> 
> In doing some more testing on this, I believe our previous patch was an
> incorrect fix.  This applied the gain only to the packet being received, but
> to all other arrivals (at least when using uan-transducer-hd), the gain was
> not applied, resulting in incorrect interference calculations.  I have
> attached a second proposed patch which moves the RX gain to be added in
> uan-transducer-hd instead.  This way, it gets applied to ALL arrivals, not
> just the packet actively being received.  I have attached a new patch.

Hi Randall,
I would make two small modifications to this patch:
1) add a SetGainDb (double RxGainDb) function to transducer and its parent class.
2) rename ApplyRxGain to ApplyRxGainDb

thanks
Comment 13 Federico Guerra 2017-04-26 09:44:04 UTC
(In reply to Federico Guerra from comment #12)
> (In reply to Randall Plate from comment #11)
> > Created attachment 2834 [details]
> > Moves RxGain calculation to uan-transducer-hd
> > 
> > In doing some more testing on this, I believe our previous patch was an
> > incorrect fix.  This applied the gain only to the packet being received, but
> > to all other arrivals (at least when using uan-transducer-hd), the gain was
> > not applied, resulting in incorrect interference calculations.  I have
> > attached a second proposed patch which moves the RX gain to be added in
> > uan-transducer-hd instead.  This way, it gets applied to ALL arrivals, not
> > just the packet actively being received.  I have attached a new patch.
> 
> Hi Randall,
> I would make two small modifications to this patch:
> 1) add a SetGainDb (double RxGainDb) function to transducer and its parent
> class.
> 2) rename ApplyRxGain to ApplyRxGainDb
> 
> thanks

Furthermore we need to clarify what's the desired meaning of this rxGain.

if it has to be considered as an "antenna" gain then this patch should be ok

on the contrary, if it has to be considered as "RxPenaltydB" param in NS-Miracle, i.e. db gain/penalty to be added to SINR/PER computation of the received packet (i.e. no interference) then we the modifications should be different (or non-existant, I need to verify the code).
Comment 14 Federico Guerra 2017-08-15 10:43:25 UTC
Created attachment 2903 [details]
updated patch

Tom, Randall,
I've partially modified the patch, by moving some primitives to the correct Transducer interface API, and then by changing some names.
Comment 15 Tom Henderson 2017-08-17 11:28:51 UTC
pushed in changeset 13045:db301bf6b92f