21 #include "ns3/simulator.h"
83 uint16_t nrSymbolsRequired = 0;
92 "SS: Error while scheduling packets: The selected connection has no packets");
97 while (connection && connection->HasPackets (packetType))
99 NS_LOG_INFO (
"FRAG_DEBUG: SS Scheduler" << std::endl);
101 uint32_t availableByte =
m_ss->GetPhy ()->
102 GetNrBytes (availableSymbols, modulationType);
104 uint32_t requiredByte = connection->GetQueue ()->GetFirstPacketRequiredByte (packetType);
106 NS_LOG_INFO (
"\t availableByte = " << availableByte <<
107 ", requiredByte = " << requiredByte);
109 if (availableByte >= requiredByte)
113 "\n\t Send packet without other fragmentation" << std::endl);
115 packet = connection->Dequeue (packetType);
116 burst->AddPacket (packet);
118 nrSymbolsRequired =
m_ss->GetPhy ()->
119 GetNrSymbols (packet->
GetSize (), modulationType);
120 availableSymbols -= nrSymbolsRequired;
127 "\n\t Check if the fragmentation is possible");
129 uint32_t headerSize = connection->GetQueue ()->GetFirstPacketHdrSize (packetType);
130 if (!connection->GetQueue ()->CheckForFragmentation (packetType))
135 NS_LOG_INFO (
"\t availableByte = " << availableByte <<
136 " headerSize = " << headerSize);
138 if (availableByte > headerSize)
141 packet = connection->Dequeue (packetType, availableByte);
142 burst->AddPacket (packet);
144 nrSymbolsRequired =
m_ss->GetPhy ()->
145 GetNrSymbols (packet->
GetSize (), modulationType);
146 availableSymbols -= nrSymbolsRequired;
150 NS_LOG_INFO (
"\t Fragmentation IS NOT possible" << std::endl);
157 "\n\t Fragmentation IS NOT possible, " << std::endl);
169 std::vector<ServiceFlow*>::const_iterator iter;
170 std::vector<ServiceFlow*> serviceFlows;
172 NS_LOG_INFO (
"SS Scheduler: Selecting connection...");
173 if (
m_ss->GetInitialRangingConnection ()->HasPackets ())
175 NS_LOG_INFO (
"Return GetInitialRangingConnection");
176 return m_ss->GetInitialRangingConnection ();
178 if (
m_ss->GetBasicConnection ()->HasPackets ())
181 return m_ss->GetBasicConnection ();
183 if (
m_ss->GetPrimaryConnection ()->HasPackets ())
186 return m_ss->GetPrimaryConnection ();
190 for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
194 if ((*iter)->HasPackets () && (currentTime
195 +
m_ss->GetPhy ()->GetFrameDuration () > MilliSeconds (
196 (*iter)->GetUnsolicitedGrantInterval ())))
198 NS_LOG_INFO (
"Return UGS SF: CID = " << (*iter)->GetCid () <<
"SFID = "
199 << (*iter)->GetSfid ());
200 return (*iter)->GetConnection ();
208 for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
211 && (currentTime +
m_ss->GetPhy ()->GetFrameDuration ()
213 (*iter)->GetUnsolicitedPollingInterval ())))
215 NS_LOG_INFO (
"Return RTPS SF: CID = " << (*iter)->GetCid () <<
"SFID = "
216 << (*iter)->GetSfid ());
217 return (*iter)->GetConnection ();
222 for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
226 NS_LOG_INFO (
"Return NRTPS SF: CID = " << (*iter)->GetCid () <<
"SFID = "
227 << (*iter)->GetSfid ());
228 return (*iter)->GetConnection ();
233 for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
237 NS_LOG_INFO (
"Return BE SF: CID = " << (*iter)->GetCid () <<
"SFID = "
238 << (*iter)->GetSfid ());
239 return (*iter)->GetConnection ();
243 if (
m_ss->GetBroadcastConnection ()->HasPackets ())
245 return m_ss->GetBroadcastConnection ();
void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
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)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
uint32_t GetSize(void) const
NS_LOG_COMPONENT_DEFINE("SSScheduler")
bool GetPollMe(void) const
Ptr< SubscriberStationNetDevice > m_ss
SSScheduler(Ptr< SubscriberStationNetDevice > ss)
static TypeId GetTypeId(void)
static Time Now(void)
Return the "current simulation time".
#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)