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
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)
Destructor implementation.
Simulation virtual time values and 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)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
bool GetPollMe(void) const
Ptr< SubscriberStationNetDevice > m_ss
SSScheduler(Ptr< SubscriberStationNetDevice > ss)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static TypeId GetTypeId(void)
static Time Now(void)
Return the current simulation virtual time.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
A base class which provides memory management and object aggregation.
Ptr< WimaxConnection > SelectConnection(void)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
HeaderType
this class implements the mac header type field.