25 #include <ns3/boolean.h>
26 #include <ns3/double.h>
28 #include <ns3/pointer.h>
29 #include <ns3/trace-source-accessor.h>
35 NS_LOG_COMPONENT_DEFINE(
"SatMobilityObserver");
40 NS_OBJECT_ENSURE_REGISTERED(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");
93 NS_LOG_FUNCTION(
this);
100 NS_LOG_FUNCTION(
this);
107 Ptr<SatMobilityModel> geoSatMobility,
109 : m_ownMobility(ownMobility),
110 m_anotherMobility(nullptr),
111 m_geoSatMobility(geoSatMobility),
112 m_ownProgDelayModel(nullptr),
113 m_anotherProgDelayModel(nullptr),
114 m_initialized(false),
115 m_isRegenerative(isRegenerative)
117 NS_LOG_FUNCTION(
this << ownMobility << geoSatMobility);
125 double satelliteAltitude = satellitePosition.
GetAltitude();
128 NS_ASSERT(satelliteAltitude > 0.0);
132 CalculateDistance(satellitePosition.
ToVector(), Vector(0, 0, 0)) - satelliteAltitude;
154 NS_LOG_FUNCTION(
this);
165 NS_LOG_FUNCTION(
this);
170 Ptr<PropagationDelayModel> anotherDelayModel,
171 Ptr<SatMobilityModel> anotherMobility)
173 NS_LOG_FUNCTION(
this << ownDelayModel << anotherDelayModel << anotherMobility);
175 NS_ASSERT(ownDelayModel !=
nullptr);
176 NS_ASSERT(anotherDelayModel !=
nullptr);
177 NS_ASSERT(anotherMobility !=
nullptr);
199 NS_LOG_FUNCTION(
this);
217 NS_LOG_FUNCTION(
this);
220 m_velocity = std::sqrt((velocity.x * velocity.x) + (velocity.y * velocity.y) +
221 (velocity.z * velocity.z));
229 NS_LOG_FUNCTION(
this);
255 NS_LOG_FUNCTION(
this);
266 NS_LOG_FUNCTION(
this << context << position);
277 if (context ==
"Satellite")
288 NS_LOG_FUNCTION(
this);
302 double distanceToSatellite =
314 double longitudeDelta = satLongitude - earthLongitude;
321 double centralAngleCos =
322 (std::cos(earthLatitude) * std::cos(satLatitude) * std::cos(longitudeDelta)) +
323 (std::sin(earthLatitude) * std::sin(satLatitude));
327 std::sin(std::acos(centralAngleCos)) /
337 NS_LOG_FUNCTION(
this);
356 NS_LOG_FUNCTION(
this);
358 double satelliteAltitude =
m_geoSatMobility->GetGeoPosition().GetAltitude();
361 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.
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
TypeId GetInstanceTypeId(void) const
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.