GNU Radio Manual and C++ API Reference  3.7.9.2
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
mpsk_snr_est.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2011,2012 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef INCLUDED_DIGITAL_MPSK_SNR_EST_H
24 #define INCLUDED_DIGITAL_MPSK_SNR_EST_H
25 
26 #include <gnuradio/digital/api.h>
27 #include <gnuradio/gr_complex.h>
28 
29 namespace gr {
30  namespace digital {
31 
32  /*!
33  * \brief A block for computing SNR of a signal.
34  * \ingroup measurement_tools_blk
35  *
36  * \details
37  * Below are some ROUGH estimates of what values of SNR each of
38  * these types of estimators is good for. In general, these offer
39  * a trade-off between accuracy and performance.
40  *
41  * \li SNR_EST_SIMPLE: Simple estimator (>= 7 dB)
42  * \li SNR_EST_SKEW: Skewness-base est (>= 5 dB)
43  * \li SNR_EST_M2M4: 2nd & 4th moment est (>= 1 dB)
44  * \li SNR_EST_SVR: SVR-based est (>= 0dB)
45  */
46  typedef enum {
47  SNR_EST_SIMPLE = 0, // Simple estimator (>= 7 dB)
48  SNR_EST_SKEW, // Skewness-base est (>= 5 dB)
49  SNR_EST_M2M4, // 2nd & 4th moment est (>= 1 dB)
50  SNR_EST_SVR // SVR-based est (>= 0dB)
52 
53  /*! \brief A parent class for SNR estimators, specifically for
54  * M-PSK signals in AWGN channels.
55  * \ingroup snr_blk
56  */
58  {
59  protected:
60  double d_alpha, d_beta;
61  double d_signal, d_noise;
62 
63  public:
64  /*! Constructor
65  *
66  * Parameters:
67  * \param alpha: the update rate of internal running average
68  * calculations.
69  */
70  mpsk_snr_est(double alpha);
71  virtual ~mpsk_snr_est();
72 
73  //! Get the running-average coefficient
74  double alpha() const;
75 
76  //! Set the running-average coefficient
77  void set_alpha(double alpha);
78 
79  //! Update the current registers
80  virtual int update(int noutput_items,
81  const gr_complex *input);
82 
83  //! Use the register values to compute a new estimate
84  virtual double snr();
85 
86  //! Returns the signal power estimate
87  virtual double signal();
88 
89  //! Returns the noise power estimate
90  virtual double noise();
91  };
92 
93 
94  //! \brief SNR Estimator using simple mean/variance estimates.
95  /*! \ingroup snr_blk
96  *
97  * A very simple SNR estimator that just uses mean and variance
98  * estimates of an M-PSK constellation. This esimator is quick
99  * and cheap and accurate for high SNR (above 7 dB or so) but
100  * quickly starts to overestimate the SNR at low SNR.
101  */
103  public mpsk_snr_est
104  {
105  private:
106  double d_y1, d_y2;
107  double d_counter;
108 
109  public:
110  /*! Constructor
111  *
112  * Parameters:
113  * \param alpha: the update rate of internal running average
114  * calculations.
115  */
116  mpsk_snr_est_simple(double alpha);
118 
119  int update(int noutput_items,
120  const gr_complex *input);
121  double snr();
122  };
123 
124 
125  //! \brief SNR Estimator using skewness correction.
126  /*! \ingroup snr_blk
127  *
128  * This is an estimator that came from a discussion between Tom
129  * Rondeau and fred harris with no known paper reference. The
130  * idea is that at low SNR, the variance estimations will be
131  * affected because of fold-over around the decision boundaries,
132  * which results in a skewness to the samples. We estimate the
133  * skewness and use this as a correcting term.
134  *
135  * This algorithm only appears to work well for BPSK signals.
136  */
138  public mpsk_snr_est
139  {
140  private:
141  double d_y1, d_y2, d_y3;
142  double d_counter;
143 
144  public:
145  /*! Constructor
146  *
147  * Parameters:
148  * \param alpha: the update rate of internal running average
149  * calculations.
150  */
151  mpsk_snr_est_skew(double alpha);
153 
154  int update(int noutput_items,
155  const gr_complex *input);
156  double snr();
157  };
158 
159 
160  //! \brief SNR Estimator using 2nd and 4th-order moments.
161  /*! \ingroup snr_blk
162  *
163  * An SNR estimator for M-PSK signals that uses 2nd (M2) and 4th
164  * (M4) order moments. This estimator uses knowledge of the
165  * kurtosis of the signal (k_a) and noise (k_w) to make its
166  * estimation. We use Beaulieu's approximations here to M-PSK
167  * signals and AWGN channels such that k_a=1 and k_w=2. These
168  * approximations significantly reduce the complexity of the
169  * calculations (and computations) required.
170  *
171  * Reference:
172  * D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR
173  * estimation techniques for the AWGN channel," IEEE
174  * Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000.
175  */
177  public mpsk_snr_est
178  {
179  private:
180  double d_y1, d_y2;
181 
182  public:
183  /*! Constructor
184  *
185  * Parameters:
186  * \param alpha: the update rate of internal running average
187  * calculations.
188  */
189  mpsk_snr_est_m2m4(double alpha);
191 
192  int update(int noutput_items,
193  const gr_complex *input);
194  double snr();
195  };
196 
197 
198  //! \brief SNR Estimator using 2nd and 4th-order moments.
199  /*! \ingroup snr_blk
200  *
201  * An SNR estimator for M-PSK signals that uses 2nd (M2) and 4th
202  * (M4) order moments. This estimator uses knowledge of the
203  * kurtosis of the signal (k_a) and noise (k_w) to make its
204  * estimation. In this case, you can set your own estimations for
205  * k_a and k_w, the kurtosis of the signal and noise, to fit this
206  * estimation better to your signal and channel conditions.
207  *
208  * A word of warning: this estimator has not been fully tested or
209  * proved with any amount of rigor. The estimation for M4 in
210  * particular might be ignoring effectf of when k_a and k_w are
211  * different. Use this estimator with caution and a copy of the
212  * reference on hand.
213  *
214  * The digital_mpsk_snr_est_m2m4 assumes k_a and k_w to simplify
215  * the computations for M-PSK and AWGN channels. Use that
216  * estimator unless you have a way to guess or estimate these
217  * values here.
218  *
219  * Original paper:
220  * R. Matzner, "An SNR estimation algorithm for complex baseband
221  * signal using higher order statistics," Facta Universitatis
222  * (Nis), no. 6, pp. 41-52, 1993.
223  *
224  * Reference used in derivation:
225  * D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR
226  * estimation techniques for the AWGN channel," IEEE
227  * Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000.
228  */
230  public mpsk_snr_est
231  {
232  private:
233  double d_y1, d_y2;
234  double d_ka, d_kw;
235 
236  public:
237  /*! Constructor
238  *
239  * Parameters:
240  * \param alpha: the update rate of internal running average
241  * calculations.
242  * \param ka: estimate of the signal kurtosis (1 for PSK)
243  * \param kw: estimate of the channel noise kurtosis (2 for AWGN)
244  */
245  snr_est_m2m4(double alpha, double ka, double kw);
247 
248  int update(int noutput_items,
249  const gr_complex *input);
250  double snr();
251  };
252 
253 
254  //! \brief Signal-to-Variation Ratio SNR Estimator.
255  /*! \ingroup snr_blk
256  *
257  * This estimator actually comes from an SNR estimator for M-PSK
258  * signals in fading channels, but this implementation is
259  * specifically for AWGN channels. The math was simplified to
260  * assume a signal and noise kurtosis (k_a and k_w) for M-PSK
261  * signals in AWGN. These approximations significantly reduce the
262  * complexity of the calculations (and computations) required.
263  *
264  * Original paper:
265  * A. L. Brandao, L. B. Lopes, and D. C. McLernon, "In-service
266  * monitoring of multipath delay and cochannel interference for
267  * indoor mobile communication systems," Proc. IEEE
268  * Int. Conf. Communications, vol. 3, pp. 1458-1462, May 1994.
269  *
270  * Reference:
271  * D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR
272  * estimation techniques for the AWGN channel," IEEE
273  * Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000.
274  */
276  public mpsk_snr_est
277  {
278  private:
279  double d_y1, d_y2;
280 
281  public:
282  /*! Constructor
283  *
284  * Parameters:
285  * \param alpha: the update rate of internal running average
286  * calculations.
287  */
288  mpsk_snr_est_svr(double alpha);
290 
291  int update(int noutput_items,
292  const gr_complex *input);
293  double snr();
294  };
295 
296  } /* namespace digital */
297 } /* namespace gr */
298 
299 #endif /* INCLUDED_DIGITAL_MPSK_SNR_EST_H */
double d_beta
Definition: mpsk_snr_est.h:60
SNR Estimator using simple mean/variance estimates.
Definition: mpsk_snr_est.h:102
snr_est_type_t
A block for computing SNR of a signal.
Definition: mpsk_snr_est.h:46
Definition: mpsk_snr_est.h:48
Definition: mpsk_snr_est.h:47
A parent class for SNR estimators, specifically for M-PSK signals in AWGN channels.
Definition: mpsk_snr_est.h:57
#define DIGITAL_API
Definition: gr-digital/include/gnuradio/digital/api.h:30
Definition: mpsk_snr_est.h:49
~mpsk_snr_est_simple()
Definition: mpsk_snr_est.h:117
Signal-to-Variation Ratio SNR Estimator.
Definition: mpsk_snr_est.h:275
std::complex< float > gr_complex
Definition: gr_complex.h:27
double d_signal
Definition: mpsk_snr_est.h:61
SNR Estimator using skewness correction.
Definition: mpsk_snr_est.h:137
Include this header to use the message passing features.
Definition: logger.h:131
SNR Estimator using 2nd and 4th-order moments.
Definition: mpsk_snr_est.h:176
Definition: mpsk_snr_est.h:50
SNR Estimator using 2nd and 4th-order moments.
Definition: mpsk_snr_est.h:229
~mpsk_snr_est_svr()
Definition: mpsk_snr_est.h:289
~mpsk_snr_est_m2m4()
Definition: mpsk_snr_est.h:190
~snr_est_m2m4()
Definition: mpsk_snr_est.h:246
~mpsk_snr_est_skew()
Definition: mpsk_snr_est.h:152