Methods Summary |
---|
public void | addMetricToMap(int metric)
int downIndex = convertBitsPerSec2meshIndex(lastDownloadBitsPerSec);
int upIndex = convertBitsPerSec2meshIndex(lastUploadBitsPerSec);
totalPointsInMap++;
if( metric<goodPingInMilliSec ){
gridRegion[upIndex][downIndex].incrementMetricCount( GridRegion.INDEX_PING_GOOD );
}else if( metric<badPingInMilliSec ){
gridRegion[upIndex][downIndex].incrementMetricCount( GridRegion.INDEX_PING_NEUTRAL );
}else{
gridRegion[upIndex][downIndex].incrementMetricCount( GridRegion.INDEX_PING_BAD );
}
|
private com.aelitis.azureus.core.speedmanager.impl.v2.PingSpaceMapper$Result[] | calculate()Look at the Map and find the highest index for each catagory.
Result[] retVal = new Result[2];
retVal[GOOD_PING_INDEX] = new Result();
retVal[ANY_PING_INDEX] = new Result();
for(int upIndex=0;upIndex<maxMeshIndex;upIndex++){
for(int downIndex=0;downIndex<maxMeshIndex;downIndex++)
{
//Register this grid point if it has more good then bad pings.
float rating = gridRegion[upIndex][downIndex].getRating();
if( rating>0.0f ){
retVal[GOOD_PING_INDEX].checkAndUpdate(upIndex,downIndex);
}
//Register this grid point if it has any ping values.
int count = gridRegion[upIndex][downIndex].getTotal();
if( count>0 ){
retVal[ANY_PING_INDEX].checkAndUpdate(upIndex,downIndex);
}
}//for
}//for
return retVal;
|
private int | convertBitsPerSec2meshIndex(int bitsPerSec)We have a hard coded mesh.
0-9999 = 0, 10000-
if( bitsPerSec<0){
return 0;
}
int bytesPerSec = bitsPerSec/1024;
if( bytesPerSec<100){
return bytesPerSec/10;
}else if(bytesPerSec<500){
return 10 + ((bytesPerSec-100)/50);
}else if(bytesPerSec<5000){
return 10 + 8 + ((bytesPerSec-500)/100);
}
//return max mesh index.
return 10 + 8 + 45;
|
private int | convertMeshIndex2bitsPerSec(int meshIndex)The reverse of bit/sec -> mesh index calculation.
int bytesPerSec=0;
if(meshIndex<=0){
return 0;
}
if(meshIndex<=10){
bytesPerSec = meshIndex*10;
}else if(meshIndex<=18){
bytesPerSec = 100 + (meshIndex-10) * 50;
}else{
bytesPerSec = 500 + (meshIndex-18) * 100;
}
return bytesPerSec*1024;
|
private void | createNewGrid()
//create the mesh. We will have 70 by 70 grid. Even though we only use 63.
gridRegion = null;
gridRegion = new GridRegion[maxMeshIndex][maxMeshIndex];
for(int upIndex=0;upIndex<maxMeshIndex;upIndex++){
for(int downIndex=0;downIndex<maxMeshIndex;downIndex++){
gridRegion[upIndex][downIndex] = new GridRegion();
}
}
|
private com.aelitis.azureus.core.speedmanager.impl.v2.PingSpaceMapper$Result | getHighestMeshIndexWithAnyPing()
Result[] retVal = calculate();
return retVal[ANY_PING_INDEX];
|
private com.aelitis.azureus.core.speedmanager.impl.v2.PingSpaceMapper$Result | getHighestMeshIndexWithGoodPing()
Result[] retVal = calculate();
return retVal[GOOD_PING_INDEX];
|
public int | guessDownloadLimit()Make a guess at the download capacity based on metric data.
Result result = getHighestMeshIndexWithGoodPing();
int downMeshIndex = result.getDownloadIndex();
return convertMeshIndex2bitsPerSec( downMeshIndex );
|
public int | guessUploadLimit()Make a guess at the upload capacity based on metric data.
Result result = getHighestMeshIndexWithGoodPing();
int upMeshIndex = result.getUploadIndex();
return convertMeshIndex2bitsPerSec( upMeshIndex );
|
public boolean | hadChockingPing(boolean isDownloadTest)Try to determine if a chocking ping occured during this test.
Result[] res = calculate();
int goodPingIndex;
int highPingIndex;
if( isDownloadTest ){
goodPingIndex = res[GOOD_PING_INDEX].getDownloadIndex();
highPingIndex = res[ANY_PING_INDEX].getDownloadIndex();
}else{
goodPingIndex = res[GOOD_PING_INDEX].getUploadIndex();
highPingIndex = res[ANY_PING_INDEX].getUploadIndex();
}
return (highPingIndex>goodPingIndex);
|
public void | reset()Start accumlating data from scratch.
totalPointsInMap=0;
createNewGrid();
|
public void | setCurrentTransferRates(int downloadBitPerSec, int uploadBitsPerSec)
lastDownloadBitsPerSec = downloadBitPerSec;
lastUploadBitsPerSec = uploadBitsPerSec;
|