Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Empty buffer for cid XX while expected SDUs were YY runtime error in multiple D2D application usecase #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/stack/mac/layer/LteMacUe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ int LteMacUe::macSduRequest()
allocatedBytes.push_back(schedulingGrant_->getGrantedCwBytes(cw));

LteMacScheduleList* scheduledBytesList = lcgScheduler_->getScheduledBytesList();
bool firstSdu = true;

// Ask for a MAC sdu for each scheduled user on each codeword
LteMacScheduleList::const_iterator it;
Expand All @@ -190,10 +189,9 @@ int LteMacUe::macSduRequest()
LteMacScheduleList::const_iterator bit = scheduledBytesList->find(key);

unsigned int sduSize = bit->second;
if (firstSdu)
if (lcgScheduler_->isFirstSdu(destCid))
{
sduSize -= MAC_HEADER; // do not consider MAC header size
firstSdu = false;
}

// consume bytes on this codeword
Expand Down
51 changes: 26 additions & 25 deletions src/stack/mac/scheduler/LcgScheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,18 @@ ScheduleList& LcgScheduler::schedule(unsigned int availableBytes, Direction gran
*/
statusMap_.clear();

/*
* clean firstSduCid
*/
firstSduCid = 0;

// If true, assure a minimum reserved rate to all connection (LCP first
// phase), if false, provide a best effort service (LCP second phase)
bool priorityService = true;

bool firstSdu = true;
// reserve Bytes for MAC_HEADER
availableBytes -= MAC_HEADER;

LcgMap& lcgMap = mac_->getLcgMap();

Expand Down Expand Up @@ -80,27 +87,24 @@ ScheduleList& LcgScheduler::schedule(unsigned int availableBytes, Direction gran
// TODO get the QoS parameters

// connection must have the same direction of the grant
if (connDesc.getDirection() != grantDir)
if (connDesc.getDirection() != grantDir){
continue;

unsigned int toServe = queueLength;
}
// Check whether the virtual buffer is empty
if (queueLength == 0)
{
EV << "LcgScheduler::schedule scheduled connection is no more active " << endl;
continue; // go to next connection
}
else
{
// we need to consider also the size of RLC and MAC headers
if (connDesc.getRlcType() == UM)
toServe += RLC_HEADER_UM;
else if (connDesc.getRlcType() == AM)
toServe += RLC_HEADER_AM;

if (firstSdu)
toServe += MAC_HEADER;
}


unsigned int toServe = queueLength;
// we need to consider also the size of RLC and MAC headers
if (connDesc.getRlcType() == UM)
toServe += RLC_HEADER_UM;
else if (connDesc.getRlcType() == AM)
toServe += RLC_HEADER_AM;


// get a pointer to the appropriate status element: we need a tracing element
// in order to store information about connections and data transmitted. These
Expand All @@ -111,7 +115,7 @@ ScheduleList& LcgScheduler::schedule(unsigned int availableBytes, Direction gran
{
// the element does not exist, initialize it
elem = &statusMap_[cid];
elem->occupancy_ = vQueue->getQueueLength();
elem->occupancy_ = vQueue->getQueueOccupancy(); // in bytes
elem->sentData_ = 0;
elem->sentSdus_ = 0;
// TODO set bucket from QoS parameters
Expand Down Expand Up @@ -204,11 +208,6 @@ ScheduleList& LcgScheduler::schedule(unsigned int availableBytes, Direction gran

// check if there is space for a SDU
int alloc = toServe;
if (firstSdu)
{
alloc -= MAC_HEADER;
firstSdu = false;
}
if (connDesc.getRlcType() == UM)
alloc -= RLC_HEADER_UM;
else if (connDesc.getRlcType() == AM)
Expand Down Expand Up @@ -247,11 +246,6 @@ ScheduleList& LcgScheduler::schedule(unsigned int availableBytes, Direction gran
elem->sentData_ += availableBytes;

int alloc = availableBytes;
if (firstSdu)
{
alloc -= MAC_HEADER;
firstSdu = false;
}
if (connDesc.getRlcType() == UM)
alloc -= RLC_HEADER_UM;
else if (connDesc.getRlcType() == AM)
Expand Down Expand Up @@ -323,6 +317,13 @@ ScheduleList& LcgScheduler::schedule(unsigned int availableBytes, Direction gran
// signal service for current connection
unsigned int* servicedSdu = nullptr;

if (elem->sentData_ > 0 && firstSdu){
// if current element was scheduled and it is the first add MAC_HEADER
elem->sentData_ += MAC_HEADER;
firstSdu = false;
firstSduCid = cid; // remeber first cid for first sdu
}

if (scheduleList_.find(cid) == scheduleList_.end())
{
// the element does not exist, initialize it
Expand Down
6 changes: 6 additions & 0 deletions src/stack/mac/scheduler/LcgScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class SIMULTE_API LcgScheduler
// scheduled bytes list
ScheduleList scheduledBytesList_;

MacCid firstSduCid;

/// Cid List
typedef std::list<MacCid> CidList;

Expand Down Expand Up @@ -111,6 +113,10 @@ class SIMULTE_API LcgScheduler
*/
virtual ScheduleList& getScheduledBytesList();

inline virtual bool isFirstSdu(const MacCid& cid){
return firstSduCid == cid;
}

// *****************************************************************************************

// /// performs request of grant to the eNbScheduler
Expand Down
4 changes: 4 additions & 0 deletions src/stack/mac/scheduler/LteSchedulerUeUl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,7 @@ LteMacScheduleList* LteSchedulerUeUl::getScheduledBytesList()
{
return &scheduledBytesList_;
}

bool LteSchedulerUeUl::isFirstSdu(const MacCid& cid){
return lcgScheduler_->isFirstSdu(cid);
}
2 changes: 2 additions & 0 deletions src/stack/mac/scheduler/LteSchedulerUeUl.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class SIMULTE_API LteSchedulerUeUl
*/
LteMacScheduleList* getScheduledBytesList();

bool isFirstSdu(const MacCid& cid);

/*
* constructor
*/
Expand Down