Im trying to read/calculate the current overall bandwidth/speed for down&up stream ( eth0 ) on my AC56U router.
The values are send via python/socket to a raspberryPi that draws a running speed chart on a ws2812b led matrix display.
right now I use /sys/class/net/eth0/statistics/rx_bytes & /sys/class/net/eth0/statistics/tx_bytes
calculating the speed through the difference over a certain time.
This works quite well for the downstream,but when I try to do this also for the upstream (tx),I kinda hit a wall.
Quite often the calculated values are a far cry from the real ones currently happening.
I.e. when I use a speedtest (@google),the upstream speed goes up all the way to match the downstream speed,which isnt possible,as my upstream speed is capped @~1/6 of the download speed.
On other occasions,i..e when downloading a torrent from a lot of sources,again,the upstream speed reaches unrealistic values.(even though throttled within the torrent program)
Or when 100% upstream speed uploading ,also the downspeed goes way(100%) up,even if there are no downloads running at all.
What other ways are there to calculate the overall speeds that yield (more) realistic values ?
PS: part of the script I use right now :
rx=open('/sys/class/net/eth0/statistics/rx_bytes', 'r')
rx_old=int(rx.read())
time.sleep(ts)
rx=open('/sys/class/net/eth0/statistics/rx_bytes', 'r')
rx_new=int(rx.read())
speed=int(((rx_new-rx_old)/1024)/ts)
The values are send via python/socket to a raspberryPi that draws a running speed chart on a ws2812b led matrix display.
right now I use /sys/class/net/eth0/statistics/rx_bytes & /sys/class/net/eth0/statistics/tx_bytes
calculating the speed through the difference over a certain time.
This works quite well for the downstream,but when I try to do this also for the upstream (tx),I kinda hit a wall.
Quite often the calculated values are a far cry from the real ones currently happening.
I.e. when I use a speedtest (@google),the upstream speed goes up all the way to match the downstream speed,which isnt possible,as my upstream speed is capped @~1/6 of the download speed.
On other occasions,i..e when downloading a torrent from a lot of sources,again,the upstream speed reaches unrealistic values.(even though throttled within the torrent program)
Or when 100% upstream speed uploading ,also the downspeed goes way(100%) up,even if there are no downloads running at all.
What other ways are there to calculate the overall speeds that yield (more) realistic values ?
PS: part of the script I use right now :
rx=open('/sys/class/net/eth0/statistics/rx_bytes', 'r')
rx_old=int(rx.read())
time.sleep(ts)
rx=open('/sys/class/net/eth0/statistics/rx_bytes', 'r')
rx_new=int(rx.read())
speed=int(((rx_new-rx_old)/1024)/ts)