# How to calculate SNR?

**URL:** <https://www.ruby-forum.com/t/how-to-calculate-snr/240051>\
**Category:** GNU Radio\
**Created:** [March 25, 2014, 7:04pm UTC](https://www.ruby-forum.com/t/how-to-calculate-snr/240051 "2014-03-25T19:04:13Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [March 25, 2014, 7:04pm UTC](https://www.ruby-forum.com/t/how-to-calculate-snr/240051/1 "2014-03-25T19:04:13Z")

</div>

Hi All,

In order to calculate the SNR at the receiver, I have generated a QPSK  
signal, sent it with an USRP through a canal and then received it with  
another USRP.  
So, I have used The “MPSK SNR Estimator” block at the receiver to  
monitor  
the SNR values. But values are not correct, I have tried “MPSK SNR  
Estimator Probe” block, but values still not correct.

I am wondering what is the proper way to use “MPSK SNR Estimator” block?  
or  
if there is another block or method to retrieve SNR values correctly? So  
that I can find correct results.  
Any help is appreciated. Thank you.

Best regards,  
Azza

---

<div class="post-metadata">

**Author:** ![Azza\_Ben\_Mosbah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e56c9b/32.png) [@Azza\_Ben\_Mosbah](https://www.ruby-forum.com/u/Azza_Ben_Mosbah)\
**Post date:** [March 25, 2014, 9:36pm UTC](https://www.ruby-forum.com/t/how-to-calculate-snr/240051/2 "2014-03-25T21:36:54Z")

</div>

On 03/25/2014 05:00 PM, Azza Ben Mosbah wrote:

> Any help is appreciated. Thank you.  
> Estimating SNR is a bit of a science. How do you know your SNR values  
> are incorrect?  
> In general, our SNR estimators have been tested a lot and should work.  
> Post your rx flow graph and your results, that way we can tell what  
> you’ve been doing.

M

---

<div class="post-metadata">

**Author:** ![Azza\_Ben\_Mosbah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e56c9b/32.png) [@Azza\_Ben\_Mosbah](https://www.ruby-forum.com/u/Azza_Ben_Mosbah)\
**Post date:** [March 25, 2014, 11:05pm UTC](https://www.ruby-forum.com/t/how-to-calculate-snr/240051/3 "2014-03-25T23:05:16Z")

</div>

Hi azza and Martin,  
I have the same problem, that is my flowgraph.  
[http://gnuradio.4.n7.nabble.com/file/n47201/SNR\_rx.jpg](http://gnuradio.4.n7.nabble.com/file/n47201/SNR_rx.jpg)  
The SNR values have not sens. For example, with 0.065 transmitting power  
i  
had values between 0.06 and -0.012. may be the problem is how to use the  
block in the flowgraph.  
I appreciate your help  
Zakaria

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/How-to-calculate-SNR-tp47193p47201.html](http://gnuradio.4.n7.nabble.com/How-to-calculate-SNR-tp47193p47201.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Azza\_Ben\_Mosbah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e56c9b/32.png) [@Azza\_Ben\_Mosbah](https://www.ruby-forum.com/u/Azza_Ben_Mosbah)\
**Post date:** [March 26, 2014, 4:15pm UTC](https://www.ruby-forum.com/t/how-to-calculate-snr/240051/4 "2014-03-26T16:15:28Z")

</div>

I calculate the SNR using the formula  
SNR=20\*log10[RMS(signal)/RMS(noise)].  
You find attached my flow graph.  
[http://gnuradio.4.n7.nabble.com/file/n47229/flowgraph.png](http://gnuradio.4.n7.nabble.com/file/n47229/flowgraph.png)

Azza

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/How-to-calculate-SNR-tp47193p47229.html](http://gnuradio.4.n7.nabble.com/How-to-calculate-SNR-tp47193p47229.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Azza\_Ben\_Mosbah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e56c9b/32.png) [@Azza\_Ben\_Mosbah](https://www.ruby-forum.com/u/Azza_Ben_Mosbah)\
**Post date:** [March 26, 2014, 10:59am UTC](https://www.ruby-forum.com/t/how-to-calculate-snr/240051/5 "2014-03-26T10:59:26Z")

</div>

On 03/25/2014 11:04 PM, zielalaoui wrote:

> Hi azza and Martin,  
> I have the same problem, that is my flowgraph.  
> [http://gnuradio.4.n7.nabble.com/file/n47201/SNR\_rx.jpg](http://gnuradio.4.n7.nabble.com/file/n47201/SNR_rx.jpg)  
> The SNR values have not sens. For example, with 0.065 transmitting power i  
> had values between 0.06 and -0.012. may be the problem is how to use the  
> block in the flowgraph.  
> I appreciate your help  
> Zakaria

Well, you need to provide valid PSK symbols.  
Have a look at gr-digital/examples/snr\_estimators.py.

M

---

<div class="post-metadata">

**Author:** ![Azza\_Ben\_Mosbah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e56c9b/32.png) [@Azza\_Ben\_Mosbah](https://www.ruby-forum.com/u/Azza_Ben_Mosbah)\
**Post date:** [March 26, 2014, 4:23pm UTC](https://www.ruby-forum.com/t/how-to-calculate-snr/240051/6 "2014-03-26T16:23:40Z")

</div>

As you can see from the flowgraph, I add noise to the signal to simulate  
a  
channel. And I calculate the SNR at the receiver. Since the noise is  
known,  
I can calculate my SNR.  
But, comparing to the output of the “MPSK SNR Estimator Probe”, it is  
not  
the same.

Azza

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/How-to-calculate-SNR-tp47193p47231.html](http://gnuradio.4.n7.nabble.com/How-to-calculate-SNR-tp47193p47231.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Azza\_Ben\_Mosbah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e56c9b/32.png) [@Azza\_Ben\_Mosbah](https://www.ruby-forum.com/u/Azza_Ben_Mosbah)\
**Post date:** [March 26, 2014, 4:17pm UTC](https://www.ruby-forum.com/t/how-to-calculate-snr/240051/7 "2014-03-26T16:17:49Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Hi Azza,

how do you know RMS(noise)?

Greetings,  
Marcus

On 26.03.2014 16:14, Azza Ben Mosbah wrote:

> [http://gnuradio.4.n7.nabble.com/How-to-calculate-SNR-tp47193p47229.html](http://gnuradio.4.n7.nabble.com/How-to-calculate-SNR-tp47193p47229.html)

Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Discuss-gnuradio  
> mailing list [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio)

-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1  
Comment: Using GnuPG with Thunderbird - [http://www.enigmail.net/](http://www.enigmail.net/)

iQEcBAEBAgAGBQJTMu9PAAoJEBQ6EdjyzlHtCJgH/3fsLtytf1iHUfNFTrE881Dk  
msf8h+VPYYaczbVjqdCxXWMWhWA/XRrUt2tHg9t1aIkDa7F2GdEe/jau8nvaEQce  
sd9dxkknZHlOvLf+Uup3hwu5Sksdw2o+DJRTugoRcdVKhntR4cEseGyGp9KPgI+h  
cef/VFRHbCCeU45zLFto8bHKiWEN/G5jb7ImaAUIFeMhOs403i7IF1pyVpnH8j8N  
ChG62isPZHzTl3a2pWJTLQWjlzuBTVknHNi05uMm1W7rTL4YAgyvNg5ysp8HgfoD  
k5mUWqn2Vbmn8+3OYg26Ojnrcza20FKyemIKX5C0z7cPcYeaViez4ovZX1bRBgM=  
=IGpn  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![Azza\_Ben\_Mosbah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e56c9b/32.png) [@Azza\_Ben\_Mosbah](https://www.ruby-forum.com/u/Azza_Ben_Mosbah)\
**Post date:** [March 26, 2014, 4:33pm UTC](https://www.ruby-forum.com/t/how-to-calculate-snr/240051/8 "2014-03-26T16:33:02Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Ah, the picture of your flowgraph took some time to load, so I thought  
it was broken.  
First of all: to get truly comparable numbers, you should set the IIR  
alpha to the same value for the probe and the RMS blocks.

Then: What you’re doing with the RMS blocks is something different  
than what the MPSK SNR estimators do; please refer to

> **[GNU Radio Manual and C++ API Reference: gr::digital::mpsk\_snr\_est Class...](https://www.gnuradio.org/doc/doxygen/classgr_1_1digital_1_1mpsk __snr__ est.html)**

and the papers linked on the respective implementations for detail.

Greetings,  
Marcus

On 26.03.2014 16:16, Marcus M. wrote:

> > [http://gnuradio.4.n7.nabble.com/file/n47229/flowgraph.png](http://gnuradio.4.n7.nabble.com/file/n47229/flowgraph.png)

-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1  
Comment: Using GnuPG with Thunderbird - [http://www.enigmail.net/](http://www.enigmail.net/)

iQEcBAEBAgAGBQJTMvK8AAoJEBQ6EdjyzlHtUHwH/RUSeDJXGXWYQtcmPAEGz+XK  
FNy79zpqogkhYWZ9EPylVPZL0qS9jDWAcymOxw/FCz280zqOM8AA+CSIGLDWrQEI  
667IcrV44/fL4fMgiiIC2p87iUPqpqIfoI6TU67qXjEkq4vsXxlosbG0NoH61DnK  
D6dxWVv3yT4zp387BZ4CfT3XS9jvXVqO4XlPt0INstAC83v/j1xiU2392fwQJZsn  
pHGUFY/SSDsYRWO8a+Mf+IxvtyEPB1EDXC3ckELs/OGxWTin+uuYx1aPCq+RmTo3  
N5v2BTaH8YVP0v6CGUzax+tTTbzAHUEZkFXXPauriv9qELsoW+/pYZLtkT2JC5I=  
=eoyN  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![Azza\_Ben\_Mosbah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e56c9b/32.png) [@Azza\_Ben\_Mosbah](https://www.ruby-forum.com/u/Azza_Ben_Mosbah)\
**Post date:** [March 26, 2014, 4:54pm UTC](https://www.ruby-forum.com/t/how-to-calculate-snr/240051/9 "2014-03-26T16:54:07Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Hi Azza,  
On 26.03.2014 16:46, Azza Ben Mosbah wrote:

> Ok. Thank you. I will see that. A one more question please: the  
> SNR, is it in dB? and why the output for the SNR block is complex?  
> This is a pass-through block; it just forwards the complex samples and  
> updates the internal estimation. You can then get the SNR estimate  
> using the snr() method.

Greetings,  
Marcus  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1  
Comment: Using GnuPG with Thunderbird - [http://www.enigmail.net/](http://www.enigmail.net/)

iQEcBAEBAgAGBQJTMvfGAAoJEBQ6EdjyzlHtFnUH/RI0ipYZHzo6d/uY4nMLeJS0  
AFUBc/3UbJfZ2nV160lECjjYA3XK4cL/0h5FOlR4r1Xe7n9wdlwlcNwcdzjDnI95  
hadvxZ1iajM1LnPTqi5xZmiKoWF5W6XUUbA4pCkWMCU2GPsCRONkkRYI4/hJHCGn  
fQ1MrEhoG5C1tjlMyWr569xhfBpC1i3okRwSqA01NVouYU4FE8eHwuaQG9qJoaeo  
7+DMgAWClVXTKxBzGP7RptCapD73ITFdL3oYOG7guhCFwelWyMVNPsvzvUmuEuTX  
emiMBV3TPNYQBIxTXx0hrzmCVmjlrgtcBLB7ff2LM6IuE++X8L3iP8OPCvqfL9o=  
=VmCN  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![Azza\_Ben\_Mosbah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e56c9b/32.png) [@Azza\_Ben\_Mosbah](https://www.ruby-forum.com/u/Azza_Ben_Mosbah)\
**Post date:** [March 26, 2014, 5:01pm UTC](https://www.ruby-forum.com/t/how-to-calculate-snr/240051/10 "2014-03-26T17:01:10Z")

</div>

On Wed, Mar 26, 2014 at 8:46 AM, Azza Ben Mosbah  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Ok. Thank you. I will see that.  
> A one more question please: the SNR, is it in dB? and why the output for the  
> SNR block is complex?
> 
> Azza

Azza,

Please try to be more specific with your questions. Notice that there  
are two blocks that calculate the SNR of an MPSK signal. Which one are  
you talking about? What output are you talking about?

The documentation for the mpsk\_snr\_est\_cc block is found here:

> **[GNU Radio Manual and C++ API Reference: gr::digital::mpsk\_snr\_est\_cc Class...](https://www.gnuradio.org/doc/doxygen/classgr_1_1digital_1_1mpsk __snr__ est__cc.html)**

It says that this block passes all incoming data on the input stream  
to the output stream. You can get the SNR by using the snr() function  
to return the current estimate. And notice that in the constructor,  
there is an argument:  
“after this many samples, a tag containing the SNR (key=‘snr’) will be  
sent”

So a stream tag is issued every so many samples containing the value  
of the SNR estimate.

The other block is the probe\_mpsk\_snr\_est\_c, which is a sink:

> **[GNU Radio Manual and C++ API Reference: gr::digital::probe\_mpsk\_snr\_est\_c...](https://www.gnuradio.org/doc/doxygen/classgr_1_1digital_1_1probe __mpsk__ snr __est__ c.html)**

Again, this has an snr() function. Instead of stream tags, this block  
emits a message every so many samples. So you can attach a block that  
receives messages to get the SNR estimates.

Tom

---

<div class="post-metadata">

**Author:** ![Azza\_Ben\_Mosbah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e56c9b/32.png) [@Azza\_Ben\_Mosbah](https://www.ruby-forum.com/u/Azza_Ben_Mosbah)\
**Post date:** [March 26, 2014, 4:47pm UTC](https://www.ruby-forum.com/t/how-to-calculate-snr/240051/11 "2014-03-26T16:47:40Z")

</div>

Ok. Thank you. I will see that.  
A one more question please: the SNR, is it in dB? and why the output for  
the  
SNR block is complex?

Azza

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/How-to-calculate-SNR-tp47193p47233.html](http://gnuradio.4.n7.nabble.com/How-to-calculate-SNR-tp47193p47233.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Azza\_Ben\_Mosbah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e56c9b/32.png) [@Azza\_Ben\_Mosbah](https://www.ruby-forum.com/u/Azza_Ben_Mosbah)\
**Post date:** [March 31, 2014, 8:58pm UTC](https://www.ruby-forum.com/t/how-to-calculate-snr/240051/12 "2014-03-31T20:58:06Z")

</div>

Hi All,

I checked this document, it gives an idea about SNR estimators in GNU  
Radio:

> **[SNR Estimators — Rondeau Research](http://www.trondeau.com/blog/2011/12/30/snr-estimators.html)**
>
> In GNU Radio, we have been slowly evolving our digital communications capabilities. One thing that becomes quickly and painfully obvious to anyone doing real over-the-air communications with digital modulations is that the modulators and demodulators...

And I checked this Python file:  
[http://gnuradio.org/redmine/projects/gnuradio/repository/revisions/ef4d48de26b64d89851a93fc5402b33fcc1a809f/entry/gr-digital/examples/snr\_estimators.py](http://gnuradio.org/redmine/projects/gnuradio/repository/revisions/ef4d48de26b64d89851a93fc5402b33fcc1a809f/entry/gr-digital/examples/snr_estimators.py)

But, I need more details about the types of estimators (simple,  
skewness,  
2nd and 4th moment, svr). What are the differences between those  
estimators?  
And in which case should I consider each type?  
Any help is appreciated.

Thank you,  
Azza

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/How-to-calculate-SNR-tp47193p47348.html](http://gnuradio.4.n7.nabble.com/How-to-calculate-SNR-tp47193p47348.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Azza\_Ben\_Mosbah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e56c9b/32.png) [@Azza\_Ben\_Mosbah](https://www.ruby-forum.com/u/Azza_Ben_Mosbah)\
**Post date:** [March 26, 2014, 5:02pm UTC](https://www.ruby-forum.com/t/how-to-calculate-snr/240051/13 "2014-03-26T17:02:56Z")

</div>

Ah, ok thank you.

Azza

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/How-to-calculate-SNR-tp47193p47237.html](http://gnuradio.4.n7.nabble.com/How-to-calculate-SNR-tp47193p47237.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Azza\_Ben\_Mosbah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e56c9b/32.png) [@Azza\_Ben\_Mosbah](https://www.ruby-forum.com/u/Azza_Ben_Mosbah)\
**Post date:** [March 31, 2014, 9:40pm UTC](https://www.ruby-forum.com/t/how-to-calculate-snr/240051/14 "2014-03-31T21:40:12Z")

</div>

Thank you. That helps.

Azza

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/How-to-calculate-SNR-tp47193p47354.html](http://gnuradio.4.n7.nabble.com/How-to-calculate-SNR-tp47193p47354.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Azza\_Ben\_Mosbah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e56c9b/32.png) [@Azza\_Ben\_Mosbah](https://www.ruby-forum.com/u/Azza_Ben_Mosbah)\
**Post date:** [March 31, 2014, 9:32pm UTC](https://www.ruby-forum.com/t/how-to-calculate-snr/240051/15 "2014-03-31T21:32:01Z")

</div>

On Mon, Mar 31, 2014 at 2:56 PM, Azza Ben Mosbah  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Any help is appreciated.
> 
> Thank you,  
> Azza

When in doubt, check the docs!

> **[GNU Radio Manual and C++ API Reference: gr::digital::mpsk\_snr\_est\_simple...](https://www.gnuradio.org/doc/doxygen/classgr_1_1digital_1_1mpsk __snr__ est__simple.html)**

> **[GNU Radio Manual and C++ API Reference: gr::digital::mpsk\_snr\_est\_skew Class...](https://www.gnuradio.org/doc/doxygen/classgr_1_1digital_1_1mpsk __snr__ est__skew.html)**

> **[GNU Radio Manual and C++ API Reference: gr::digital::mpsk\_snr\_est\_m2m4 Class...](https://www.gnuradio.org/doc/doxygen/classgr_1_1digital_1_1mpsk __snr__ est__m2m4.html)**

> **[GNU Radio Manual and C++ API Reference: gr::digital::mpsk\_snr\_est\_svr Class...](https://www.gnuradio.org/doc/doxygen/classgr_1_1digital_1_1mpsk __snr__ est__svr.html)**

Tom
