https://bugs.kde.org/show_bug.cgi?id=502411
--- Comment #5 from Claudio <[email protected]> --- Hello everybody, I confirm the erroneous measurement values. This error is related to bug no. 474828 and to bug no. 481130 and to bug no. 521440 The error is located in the NetworkManagerBackend of ksystemstats (see https://invent.kde.org/plasma/ksystemstats/-/blob/master/plugins/network/NetworkManagerBackend.cpp?ref_type=heads), currently on lines 84,85 and 92,93: 84 m_downloadSensor->setValue((newDownload - previousDownload) * (1000 / UpdateRate)); 85 m_downloadBitsSensor->setValue((newDownload - previousDownload) * (1000 / UpdateRate) * 8); 92 m_uploadSensor->setValue((newUpload - previousUpload) * (1000 / UpdateRate)); 93 m_uploadBitsSensor->setValue((newUpload - previousUpload) * (1000 / UpdateRate) * 8); The Sensor value is calculated based on constant update rate and on the pevious and current byte counters of the network card coming from /proc/net/dev. The values in /proc/net/dev are updated by the network driver at its own refresh rate. If the refresh rate of the driver is lower than the update rate of ksystemstats, sampling artefacts are created (aliasing): The code lines above then receive the same byte counter value twice. The difference is calculated resulting in zero and hence 0 GiB/s are displayed in the line chart. And when the received counter value eventually is incremeting, the increment is divided by the update period of ksystemstats instead of the refresh period of the network interface card driver. In my case it is the period 0.5 instead of 1 second. This makes the speed twice as high as it actually is. This error can be mitigated with a low pass filter on the values read from /proc/net/dev, e. g. by averaging with the previous value (which in fact is a very simple anti-aliasing filter, resp. a linear interpolation filter). Example: Network byte counter: 1.0, 2.0, 3.0, 4.0, 5.0 ksystemstats sampling: 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0 filtered ksystemstats sampling: 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0 One can see that the network byte counter has a constant increment of 1 and the filtered sampling of ksystemstats has a constant increment of 0.5. The calculated speed now is the same for both: constant 1 B/s (refresh period of 0.5, resp. 1 second). The unfiltered ksystemstats sampling produces the speed sequence 0, 2, 0, 2, 0, etc. which is wrong. The only perfect solution would be if the counter values reported in /proc/net/dev would have a time stamp. Then the actual download rate could be calculated exactly no matter what sampling rates are applied. I am not able to fix this problem in the code base. But I hope I could inspire the programmers who can. best regards Claudio -- You are receiving this mail because: You are watching all bug changes.
