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 #include <stdint.h>
33 #include <vector>
34 
35 namespace ns3
36 {
37 
45 class SatPositionAllocator : public PositionAllocator
46 {
47  public:
52  static TypeId GetTypeId(void);
53 
58 
62  virtual ~SatPositionAllocator();
63 
68  virtual GeoCoordinate GetNextGeoPosition(uint32_t satId = 0) const = 0;
69 
70  virtual Vector GetNext(void) const;
71  virtual int64_t AssignStreams(int64_t stream);
72 
73  private:
74  /*
75  * This is the flag for indicating that when calling method GetNext (defined by class
76  * PositionAlocator) is returned Vector filled by longitude (in x), latitude (in y) and altitude
77  * (in z) this enables using ns-3 mobility helper without to convert geo coordinates first to
78  * Cartesian but if for some reason used model needs Cartesian coordinates then this flag can be
79  * turned off through attribute 'AsGeoCoordinates'.
80  */
82 };
83 
92 {
93  public:
98  static TypeId GetTypeId(void);
99 
104 
109  void Add(GeoCoordinate coordinate);
110 
116  virtual GeoCoordinate GetNextGeoPosition(uint32_t satId = 0) const;
117 
118  inline virtual void SetToBegin()
119  {
120  m_current = m_positions.begin();
121  }
122 
123  inline virtual uint32_t GetCount()
124  {
125  return m_positions.size();
126  }
127 
128  private:
129  std::vector<GeoCoordinate> m_positions;
130  mutable std::vector<GeoCoordinate>::const_iterator m_current;
131 };
132 
139 {
140  public:
145  static TypeId GetTypeId(void);
146 
151 
156 
157  void SetLatitude(Ptr<RandomVariableStream> latitude);
158  void SetLongitude(Ptr<RandomVariableStream> longitude);
159  void SetAltitude(Ptr<RandomVariableStream> altitude);
160 
165  virtual GeoCoordinate GetNextGeoPosition(uint32_t satId = 0) const;
166  virtual int64_t AssignStreams(int64_t stream);
167 
168  private:
169  Ptr<RandomVariableStream> m_latitude;
170  Ptr<RandomVariableStream> m_longitude;
171  Ptr<RandomVariableStream> m_altitude;
172 };
173 
179 {
180  public:
185  static TypeId GetTypeId(void);
186 
191 
197  SatRandomCirclePositionAllocator(GeoCoordinate center, uint32_t radius);
198 
203 
204  void SetCenter(GeoCoordinate center);
205  void SetRadius(uint32_t radius);
206 
211  virtual GeoCoordinate GetNextGeoPosition(uint32_t satId = 0) const;
212  virtual int64_t AssignStreams(int64_t stream);
213 
214  private:
216  uint32_t m_radius;
217  Ptr<RandomVariableStream> m_rand;
218 };
219 
225 {
226  public:
231  static TypeId GetTypeId(void);
232 
237 
244  SatSpotBeamPositionAllocator(uint32_t beamId,
245  Ptr<SatAntennaGainPatternContainer> patternContainer,
246  GeoCoordinate geoPos);
247 
252 
253  void SetAltitude(Ptr<RandomVariableStream> altitude);
254 
259  virtual GeoCoordinate GetNextGeoPosition(uint32_t satId) const;
260  virtual int64_t AssignStreams(int64_t stream);
261 
262  private:
266  static constexpr uint32_t MAX_TRIES = 100;
267 
271  static constexpr double MIN_ANTENNA_GAIN = 40.0;
272 
276  uint32_t m_targetBeamId;
277 
285 
291  Ptr<SatAntennaGainPatternContainer> m_antennaGainPatterns;
292 
297 
301  Ptr<RandomVariableStream> m_altitude;
302 };
303 
304 } // namespace ns3
305 
306 #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.