satellite-request-manager.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  * Copyright (c) 2018 CNES
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Jani Puttonen <jani.puttonen@magister.fi>
20  * Author: Mathias Ettinger <mettinger@toulouse.viveris.com>
21  */
22 
23 #ifndef SATELLITE_REQUEST_MANAGER_H_
24 #define SATELLITE_REQUEST_MANAGER_H_
25 
27 #include "satellite-enums.h"
29 #include "satellite-node-info.h"
30 #include "satellite-queue.h"
31 
32 #include <ns3/callback.h>
33 #include <ns3/object.h>
34 
35 #include <deque>
36 #include <map>
37 #include <stdint.h>
38 #include <string>
39 #include <utility>
40 #include <vector>
41 
42 namespace ns3
43 {
44 
53 class SatRequestManager : public Object
54 {
55  public:
60 
64  virtual ~SatRequestManager();
65 
66  void Initialize(Ptr<SatLowerLayerServiceConf> llsConf, Time superFrameDuration);
67 
71  static TypeId GetTypeId(void);
72 
77  virtual TypeId GetInstanceTypeId(void) const;
78 
82  virtual void DoDispose();
83 
87  typedef Callback<SatQueue::QueueStats_t, bool> QueueCallback;
88 
95  typedef Callback<bool, Ptr<SatControlMessage>, const Address&> SendCtrlCallback;
96 
101  typedef Callback<bool> CtrlMsgTxPossibleCallback;
102 
107  typedef Callback<bool> LogonMsgTxPossibleCallback;
108 
112  typedef std::vector<std::deque<std::pair<Time, uint32_t>>> PendingRbdcRequestsContainer_t;
113 
119  void ReceiveQueueEvent(SatQueue::QueueEvent_t event, uint8_t rcIndex);
120 
126  void AddQueueCallback(uint8_t rcIndex, SatRequestManager::QueueCallback cb);
127 
133 
140 
147 
152  void SetGwAddress(Mac48Address address);
153 
158  void SetNodeInfo(Ptr<SatNodeInfo> nodeInfo);
159 
174  void CnoUpdated(uint32_t satId,
175  uint32_t beamId,
176  Address sourceMac,
177  Address gwId,
178  double cno,
179  bool isSatelliteMac);
180 
187  void AssignedDaResources(uint8_t rcIndex, uint32_t bytes);
188 
195  typedef void (*CapacityRequestTraceCallback)(Time time,
196  Mac48Address address,
197  Ptr<SatCrMessage> message);
198 
211  typedef void (*CapacityRequestTraceLogCallback)(std::string traceLog);
212 
217  typedef void (*RbdcTraceCallback)(uint32_t requestSize);
218 
223  typedef void (*VbdcTraceCallback)(uint32_t requestSize);
224 
229  typedef void (*AvbdcTraceCallback)(uint32_t requestSize);
230 
236  void SendHandoverRecommendation(uint32_t satId, uint32_t beamId);
237 
241  void SendLogonMessage();
242 
247  void SetHeaderOffsetVbdc(double headerOffsetVbcd);
248 
249  private:
250  typedef std::map<uint8_t, QueueCallback> CallbackContainer_t;
251 
256  void DoPeriodicalEvaluation();
257 
262  void DoEvaluation();
263 
270  uint32_t DoRbdc(uint8_t rc, const SatQueue::QueueStats_t& stats);
271 
278  uint32_t DoRbdcLegacy(uint8_t rc, const SatQueue::QueueStats_t& stats);
279 
288  const SatQueue::QueueStats_t& stats,
289  uint32_t& rcVbdcBytes);
290 
299  const SatQueue::QueueStats_t& stats,
300  uint32_t& rcVbdcBytes);
301 
308  uint32_t GetVbdcBytes(uint8_t rc, const SatQueue::QueueStats_t& stats);
309 
316  uint32_t GetAvbdcBytes(uint8_t rc, const SatQueue::QueueStats_t& stats);
317 
323 
329  uint32_t GetPendingRbdcSumKbps(uint8_t rc);
330 
336  void UpdatePendingRbdcCounters(uint8_t rc, uint32_t kbps);
337 
343 
348 
353  void UpdatePendingVbdcCounters(uint8_t rc);
354 
360  void SendCapacityRequest(Ptr<SatCrMessage> crMsg);
361 
365  void SendCnoReport();
366 
370  void ResetAssignedResources();
371 
376  void Reset(uint8_t rc);
377 
386  uint16_t GetQuantizedRbdcValue(uint8_t index, uint16_t reqRbdcKbps) const;
387 
396  uint16_t GetQuantizedVbdcValue(uint8_t index, uint16_t reqVbdcBytes) const;
397 
402 
407 
413 
419 
423  Mac48Address m_gwAddress;
424 
428  Mac48Address m_satAddress;
429 
434  double m_lastCno;
435 
441 
446  Ptr<SatLowerLayerServiceConf> m_llsConf;
447 
452 
457 
462 
466  double m_gainValueK;
467 
473 
480 
485 
492 
496  std::vector<uint32_t> m_pendingVbdcBytes;
497 
501  std::vector<Time> m_previousEvaluationTime;
502 
506  Ptr<SatNodeInfo> m_nodeInfo;
507 
511  std::vector<uint32_t> m_assignedDaResourcesBytes;
512 
517 
522 
529 
530  uint32_t m_numValues;
531  static const uint32_t m_rbdcScalingFactors[4];
532  static const uint32_t m_vbdcScalingFactors[4];
533 
537  TracedCallback<Time, Mac48Address, Ptr<SatCrMessage>> m_crTrace;
538 
542  TracedCallback<std::string> m_crTraceLog;
543 
550  TracedCallback<uint32_t> m_rbdcTrace;
551  TracedCallback<uint32_t> m_vbdcTrace;
552  TracedCallback<uint32_t> m_aVbdcTrace;
553 
558 
563 
569 };
570 
571 } // namespace ns3
572 
573 #endif /* SATELLITE_REQUEST_MANAGER_H_ */
SatCapacityAllocationCategory_t
Definition for different types of Capacity Request (CR) messages.
SatRequestManager analyzes periodically or on-a-need-basis UT's buffer status for different RC indice...
Time m_superFrameDuration
Superframe duration used for updating the volume backlog persistence.
double m_overEstimationFactor
Over-estimation factor used for estimating a bit more resources than there are in the buffers.
SatEnums::RbdcCapacityRequestAlgorithm_t m_rbdcCapacityRequestAlgorithm
The RBDC capacity algorithm to use.
void(* CapacityRequestTraceCallback)(Time time, Mac48Address address, Ptr< SatCrMessage > message)
Callback signature for CrTrace trace source.
void(* AvbdcTraceCallback)(uint32_t requestSize)
Callback signature for AvbdcTrace trace source.
SatEnums::SatCapacityAllocationCategory_t DoVbdcLegacy(uint8_t rc, const SatQueue::QueueStats_t &stats, uint32_t &rcVbdcBytes)
Legacy algorithm to do VBDC calculation for a RC.
void Reset(uint8_t rc)
Reset RC index counters.
SendCtrlCallback m_ctrlCallback
Callback to send control messages.
PendingRbdcRequestsContainer_t m_pendingRbdcRequestsKbps
Key = RC index Value -> Key = Time when the request was sent Value -> Value = Requested bitrate or by...
void AssignedDaResources(uint8_t rcIndex, uint32_t bytes)
Sat UT MAC informs that certain amount of resources have been received in TBTP.
TracedCallback< uint32_t > m_aVbdcTrace
double m_lastSatelliteCno
The last received user link C/N0 information from lower layer in linear format.
void SetLogonMsgTxPossibleCallback(SatRequestManager::LogonMsgTxPossibleCallback cb)
Set the callback to check the possibility of sending a control message.
TracedCallback< std::string > m_crTraceLog
Trace callback used for CR tracing.
void SendLogonMessage()
Send a logon message to the gateway.
Ptr< SatLowerLayerServiceConf > m_llsConf
Lower layer services conf pointer, which holds the configurations for RCs and capacity allocation cat...
static TypeId GetTypeId(void)
inherited from Object
void ReceiveQueueEvent(SatQueue::QueueEvent_t event, uint8_t rcIndex)
Receive a queue event.
void RemoveOldEntriesFromPendingRbdcContainer(uint8_t rc)
Clean-up the pending RBDC container from old samples.
void Initialize(Ptr< SatLowerLayerServiceConf > llsConf, Time superFrameDuration)
Mac48Address m_gwAddress
GW address.
uint32_t GetVbdcBytes(uint8_t rc, const SatQueue::QueueStats_t &stats)
Calculate the needed VBDC bytes for a RC.
LogonMsgTxPossibleCallback m_logonMsgTxPossibleCallback
Callback to check from MAC if a logon msg may be transmitted in the near future.
uint16_t GetQuantizedRbdcValue(uint8_t index, uint16_t reqRbdcKbps) const
The RBDC value is signalled with 8 bits, which means that to be able to signal larger than 256 values...
void UpdatePendingRbdcCounters(uint8_t rc, uint32_t kbps)
Update the pending RBDC counters with new request information.
Callback< SatQueue::QueueStats_t, bool > QueueCallback
Callback to fetch queue statistics.
void(* VbdcTraceCallback)(uint32_t requestSize)
Callback signature for VbdcTrace trace source.
SatEnums::VbdcCapacityRequestAlgorithm_t m_vbdcCapacityRequestAlgorithm
The VBDC capacity algorithm to use.
void UpdatePendingVbdcCounters()
Update pending VBDC counters for all RCs.
Ptr< SatNodeInfo > m_nodeInfo
Node information.
virtual ~SatRequestManager()
Destructor for SatRequestManager.
uint32_t GetPendingRbdcSumKbps(uint8_t rc)
Calculate the pending RBDC requests related to a specific RC.
Callback< bool > CtrlMsgTxPossibleCallback
Callback to check whether control msg transmission is possible.
void DoPeriodicalEvaluation()
Periodically check the buffer status and whether a new CR is needed to be sent.
void SetCtrlMsgTxPossibleCallback(SatRequestManager::CtrlMsgTxPossibleCallback cb)
Set the callback to check the possibility of sending a control message.
SatEnums::SatCapacityAllocationCategory_t DoVbdc(uint8_t rc, const SatQueue::QueueStats_t &stats, uint32_t &rcVbdcBytes)
Do VBDC calculation for a RC.
static const uint32_t m_rbdcScalingFactors[4]
std::vector< uint32_t > m_pendingVbdcBytes
Pending VBDC counter for each RC index.
Mac48Address m_satAddress
SAT address.
void SetNodeInfo(Ptr< SatNodeInfo > nodeInfo)
Set the node info of this UT.
virtual void DoDispose()
Dispose of this class instance.
TracedCallback< uint32_t > m_rbdcTrace
Traced callbacks for all sent RBDC and VBDC capacity requests.
void SendCnoReport()
Send the C/N0 report message via txCallback to SatNetDevice.
void(* CapacityRequestTraceLogCallback)(std::string traceLog)
Callback signature for CrLogTrace trace source.
void ResetAssignedResources()
Reset the assigned resources counter.
uint32_t GetAvbdcBytes(uint8_t rc, const SatQueue::QueueStats_t &stats)
Calculate the needed AVBDC bytes for a RC.
uint16_t GetQuantizedVbdcValue(uint8_t index, uint16_t reqVbdcBytes) const
The RBDC value is signalled with 8 bits, which means that to be able to signal larger than 256 values...
double m_gainValueK
Gain value K for the RBDC calculation.
Callback< bool, Ptr< SatControlMessage >, const Address & > SendCtrlCallback
Control message sending callback.
void DoEvaluation()
Do evaluation of the buffer status and decide whether or not to send CRs.
uint32_t DoRbdcLegacy(uint8_t rc, const SatQueue::QueueStats_t &stats)
Legacy algorithm to do RBDC calculation for a RC.
void AddQueueCallback(uint8_t rcIndex, SatRequestManager::QueueCallback cb)
Add a callback to fetch queue statistics.
EventId m_cnoReportEvent
Event id for the C/NO report.
uint32_t DoRbdc(uint8_t rc, const SatQueue::QueueStats_t &stats)
Do RBDC calculation for a RC.
static const uint32_t m_vbdcScalingFactors[4]
Time m_rttEstimate
Round trip time estimate.
TracedCallback< Time, Mac48Address, Ptr< SatCrMessage > > m_crTrace
Trace callback used for CR tracing.
std::vector< std::deque< std::pair< Time, uint32_t > > > PendingRbdcRequestsContainer_t
Container for the pending RBDC requests.
TracedCallback< uint32_t > m_vbdcTrace
std::vector< uint32_t > m_assignedDaResourcesBytes
Dedicated assignments received within the previous superframe.
Time m_lastVbdcCrSent
Time when the last CR including VBDC request was sent.
double m_lastCno
The last received on E2E C/N0 information from lower layer in linear format.
Time m_cnoReportInterval
Interval to send C/N0 report.
void(* RbdcTraceCallback)(uint32_t requestSize)
Callback signature for RbdcTrace trace source.
void SetGwAddress(Mac48Address address)
Set the GW address needed for CR transmission.
bool m_forcedAvbdcUpdate
Flag indicating that UT should send a forced AVBDC request, since the volume backlog persistence shal...
void SendCapacityRequest(Ptr< SatCrMessage > crMsg)
Send the capacity request control msg via txCallback to SatNetDevice.
Time m_evaluationInterval
Interval to do the periodical CR evaluation.
double m_headerOffsetVbcd
Additional VBDC to add to take into account E2E header in regenerative LINK or NETWORK,...
bool m_enableOnDemandEvaluation
Enable on demand / ad hoc CR evaluation.
void CheckForVolumeBacklogPersistence()
Check whether VBDC volume backlog persistence shall expire and whether UT should update request by AV...
void SetHeaderOffsetVbdc(double headerOffsetVbcd)
Update the value of header offset.
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
CtrlMsgTxPossibleCallback m_ctrlMsgTxPossibleCallback
Callback to check from MAC if a control msg may be transmitted in the near future.
SatRequestManager()
Default constructor.
void CnoUpdated(uint32_t satId, uint32_t beamId, Address sourceMac, Address gwId, double cno, bool isSatelliteMac)
Update C/N0 information from lower layer.
void SetCtrlMsgCallback(SatRequestManager::SendCtrlCallback cb)
Set the control message sending callback.
CallbackContainer_t m_queueCallbacks
The queue enque/deque rate getter callback.
void SendHandoverRecommendation(uint32_t satId, uint32_t beamId)
Send a handover recommendation message to the gateway.
std::map< uint8_t, QueueCallback > CallbackContainer_t
std::vector< Time > m_previousEvaluationTime
Time when CR evaluation was previously done.
Callback< bool > LogonMsgTxPossibleCallback
Callback to check whether logon msg transmission is possible.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
QueueStats_t definition for passing queue related statistics to any interested modules.