satellite-ut-scheduler.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  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Jani Puttonen <jani.puttonen@magister.fi>
19  */
20 
21 #ifndef SATELLITE_UT_SCHEDULER_H_
22 #define SATELLITE_UT_SCHEDULER_H_
23 
24 #include "satellite-frame-conf.h"
25 
26 #include <ns3/callback.h>
27 #include <ns3/mac48-address.h>
28 #include <ns3/object.h>
29 
30 #include <vector>
31 
32 namespace ns3
33 {
34 
35 class Packet;
36 class SatNodeInfo;
37 class SatLowerLayerServiceConf;
38 class SatSchedulingObject;
39 
51 {
52  public:
57  SortByMetric(const std::vector<uint32_t>& m)
58  : m_cont(m)
59  {
60  }
61 
69  bool operator()(uint8_t p1, uint8_t p2)
70  {
71  return m_cont.at(p1) < m_cont.at(p2);
72  }
73 
74  private:
75  const std::vector<uint32_t>& m_cont;
76 };
77 
87 class SatUtScheduler : public Object
88 {
89  public:
94 
99  SatUtScheduler(Ptr<SatLowerLayerServiceConf> lls);
100 
104  virtual ~SatUtScheduler();
105 
111  typedef enum
112  {
113  STRICT = 0,
114  LOOSE = 1
116 
120  static TypeId GetTypeId(void);
124  virtual TypeId GetInstanceTypeId(void) const;
128  virtual void DoDispose(void);
129 
134  typedef Callback<void, std::vector<Ptr<SatSchedulingObject>>&> SchedContextCallback;
135 
145  typedef Callback<Ptr<Packet>, uint32_t, Mac48Address, uint8_t, uint32_t&, uint32_t&>
147 
153  typedef std::vector<uint32_t> ByteCounterContainer_t;
154 
162 
169 
181  void DoScheduling(std::vector<Ptr<Packet>>& packets,
182  uint32_t payloadBytes,
184  uint8_t rcIndex,
185  SatCompliancePolicy_t policy);
186 
191  virtual void SetNodeInfo(Ptr<SatNodeInfo> nodeInfo);
192 
193  private:
201  uint32_t DoSchedulingForRcIndex(std::vector<Ptr<Packet>>& packets,
202  uint32_t& payloadBytes,
203  uint8_t rcIndex);
204 
210  std::vector<uint8_t> GetPrioritizedRcIndexOrder();
211 
216 
223 
227  Ptr<SatLowerLayerServiceConf> m_llsConf;
228 
234 
239 
243  Ptr<SatNodeInfo> m_nodeInfo;
244 
252 
256  std::vector<uint8_t> m_rcIndices;
257 };
258 
259 } // namespace ns3
260 
261 #endif /* SATELLITE_UT_SCHEDULER_H_ */
SatTimeSlotType_t
Types for time slot.
The SatUtScheduler is responsible of getting a packet of proper size from higher protocol layer.
SatUtScheduler()
Default constructor.
static TypeId GetTypeId(void)
Derived from Object.
std::vector< uint32_t > ByteCounterContainer_t
Byte counter container.
virtual void DoDispose(void)
Dispose of SatUtScheduler.
void SetSchedContextCallback(SatUtScheduler::SchedContextCallback cb)
Method to set Tx opportunity callback.
bool m_prioritizeControl
Strictly prioritize the control message scheduling regardless of the time slot information given from...
SatCompliancePolicy_t
Enum describing the wanted scheduler policy.
std::vector< uint8_t > m_rcIndices
Available RC indices for scheduling.
SatUtScheduler::TxOpportunityCallback m_txOpportunityCallback
Callback to notify the txOpportunity to upper layer Returns a packet Attributes: payload in bytes.
Ptr< SatLowerLayerServiceConf > m_llsConf
The configured lower layer service configuration for this UT MAC.
virtual ~SatUtScheduler()
Destructor.
Callback< void, std::vector< Ptr< SatSchedulingObject > > & > SchedContextCallback
Callback to get scheduling contexts from upper layer.
SatUtScheduler::SchedContextCallback m_schedContextCallback
The scheduling context getter callback.
virtual TypeId GetInstanceTypeId(void) const
Derived from Object.
std::vector< uint8_t > GetPrioritizedRcIndexOrder()
Get a prioritized order of the available RC indices for LOOSE policy UT scheduling.
void SetTxOpportunityCallback(SatUtScheduler::TxOpportunityCallback cb)
Method to set Tx opportunity callback.
uint32_t DoSchedulingForRcIndex(std::vector< Ptr< Packet >> &packets, uint32_t &payloadBytes, uint8_t rcIndex)
Do scheduling for a given RC index.
ByteCounterContainer_t m_utScheduledByteCounters
Byte counters for RC indices.
virtual void SetNodeInfo(Ptr< SatNodeInfo > nodeInfo)
Set the node info.
Callback< Ptr< Packet >, uint32_t, Mac48Address, uint8_t, uint32_t &, uint32_t & > TxOpportunityCallback
Callback to notify upper layer about Tx opportunity.
void DoScheduling(std::vector< Ptr< Packet >> &packets, uint32_t payloadBytes, SatTimeSlotConf::SatTimeSlotType_t type, uint8_t rcIndex, SatCompliancePolicy_t policy)
UT scheduling is responsible of selecting with which RC index to use when requesting packets from hig...
Ptr< SatNodeInfo > m_nodeInfo
Node information.
uint32_t m_framePduHeaderSizeInBytes
Frame PDU header size.
Sort metric which sorts a vector available RC indices based on "unallocated load".
const std::vector< uint32_t > & m_cont
bool operator()(uint8_t p1, uint8_t p2)
Operator overload for function call.
SortByMetric(const std::vector< uint32_t > &m)
Sort a vector available RC indices based on unallocated load.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.