Loading...
Searching...
No Matches
satellite-cno-estimator.h
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2014 Magister Solutions Ltd
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Sami Rantanen <sami.rantanen@magister.fi>
19 */
20
21#ifndef SAT_CNO_ESTIMATOR
22#define SAT_CNO_ESTIMATOR
23
25
26#include "ns3/nstime.h"
27#include "ns3/simple-ref-count.h"
28
29#include <cmath>
30#include <map>
31#include <utility>
32
33namespace ns3
34{
35
41class SatCnoEstimator : public SimpleRefCount<SatCnoEstimator>
42{
43 public:
47 typedef enum
48 {
53
58
64 virtual ~SatCnoEstimator();
65
72 void AddSample(double cno);
73
81 double GetCnoEstimation();
82
83 private:
90 virtual void DoAddSample(double cno) = 0;
91
99 virtual double DoGetCnoEstimation() = 0;
100};
101
116{
117 public:
125 static inline double AddToSum(double currentSum, const std::pair<Time, double>& sample)
126 {
127 double newSum = currentSum;
128
129 if (!std::isnan(sample.second))
130 {
131 newSum += sample.second;
132 }
133
134 return newSum;
135 }
136
141
146
153
154 private:
155 typedef std::map<Time, double> SampleMap_t;
156
160
166 virtual void DoAddSample(double cno);
167
174 virtual double DoGetCnoEstimation();
175
180};
181
182} // namespace ns3
183
184#endif /* SAT_CNO_ESTIMATOR */
void ClearOutdatedSamples()
Clear outdated samples from storage.
static double AddToSum(double currentSum, const std::pair< Time, double > &sample)
Method to add a sample value to current sum.
virtual void DoAddSample(double cno)
Add a C/N0 sample to estimator.
SatBasicCnoEstimator()
Default construct a SatCnoEstimator.
std::map< Time, double > SampleMap_t
~SatBasicCnoEstimator()
Destroy a SatCnoEstimator.
virtual double DoGetCnoEstimation()
Estimate C/N0 value of the samples in window.
double GetCnoEstimation()
Estimate C/N0 value of the samples.
virtual void DoAddSample(double cno)=0
Add a C/N0 sample to estimator.
virtual double DoGetCnoEstimation()=0
Estimate C/N0 value of the samples.
EstimationMode_t
Definition of modes for estimator.
@ MINIMUM
Minimum value in the given window returned.
@ LAST
Last value in the given window returned.
@ AVERAGE
Average value in the given window returned.
virtual ~SatCnoEstimator()
Destroy a SatCnoEstimator.
void AddSample(double cno)
Add a C/N0 sample to estimator.
SatCnoEstimator()
Default construct a SatCnoEstimator.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.