Commit 71e1a6a
committed
MAC: fix ASSERT failure on D2D mode switching
Repro:
$ cd simulations/nr/d2d && simu5g_dbg -u Cmdenv -c SinglePair-modeSwitching-UDP
<!> Error: ASSERT: Condition 'connDescOut_.find(cid) != connDescOut_.end()' does not hold in function 'bufferizePacket' at simu5g/stack/mac/LteMacUe.cc:259 -- in module (simu5g::NrMacUe) SingleCell_Standalone_D2D.ueD2DTx[0].cellularNic.nrMac (id=309), at t=15.05952167965s, event #172116
Root cause: When D2D mode switches from DM->IM, macHandleD2DModeSwitch()
calls deleteOutgoingConnection() which permanently destroys the
MAC connection (connDescOut_ entry, queue, and virtual buffer).
However, the PDCP layer retains its LCID table entry and TX entity
for that CID.
When the mode switches back (IM->DM), PDCP considers the connection
"existing" and doesn't trigger binder_->establishUnidirectionalDataConnection().
The packet flows down to MAC which ASSERTs the connection exists -
but it was permanently deleted.
Fix:
LteMacBase: Added clearOutgoingConnectionBuffers(MacCid) that empties
queue and virtual buffer contents without destroying the connection
structure
LteMacUeD2D: Replaced deleteOutgoingConnection(cid) with
clearOutgoingConnectionBuffers(cid) in the mode switch handler,
and removed the now-unnecessary redundant lcgMap_ cleanup code
(which was dead code since deleteOutgoingConnection already cleaned it)
This ensures the MAC connection persists across mode switches with
empty buffers, ready to receive data when the mode switches back.
The idle connection with empty buffers has zero scheduling impact.1 parent 88160e1 commit 71e1a6a
3 files changed
Lines changed: 26 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
237 | 254 | | |
238 | 255 | | |
239 | 256 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
431 | 438 | | |
432 | 439 | | |
433 | 440 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
848 | 848 | | |
849 | 849 | | |
850 | 850 | | |
851 | | - | |
| 851 | + | |
| 852 | + | |
852 | 853 | | |
853 | 854 | | |
854 | 855 | | |
| |||
886 | 887 | | |
887 | 888 | | |
888 | 889 | | |
889 | | - | |
890 | | - | |
891 | | - | |
892 | | - | |
893 | | - | |
894 | | - | |
895 | | - | |
896 | | - | |
897 | | - | |
898 | | - | |
899 | | - | |
900 | | - | |
901 | | - | |
902 | 890 | | |
903 | 891 | | |
904 | 892 | | |
| |||
0 commit comments