Class PingSpaceMapper
- java.lang.Object
-
- com.biglybt.core.speedmanager.impl.v2.PingSpaceMapper
-
public class PingSpaceMapper extends java.lang.Object
Classifies the ping-times and then maps them against the a grid of upload and download rates. Create a two dimensional map of upload and download rates. Map onto this space ping times. The mesh size will be smaller near zero, and larger higher up. 0 - 100 kByte/sec - 10 kBytes mesh size. 100 - 500 kBytes/sec - 50 kBytes mesh size. 500 - 5000 kBytes/sec - 100 kBytes mesh size. Anything above 5 MBytes/sec is one region.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
PingSpaceMapper.GridRegion
A region on the grid for accumulating counts.(package private) static class
PingSpaceMapper.Result
Class to return a result.
-
Field Summary
Fields Modifier and Type Field Description (package private) static int
ANY_PING_INDEX
(package private) int
badPingInMilliSec
(package private) static int
GOOD_PING_INDEX
(package private) int
goodPingInMilliSec
(package private) PingSpaceMapper.GridRegion[][]
gridRegion
(package private) int
lastDownloadBitsPerSec
(package private) int
lastUploadBitsPerSec
private static int
maxMeshIndex
static int
RESULT_DOWNLOAD_INDEX
static int
RESULT_UPLOAD_INDEX
(package private) int
totalPointsInMap
-
Constructor Summary
Constructors Constructor Description PingSpaceMapper(int _goodPingInMilliSec, int _badPingInMilliSec)
Create a grid and define good and bad ping times.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMetricToMap(int metric)
private PingSpaceMapper.Result[]
calculate()
Look at the Map and find the highest index for each catagory.private int
convertBitsPerSec2meshIndex(int bitsPerSec)
We have a hard coded mesh.private int
convertMeshIndex2bitsPerSec(int meshIndex)
The reverse of bit/sec -> mesh index calculation.private void
createNewGrid()
private PingSpaceMapper.Result
getHighestMeshIndexWithAnyPing()
private PingSpaceMapper.Result
getHighestMeshIndexWithGoodPing()
int
guessDownloadLimit()
Make a guess at the download capacity based on metric data.int
guessUploadLimit()
Make a guess at the upload capacity based on metric data.boolean
hadChockingPing(boolean isDownloadTest)
Try to determine if a chocking ping occured during this test.void
reset()
Start accumlating data from scratch.void
setCurrentTransferRates(int downloadBitPerSec, int uploadBitsPerSec)
-
-
-
Field Detail
-
gridRegion
PingSpaceMapper.GridRegion[][] gridRegion
-
lastDownloadBitsPerSec
int lastDownloadBitsPerSec
-
lastUploadBitsPerSec
int lastUploadBitsPerSec
-
goodPingInMilliSec
final int goodPingInMilliSec
-
badPingInMilliSec
final int badPingInMilliSec
-
totalPointsInMap
int totalPointsInMap
-
maxMeshIndex
private static final int maxMeshIndex
- See Also:
- Constant Field Values
-
RESULT_UPLOAD_INDEX
public static final int RESULT_UPLOAD_INDEX
- See Also:
- Constant Field Values
-
RESULT_DOWNLOAD_INDEX
public static final int RESULT_DOWNLOAD_INDEX
- See Also:
- Constant Field Values
-
GOOD_PING_INDEX
static final int GOOD_PING_INDEX
- See Also:
- Constant Field Values
-
ANY_PING_INDEX
static final int ANY_PING_INDEX
- See Also:
- Constant Field Values
-
-
Method Detail
-
createNewGrid
private void createNewGrid()
-
convertBitsPerSec2meshIndex
private int convertBitsPerSec2meshIndex(int bitsPerSec)
We have a hard coded mesh. 0-9999 = 0, 10000-- Parameters:
bitsPerSec
- -- Returns:
- - mesh index.
-
convertMeshIndex2bitsPerSec
private int convertMeshIndex2bitsPerSec(int meshIndex)
The reverse of bit/sec -> mesh index calculation.- Parameters:
meshIndex
- - value between 0 and 70- Returns:
- lowest BitsPerSecond that meets that criteria.
-
setCurrentTransferRates
public void setCurrentTransferRates(int downloadBitPerSec, int uploadBitsPerSec)
-
addMetricToMap
public void addMetricToMap(int metric)
-
reset
public void reset()
Start accumlating data from scratch.
-
getHighestMeshIndexWithGoodPing
private PingSpaceMapper.Result getHighestMeshIndexWithGoodPing()
-
getHighestMeshIndexWithAnyPing
private PingSpaceMapper.Result getHighestMeshIndexWithAnyPing()
-
hadChockingPing
public boolean hadChockingPing(boolean isDownloadTest)
Try to determine if a chocking ping occured during this test.- Parameters:
isDownloadTest
- - set true if this is a download_search_test. set false if upload search test.- Returns:
- - true if it appears a chocking ping occured.
-
calculate
private PingSpaceMapper.Result[] calculate()
Look at the Map and find the highest index for each catagory.- Returns:
- Result[2], where index 0 is goodPing, index 1 is anyPing
-
guessUploadLimit
public int guessUploadLimit()
Make a guess at the upload capacity based on metric data.- Returns:
- -
-
guessDownloadLimit
public int guessDownloadLimit()
Make a guess at the download capacity based on metric data.- Returns:
- -
-
-