25#include "ns3/boolean.h"
26#include "ns3/double.h"
28#include "ns3/pointer.h"
29#include "ns3/trace-source-accessor.h"
35NS_LOG_COMPONENT_DEFINE(
"SatMobilityObserver");
46 TypeId(
"ns3::SatMobilityObserver")
48 .AddAttribute(
"OwnMobility",
52 MakePointerChecker<SatMobilityModel>())
53 .AddAttribute(
"SatelliteMobility",
54 "The mobility of the satellite.",
57 MakePointerChecker<SatMobilityModel>())
58 .AddAttribute(
"AnotherMobility",
59 "The mobility of the another end node.",
62 MakePointerChecker<SatMobilityModel>())
63 .AddAttribute(
"OwnPropagation",
64 "Own propagation delay model.",
67 MakePointerChecker<SatMobilityModel>())
68 .AddAttribute(
"AnotherPropagation",
69 "The propagation delay model of the another end node.",
72 MakePointerChecker<SatMobilityModel>())
73 .AddAttribute(
"MinAltitude",
74 "The minimum altitude accepted for own position.",
77 MakeDoubleChecker<double>())
78 .AddAttribute(
"MaxAltitude",
79 "The maximum altitude accepted for own position.",
82 MakeDoubleChecker<double>())
83 .AddTraceSource(
"PropertyChanged",
84 "The value of the some property has changed",
86 "ns3::SatMobilityObserver::PropertyChangedCallback");
92 NS_LOG_FUNCTION(
this);
99 Ptr<SatMobilityModel> geoSatMobility,
109 NS_LOG_FUNCTION(
this << ownMobility << geoSatMobility);
117 double satelliteAltitude = satellitePosition.
GetAltitude();
120 NS_ASSERT(satelliteAltitude > 0.0);
124 CalculateDistance(satellitePosition.
ToVector(), Vector(0, 0, 0)) - satelliteAltitude;
146 NS_LOG_FUNCTION(
this);
157 NS_LOG_FUNCTION(
this);
162 Ptr<PropagationDelayModel> anotherDelayModel,
163 Ptr<SatMobilityModel> anotherMobility)
165 NS_LOG_FUNCTION(
this << ownDelayModel << anotherDelayModel << anotherMobility);
167 NS_ASSERT(ownDelayModel !=
nullptr);
168 NS_ASSERT(anotherDelayModel !=
nullptr);
169 NS_ASSERT(anotherMobility !=
nullptr);
191 NS_LOG_FUNCTION(
this);
209 NS_LOG_FUNCTION(
this);
212 m_velocity = std::sqrt((velocity.x * velocity.x) + (velocity.y * velocity.y) +
213 (velocity.z * velocity.z));
221 NS_LOG_FUNCTION(
this);
247 NS_LOG_FUNCTION(
this);
258 NS_LOG_FUNCTION(
this << context << position);
269 if (context ==
"Satellite")
280 NS_LOG_FUNCTION(
this);
294 double distanceToSatellite =
306 double longitudeDelta = satLongitude - earthLongitude;
313 double centralAngleCos =
314 (std::cos(earthLatitude) * std::cos(satLatitude) * std::cos(longitudeDelta)) +
315 (std::sin(earthLatitude) * std::sin(satLatitude));
319 std::sin(std::acos(centralAngleCos)) /
329 NS_LOG_FUNCTION(
this);
348 NS_LOG_FUNCTION(
this);
350 double satelliteAltitude =
m_geoSatMobility->GetGeoPosition().GetAltitude();
353 NS_ASSERT(satelliteAltitude > 0.0);
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.
ReferenceEllipsoid_t GetRefEllipsoid()
Gets reference ellipsoid used by GeoCoordinate object.
double GetLongitude() const
Gets longitude value of coordinate.
Vector ToVector() const
Converts Geodetic coordinates to Cartesian coordinates.
Observes given mobilities and keeps track of certain wanted properties.
Ptr< SatMobilityModel > m_geoSatMobility
virtual ~SatMobilityObserver()
Destructor of the mobility observer.
virtual void DoDispose(void)
Dispose of this class instance.
void UpdateElevationAngle()
Update elevation angle.
SatMobilityObserver()
Default constructor of the mobility observer (should not be called).
void ObserveTimingAdvance(Ptr< PropagationDelayModel > ownDelayModel, Ptr< PropagationDelayModel > anotherDelayModel, Ptr< SatMobilityModel > anotherMobility)
Enable observing of the timing advance.
Time GetTimingAdvance(void)
Get timing advance.
void PositionChanged(std::string context, Ptr< const SatMobilityModel > position)
Listener (callback) for mobility position changes.
void SatelliteStatusChanged()
Do actions needed when satellite position is changed.
void UpdateTimingAdvance()
Update timing advance.
double m_maxDistanceToSatellite
double GetVelocity(void)
Get velocity of own movement (speed).
static TypeId GetTypeId(void)
Get the type ID.
Ptr< SatMobilityModel > m_anotherMobility
bool m_updateTimingAdvance
void NotifyPropertyChange(void) const
Notify listeners about some property is changed.
double GetElevationAngle(void)
Get elevation angle.
TracedCallback< Ptr< const SatMobilityObserver > > m_propertyChangeTrace
Used to alert subscribers that a change in some observed property has occurred.
Ptr< PropagationDelayModel > m_anotherProgDelayModel
Ptr< PropagationDelayModel > m_ownProgDelayModel
Ptr< SatMobilityModel > m_ownMobility
bool m_updateElevationAngle
static T RadiansToDegrees(T radian)
Converts radians to degrees.
static T DegreesToRadians(T degree)
Converts degrees to radians.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.