How to estimate download time

One of our apps right now has a design where, through the app, you make an IAP purchase, we then download 5-6 tarred file content down to your device. All together it is 10-15MB of data. And our experience so far is that the download item can vary greatly depending on 3G vs Wifi, Android vs iOS, and even different Wifi broadband providers.

We want to be able to show a download progress bar for the user to track how the download is doing (eg 30% complete), but the challenge is how do we estimate that?

Currently, we just have 2 different estimated download time based on iOS vs Android. We may add another estimate based on 3G vs Wifi (on iOS at least). But depending on the network condition, both of these can be way off.

Any suggestions would be greatly welcomed.

FYI we use Google App Engine for backend, if that helps any.
[import]uid: 41124 topic_id: 28653 reply_id: 328653[/import]

Do you know the size of the file you’re downloading beforehand? If so, you can calculate the download time at every 5 or 10-second interval. Determine how much of the TAR file has downloaded in that interval, and that’s the current “speed” for the download. Divide the remaining amount to download by the calculated speed and that will be the estimated remaining time.

But, since the download speed can fluctuate, you should continually sample the speed and plug it into the equation to “smooth” out the resulting number, as described in this example found here: http://stackoverflow.com/questions/2779600/how-to-estimate-download-time-remaining-accurately

averageSpeed = SMOOTHING\_FACTOR \* lastSpeed + ( 1 - SMOOTHING\_FACTOR ) \* averageSpeed;

or

speed = speedNow \* 0.5 + speedLastHalfMinute \* 0.3 + speedLastMinute \* 0.2

Hope that helps! [import]uid: 6084 topic_id: 28653 reply_id: 115568[/import]

Interesting idea. We do know how large the download file is. I suppose we can try to measure the size of the file using file:seek() to see how large the file is over time? But, would that interfere with the actual download itself and corrupt the data?
[import]uid: 41124 topic_id: 28653 reply_id: 115690[/import]