Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rlc um reassemble #21

Merged
merged 3 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
add nextSduSno field to struc Buffered, add clearBufferedSdu method
  • Loading branch information
stefanSchuhbaeck committed Jan 21, 2022
commit c4c0f8df9985226a297ac88a167ad47db3c05920
131 changes: 30 additions & 101 deletions src/stack/rlc/um/entity/UmRxEntity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -422,32 +422,21 @@ void UmRxEntity::reassemble(unsigned int index)
toPdcp(pktSdu);
pktSdu = nullptr;

// for burst
ttiBits_ += sduLengthPktLeng;

if (buffered_.pkt != nullptr)
{
delete buffered_.pkt;
buffered_.pkt = nullptr;
buffered_.size = 0;
}
clearBufferedSdu();

break;
}
case 1: { // FI=01
EV << NOW << " UmRxEntity::reassemble The PDU includes the first part [" << sduLengthPktLeng <<" B] of a SDU [sno=" << sduSno << "]" << endl;

if (buffered_.pkt != nullptr)
{
delete buffered_.pkt;
buffered_.pkt = nullptr;
buffered_.size = 0;
}
clearBufferedSdu();

// buffer the SDU and wait for the missing portion
buffered_.pkt = pktSdu;
pktSdu = nullptr;
buffered_.size = sduLengthPktLeng;
buffered_.currentPduSno = pduSno;

// for burst
ttiBits_ += sduLengthPktLeng;
EV << NOW << " UmRxEntity::reassemble Wait for the missing part..." << endl;
Expand All @@ -461,15 +450,7 @@ void UmRxEntity::reassemble(unsigned int index)
// check SDU SN
if (buffered_.pkt == nullptr || (rlcSdu->getSnoMainPacket() != buffered_.pkt->peekAtFront<LteRlcSdu>()->getSnoMainPacket()) || ignoreFragment)
{
if (buffered_.pkt != nullptr)
{
// for burst
ttiBits_ -= buffered_.size; // remove the discarded SDU size from the tput
delete buffered_.pkt;
buffered_.pkt = nullptr;
buffered_.size = 0;
}

clearBufferedSdu();
EV << NOW << " UmRxEntity::reassemble The SDU cannot be reassembled, first part missing" << endl;

//delete rlcSdu;
Expand All @@ -483,15 +464,7 @@ void UmRxEntity::reassemble(unsigned int index)
unsigned int reassembledLength = buffered_.size + sduLengthPktLeng;
if (reassembledLength < sduWholeLength)
{
if (buffered_.pkt != nullptr)
{
// for burst
ttiBits_ -= buffered_.size; // remove the discarded SDU size from the tput
delete buffered_.pkt;
buffered_.pkt = nullptr;
buffered_.size = 0;
}

clearBufferedSdu();
EV << NOW << " UmRxEntity::reassemble The SDU cannot be reassembled, mid part missing" << endl;

//delete rlcSdu;
Expand All @@ -509,12 +482,7 @@ void UmRxEntity::reassemble(unsigned int index)
toPdcp(pktSdu);
pktSdu = nullptr;

if (buffered_.pkt != nullptr)
{
delete buffered_.pkt;
buffered_.pkt = nullptr;
buffered_.size = 0;
}
clearBufferedSdu();

break;
}
Expand All @@ -528,15 +496,7 @@ void UmRxEntity::reassemble(unsigned int index)
snoMainPacketBuffered = buffered_.pkt->peekAtFront<LteRlcSdu>()->getSnoMainPacket();
if (buffered_.pkt == nullptr || (rlcSdu->getSnoMainPacket() != snoMainPacketBuffered))
{
if (buffered_.pkt != nullptr)
{
// for burst
ttiBits_ -= buffered_.size; // remove the discarded SDU size from the tput
delete buffered_.pkt;
buffered_.pkt = nullptr;
buffered_.size = 0;
}

clearBufferedSdu();
EV << NOW << " UmRxEntity::reassemble The SDU cannot be reassembled, first part missing" << endl;

delete pktSdu;
Expand All @@ -549,6 +509,7 @@ void UmRxEntity::reassemble(unsigned int index)
// for burst
ttiBits_ += sduLengthPktLeng;
buffered_.size += sduLengthPktLeng;
buffered_.currentPduSno = pduSno;
delete pktSdu;
pktSdu = nullptr;

Expand Down Expand Up @@ -580,12 +541,7 @@ void UmRxEntity::reassemble(unsigned int index)
toPdcp(pktSdu);
pktSdu = nullptr;

if (buffered_.pkt != nullptr)
{
delete buffered_.pkt;
buffered_.pkt = nullptr;
buffered_.size = 0;
}
clearBufferedSdu();

break;
}
Expand All @@ -596,15 +552,8 @@ void UmRxEntity::reassemble(unsigned int index)
// check SDU SN
if (buffered_.pkt == nullptr || (rlcSdu->getSnoMainPacket() != buffered_.pkt->peekAtFront<LteRlcSdu>()->getSnoMainPacket()) || ignoreFragment)
{
if (buffered_.pkt != nullptr)
{
// for burst
ttiBits_ -= buffered_.size; // remove the discarded SDU size from the tput
delete buffered_.pkt;
buffered_.pkt = nullptr;
buffered_.size = 0;
}

clearBufferedSdu();
EV << NOW << " UmRxEntity::reassemble The SDU cannot be reassembled, first part missing" << endl;

delete pktSdu;
Expand All @@ -618,15 +567,7 @@ void UmRxEntity::reassemble(unsigned int index)
unsigned int reassembledLength = buffered_.size + sduLengthPktLeng;
if (reassembledLength < sduWholeLength)
{
if (buffered_.pkt != nullptr)
{
// for burst
ttiBits_ -= buffered_.size; // remove the discarded SDU size from the tput
delete buffered_.pkt;
buffered_.pkt = nullptr;
buffered_.size = 0;
}

clearBufferedSdu();
EV << NOW << " UmRxEntity::reassemble The SDU cannot be reassembled, mid part missing" << endl;

delete pktSdu;
Expand All @@ -643,12 +584,7 @@ void UmRxEntity::reassemble(unsigned int index)
toPdcp(pktSdu);
pktSdu = nullptr;

if (buffered_.pkt != nullptr)
{
delete buffered_.pkt;
buffered_.pkt = nullptr;
buffered_.size = 0;
}
clearBufferedSdu();

break;
}
Expand All @@ -673,31 +609,22 @@ void UmRxEntity::reassemble(unsigned int index)
toPdcp(pktSdu);
pktSdu = nullptr;

if (buffered_.pkt != nullptr)
{
delete buffered_.pkt;
buffered_.pkt = nullptr;
buffered_.size = 0;
}
clearBufferedSdu();

break;
}
case 1: case 3: { // FI=01 or FI=11
// it is the first portion of a SDU, bufferize it
EV << NOW << " UmRxEntity::reassemble The PDU includes the first part [" << sduLengthPktLeng <<" B] of a SDU [sno=" << sduSno << "]" << endl;

if (buffered_.pkt != nullptr)
{
delete buffered_.pkt;
buffered_.pkt = nullptr;
buffered_.size = 0;
}
clearBufferedSdu();

// for burst
ttiBits_ += sduLengthPktLeng;

buffered_.pkt = pktSdu;
buffered_.size = sduLengthPktLeng;
buffered_.currentPduSno = pduSno;
pktSdu = nullptr;

EV << NOW << " UmRxEntity::reassemble Wait for the missing part..." << endl;
Expand All @@ -719,12 +646,7 @@ void UmRxEntity::reassemble(unsigned int index)
toPdcp(pktSdu);
pktSdu = nullptr;

if (buffered_.pkt != nullptr)
{
delete buffered_.pkt;
buffered_.pkt = nullptr;
buffered_.size = 0;
}
clearBufferedSdu();
}

if (pktSdu != nullptr) {
Expand Down Expand Up @@ -890,6 +812,17 @@ void UmRxEntity::handleMessage(cMessage* msg)
}
}

void UmRxEntity::clearBufferedSdu(){
if (buffered_.pkt != nullptr){
// for burst
ttiBits_ -= buffered_.size; // remove the discarded SDU size from the tput
delete buffered_.pkt;
buffered_.pkt = nullptr;
buffered_.size = 0;
buffered_.currentPduSno = 0;
}
}

void UmRxEntity::rlcHandleD2DModeSwitch(bool oldConnection, bool oldMode, bool clearBuffer)
{
if (oldConnection)
Expand Down Expand Up @@ -918,12 +851,8 @@ void UmRxEntity::rlcHandleD2DModeSwitch(bool oldConnection, bool oldMode, bool c
received_[i] = false;
}

if (buffered_.pkt != nullptr)
{
delete buffered_.pkt;
buffered_.pkt = nullptr;
buffered_.size = 0;
}
clearBufferedSdu();


// stop the timer
if (t_reordering_.busy())
Expand Down
5 changes: 5 additions & 0 deletions src/stack/rlc/um/entity/UmRxEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class UmRxEntity : public omnetpp::cSimpleModule
struct Buffered {
inet::Packet* pkt = nullptr;
size_t size;
unsigned int currentPduSno; // next PDU sequence number expected
} buffered_;

// Sequence number of the last SDU delivered to the upper layer
Expand Down Expand Up @@ -187,6 +188,10 @@ class UmRxEntity : public omnetpp::cSimpleModule

// deliver a PDCP PDU to the PDCP layer
void toPdcp(inet::Packet* rlcSdu);

// clear buffered SDU
void clearBufferedSdu();

};

#endif
Expand Down