tomaae / homeassistant-mikrotik_router

Mikrotik router integration for Home Assistant
Apache License 2.0
282 stars 43 forks source link

[Bug] Port Traffic Statistic show incorrect values depending on Integration Update Intervall #319

Open Zarox666 opened 9 months ago

Zarox666 commented 9 months ago

Describe the issue

When decreasing the Update Intervall the reported Mbit/s increases.

I have 1 leg up to my Multi-WAN Router. When I saturate my WAN Connection (Speedtest, large Downloads) the Mikrotik Switch shows traffic on this Interface as ~90Mbits/s. When I use the default 30 Second Update intervall this gets reported in HA as ~90Mbits/s. However when I reduce the Update interval of the Integration to 10 Seconds it gets reported as ~135Mbits/s and when I further drop it to 5 Seconds it shows as 160Mbits/s.

So something is not quite right with the calculation of these Values. The Switch shows ~90Mbits/s for all these tests. ( I am aware that a 5 second update interval is redicoulously short if the update itself takes 5+ seconds, but this is for illustration purposes only)

How to reproduce the issue

  1. Set up a Port Traffic Sensor and put a measurable / consistent amount of traffic overt his port.
  2. Change the Update intervall of the Mikrotik Router Integration and compare values reported by RouterOS vs. HA

Expected behavior

Throughput per Second Values should not change dependant on the duration between updates.

Screenshots

One WAN link was down, so I only got ~50Mbit/s but nevertheless the difference in the reported Values is starkly visbile. This was with a 5 Second Update intervall. image

The Diagnostic Logs are from this test. The Data has been stopped and connected while the Bandwitdh test was still running.

Software versions

Home Assistant 2023.10.0 Supervisor 2023.10.0 Operating System 10.5 Frontend 20231002.0 - latest Mikrotik Router integration version: v.2.1.4 RouterOS version: v6.49.7 (stable)

Diagnostics data

home-assistant_mikrotik_router_2023-10-16T05-39-33.491Z.log

tomaae commented 8 months ago

does this apply to all interfaces or just wan?

Zarox666 commented 8 months ago

all interfaces and on the site of the switch there is nothing special about the "WAN" interface. its just an Ethernet port that connects to the router that is having the WAN Ports. But for me its the easiest to saturate and thus produce reliable numbers.