satellite-position-allocator.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 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  * Author: Bastien Tauran <bastien.tauran@viveris.fr>
20  */
21 
22 #ifndef SATELLITE_POSITION_ALLOCATOR_H
23 #define SATELLITE_POSITION_ALLOCATOR_H
24 
25 #include "geo-coordinate.h"
27 
28 #include <ns3/object.h>
29 #include <ns3/position-allocator.h>
30 #include <ns3/random-variable-stream.h>
31 
32 namespace ns3
33 {
34 
42 class SatPositionAllocator : public PositionAllocator
43 {
44  public:
49  static TypeId GetTypeId(void);
50 
55 
59  virtual ~SatPositionAllocator();
60 
65  virtual GeoCoordinate GetNextGeoPosition(uint32_t satId = 0) const = 0;
66 
67  virtual Vector GetNext(void) const;
68  virtual int64_t AssignStreams(int64_t stream);
69 
70  private:
71  /*
72  * This is the flag for indicating that when calling method GetNext (defined by class
73  * PositionAlocator) is returned Vector filled by longitude (in x), latitude (in y) and altitude
74  * (in z) this enables using ns-3 mobility helper without to convert geo coordinates first to
75  * Cartesian but if for some reason used model needs Cartesian coordinates then this flag can be
76  * turned off through attribute 'AsGeoCoordinates'.
77  */
79 };
80 
89 {
90  public:
95  static TypeId GetTypeId(void);
96 
101 
106  void Add(GeoCoordinate coordinate);
107 
113  virtual GeoCoordinate GetNextGeoPosition(uint32_t satId = 0) const;
114 
115  inline virtual void SetToBegin()
116  {
117  m_current = m_positions.begin();
118  }
119 
120  inline virtual uint32_t GetCount()
121  {
122  return m_positions.size();
123  }
124 
125  private:
126  std::vector<GeoCoordinate> m_positions;
127  mutable std::vector<GeoCoordinate>::const_iterator m_current;
128 };
129 
136 {
137  public:
142  static TypeId GetTypeId(void);
143 
148 
153 
154  void SetLatitude(Ptr<RandomVariableStream> latitude);
155  void SetLongitude(Ptr<RandomVariableStream> longitude);
156  void SetAltitude(Ptr<RandomVariableStream> altitude);
157 
162  virtual GeoCoordinate GetNextGeoPosition(uint32_t satId = 0) const;
163  virtual int64_t AssignStreams(int64_t stream);
164 
165  private:
166  Ptr<RandomVariableStream> m_latitude;
167  Ptr<RandomVariableStream> m_longitude;
168  Ptr<RandomVariableStream> m_altitude;
169 };
170 
176 {
177  public:
182  static TypeId GetTypeId(void);
183 
188 
194  SatRandomCirclePositionAllocator(GeoCoordinate center, uint32_t radius);
195 
200 
201  void SetCenter(GeoCoordinate center);
202  void SetRadius(uint32_t radius);
203 
208  virtual GeoCoordinate GetNextGeoPosition(uint32_t satId = 0) const;
209  virtual int64_t AssignStreams(int64_t stream);
210 
211  private:
213  uint32_t m_radius;
214  Ptr<RandomVariableStream> m_rand;
215 };
216 
222 {
223  public:
228  static TypeId GetTypeId(void);
229 
234 
241  SatSpotBeamPositionAllocator(uint32_t beamId,
242  Ptr<SatAntennaGainPatternContainer> patternContainer,
243  GeoCoordinate geoPos);
244 
249 
250  void SetAltitude(Ptr<RandomVariableStream> altitude);
251 
256  virtual GeoCoordinate GetNextGeoPosition(uint32_t satId) const;
257  virtual int64_t AssignStreams(int64_t stream);
258 
259  private:
263  static constexpr uint32_t MAX_TRIES = 100;
264 
268  static constexpr double MIN_ANTENNA_GAIN = 40.0;
269 
273  uint32_t m_targetBeamId;
274 
282 
288  Ptr<SatAntennaGainPatternContainer> m_antennaGainPatterns;
289 
294 
298  Ptr<RandomVariableStream> m_altitude;
299 };
300 
301 } // namespace ns3
302 
303 #endif /* POSITION_ALLOCATOR_H */
GeoCoordinate class is used to store and operate with geodetic coordinates.
Allocate positions from a deterministic list specified by the user.
void Add(GeoCoordinate coordinate)
std::vector< GeoCoordinate > m_positions
static TypeId GetTypeId(void)
Get the type ID.
virtual GeoCoordinate GetNextGeoPosition(uint32_t satId=0) const
Get next position.
std::vector< GeoCoordinate >::const_iterator m_current
Allocate a set of satellite positions.
virtual Vector GetNext(void) const
SatPositionAllocator()
Default constructor.
static TypeId GetTypeId(void)
Get the type ID.
virtual ~SatPositionAllocator()
Destructor for SatPositionAllocator.
virtual GeoCoordinate GetNextGeoPosition(uint32_t satId=0) const =0
Get next position.
virtual int64_t AssignStreams(int64_t stream)
Allocate random positions within a 3D box according to a set of three random variables (longitude,...
virtual ~SatRandomBoxPositionAllocator()
Destructor for SatRandomBoxPositionAllocator.
virtual int64_t AssignStreams(int64_t stream)
void SetLongitude(Ptr< RandomVariableStream > longitude)
virtual GeoCoordinate GetNextGeoPosition(uint32_t satId=0) const
Get next position.
void SetAltitude(Ptr< RandomVariableStream > altitude)
static TypeId GetTypeId(void)
Get the type ID.
void SetLatitude(Ptr< RandomVariableStream > latitude)
Allocate random positions within a circle (center and radius), uniformly distributed.
virtual ~SatRandomCirclePositionAllocator()
Destructor for SatRandomCirclePositionAllocator.
virtual GeoCoordinate GetNextGeoPosition(uint32_t satId=0) const
Get next position.
static TypeId GetTypeId(void)
Get the type ID.
Allocate random positions within the area of a certain spot-beam.
static constexpr double MIN_ANTENNA_GAIN
Minimum accepted antenna gain for a UT.
GeoCoordinate m_geoPos
Position of the GEO satellite.
Ptr< RandomVariableStream > m_altitude
A random variable stream for altitude.
virtual int64_t AssignStreams(int64_t stream)
static constexpr uint32_t MAX_TRIES
Max number of tries to pick a random position for a UT.
void SetAltitude(Ptr< RandomVariableStream > altitude)
virtual ~SatSpotBeamPositionAllocator()
Destructor for SatSpotBeamPositionAllocator.
Ptr< SatAntennaGainPatternContainer > m_antennaGainPatterns
Antenna pattern used to check that the give position is valid based on antenna gains.
virtual GeoCoordinate GetNextGeoPosition(uint32_t satId) const
Get next position.
uint32_t m_targetBeamId
Target beam id to which the UT is tried to be placed.
double m_minElevationAngleInDeg
Minimum accepted elevation angle in degrees for UTs.
static TypeId GetTypeId(void)
Get the type ID.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.