Skip to content

Commit 8c4bb10

Browse files
committed
SDAP refactor: Refactor UE QFI resolution chain, make DSCP fallback opt-in (useDscpAsQfiFallback)
1 parent 8e3083c commit 8c4bb10

2 files changed

Lines changed: 21 additions & 17 deletions

File tree

src/simu5g/stack/sdap/NrSdap.cc

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -115,32 +115,30 @@ void NrSdap::handleUpperPacket(inet::Packet *pkt)
115115
EV_INFO << "SDAP TX: QFI = " << (int)qfi << " extracted from QfiReq\n";
116116
}
117117
else if (isUe) {
118-
// UE UL: derive QFI from DSCP field of the IP header (DSCP = TOS >> 2)
119-
// FlowControlInfo.typeOfService is the raw TOS byte set by Ip2Nic::toStackUe()
120-
// Only applicable for IP PDU sessions; non-IP sessions use QfiReq or default QFI.
121-
if (pkt->hasTag<FlowControlInfo>()) {
122-
auto fci = pkt->getTag<FlowControlInfo>();
123-
uint8_t tos = (uint8_t)fci->getTypeOfService();
124-
if (tos > 0) {
125-
uint8_t dscp = tos >> 2;
126-
qfi = dscp;
127-
EV_INFO << "SDAP TX: QFI = " << (int)qfi << " derived from DSCP=" << (int)dscp << "\n";
128-
}
129-
}
130-
// If DSCP gave no QFI, try reflective QoS
131-
if (qfi == 0 && reflectiveQosTable != nullptr) {
118+
// UE UL: try reflective QoS first (3GPP-defined mechanism)
119+
if (reflectiveQosTable != nullptr) {
132120
uint8_t reflectiveQfi = reflectiveQosTable->lookupUplinkQfi(pkt);
133121
if (reflectiveQfi > 0) {
134122
qfi = reflectiveQfi;
135123
qfiFromReflectiveQos = true;
136124
EV_INFO << "SDAP TX: QFI = " << (int)qfi << " derived from reflective QoS\n";
137125
}
138126
}
127+
// Optional non-standard fallback: derive QFI from DSCP field of the IP header
128+
if (qfi == 0 && par("useDscpAsQfiFallback").boolValue()) {
129+
if (pkt->hasTag<FlowControlInfo>()) {
130+
uint8_t tos = (uint8_t)pkt->getTag<FlowControlInfo>()->getTypeOfService();
131+
if (tos > 0) {
132+
qfi = tos >> 2;
133+
EV_INFO << "SDAP TX: QFI = " << (int)qfi << " derived from DSCP (fallback)\n";
134+
}
135+
}
136+
}
139137
if (qfi == 0)
140-
EV_WARN << "SDAP TX: No QFI from DSCP or reflective QoS, defaulting QFI to 0\n";
138+
EV_WARN << "SDAP TX: No QFI from reflective QoS or DSCP, using QFI=0 (default DRB)\n";
141139
}
142140
else {
143-
EV_WARN << "SDAP TX: QfiReq not found on gNB path, defaulting QFI to 0\n";
141+
throw cRuntimeError("SDAP TX: QfiReq tag missing on gNB DL path -- GtpUser should always set it");
144142
}
145143

146144
// Lookup DRB context: nodeId is NODEID_NONE on UE, destUeId on gNB

src/simu5g/stack/sdap/NrSdap.ned

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ package simu5g.stack.sdap;
2020
//
2121
// For SDUs received from the upper layer, performs QFI-to-DRB mapping,
2222
// encapsulates the data with SDAP headers if needed, and forwards the packets
23-
// to the PDCP layer.
23+
// to the PDCP layer. On the gNB DL path, the QFI is always taken from the
24+
// QfiReq tag (set by GtpUser). On the UE UL path, the QFI resolution chain is:
25+
// 1. QfiReq tag (if set by the application)
26+
// 2. Reflective QoS table (if enabled)
27+
// 3. DSCP field of the IP header (if useDscpAsQfiFallback is enabled)
28+
// 4. QFI=0 (falls back to default DRB)
2429
//
2530
// An SDAP header is only added when the QFI cannot be unambiguously recovered
2631
// from the DRB alone on the RX side, i.e. when the DRB is the default DRB
@@ -56,6 +61,7 @@ simple NrSdap like INrSdap
5661
object drbConfig = default([]); // JSON array: [{drb, ue, qfiList, rlcType, pduSessionType, upperProtocol, isDefault}, ...]; see banner comment for details
5762
string reflectiveQosTableModule = default(""); // UE only: path to ReflectiveQosTable module (empty = disabled)
5863
bool useReflectiveQos = default(false); // UE only
64+
bool useDscpAsQfiFallback = default(false); // UE only: use IP DSCP value as QFI when no QfiReq or reflective QoS match
5965
@display("i=block/layer");
6066
gates:
6167
input upperLayerIn; // from upper layer (Ip2Nic or app)

0 commit comments

Comments
 (0)