thiezn / iperf3-python

Python wrapper around iperf3
https://iperf3-python.readthedocs.org/
MIT License
109 stars 52 forks source link

correcting kB_s and MB_s in UDP for correct calculation #34

Closed gleichda closed 5 years ago

gleichda commented 6 years ago

During using of the Python Wrapper I saw that kB_s and MB_s are not correctly calculated. This is the fix for it

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 97.625% when pulling f80cd3e9b4df91ebc17a699b18d049a86c412538 on mirgleich:master into 6656d041d2b67736477f86c8d8f7a5a61dcd03e5 on thiezn:master.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 97.625% when pulling 8fa7019f31f592bed4e41a3519372b2d3a8b8b77 on mirgleich:master into 6656d041d2b67736477f86c8d8f7a5a61dcd03e5 on thiezn:master.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 97.625% when pulling 8fa7019f31f592bed4e41a3519372b2d3a8b8b77 on mirgleich:master into 6656d041d2b67736477f86c8d8f7a5a61dcd03e5 on thiezn:master.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 97.625% when pulling 8fa7019f31f592bed4e41a3519372b2d3a8b8b77 on mirgleich:master into 6656d041d2b67736477f86c8d8f7a5a61dcd03e5 on thiezn:master.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 97.625% when pulling 8fa7019f31f592bed4e41a3519372b2d3a8b8b77 on mirgleich:master into 6656d041d2b67736477f86c8d8f7a5a61dcd03e5 on thiezn:master.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 97.625% when pulling 8fa7019f31f592bed4e41a3519372b2d3a8b8b77 on mirgleich:master into 6656d041d2b67736477f86c8d8f7a5a61dcd03e5 on thiezn:master.

ChristofKaufmann commented 5 years ago

Yes, it is wrong currently. However, there is a comment, that says:

# Bits are measured in 10**3 terms
# Bytes are measured in 2**10 terms

So your fix should actually be:

diff --git a/iperf3/iperf3.py b/iperf3/iperf3.py
index 7aceed1..a3f5c4e 100755
--- a/iperf3/iperf3.py
+++ b/iperf3/iperf3.py
@@ -841,8 +841,8 @@ class TestResult(object):
                 self.jitter_ms = self.json['end']['sum']['jitter_ms']
                 self.kbps = self.bps / 1000
                 self.Mbps = self.kbps / 1000
-                self.kB_s = self.kbps / (8 * 1024)
-                self.MB_s = self.Mbps / 1024
+                self.kB_s = self.bps / (8 * 1024)
+                self.MB_s = self.kB_s / 1024
                 self.packets = self.json['end']['sum']['packets']
                 self.lost_packets = self.json['end']['sum']['lost_packets']
                 self.lost_percent = self.json['end']['sum']['lost_percent']
gleichda commented 5 years ago

Thanks @ChristofKaufmann adapted the code