21 #include "ns3/simulator.h"
82 uint16_t nrSymbolsRequired = 0;
91 "SS: Error while scheduling packets: The selected connection has no packets");
96 while (connection && connection->HasPackets (packetType))
98 NS_LOG_INFO (
"FRAG_DEBUG: SS Scheduler" << std::endl);
100 uint32_t availableByte =
m_ss->GetPhy ()->
101 GetNrBytes (availableSymbols, modulationType);
103 uint32_t requiredByte = connection->GetQueue ()->GetFirstPacketRequiredByte (packetType);
105 NS_LOG_INFO (
"\t availableByte = " << availableByte <<
106 ", requiredByte = " << requiredByte);
108 if (availableByte >= requiredByte)
112 "\n\t Send packet without other fragmentation" << std::endl);
114 packet = connection->Dequeue (packetType);
115 burst->AddPacket (packet);
117 nrSymbolsRequired =
m_ss->GetPhy ()->
118 GetNrSymbols (packet->
GetSize (), modulationType);
119 availableSymbols -= nrSymbolsRequired;
126 "\n\t Check if the fragmentation is possible");
128 uint32_t headerSize = connection->GetQueue ()->GetFirstPacketHdrSize (packetType);
129 if (!connection->GetQueue ()->CheckForFragmentation (packetType))
134 NS_LOG_INFO (
"\t availableByte = " << availableByte <<
135 " headerSize = " << headerSize);
137 if (availableByte > headerSize)
140 packet = connection->Dequeue (packetType, availableByte);
141 burst->AddPacket (packet);
143 nrSymbolsRequired =
m_ss->GetPhy ()->
144 GetNrSymbols (packet->
GetSize (), modulationType);
145 availableSymbols -= nrSymbolsRequired;
149 NS_LOG_INFO (
"\t Fragmentation IS NOT possible" << std::endl);
156 "\n\t Fragmentation IS NOT possible, " << std::endl);
168 std::vector<ServiceFlow*>::const_iterator iter;
169 std::vector<ServiceFlow*> serviceFlows;
171 NS_LOG_INFO (
"SS Scheduler: Selecting connection...");
172 if (
m_ss->GetInitialRangingConnection ()->HasPackets ())
174 NS_LOG_INFO (
"Return GetInitialRangingConnection");
175 return m_ss->GetInitialRangingConnection ();
177 if (
m_ss->GetBasicConnection ()->HasPackets ())
180 return m_ss->GetBasicConnection ();
182 if (
m_ss->GetPrimaryConnection ()->HasPackets ())
185 return m_ss->GetPrimaryConnection ();
189 for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
193 if ((*iter)->HasPackets () && (currentTime
194 +
m_ss->GetPhy ()->GetFrameDuration () > MilliSeconds (
195 (*iter)->GetUnsolicitedGrantInterval ())))
197 NS_LOG_INFO (
"Return UGS SF: CID = " << (*iter)->GetCid () <<
"SFID = "
198 << (*iter)->GetSfid ());
199 return (*iter)->GetConnection ();
207 for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
210 && (currentTime +
m_ss->GetPhy ()->GetFrameDuration ()
212 (*iter)->GetUnsolicitedPollingInterval ())))
214 NS_LOG_INFO (
"Return RTPS SF: CID = " << (*iter)->GetCid () <<
"SFID = "
215 << (*iter)->GetSfid ());
216 return (*iter)->GetConnection ();
221 for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
225 NS_LOG_INFO (
"Return NRTPS SF: CID = " << (*iter)->GetCid () <<
"SFID = "
226 << (*iter)->GetSfid ());
227 return (*iter)->GetConnection ();
232 for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
236 NS_LOG_INFO (
"Return BE SF: CID = " << (*iter)->GetCid () <<
"SFID = "
237 << (*iter)->GetSfid ());
238 return (*iter)->GetConnection ();
242 if (
m_ss->GetBroadcastConnection ()->HasPackets ())
244 return m_ss->GetBroadcastConnection ();
keep track of time values and allow control of global simulation resolution
smart pointer class similar to boost::intrusive_ptr
Ptr< PacketBurst > Schedule(uint16_t availableSymbols, WimaxPhy::ModulationType modulationType, MacHeaderType::HeaderType packetType, Ptr< WimaxConnection > &connection)
void SetPollMe(bool pollMe)
uint32_t GetSize(void) const
NS_LOG_COMPONENT_DEFINE("SSScheduler")
bool GetPollMe(void) const
Ptr< SubscriberStationNetDevice > m_ss
SSScheduler(Ptr< SubscriberStationNetDevice > ss)
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
static TypeId GetTypeId(void)
#define NS_ASSERT_MSG(condition, message)
a base class which provides memory management and object aggregation
Ptr< WimaxConnection > SelectConnection(void)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)