forked from sns3/sns3-satellite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
satellite-bbframe.h
213 lines (183 loc) · 5.79 KB
/
satellite-bbframe.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013 Magister Solutions Ltd
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Sami Rantanen <[email protected]>
*/
#ifndef SATELLITE_BBFRAME_H_
#define SATELLITE_BBFRAME_H_
#include <vector>
#include "ns3/simple-ref-count.h"
#include "ns3/packet.h"
#include "ns3/nstime.h"
#include "ns3/traced-callback.h"
#include "ns3/satellite-bbframe-conf.h"
#include "satellite-enums.h"
namespace ns3 {
/**
* \ingroup satellite
*
* \brief SatBbFrame class implements functionality for BB frames.
* Holds information of a BB Frame for forward link scheduling.
* It also provides methods to query information of the frame and methods
* to modify frames like shrink, extend and merge.
*
*/
class SatBbFrame : public SimpleRefCount<SatBbFrame>
{
public:
/**
* Define type SatBbFramePayload_t
*/
typedef std::vector<Ptr<Packet > > SatBbFramePayload_t;
/**
* Default constructor. Constructs BB frame with default ModCod and default frame type.
*/
SatBbFrame ();
/**
* Constructor to create BB frame according to given type and MODCOD, type and BB frame configuration.
*
* \param modCod Used ModCod
* \param type Type of the frame
* \param conf Pointer to BBFrame configuration
*/
SatBbFrame (SatEnums::SatModcod_t modCod, SatEnums::SatBbFrameType_t type, Ptr<SatBbFrameConf> conf);
/**
* Destructor fro BB frame.
*/
virtual ~SatBbFrame ();
/**
* Get the data in the BB Frame info as container of the packet pointers.
* \return Container having data as packet pointers.
*/
const SatBbFramePayload_t& GetPayload ();
/**
* Add payload (packet) to transmit buffer of this BB Frame info
*
* \param packet Pointer to packet wanted to add to transmit buffer
* \return Space left bytes in transmit buffer after addition
*/
uint32_t AddPayload (Ptr<Packet> packet);
/**
* Get space left in BB frame transmit buffer in bytes.
* \return space left in bytes in transmit buffer
*/
uint32_t GetSpaceLeftInBytes () const;
/**
* Get space used in BB frame transmit buffer in bytes.
* \return space used in bytes in transmit buffer
*/
uint32_t GetSpaceUsedInBytes () const;
/**
* Get the maximum size of the BB Frame transmit buffer in bytes.
* \return the maximum size of the BB Frame transmit buffer in bytes
*/
uint32_t GetMaxSpaceInBytes () const;
/**
* Get the occupancy of the of the BB Frame.
* \return the occupancy of the BB Frame 0 - 1.
*/
double GetOccupancy () const;
/**
* Get spectra efficiency of the frame.
*
* \param carrierBandwidthInHz Carrier bandwidth in hertz.
* \return
*/
double GetSpectralEfficiency (double carrierBandwidthInHz) const;
/**
* Checks occupancy of the frame if given frame would been merged with this frame.
*
* \param mergedFrame Another frame wanted to merge with this frame.
* \return O, if frames cannot be merged, occupancy of the merged frame in otherwise.
*/
double GetOccupancyIfMerged (Ptr<SatBbFrame> mergedFrame) const;
/**
* Merge given frame with this frame.
*
* \param mergedFrame Another frame to be merged with this frame.
* \param mergeTraceCb Logging trace source for BB frame optimization.
* \return true if merging done, false otherwise.
*/
bool MergeWithFrame (Ptr<SatBbFrame> mergedFrame, TracedCallback<Ptr<SatBbFrame>, Ptr<SatBbFrame> > mergeTraceCb);
/**
* Shrink BB frame to the shortest type possible according to
* current load in the frame.
* \param conf Pointer to BB frame configuration
* \return Decrease of the frame duration after shrinking it
*/
Time Shrink (Ptr<SatBbFrameConf> conf);
/**
* Extent BB frame to the longest type.
* \param conf Pointer to BB frame configuration
* \return Increase of the frame duration after extending it
*/
Time Extend (Ptr<SatBbFrameConf> conf);
/**
* Get duration of the frame transmission.
* \return duration of the frame transmission
*/
inline Time GetDuration () const
{
return m_duration;
}
/**
* Get type of the frame.
* \return Type of the frame
*/
inline SatEnums::SatBbFrameType_t GetFrameType () const
{
return m_frameType;
}
/**
* Get type of the frame.
* \return Type of the frame
*/
inline SatEnums::SatModcod_t GetModcod () const
{
return m_modCod;
}
/**
* Get header size of the frame.
* \return Header size in bytes.
*/
inline uint32_t GetFrameHeaderSize () const
{
return m_headerSizeInBytes;
}
/**
* Callback signature for Ptr<SatBbFrame>.
* \param bbFrame The BB frame.
*/
typedef void (*BbFrameCallback)(Ptr<SatBbFrame> bbFrame);
/**
* Callback signature for merging of two instances of SatBbFrame.
* \param to The frame merged to.
* \param to The frame merged from.
*/
typedef void (*BbFrameMergeCallback)
(Ptr<SatBbFrame> to, Ptr<SatBbFrame> from);
private:
SatEnums::SatModcod_t m_modCod;
uint32_t m_freeSpaceInBytes;
uint32_t m_maxSpaceInBytes;
uint32_t m_headerSizeInBytes;
SatBbFramePayload_t m_framePayload;
Time m_duration;
SatEnums::SatBbFrameType_t m_frameType;
};
} // namespace ns3
#endif /* SATELLITE_BBFRAME_H_ */