Loading...
Searching...
No Matches
satellite-fwd-link-scheduler-default.cc
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: Bastien Tauran <bastien.tauran@viveris.fr>
19 */
20
22
23#include "ns3/log.h"
24
25#include <utility>
26#include <vector>
27
28NS_LOG_COMPONENT_DEFINE("SatFwdLinkSchedulerDefault");
29
30namespace ns3
31{
32
33NS_OBJECT_ENSURE_REGISTERED(SatFwdLinkSchedulerDefault);
34
35TypeId
37{
38 static TypeId tid =
39 TypeId("ns3::SatFwdLinkSchedulerDefault")
40 .SetParent<SatFwdLinkScheduler>()
41 .AddConstructor<SatFwdLinkSchedulerDefault>()
42 .AddAttribute(
43 "SchedulingStartThresholdTime",
44 "Threshold time of total transmissions in BB Frame container to trigger a "
45 "scheduling round.",
46 TimeValue(MilliSeconds(5)),
48 MakeTimeChecker())
49 .AddAttribute(
50 "SchedulingStopThresholdTime",
51 "Threshold time of total transmissions in BB Frame container to stop a scheduling "
52 "round.",
53 TimeValue(MilliSeconds(15)),
55 MakeTimeChecker())
56 .AddAttribute("BBFrameContainer",
57 "BB frame container of this scheduler.",
58 PointerValue(),
60 MakePointerChecker<SatBbFrameContainer>());
61 return tid;
62}
63
66{
67 NS_LOG_FUNCTION(this);
68 NS_FATAL_ERROR("Default constructor for SatFwdLinkSchedulerDefault not supported");
69}
70
72 Mac48Address address,
73 double carrierBandwidthInHz)
74 : SatFwdLinkScheduler(conf, address, carrierBandwidthInHz),
76{
77 NS_LOG_FUNCTION(this << conf << address << carrierBandwidthInHz);
78}
79
80void
82{
83 NS_LOG_FUNCTION(this);
84
86
87 std::vector<SatEnums::SatModcod_t> modCods = m_bbFrameConf->GetModCodsUsed();
88
89 m_bbFrameContainer = CreateObject<SatBbFrameContainer>(modCods, m_bbFrameConf);
90}
91
96
97void
99{
100 NS_LOG_FUNCTION(this);
102 m_bbFrameContainer = nullptr;
103}
104
105std::pair<Ptr<SatBbFrame>, const Time>
107{
108 NS_LOG_FUNCTION(this);
109
110 if (m_bbFrameContainer->GetTotalDuration() < m_schedulingStartThresholdTime)
111 {
113 }
114
115 Ptr<SatBbFrame> frame = m_bbFrameContainer->GetNextFrame();
116 Time frameDuration;
117
118 if (frame != nullptr)
119 {
120 m_symbolsSent += ceil(frame->GetDuration().GetSeconds() * m_carrierBandwidthInHz);
121 }
122
123 // create dummy frame
124 if (m_dummyFrameSendingEnabled && frame == nullptr)
125 {
126 frame = Create<SatBbFrame>(m_bbFrameConf->GetDefaultModCod(),
129
130 // create dummy packet
131 Ptr<Packet> dummyPacket = Create<Packet>(1);
132
133 // Add MAC tag
134 SatMacTag mTag;
135 mTag.SetDestAddress(Mac48Address::GetBroadcast());
137 dummyPacket->AddPacketTag(mTag);
138
139 // Add E2E address tag
140 SatAddressE2ETag addressE2ETag;
141 addressE2ETag.SetE2EDestAddress(Mac48Address::GetBroadcast());
142 addressE2ETag.SetE2ESourceAddress(m_macAddress);
143 dummyPacket->AddPacketTag(addressE2ETag);
144
145 // Add dummy packet to dummy frame
146 frame->AddPayload(dummyPacket);
147
148 frameDuration = frame->GetDuration();
149 }
150 // If no bb frame available and dummy frames disabled
151 else if (frame == nullptr)
152 {
153 frameDuration = m_bbFrameConf->GetDummyBbFrameDuration();
154 }
155
156 if (frame != nullptr)
157 {
158 frameDuration = frame->GetDuration();
159 frame->SetSliceId(0);
160 }
161
162 return std::make_pair(frame, frameDuration);
163}
164
165void
167{
168 NS_LOG_FUNCTION(this);
169
170 m_bbFrameContainer->ClearAllFrames();
171}
172
173void
175{
176 NS_LOG_FUNCTION(this);
177
178 m_schedulingSymbolRateTrace(0, m_symbolsSent / Seconds(1).GetSeconds());
179
180 m_symbolsSent = 0;
181}
182
183void
185{
186 NS_LOG_FUNCTION(this);
187
188 // Get scheduling objects from LLC
189 std::vector<Ptr<SatSchedulingObject>> so;
191
192 for (std::vector<Ptr<SatSchedulingObject>>::const_iterator it = so.begin();
193 (it != so.end()) &&
195 it++)
196 {
197 uint32_t currentObBytes = (*it)->GetBufferedBytes();
198 uint32_t currentObMinReqBytes = (*it)->GetMinTxOpportunityInBytes();
199 uint8_t flowId = (*it)->GetFlowId();
200 SatEnums::SatModcod_t modcod =
201 m_bbFrameContainer->GetModcod(flowId, GetSchedulingObjectCno(*it));
202
203 uint32_t frameBytes = m_bbFrameContainer->GetBytesLeftInTailFrame(flowId, modcod);
204
205 while (((m_bbFrameContainer->GetTotalDuration() < m_schedulingStopThresholdTime)) &&
206 (currentObBytes > 0))
207 {
208 if (frameBytes < currentObMinReqBytes)
209 {
210 frameBytes = m_bbFrameContainer->GetMaxFramePayloadInBytes(flowId, modcod) -
211 m_bbFrameConf->GetBbFrameHeaderSizeInBytes();
212
213 // if frame bytes still too small, we must have too long control message, so let's
214 // crash
215 if (frameBytes < currentObMinReqBytes)
216 {
217 NS_FATAL_ERROR("Control package too probably too long!!!");
218 }
219 }
220
221 Ptr<Packet> p = m_txOpportunityCallback(frameBytes,
222 (*it)->GetMacAddress(),
223 flowId,
224 currentObBytes,
225 currentObMinReqBytes);
226
227 if (p)
228 {
229 m_bbFrameContainer->AddData(flowId, modcod, p);
230 frameBytes = m_bbFrameContainer->GetBytesLeftInTailFrame(flowId, modcod);
231 }
232 else if (m_bbFrameContainer->GetMaxFramePayloadInBytes(flowId, modcod) !=
233 m_bbFrameContainer->GetBytesLeftInTailFrame(flowId, modcod))
234 {
235 frameBytes = m_bbFrameContainer->GetMaxFramePayloadInBytes(flowId, modcod);
236 }
237 else
238 {
239 NS_FATAL_ERROR("Packet does not fit in empty BB Frame. Control package too long or "
240 "fragmentation problem in user package!!!");
241 }
242 }
243
245 }
246}
247
248void
249SatFwdLinkSchedulerDefault::GetSchedulingObjects(std::vector<Ptr<SatSchedulingObject>>& output)
250{
251 NS_LOG_FUNCTION(this);
252
253 if (m_bbFrameContainer->GetTotalDuration() < m_schedulingStopThresholdTime)
254 {
255 // Get scheduling objects from LLC
257
258 SortSchedulingObjects(output);
259 }
260}
261
262} // namespace ns3
This class implements a tag that carries the satellite MAC of GW and UT.
void SetE2ESourceAddress(Mac48Address e2eSourceAddress)
Set E2E source MAC address.
void SetE2EDestAddress(Mac48Address e2eDestAddress)
Set E2E destination MAC address.
SatModcod_t
Modulation scheme and coding rate for DVB-S2.
This class implements a tag that carries the satellite MAC specific information, such as source and d...
void SetDestAddress(Mac48Address dest)
Set destination MAC address.
void SetSourceAddress(Mac48Address source)
Set source MAC address.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.