28#include "ns3/simulator.h"
29#include "ns3/uinteger.h"
35NS_LOG_COMPONENT_DEFINE(
"SatHandoverModule");
46 TypeId(
"ns3::SatHandoverModule")
48 .AddConstructor<SatHandoverModule>()
49 .AddAttribute(
"Timeout",
50 "Amount of time to wait before sending a new handover recommendation if "
51 "no TIM-U is received",
52 TimeValue(MilliSeconds(1000)),
55 .AddAttribute(
"HandoverDecisionAlgorithm",
56 "Algorithm to use for handovers",
58 MakeEnumAccessor<SatHandoverModule::HandoverDecisionAlgorithm_t>(
61 .AddAttribute(
"NumberClosestSats",
62 "Number of satellites to consider when using algorithm SAT_N_CLOSEST_SAT",
65 MakeUintegerChecker<uint32_t>())
66 .AddTraceSource(
"AntennaGainTrace",
67 "Trace antenna gains when checking for beam compliance",
69 "ns3::SatAntennaGainPattern::AntennaGainTrace");
76 NS_LOG_FUNCTION(
this);
92 NS_LOG_FUNCTION(
this);
94 NS_FATAL_ERROR(
"SatHandoverModule default constructor should not be used!");
98 NodeContainer satellites,
99 Ptr<SatAntennaGainPatternContainer> agpContainer)
111 NS_LOG_FUNCTION(
this << agpContainer);
116 NS_LOG_FUNCTION(
this);
122 NS_LOG_FUNCTION(
this << &cb);
142 NS_LOG_FUNCTION(
this);
150 NS_LOG_FUNCTION(
this << satId << beamId);
152 Time now = Simulator::Now();
158 Ptr<SatMobilityModel> mobilityModel = GetObject<SatMobilityModel>();
161 NS_LOG_FUNCTION(
"Bailing out for lack of mobility model");
171 NS_LOG_FUNCTION(
"Current beam is good, do nothing");
186 bestSatId = bestSatAndBeam.first;
187 bestBeamId = bestSatAndBeam.second;
191 NS_FATAL_ERROR(
"Incorrect handover decision algorithm");
195 if ((bestSatId != satId || bestBeamId != beamId) &&
198 NS_LOG_FUNCTION(
"Sending handover recommendation for beam " << bestBeamId <<
" on sat "
215 NS_LOG_FUNCTION(
this << numberOfSats);
217 std::map<double, uint32_t> satellites;
227 satellites.emplace(distance, i);
230 std::vector<uint32_t> closest;
232 for (
auto&& [dist, satId] : satellites)
234 if (i++ < numberOfSats)
236 closest.push_back(satId);
247std::pair<uint32_t, uint32_t>
250 NS_LOG_FUNCTION(
this << coords);
254 uint32_t bestSatId = satellites[0];
260 for (uint32_t i = 1; i < satellites.size(); i++)
270 bestSatId = satellites[i];
276 return std::make_pair(bestSatId, bestBeamId);
GeoCoordinate class is used to store and operate with geodetic coordinates.
void HandoverFinished()
Method to call when a handover has been performed.
HandoverDecisionAlgorithm_t m_handoverDecisionAlgorithm
Algorithm used to detect if handover is needed.
uint32_t GetAskedBeamId()
Get the best beam ID.
~SatHandoverModule()
Destroy a SatHandoverModule.
void SetHandoverRequestCallback(SatHandoverModule::HandoverRequestCallback cb)
Set the handover recommendation message sending callback.
HandoverRequestCallback m_handoverCallback
SatHandoverModule()
Default constructor, which is not used.
bool CheckForHandoverRecommendation(uint32_t satId, uint32_t beamId)
Inspect whether or not the given beam is still suitable for the underlying mobility model.
Time m_repeatRequestTimeout
virtual void DoDispose()
Dispose of this class instance.
NodeContainer m_satellites
std::pair< uint32_t, uint32_t > AlgorithmNClosest(GeoCoordinate coords)
Handover algorithm choosing best beam between N closest satellites.
TracedCallback< double > m_antennaGainTrace
Ptr< SatAntennaGainPatternContainer > m_antennaGainPatterns
uint32_t GetAskedSatId()
Get the best sat ID.
uint32_t m_numberClosestSats
Number of satellites to consider when using algorithm SAT_N_CLOSEST_SAT.
std::vector< uint32_t > GetNClosestSats(uint32_t numberOfSats)
Get the N closest satellites to the UT node.
static TypeId GetTypeId(void)
Derived from Object.
Callback< void, uint32_t, uint32_t > HandoverRequestCallback
Handover recommendation message sending callback.
Keep track of the current position and velocity of an object in satellite network.
double GetDistanceFrom(Ptr< const SatMobilityModel > position) const
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
Ptr< SatMobilityModel > satMobility