Last active
June 10, 2016 21:42
-
-
Save ronen-e/db8bcb756e5dfabbe99d39d4f6650fc6 to your computer and use it in GitHub Desktop.
Calculate resource download time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Returns download time from server | |
| * | |
| * @param {number} cwnd - Initial Congestion Window size | |
| * @param {number} rtt - Roundtrip Time in Milliseconds | |
| * @param {number} packetSize - Packet Size in Bytes | |
| * @param {number} totalSize - Total Transfer Size in Bytes | |
| * @return {number} time - Download Time in Milliseconds | |
| */ | |
| function downloadTime(cwnd, rtt, packetSize, totalSize) { | |
| var segments = totalSize / packetSize; | |
| return rtt * Math.ceil( Math.log2(segments / cwnd) ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment