Skip to content

Commit 65b7eec

Browse files
MohamedSeliemavarga
authored andcommitted
MAC: guard against unsigned underflow in macSduRequest when grant < MAC_HEADER
LteMacEnb::macSduRequest() computed the SDU size as allocatedBytes - MAC_HEADER in unsigned arithmetic. When the scheduler allocates a grant smaller than MAC_HEADER (2 bytes), this underflows to a huge value, so the MAC would request an absurdly large SDU from RLC, tripping a misleading "configured queueSize too low" error. Reproducible with 3 UEs x 4-5 DRBs under QOS_PF contention. Workaround: Clamp the requested size to 0 instead. Also added TODO comments.
1 parent b6116b5 commit 65b7eec

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/simu5g/stack/mac/LteMacEnb.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,15 @@ void LteMacEnb::macSduRequest()
223223

224224
// send the request message to the upper layer
225225
auto pkt = new Packet("LteMacSduRequest");
226-
auto macSduRequest = makeShared<LteMacSduRequest>();
226+
auto macSduRequest = makeShared<LteMacSduRequest>(); //TODO this should be a tag on a Message, not a packet
227227
macSduRequest->setUeId(destId);
228228
macSduRequest->setChunkLength(b(1)); // TODO: should be 0
229229
macSduRequest->setUeId(destId);
230230
macSduRequest->setLcid(destCid.getLcid());
231-
macSduRequest->setSduSize(allocatedBytes - MAC_HEADER); // do not consider MAC header size
231+
// discount MAC header size from grant; clamp to zero if grant is smaller than MAC header
232+
//TODO maybe simply skip sending if grant<=MAC_HEADER (i.e. no room for SDU)
233+
unsigned int sduSize = (allocatedBytes > MAC_HEADER) ? (allocatedBytes - MAC_HEADER) : 0;
234+
macSduRequest->setSduSize(sduSize);
232235
pkt->insertAtFront(macSduRequest);
233236
if (queueSize_ != 0 && queueSize_ < macSduRequest->getSduSize()) {
234237
throw cRuntimeError("LteMacEnb::macSduRequest: configured queueSize too low - requested SDU will not fit in queue!"

0 commit comments

Comments
 (0)