Accounting Stop Handling (mac_auth_handle_acct_stop)
Overview
Accounting Stop packets evaluate the final cumulative runtime from Acct-Session-Time and total bytes generated by <Input/Output>-Octets. They must subtract the usage already consumed during intermediate session continuations to find the leftover delta.
Delta Deductions
-
Time Delta (
QTDiff):-
Validates the total
Acct-Session-Timeagainst the legacy caching ofOldQT. -
QTDiff = Acct-Session-Time - OldQT(Defaults to 0 if an anomaly exists).
-
-
Volume Delta (
QVDiff):-
Maps
Input + Output Octets. -
Deducts the locally cached
OldQVsafely.
-
Double Deduction Protection (Session Matching)
BNG layers push concurrent streams (the physical underlying main session and the logical service queue running atop it). A careless handler might deduct the same usage values from both streams improperly.
The logic deliberately zeroes the time deduction (QTDiff = 0) if the stream mirrors a service-session:
* Differentiates sessions by inspecting Acct-Multi-Session-Id != Acct-Session-Id
* Differentiates queue labels containing explicit strings like SSG.
Only the underlying true session strips the time penalty, while volume limits gracefully process down via mac_auth_handle_acct_stop.
Final Cleanup
-
Deletes the active row located on
L2RADONLINE. -
Injects the comprehensive lifecycle into
MACL2CDR(sql_mac_auth5) for history bounds. -
Pushes finalized subtractions across the user DB (
MACL2USERS) and location CDR structure (LOCTOPACKAGE).
Pseudocode
Control.OldQT = DB.GetRadOnline_OldQT()
Control.OldQV = DB.GetRadOnline_OldQV()
// Delta Generation
if Acct-Session-Time > OldQT:
QTDiff = Acct-Session-Time - OldQT
else:
QTDiff = 0
TotalVol = Acct-Input-Octets + Acct-Output-Octets
if TotalVol > OldQV:
QVDiff = TotalVol - OldQV
else:
QVDiff = 0
// Remove Session From Tracker
DB.DeleteRadOnline()
DB.WriteCDR_Log()
// Prevent Double Deduction on Time
if Session is recognized as a Service Queue Stream:
QTDiff = 0 // Nullify to prevent double dipping TimeQuota
// Proceed with writes
if Auth NOT FUP_MODE:
DB.DeductFromMACL2USERS(QTDiff, QVDiff)
DB.DeductFromLocation(QVDiff)