26#include "ns3/packet-burst.h" 
   27#include "ns3/simulator.h" 
   41                            .SetGroupName(
"Wimax")
 
 
   62    std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst>>>* downlinkBursts = 
m_downlinkBursts;
 
   63    std::pair<OfdmDlMapIe*, Ptr<PacketBurst>> pair;
 
   64    while (!downlinkBursts->empty())
 
   66        pair = downlinkBursts->front();
 
   67        pair.second = 
nullptr;
 
 
   76std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst>>>*
 
   89    dlMapIe->SetCid(connection->GetCid());
 
   90    dlMapIe->SetDiuc(diuc);
 
   92    NS_LOG_INFO(
"BS scheduler, burst size: " << burst->GetSize() << 
" bytes" 
   93                                             << 
", pkts: " << burst->GetNPackets()
 
   94                                             << 
", connection: " << connection->GetTypeStr()
 
   95                                             << 
", CID: " << connection->GetCid());
 
   98        NS_LOG_INFO(
", SFID: " << connection->GetServiceFlow()->GetSfid() << 
", service: " 
   99                               << connection->GetServiceFlow()->GetSchedulingTypeStr());
 
 
  144            "BS scheduler, number of bursts: " 
  145            << 
m_downlinkBursts->size() << 
", symbols left: " << availableSymbols << std::endl
 
  146            << 
"BS scheduler, queues:" 
  147            << 
" IR " << 
GetBs()->GetInitialRangingConnection()->GetQueue()->
GetSize()
 
  148            << 
" broadcast " << 
GetBs()->GetBroadcastConnection()->GetQueue()->
GetSize()
 
 
  176        nrSymbolsRequired = 
GetBs()->GetPhy()->GetNrSymbols(FirstPacketSize, modulationType);
 
  177        if (availableSymbols < nrSymbolsRequired &&
 
  181                GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType);
 
  183            availableSymbols = 0;
 
  187            packet = connection->Dequeue();
 
  188            availableSymbols -= nrSymbolsRequired;
 
  190        burst->AddPacket(packet);
 
  191        if (availableSymbols <= 0)
 
 
  216    while (
GetBs()->GetBroadcastConnection()->HasPackets() && availableSymbols > 0)
 
  218        connection = 
GetBs()->GetBroadcastConnection();
 
  220        packet = connection->GetQueue()->Peek(hdr);
 
  221        nrSymbolsRequired = 
GetBs()->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType);
 
  223        if (availableSymbols < nrSymbolsRequired &&
 
  228        else if (availableSymbols < nrSymbolsRequired &&
 
  232                GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType);
 
  237            packet = connection->Dequeue();
 
  241                      "Base station: Error while scheduling broadcast connection: header CID != " 
  243        burst->AddPacket(packet);
 
  244        availableSymbols -= nrSymbolsRequired;
 
  246    if (burst->GetNPackets() != 0)
 
 
  263    while (
GetBs()->GetInitialRangingConnection()->HasPackets() && availableSymbols > 0)
 
  265        connection = 
GetBs()->GetInitialRangingConnection();
 
  267        packet = connection->GetQueue()->Peek(hdr);
 
  268        nrSymbolsRequired = 
GetBs()->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType);
 
  271        if (availableSymbols < nrSymbolsRequired &&
 
  276        else if (availableSymbols < nrSymbolsRequired &&
 
  280                GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType);
 
  285            packet = connection->Dequeue();
 
  289                      "Base station: Error while scheduling initial ranging connection: header CID " 
  290                      "!= connection CID");
 
  291        burst->AddPacket(packet);
 
  292        availableSymbols -= nrSymbolsRequired;
 
  294    if (burst->GetNPackets())
 
 
  311    std::vector<Ptr<WimaxConnection>> connections;
 
  313    connections = 
GetBs()->GetConnectionManager()->GetConnections(
Cid::BASIC);
 
  314    for (
auto iter = connections.begin(); iter != connections.end(); ++iter)
 
  316        while ((*iter)->HasPackets() && availableSymbols > 0)
 
  321                GetBs()->GetSSManager()->GetSSRecord(connection->GetCid())->GetModulationType();
 
  322            diuc = 
