29 #include <ns3/boolean.h>
30 #include <ns3/double.h>
33 #include <ns3/pointer.h>
34 #include <ns3/string.h>
35 #include <ns3/uinteger.h>
40 NS_LOG_COMPONENT_DEFINE(
"SatPositionAllocator");
45 NS_OBJECT_ENSURE_REGISTERED(SatPositionAllocator);
51 TypeId(
"ns3::SatPositionAllocator")
52 .SetParent<PositionAllocator>()
53 .AddAttribute(
"AsGeoCoordinates",
54 "GetNext method returns geodetic coordinates in returned Vector, "
55 "x=longitude, y=latitude, z=altitude",
58 MakeBooleanChecker());
63 : m_GetAsGeoCoordinates(true)
99 static TypeId tid = TypeId(
"ns3::SatListPositionAllocator")
101 .AddConstructor<SatListPositionAllocator>();
140 TypeId(
"ns3::SatRandomBoxPositionAllocator")
142 .SetGroupName(
"Mobility")
144 .AddAttribute(
"Longitude",
145 "A random variable which represents the longitude coordinate of a "
146 "position in a random rectangle.",
147 StringValue(
"ns3::UniformRandomVariable[Min=-180.0|Max=180.0]"),
149 MakePointerChecker<RandomVariableStream>())
150 .AddAttribute(
"Latitude",
151 "A random variable which represents the latitude coordinate of a "
152 "position in a random rectangle.",
153 StringValue(
"ns3::UniformRandomVariable[Min=-90.0|Max=90.0]"),
155 MakePointerChecker<RandomVariableStream>())
156 .AddAttribute(
"Altitude",
157 "A random variable which represents the altitude coordinate of a "
158 "position in a random box.",
159 StringValue(
"ns3::UniformRandomVariable[Min=0.0]"),
161 MakePointerChecker<RandomVariableStream>());
222 static TypeId tid = TypeId(
"ns3::SatRandomCirclePositionAllocator")
224 .SetGroupName(
"Mobility")
231 m_rand = CreateObject<UniformRandomVariable>();
239 m_rand = CreateObject<UniformRandomVariable>();
268 double theta =
m_rand->GetValue() * 2 * M_PI;
276 double lat2 = asin(sin(latitude) * cos(radiusNormalized) +
277 cos(latitude) * sin(radiusNormalized) * cos(theta));
278 double lon2 = longitude + atan2(sin(theta) * sin(radiusNormalized) * cos(latitude),
279 cos(radiusNormalized) - sin(latitude) * sin(lat2));
289 m_rand->SetStream(stream);
299 TypeId(
"ns3::SatSpotBeamPositionAllocator")
301 .SetGroupName(
"Mobility")
303 .AddAttribute(
"Altitude",
304 "A random variable which represents the altitude coordinate of a "
305 "position in a random box.",
306 StringValue(
"ns3::UniformRandomVariable[Min=0.0]"),
308 MakePointerChecker<RandomVariableStream>())
310 "MinElevationAngleInDegForUT",
311 "Minimum accepted elevation angle in degrees for UTs",
314 MakeDoubleChecker<double>());
320 m_minElevationAngleInDeg(1)
326 Ptr<SatAntennaGainPatternContainer> patterns,
328 : m_targetBeamId(beamId),
329 m_minElevationAngleInDeg(1),
330 m_antennaGainPatterns(patterns),
342 NS_LOG_FUNCTION(
this);
350 NS_LOG_FUNCTION(
this);
352 uint32_t bestBeamId(std::numeric_limits<uint32_t>::max());
358 Ptr<SatConstantPositionMobilityModel> utMob = CreateObject<SatConstantPositionMobilityModel>();
359 Ptr<SatConstantPositionMobilityModel> geoMob = CreateObject<SatConstantPositionMobilityModel>();
362 Ptr<SatMobilityObserver> utObserver = CreateObject<SatMobilityObserver>(utMob, geoMob);
364 double elevation(std::numeric_limits<double>::max());
371 while ((bestBeamId == 0 || bestBeamId !=
m_targetBeamId || std::isnan(elevation) ||
375 pos = agp->GetValidRandomPosition(mobility);
379 utMob->SetGeoPosition(pos);
382 elevation = utObserver->GetElevationAngle();
390 NS_FATAL_ERROR(
this <<
" max number of tries for spot-beam allocation exceeded!");
397 pos.
GetLongitude() > 180.0 || elevation < m_minElevationAngleInDeg || elevation > 90.0)
400 "SatSpotBeamPositionAllocator::GetNextGeoPosition - unvalid selected position!");
409 NS_LOG_FUNCTION(
this);
GeoCoordinate class is used to store and operate with geodetic coordinates.
void SetAltitude(double altitude)
Sets altitude value of coordinate.
double GetAltitude() const
Gets altitude value of coordinate.
double GetLatitude() const
Gets latitude value of coordinate.
double GetLongitude() const
Gets longitude value of coordinate.
Vector ToVector() const
Converts Geodetic coordinates to Cartesian coordinates.
static constexpr double polarRadius_sphere
Allocate positions from a deterministic list specified by the user.
SatListPositionAllocator()
Default constructor.
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.
bool m_GetAsGeoCoordinates
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,...
SatRandomBoxPositionAllocator()
Default constructor.
Ptr< RandomVariableStream > m_latitude
virtual ~SatRandomBoxPositionAllocator()
Destructor for SatRandomBoxPositionAllocator.
Ptr< RandomVariableStream > m_altitude
virtual int64_t AssignStreams(int64_t stream)
void SetLongitude(Ptr< RandomVariableStream > longitude)
Ptr< RandomVariableStream > m_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.
void SetRadius(uint32_t radius)
virtual int64_t AssignStreams(int64_t stream)
virtual GeoCoordinate GetNextGeoPosition(uint32_t satId=0) const
Get next position.
SatRandomCirclePositionAllocator()
Default constructor.
Ptr< RandomVariableStream > m_rand
static TypeId GetTypeId(void)
Get the type ID.
void SetCenter(GeoCoordinate center)
Allocate random positions within the area of a certain spot-beam.
GeoCoordinate m_geoPos
Position of the GEO satellite.
Ptr< RandomVariableStream > m_altitude
A random variable stream for altitude.
SatSpotBeamPositionAllocator()
Default constructor.
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.