Methods Summary |
---|
public void | calculate(com.aelitis.azureus.core.speedmanager.SpeedManagerPingSource[] sources)Called whenever a new set of ping values is available for processing
limitMonitor.logPMDataEx();
//Get new data to ping-source-manager.
int len = sources.length;
for(int i=0; i<len; i++){
pingSourceManager.addPingTime( sources[i] );
int pingTime = sources[i].getPingTime();
//exclude ping-times of -1 which mess up the averages.
if(pingTime>0){
//pingTimeList.add( new Integer( sources[i].getPingTime() ) );
intervalCount++;
}//if
}//for
//if we are in a limit finding mode then don't even bother with this calculation.
if( limitMonitor.isConfTestingLimits() ){
if( limitMonitor.isConfLimitTestFinished() ){
endLimitTesting();
return;
}else{
//will increase the limit each cycle.
SMUpdate ramp = limitMonitor.rampTestingLimit(
adapter.getCurrentUploadLimit(),
adapter.getCurrentDownloadLimit()
);
logNewLimits( ramp );
setNewLimits( ramp );
}
}//if - isConfTestingLimits
long currTime = SystemTime.getCurrentTime();
if( timeSinceLastUpdate==0 ){
timeSinceLastUpdate=currTime;
}
//use the variance ping times instead.
if ( calculatePingMetric() ){
return;
}
log("metric:"+ lastMetricValue);
logLimitStatus();
//update the metric data
//limitMonitor.addToPingMapData(lastMetricValue);
float signalStrength = determineSignalStrength(lastMetricValue);
//if are are NOT looking for limits and we have a signal then make an adjustment.
if( signalStrength!=0.0f && !limitMonitor.isConfTestingLimits() ){
hadAdjustmentLastInterval=true;
float multiple = consectiveMultiplier();
int currUpLimit = adapter.getCurrentUploadLimit();
int currDownLimit = adapter.getCurrentDownloadLimit();
limitMonitor.checkForUnpinningCondition();
SMUpdate update = limitMonitor.modifyLimits(signalStrength,multiple,currUpLimit, currDownLimit);
//log
logNewLimits(update);
//setting new
setNewLimits( update );
}else{
hadAdjustmentLastInterval=false;
//verify the limits. It is possible for the user to adjust the capacity down below the current limit, so check that condition here.
int currUploadLimit = adapter.getCurrentUploadLimit();
int currDownloadLimit = adapter.getCurrentDownloadLimit();
if( !limitMonitor.areSettingsInSpec(currUploadLimit, currDownloadLimit) ){
SMUpdate update = limitMonitor.adjustLimitsToSpec(currUploadLimit, currDownloadLimit);
logNewLimits( update );
setNewLimits( update );
}
}
//determine if we need to drop a ping source.
pingSourceManager.checkPingSources(sources);
|
private float | calculateDownTickMultiple(int c)Want to drop rate faster then increase.
float multiple=0.0f;
if(c<0){
return multiple;
}
switch(c){
case 0:
case 1:
multiple=0.25f;
break;
case 2:
multiple=0.5f;
break;
case 3:
multiple=1.0f;
break;
case 4:
multiple=2.0f;
break;
case 5:
multiple=3.0f;
break;
case 6:
multiple=4.0f;
break;
case 7:
multiple=6.0f;
break;
case 8:
multiple=9.0f;
break;
case 9:
multiple=15.0f;
break;
default:
multiple=20.0f;
}//switch
return multiple;
|
private boolean | calculatePingMetric()Variance PingMap data is the metrics used. Calculate it here.
//Don't count this data point, if we skip the next ping times after an adjustment.
if(skipIntervalAfterAdjustment && hadAdjustmentLastInterval){
hadAdjustmentLastInterval=false;
pingTimeList = new ArrayList();
intervalCount=0;
return true;
}
//have we accululated enough data to make an adjustment?
if( intervalCount < numIntervalsBetweenCal ){
//get more data before making another calculation.
return true;
}
//we have enough data. find the median ping time.
lastMetricValue = (float)adapter.getPingMapper().getCurrentMetricRating();
//we have now consumed this data. reset the counters.
intervalCount=0;
return false;
|
private float | calculateUpTickMultiple(int c)Want to rise much slower then drop.
float multiple=0.0f;
if(c<0){
return multiple;
}
switch(c){
case 0:
case 1:
multiple=0.25f;
break;
case 2:
multiple=0.5f;
break;
case 3:
multiple=1.0f;
break;
case 4:
multiple=1.25f;
break;
case 5:
multiple=1.5f;
break;
case 6:
multiple=1.75f;
break;
case 7:
multiple=2.0f;
break;
case 8:
multiple=2.25f;
break;
case 9:
multiple=2.5f;
break;
default:
multiple=3.0f;
}//switch
//decrease the signal strength if bandwith usage is only in MED use.
if( limitMonitor.bandwidthUsageMedium() ){
multiple /= 2.0f;
}
return multiple;
|
public void | configurationSaved()
try{
limitMonitor.readFromPersistentMap();
limitMonitor.updateFromCOConfigManager();
skipIntervalAfterAdjustment=COConfigurationManager.getBooleanParameter(
SpeedManagerAlgorithmProviderV2.SETTING_WAIT_AFTER_ADJUST);
numIntervalsBetweenCal=COConfigurationManager.getIntParameter(
SpeedManagerAlgorithmProviderV2.SETTING_INTERVALS_BETWEEN_ADJUST);
limitMonitor.initPingSpaceMap();
SpeedManagerLogger.trace("..VariancePingMap - configurationSaved called.");
}catch( Throwable t ){
SpeedManagerLogger.log(t.getMessage());
}
|
private float | consectiveMultiplier()The longer were get the same signal the stronger it is. On upticks however we only increase the
rates when if the upload or download is saturated.
float multiple;
if( consecutiveUpticks > consecutiveDownticks ){
//Set the consecutive upticks back to zero if the bandwidth is not being used.
if( limitMonitor.bandwidthUsageLow() ){
consecutiveUpticks=0;
}
multiple = calculateUpTickMultiple(consecutiveUpticks);
}else{
multiple = calculateDownTickMultiple(consecutiveDownticks);
limitMonitor.notifyOfDownSignal();
}
return multiple;
|
private float | convertTestMetricToSignal(float testMetric)
if( testMetric>=1.0f ){
return 1.0f;
}
if(testMetric<=-1.0f){
return -1.0f;
}
//here we will map the neutral region to -0.5f to +0.5f to singal = 0;
if( testMetric>-0.5f && testMetric<0.5f ){
return 0.0f;
}
//map weak up signal.
if( testMetric > 0.0f ){
return ( (testMetric - 0.5f) * 2.0f );
}
//map weak down signal
return ( ( testMetric+0.5f ) * 2.0f );
|
public void | destroy()
COConfigurationManager.removeListener( this );
|
private float | determineSignalStrength(float lastMetric)
//determine if this is an up-tick (+1), down-tick (-1) or neutral (0).
// range should be -1.0 (bad) to +1.0 (good)
float signal = convertTestMetricToSignal( lastMetric );
if( signal > 0.0f){
consecutiveUpticks++;
consecutiveDownticks=0;
}else if(signal < 0.0f ){
consecutiveUpticks=0;
consecutiveDownticks++;
}else{
//This is a neutral signal.
}
log("consecutive:"+consecutiveUpticks+":"+consecutiveDownticks);
return signal;
|
private void | endLimitTesting()
int downLimitGuess = limitMonitor.guessDownloadLimit();
int upLimitGuess = limitMonitor.guessUploadLimit();
SMUpdate update = limitMonitor.endLimitTesting(downLimitGuess,
upLimitGuess );
//print out the PingMap data to compare.
limitMonitor.logPingMapData();
//reset Ping Space Map for next round.
limitMonitor.resetPingSpace();
//log
logNewLimits(update);
//setting new
setNewLimits( update );
|
public boolean | getAdjustsDownloadLimits()
// TODO Auto-generated method stub
return true;
|
public int | getCurrentChokeSpeed()Returns the current view of when choking occurs
return 0;
|
public int | getCurrentPingMillis()
return 0;
|
public int | getIdlePingMillis()Various getters for interesting info shown in stats view
//return the vivaldi time.
return 0;//lastMetricValue;
|
public int | getMaxPingMillis()
return 910; //Currently a fixed number to be sure of algorightm.
|
public int | getMaxUploadSpeed()
return sessionMaxUploadRate;
|
protected void | log(java.lang.String str)
SpeedManagerLogger.log(str);
|
private void | logCurrentData(int downRate, int currDownLimit, int upRate, int currUploadLimit)log "curr-data" line to the AutoSpeed-Beta file.
StringBuffer sb = new StringBuffer("curr-data-m:"+downRate+":"+currDownLimit+":");
sb.append( limitMonitor.getDownloadMaxLimit() ).append(":");
sb.append(limitMonitor.getDownloadBandwidthMode()).append(":");
sb.append(limitMonitor.getDownloadLimitSettingMode()).append(":");
sb.append(upRate).append(":").append(currUploadLimit).append(":");
sb.append( limitMonitor.getUploadMaxLimit() ).append(":");
sb.append(limitMonitor.getUploadBandwidthMode()).append(":");
sb.append(limitMonitor.getUploadLimitSettingMode()).append(":");
sb.append(limitMonitor.getTransferModeAsString());
SpeedManagerLogger.log( sb.toString() );
|
private void | logLimitStatus()Log the limit status. Max, Min and Conf.
log("limits:down-max:down-min:down-conf:up-max:up-min:up-conf");
StringBuffer msg = new StringBuffer();
msg.append("limits:");
msg.append(limitMonitor.getUploadMaxLimit()).append(":");
msg.append(limitMonitor.getUploadMinLimit()).append(":");
msg.append(limitMonitor.getUploadConfidence()).append(":");
msg.append(limitMonitor.getDownloadMaxLimit()).append(":");
msg.append(limitMonitor.getDownloadMinLimit()).append(":");
msg.append(limitMonitor.getDownloadConfidence());
SpeedManagerLogger.log( msg.toString() );
|
private void | logNewLimits(SMUpdate update)
if( update.hasNewUploadLimit ){
int kbpsUpoadLimit = update.newUploadLimit/1024;
log(" new up limit : "+ kbpsUpoadLimit +" kb/s");
}
if( update.hasNewDownloadLimit ){
int kpbsDownloadLimit = update.newDownloadLimit/1024;
log(" new down limit: "+kpbsDownloadLimit+" kb/s");
}
|
public void | pingSourceFailed(com.aelitis.azureus.core.speedmanager.SpeedManagerPingSource source)Ping source has failed
//Where does the vivaldi data for the chart come from.
log("pingSourceFailed");
pingSourceManager.pingSourceFailed(source);
|
public void | pingSourceFound(com.aelitis.azureus.core.speedmanager.SpeedManagerPingSource source, boolean is_replacement)Called when a new source of ping times has been found
//We might not use ping source if the vivaldi data is available.
log("pingSourceFound");
//add a new ping source to the list.
pingSourceManager.pingSourceFound(source, is_replacement);
|
public void | reset()Reset any state to start of day values
log("reset");
log("curr-data-m: curr-down-rate : curr-down-limit : down-capacity : down-bandwith-mode : down-limit-mode : curr-up-rate : curr-up-limit : up-capacity : upload-bandwidth-mode : upload-limit-mode : transfer-mode");
log("new-limit:newLimit:currStep:signalStrength:multiple:currUpLimit:maxStep:uploadLimitMax:uploadLimitMin:transferMode" );
log("consecutive:up:down");
log("metric:value:type");
log("user-comment:log");
log("pin:upload-status,download-status,upload-unpin-timer,download-unpin-timer");
log("limits:down-max:down-min:down-conf:up-max:up-min:up-conf");
limitMonitor.resetPingSpace();
|
private void | setNewLimits(SMUpdate update)Just update the limits.
adapter.setCurrentUploadLimit( update.newUploadLimit );
adapter.setCurrentDownloadLimit( update.newDownloadLimit );
|
public void | updateStats()Called periodically (see period above) to allow stats to be updated.
//update some stats used in the UI.
int currUploadLimit = adapter.getCurrentUploadLimit();
int currDataUploadSpeed = adapter.getCurrentDataUploadSpeed();
int currProtoUploadSpeed = adapter.getCurrentProtocolUploadSpeed();
int upRateBitsPerSec = currDataUploadSpeed + currProtoUploadSpeed;
int currDownLimit = adapter.getCurrentDownloadLimit();
int downDataRate = adapter.getCurrentDataDownloadSpeed();
int downProtoRate = adapter.getCurrentProtocolDownloadSpeed();
int downRateBitsPerSec = downDataRate+downProtoRate;
//update the bandwidth status
limitMonitor.setDownloadBandwidthMode(downRateBitsPerSec,currDownLimit);
limitMonitor.setUploadBandwidthMode(upRateBitsPerSec,currUploadLimit);
//update the limts status. (is it near a forced max or min?)
limitMonitor.setDownloadLimitSettingMode(currDownLimit);
limitMonitor.setUploadLimitSettingMode(currUploadLimit);
limitMonitor.updateTransferMode();
if( limitMonitor.isConfTestingLimits() ){
limitMonitor.updateLimitTestingData(downRateBitsPerSec,upRateBitsPerSec);
}
//update ping maps
limitMonitor.setCurrentTransferRates(downRateBitsPerSec,upRateBitsPerSec);
//only for the UI.
if( upRateBitsPerSec > sessionMaxUploadRate ){
sessionMaxUploadRate = upRateBitsPerSec;
}
//"curr-data" ....
logCurrentData(downRateBitsPerSec, currDownLimit, upRateBitsPerSec, currUploadLimit);
|