GetBs()->GetBurstProfileManager()->GetBurstProfile(
 
  326            packet = connection->GetQueue()->Peek(hdr);
 
  327            nrSymbolsRequired = 
GetBs()->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType);
 
  330            if (availableSymbols < nrSymbolsRequired &&
 
  335            else if (availableSymbols < nrSymbolsRequired &&
 
  339                    GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType);
 
  344                packet = connection->Dequeue();
 
  348                          "Base station: Error while scheduling basic connection: header CID != " 
  350            burst->AddPacket(packet);
 
  351            availableSymbols -= nrSymbolsRequired;
 
  353        if (burst->GetNPackets() != 0)
 
 
  372    std::vector<Ptr<WimaxConnection>> connections;
 
  375    for (
auto iter = connections.begin(); iter != connections.end(); ++iter)
 
  377        while ((*iter)->HasPackets() && availableSymbols > 0)
 
  382                GetBs()->GetSSManager()->GetSSRecord(connection->GetCid())->GetModulationType();
 
  383            diuc = 
GetBs()->GetBurstProfileManager()->GetBurstProfile(
 
  387            packet = connection->GetQueue()->Peek(hdr);
 
  388            nrSymbolsRequired = 
GetBs()->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType);
 
  391            if (availableSymbols < nrSymbolsRequired &&
 
  396            else if (availableSymbols < nrSymbolsRequired &&
 
  400                    GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType);
 
  405                packet = connection->Dequeue();
 
  409                          "Base station: Error while scheduling primary connection: header CID != " 
  411            burst->AddPacket(packet);
 
  412            availableSymbols -= nrSymbolsRequired;
 
  414        if (burst->GetNPackets() != 0)
 
 
  435    std::vector<ServiceFlow*> serviceFlows;
 
  438    for (
auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter)
 
  440        serviceFlowRecord = (*iter)->GetRecord();
 
  443        if ((*iter)->HasPackets() &&
 
  445             GetBs()->GetPhy()->GetFrameDuration()) > 
MilliSeconds((*iter)->GetMaximumLatency()))
 
  447            connection = (*iter)->GetConnection();
 
  450                modulationType = connection->GetServiceFlow()->GetModulation();
 
  455                    GetBs()->GetSSManager()->GetSSRecord(connection->GetCid())->GetModulationType();
 
  457            diuc = 
GetBs()->GetBurstProfileManager()->GetBurstProfile(
 
  461            nrSymbolsRequired = connection->GetServiceFlow()->GetRecord()->GetGrantSize();
 
  464            if (availableSymbols > nrSymbolsRequired)
 
  466                availableSymbols -= nrSymbolsRequired;
 
  468                    CreateUgsBurst(connection->GetServiceFlow(), modulationType, nrSymbolsRequired);
 
  469                if (burst->GetNPackets() != 0)
 
 
  491    std::vector<Ptr<WimaxConnection>> connections;
 
  493    std::vector<ServiceFlow*> serviceFlows;
 
  501    int nbConnection = 0;
 
  504                << 
"\t\tavailableSymbols = " << availableSymbols);
 
  508    for (
auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2)
 
  511        serviceFlowRecord = (*iter2)->GetRecord();
 
  513        if ((*iter2)->HasPackets())
 
  517            rtPSConnection[nbConnection] = (*iter2)->GetConnection();
 
  520                modulationType_[nbConnection] =
 
  521                    rtPSConnection[nbConnection]->GetServiceFlow()->GetModulation();
 
  525                modulationType_[nbConnection] =
 
  528                        ->GetSSRecord(rtPSConnection[nbConnection]->GetCid())
 
  529                        ->GetModulationType();
 
  531            diuc_[nbConnection] = 
GetBs()->GetBurstProfileManager()->GetBurstProfile(
 
  532                modulationType_[nbConnection],
 
  535            dataToSend = rtPSConnection[nbConnection]->GetQueue()->GetQueueLengthWithMACOverhead();
 
  536            NS_LOG_INFO(
"\t\tRTPS DL Scheduler for CID = " << rtPSConnection[nbConnection]->GetCid()
 
  537                                                           << 
"\n\t\t\t dataToSend = " 
  540            symbolsRequired[nbConnection] =
 
  541                GetBs()->GetPhy()->GetNrSymbols(dataToSend, modulationType_[nbConnection]);
 
  543            totSymbolsRequired += symbolsRequired[nbConnection];
 
  548    NS_LOG_INFO(
"\t\ttotSymbolsRequired = " << totSymbolsRequired);
 
  551    while (totSymbolsRequired > availableSymbols)
 
  553        NS_LOG_INFO(
"\tDL Channel Saturation: totSymbolsRequired > availableSymbols_rtPS");
 
  554        double delta = 
double(availableSymbols) / 
double(totSymbolsRequired);
 
  556        totSymbolsRequired = 0;
 
  557        for (
int i = 0; i < nbConnection; i++)
 
  559            NS_LOG_INFO(
"\t\tprevious symbolsRequired[" << i << 
"] = " << symbolsRequired[i]);
 
  560            symbolsRequired[i] = (
uint32_t)std::floor(symbolsRequired[i] * delta);
 
  561            totSymbolsRequired += symbolsRequired[i];
 
  562            NS_LOG_INFO(
"\t\tnew symbolsRequired[" << i << 
"] = " << symbolsRequired[i]);
 
  564        NS_LOG_INFO(
"\t\ttotSymbolsRequired = " << totSymbolsRequired);
 
  568    for (
int i = 0; i < nbConnection; i++)
 
  570        packet = rtPSConnection[i]->GetQueue()->Peek(hdr);
 
  571        uint32_t symbolsForPacketTransmission = 0;
 
  573        NS_LOG_INFO(
"\t\tCID = " << rtPSConnection[i]->GetCid()
 
  574                                 << 
" assignedSymbols = " << symbolsRequired[i]);
 
  576        while (symbolsRequired[i] > 0)
 
  578            symbolsForPacketTransmission = 
GetBs()->GetPhy()->GetNrSymbols(
 
  579                rtPSConnection[i]->GetQueue()->GetFirstPacketRequiredByte(
 
  584            if (symbolsForPacketTransmission > symbolsRequired[i] &&
 
  589            else if (symbolsForPacketTransmission > symbolsRequired[i] &&
 
  595                    GetBs()->GetPhy()->GetNrBytes(symbolsRequired[i], modulationType_[i]);
 
  598                symbolsRequired[i] = 0;
 
  602                packet = rtPSConnection[i]->Dequeue();
 
  603                symbolsRequired[i] -= symbolsForPacketTransmission;
 
  607                          "Base station: Error while scheduling RTPs connection: header CID != " 
  609            burst->AddPacket(packet);
 
  612        if (burst->GetNPackets() != 0)
 
  618    availableSymbols -= totSymbolsRequired;
 
 
  632    std::vector<ServiceFlow*> serviceFlows;
 
  635    for (
auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter)
 
  637        connection = (*iter)->GetConnection();
 
  639        while ((*iter)->HasPackets() && availableSymbols > 0)
 
  643                modulationType = connection->GetServiceFlow()->GetModulation();
 
  648                    GetBs()->GetSSManager()->GetSSRecord(connection->GetCid())->GetModulationType();
 
  651            diuc = 
GetBs()->GetBurstProfileManager()->GetBurstProfile(
 
  655            packet = connection->GetQueue()->Peek(hdr);
 
  656            nrSymbolsRequired = 
GetBs()->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType);
 
  658            if (availableSymbols < nrSymbolsRequired)
 
  663            packet = connection->Dequeue();
 
  665                          "Base station: Error while scheduling NRTPs connection: header CID != " 
  667            burst->AddPacket(packet);
 
  668            availableSymbols -= nrSymbolsRequired;
 
  670        if (burst->GetNPackets() != 0)
 
 
  689    std::vector<ServiceFlow*> serviceFlows;
 
  692    for (
auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter)
 
  694        connection = (*iter)->GetConnection();
 
  696        while ((*iter)->HasPackets() && availableSymbols > 0)
 
  700                modulationType = connection->GetServiceFlow()->GetModulation();
 
  705                    GetBs()->GetSSManager()->GetSSRecord(connection->GetCid())->GetModulationType();
 
  707            diuc = 
GetBs()->GetBurstProfileManager()->GetBurstProfile(
 
  711            packet = connection->GetQueue()->Peek(hdr);
 
  712            nrSymbolsRequired = 
GetBs()->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType);
 
  714            if (availableSymbols < nrSymbolsRequired)
 
  719            packet = connection->Dequeue();
 
  721                hdr.
GetCid() == connection->GetCid(),
 
  722                "Base station: Error while scheduling BE connection: header CID != connection CID");
 
  723            burst->AddPacket(packet);
 
  724            availableSymbols -= nrSymbolsRequired;
 
  726        if (burst->GetNPackets() != 0)
 
 
virtual Ptr< BaseStationNetDevice > GetBs()
Get the base station.
virtual void SetBs(Ptr< BaseStationNetDevice > bs)
Set the base station.
bool CheckForFragmentation(Ptr< WimaxConnection > connection, int availableSymbols, WimaxPhy::ModulationType modulationType)
Check if the packet fragmentation is possible for transport connection.
This class implements a simple downlink scheduler for rtPS flows.
static TypeId GetTypeId()
Get the type ID.
void Schedule() override
Schedule function.
void BSSchedulerPrimaryConnection(uint32_t &availableSymbols)
schedules the primary connection
std::list< std::pair< OfdmDlMapIe *, Ptr< PacketBurst > > > * GetDownlinkBursts() const override
This function returns all the downlink bursts scheduled for the next downlink sub-frame.
void BSSchedulerUGSConnection(uint32_t &availableSymbols)
schedules the UGS connection
void BSSchedulerBEConnection(uint32_t &availableSymbols)
schedules the BE connection
void BSSchedulerBasicConnection(uint32_t &availableSymbols)
schedules the basic connections
void AddDownlinkBurst(Ptr< const WimaxConnection > connection, uint8_t diuc, WimaxPhy::ModulationType modulationType, Ptr< PacketBurst > burst) override
This function adds a downlink burst to the list of downlink bursts scheduled for the next downlink su...
~BSSchedulerRtps() override
void BSSchedulerInitialRangingConnection(uint32_t &availableSymbols)
schedules the IR connections
void BSSchedulerRTPSConnection(uint32_t &availableSymbols)
Downlink Scheduler for rtPS connections.
void BSSchedulerBroadcastConnection(uint32_t &availableSymbols)
schedules the broadcast connections
void BSSchedulerNRTPSConnection(uint32_t &availableSymbols)
schedules the NRTPS connections
Ptr< PacketBurst > CreateUgsBurst(ServiceFlow *serviceFlow, WimaxPhy::ModulationType modulationType, uint32_t availableSymbols) override
Creates a downlink UGS burst.
bool SelectConnection(Ptr< WimaxConnection > &connection) override
Selects a connection from the list of connections having packets to be sent .
std::list< std::pair< OfdmDlMapIe *, Ptr< PacketBurst > > > * m_downlinkBursts
down link bursts
uint16_t GetIdentifier() const
This class implements the OFDM DL-MAP information element as described by "IEEE Standard forLocal and...
this class implement a burst as a list of packets
Smart pointer class similar to boost::intrusive_ptr.
This class implements service flows as described by the IEEE-802.16 standard.
bool HasPackets() const
Check if packets are present.
Ptr< WimaxConnection > GetConnection() const
Can return a null connection is this service flow has not been associated yet to a connection.
this class implements a structure to manage some parameters and statistics related to a service flow
void SetDlTimeStamp(Time dlTimeStamp)
Set the DlTimeStamp.
Time GetDlTimeStamp() const
static Time Now()
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
ModulationType
ModulationType enumeration.
@ MODULATION_TYPE_BPSK_12
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t GetSize(Ptr< const Packet > packet, const WifiMacHeader *hdr, bool isAmpdu)
Return the total size of the packet after WifiMacHeader and FCS trailer have been added.