When calculating upload speed, ifaddrs.ifa_data.ifi_obytes contains wrong value

Hello,

I am trying to calculate the upload speed of my WiFi network adapter. I have noticed that the value for the sent bytes (upload) is always double the expected value.
I am running a speediest and my downstream is 30Mb/s. However, my upload speed in my app shows a little less than 8 MB/s which is actually double the value (it should be approx. 4MB/s).



This issue can be reproduced with the attached Playground. What could be the reason for this? It does not happen with Download speed.
Please repeat this test in a command-line tool rather than a playground. Playgrounds have all sorts of interesting runtime effects.

Also, how does the ifi_obytes value compare to the actual number of bytes that you see transmitted on the wire, as observed by a packet trace For info on how to record a packet trace, see Recording a Packet Trace.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
I have repeated the test in a command line tool and the results are the same.

I have repeated the test in a command line tool and the results are
the same.

OK.

And the result of your packet trace test?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
When calculating upload speed, ifaddrs.ifa_data.ifi_obytes contains wrong value
 
 
Q