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 <stdint.h>
31 #include <vector>
32 
33 namespace ns3
34 {
35 
36 class Packet;
37 class SatNodeInfo;
38 class SatLowerLayerServiceConf;
39 class SatSchedulingObject;
40 
52 {
53  public:
58  SortByMetric(const std::vector<uint32_t>& m)
59  : m_cont(m)
60  {
61  }
62 
70  bool operator()(uint8_t p1, uint8_t p2)
71  {
72  return m_cont.at(p1) < m_cont.at(p2);
73  }
74 
75  private:
76  const std::vector<uint32_t>& m_cont;
77 };
78 
88 class SatUtScheduler : public Object
89 {
90  public:
95 
100  SatUtScheduler(Ptr<SatLowerLayerServiceConf> lls);
101 
105  virtual ~SatUtScheduler();
106 
112  typedef enum
113  {
114  STRICT = 0,
115  LOOSE = 1
117 
121  static TypeId GetTypeId(void);
125  virtual TypeId GetInstanceTypeId(void) const;
129  virtual void DoDispose(void);
130 
135  typedef Callback<void, std::vector<Ptr<SatSchedulingObject>>&> SchedContextCallback;
136 
146  typedef Callback<Ptr<Packet>, uint32_t, Mac48Address, uint8_t, uint32_t&, uint32_t&>
148 
154  typedef std::vector<uint32_t> ByteCounterContainer_t;
155 
163 
170 
182  void DoScheduling(std::vector<Ptr<Packet>>& packets,
183  uint32_t payloadBytes,
185  uint8_t rcIndex,
186  SatCompliancePolicy_t policy);
187 
192  virtual void SetNodeInfo(Ptr<SatNodeInfo> nodeInfo);
193 
194  private:
202  uint32_t DoSchedulingForRcIndex(std::vector<Ptr<Packet>>& packets,
203  uint32_t& payloadBytes,
204  uint8_t rcIndex);
205 
211  std::vector<uint8_t> GetPrioritizedRcIndexOrder();
212 
217 
224 
228  Ptr<SatLowerLayerServiceConf> m_llsConf;
229 
235 
240 
244  Ptr<SatNodeInfo> m_nodeInfo;
245 
253 
257  std::vector<uint8_t> m_rcIndices;
258 };
259 
260 } // namespace ns3
261 
262 #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.