R
R
Roman Semenov2019-06-26 18:24:24
iOS
Roman Semenov, 2019-06-26 18:24:24

Swift iOS How to measure connection speed?

How to implement connection speed measurement like in the Speed ​​test application?
It is necessary to make the measurement run until the user presses the Stop button, until that moment the connection speed should be displayed and the arrow animation should be performed.
I imagine that there should be some object that sends packets and when it receives them, the viewcontroller should be updated. How to do this and at the same time, so that the measurement is long, I can’t imagine.
I would be grateful if you share your thoughts and show the main ideas in the code.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
doublench21, 2019-06-26
@romasemenov

If you do it reliably , you can take the well-known ipef3 , the C sources are safely here https://github.com/esnet/iperf
Write a simple Swift wrapper with the measurement types you need above this library. (This is done very easily, there is a lot of information)
Well, actually, now you connect your wrapper to Swift ( import MySwiftIperf) and start measuring.
If it's easierURLSession to do, then you can download some large file as usual . AtURLSessionthere is an excellent delegate in which you can look at the current portion of the downloaded data. This is enough to measure the speed. Initial time, current time, current number of bytes downloaded, all this is divided by the required measurement in kb / mb / ...
PS A beautiful arrow is a topic for a separate discussion.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question