Tr064 binding: received total bytes - buffer overflow?

Happy new year !

I read every minute the total received bytes via tr064 binding from my 7490 FritzBox. Since a few days I run more and more into trouble - randomly. Finally today, I detected an exceptionally behavior and the root cause:

2020-01-01 22:53:41.058 [vent.ItemStateChangedEvent] - fboxWanTotalBytesReceived changed from 3958488817 to 590758032.

So decreasing value instead of mandatory increasing value…

This can’t be - assuming, the Fritzbox is sending the correct values, the value MUST ALWAYS increment - but never decrement as asserted in the log, right?

This unexpected behavior leads to corrupt data in my influxDB.

After a reboot of my Fritzbox (since a few weeks running without a neccessary reboot) the issue seems to be eliminated - temporarely:

2020-01-01 23:17:20.047 [vent.ItemStateChangedEvent] - fboxWanTotalBytesSent changed from 73362328 to 73476580.

But after downloading a large file, approx… 2 Gb size, I run again into this issue.

It might not be an option for me, to force a reboot of my Fritzbox due to buffer overflow of the binding or whatever the root cause is.

Any idea to prevent this issue are highly appreciated, thank you!

Dirk

There’s always an upper limit for a counter.
What you want to check is the largest value seen before the number rolls over.
A debug log would also be a good idea.

The Value from TR64 from fritzbox is an ui4 (32bit) Value. Internallay the box use an other, so there is an overrun. AVM is informed about this and may correct this for next version of Fritz!OS 7.20.

1 Like

Thank you all for the information, this makes this silly stuff more clear for me. In meanwhile I use this workaround in a rule, which is close (not 100%) to the real received bytes algorithmus. I skip the value, when the overflow occurs.

here part of my ‘crone.rules’:

rule “each minute plus 15 seconds” //

when

Time cron "15 * * * * ?" 

then

var a = fboxWanTotalBytesReceived.state as Number

var delta = 0 as Number   

  

if (LTRB != NULL)

{

    var b = LTRB.state as Number  

     delta = ((a-b)/1024 /1024)   

    var xtmbr = TMBR.state as Number 

    var t = (xtmbr + delta) as Number

    

    if (a > b)

    {

        postUpdate(DTRB,delta) // Differenz in [Mb]

        postUpdate(wann,new DateTimeType().format("%1$tH:%1$tM:%1$tS"))

        postUpdate(TMBR, t)        

    }

    else

    {

        LastAnouncement.postUpdate( "Fehler in tr064 Bainding! ")

        if (DEBUGAUDIO.state == 1){say(LastAnouncement, "voicerss:deDE", "enhancedjavasound")}

            else if (DEBUGAUDIO.state == 2){say(LastAnouncement, "voicerss:deDE", "sonos:PLAY1:Wohnzimmer")}

            else if (DEBUGAUDIO.state == 3){say(LastAnouncement, "voicerss:deDE", "sonos:PLAY1:Kueche")}

            else if (DEBUGAUDIO.state == 4){say(LastAnouncement, "voicerss:deDE", "sonos:PLAY1:Bad")}

            else if (DEBUGAUDIO.state == 5){say(LastAnouncement, "voicerss:deDE", "sonos:PLAY1:Lea")}

    }

}

else

{

   logInfo("loggerName", "WARNING: LTRB is NULL -> check rule >jede Minute<") 

}

logInfo("RULE TRIGGERED: ",  "Megabyte received: " + delta  )     

postUpdate(LTRB,fboxWanTotalBytesReceived.state)

end

And here the extract from ‘fritzbox.items’:

…Number fboxWanTotalBytesSent “WAN total bytes sent [%s]” (gTEST1) {fritzboxtr064=“wanTotalBytesSent”}

Number fboxWanTotalMegaBytesSent “WAN total Megabytes sent [%s]” (gTEST1)

Number fboxWanTotalBytesReceived “WAN total bytes received [%s]” (gTEST1) {fritzboxtr064=“wanTotalBytesReceived”}

Number fboxWanTotalMegaBytesReceived “WAN total Megabytes received [%s]” (gTEST1)

String wann “last time [%s]” (gTEST1)

Number AVG5Download “Average DWN last 5 Minutes” (gTEST1)

Number LTRB “Last WAN total received Bytes [%s]” (gTEST1)

Number DTRB “Delta total receives Megabytes[%.2f]” (gTEST1,gLogDSL)

Number TMBR “Total Megabytes received [%.2f]” (gTEST1,gLogDSL)

best regards,

Dirk