@@ -278,56 +278,57 @@ void LteMacEnb::macSduRequest()
278278 EV << " ------ END LteMacEnb::macSduRequest ------\n " ;
279279}
280280
281+ LteMacBuffer* LteMacEnb::createBsrBuffer (MacCid cid)
282+ {
283+ // Create new BSR buffer
284+ LteMacBuffer *bsrqueue = new LteMacBuffer ();
285+ bsrbuf_[cid] = bsrqueue;
286+
287+ EV << " LteBsrBuffers : Added new BSR buffer for node: "
288+ << cid.getNodeId () << " for LCID: " << cid.getLcid () << " \n " ;
289+
290+ return bsrqueue;
291+ }
292+
281293void LteMacEnb::bufferizeBsr (MacBsr *bsr, MacCid cid)
282294{
283295 LteMacBufferMap::iterator it = bsrbuf_.find (cid);
296+ LteMacBuffer *bsrqueue = nullptr ;
297+
298+ // If connection not found, create it
284299 if (it == bsrbuf_.end ()) {
285- if (bsr->getSize () > 0 ) {
286- // Queue not found for this CID: create
287- LteMacBuffer *bsrqueue = new LteMacBuffer ();
300+ bsrqueue = createBsrBuffer (cid);
301+ }
302+ else {
303+ bsrqueue = it->second ;
304+ }
288305
289- PacketInfo vpkt (bsr->getSize (), bsr->getTimestamp ());
290- bsrqueue->pushBack (vpkt);
291- bsrbuf_[cid] = bsrqueue;
306+ // Insert into queue
307+ if (bsr->getSize () > 0 ) {
308+ // Update buffer with new BSR data
309+ PacketInfo queuedBsr;
310+ if (!bsrqueue->isEmpty ())
311+ queuedBsr = bsrqueue->popFront ();
292312
293- EV << " LteBsrBuffers : Added new BSR buffer for node: "
294- << cid. getNodeId () << " for LCID: " << cid. getLcid ()
295- << " Current BSR size: " << bsr-> getSize () << " \n " ;
313+ queuedBsr. first = bsr-> getSize ();
314+ queuedBsr. second = bsr-> getTimestamp ();
315+ bsrqueue-> pushBack (queuedBsr) ;
296316
297- // signal backlog to Uplink scheduler
298- enbSchedulerUl_->backlog (cid);
299- }
300- // do not store if BSR size = 0
317+ EV << " LteBsrBuffers : BSR buffer for node: " << cid.getNodeId ()
318+ << " for LCID: " << cid.getLcid ()
319+ << " Current BSR size: " << bsr->getSize () << " \n " ;
320+
321+ // Signal backlog to Uplink scheduler
322+ enbSchedulerUl_->backlog (cid);
301323 }
302324 else {
303- // Found
304- LteMacBuffer *bsrqueue = it->second ;
305- if (bsr->getSize () > 0 ) {
306- // update buffer
307- PacketInfo queuedBsr;
308- if (!bsrqueue->isEmpty ())
309- queuedBsr = bsrqueue->popFront ();
310-
311- queuedBsr.first = bsr->getSize ();
312- queuedBsr.second = bsr->getTimestamp ();
313- bsrqueue->pushBack (queuedBsr);
314-
315- EV << " LteBsrBuffers : Using old buffer for node: " << cid.getNodeId ()
316- << " for LCID: " << cid.getLcid ()
317- << " Current BSR size: " << bsr->getSize () << " \n " ;
318-
319- // signal backlog to Uplink scheduler
320- enbSchedulerUl_->backlog (cid);
321- }
322- else {
323- // the UE has no backlog, remove BSR
324- if (!bsrqueue->isEmpty ())
325- bsrqueue->popFront ();
325+ // The UE has no backlog, remove BSR
326+ if (!bsrqueue->isEmpty ())
327+ bsrqueue->popFront ();
326328
327- EV << " LteBsrBuffers : Using old buffer for node: " << cid.getNodeId ()
328- << " for LCID: " << cid.getLcid ()
329- << " - now empty" << " \n " ;
330- }
329+ EV << " LteBsrBuffers : BSR buffer for node: " << cid.getNodeId ()
330+ << " for LCID: " << cid.getLcid ()
331+ << " - now empty" << " \n " ;
331332 }
332333}
333334
0 commit comments