@@ -180,13 +180,15 @@ void DownlinkHandling::evaluateDataModel(DataNodeUsageMsgPayload *dataUsageMsg,
180180 double droppedRatePotential = 0.0 ;
181181
182182 if (validParams) {
183+ // Convert link quality into per-bit energy so BER can reflect user-selected bit rate.
183184 this ->downlinkOutBuffer .cnr_dB = 10.0 * std::log10 (selectedCnr);
184185 this ->downlinkOutBuffer .cNo_dBHz = this ->downlinkOutBuffer .cnr_dB + 10.0 * std::log10 (this ->linkBudgetBuffer .bandwidth );
185186 this ->downlinkOutBuffer .ebN0_dB = this ->downlinkOutBuffer .cNo_dBHz - 10.0 * std::log10 (this ->bitRateRequest );
186187
187188 ber = this ->computeBerFromEbN0dB (this ->downlinkOutBuffer .ebN0_dB );
188189 ber = this ->clampProbability (ber);
189190
191+ // Any corrupted bit causes packet failure (checksum detect model).
190192 if (ber >= 1.0 ) {
191193 per = 1.0 ;
192194 } else if (ber <= 0.0 ) {
@@ -205,10 +207,12 @@ void DownlinkHandling::evaluateDataModel(DataNodeUsageMsgPayload *dataUsageMsg,
205207 if (successOneAttempt <= 0.0 ) {
206208 expectedAttemptsPerPacket = static_cast <double >(maxRetx);
207209 } else {
210+ // Truncated geometric expectation under retry cap.
208211 expectedAttemptsPerPacket = packetSuccessProb / successOneAttempt;
209212 expectedAttemptsPerPacket = std::max (1.0 , expectedAttemptsPerPacket);
210213 }
211214
215+ // attemptedRatePotential is channel usage; storageRemoval is source-packet outflow.
212216 attemptedRatePotential = this ->bitRateRequest ;
213217 storageRemovalRatePotential = attemptedRatePotential / expectedAttemptsPerPacket;
214218 deliveredRatePotential = storageRemovalRatePotential * packetSuccessProb;
@@ -222,6 +226,7 @@ void DownlinkHandling::evaluateDataModel(DataNodeUsageMsgPayload *dataUsageMsg,
222226 this ->downlinkOutBuffer .expectedAttemptsPerPacket = expectedAttemptsPerPacket;
223227
224228 double scale = 0.0 ;
229+ // Optional packet gating plus storage saturation: never remove more than available this step.
225230 bool enoughForPacket = (!this ->requireFullPacket ) || (this ->availableDataBits >= this ->packetSizeBits );
226231 if (storageRemovalRatePotential > 0.0 && this ->currentTimeStep > 0.0 && enoughForPacket) {
227232 double availableRemovalRate = this ->availableDataBits / this ->currentTimeStep ;
0 commit comments