Class SpeedLimitMonitor
java.lang.Object
com.biglybt.core.speedmanager.impl.v2.SpeedLimitMonitor
- All Implemented Interfaces:
PSMonitorListener
This class is responsible for re-adjusting the limits used by AutoSpeedV2.
This class will keep track of the "status" (i.e. seeding, downloading)of the
application. It will then re-adjust the MAX limits when it thinks limits
are being reached.
Here are the rules it will use.
#1) When seeding. If the upload is AT_LIMIT for a period of time it will allow
that to adjust upward.
#2) When downloading. If the download is AT_LIMIT for a period of time it will
allow that to adjust upward.
#3) When downloading, if a down-tick is detected and the upload is near a limit,
it will drop the upload limit to 80% of MAX_UPLOAD.
#4) Once that limit is reached it will drop both the upload and download limits together.
#5) Seeding mode is triggered when - download bandwidth at LOW - compared to CAPACITY for 5 minutes continuously.
#6) Download mode is triggered when - download bandwidth reaches MEDIUM - compared to CURRENT_LIMIT for the first time.
Rules #5 and #6 favor downloading over seeding.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate longprivate longprivate static final longprivate booleanstatic final Stringprivate longprivate SaturatedModeprivate SpeedLimitConfidenceprivate longprivate longprivate SaturatedModeprivate longprivate longprivate booleanprivate boolean(package private) final PingSpaceMonprivate float(package private) final SpeedLimitListener(package private) PingSpaceMapper(package private) PingSpaceMapperprivate longprivate longprivate longprivate long(package private) final LimitControlprivate static final longprivate final TransferMode(package private) SpeedManagerPingMapperstatic final Stringstatic final Stringprivate longprivate SaturatedModeprivate intprivate SpeedLimitConfidenceprivate longprivate longprivate SaturatedModeprivate intstatic final Stringstatic final String(package private) boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToPingMapData(int lastMetricValue) adjustLimitsToSpec(long currUploadLimit, long currDownloadLimit) It is likely the user adjusted the "line speed capacity" on the configuration panel.booleanareSettingsInSpec(long currUploadLimit, long currDownloadLimit) If the user changes the line capacity settings on the configuration panel and adjustment needs to occur even if the signal is NO-CHANGE-NEEDED.booleanTrue if both are at limits.booleanAre both the upload and download bandwidths usages is low? Otherwise false.booleanvoidbetaLogPingMapperEstimates(String name, SpeedManagerLimitEstimate transEst, boolean hadChockPing, SpeedManagerLimitEstimate permEst, PingSpaceMapper downMode, PingSpaceMapper seedMode) This is a lot of data, but is important debug info.calculateNewUnpinnedLimits(float signalStrength) private longcalculateUnpinnedStepSize(long currLimitMax) If setting is less then 100kBytes take 1 kByte steps.private SMUpdateIf a progressive download is currently active.voidMake a decision about unpinning either the upload or download limit.private longchoseBestLimit(SpeedManagerLimitEstimate estimate, long currMaxLimit, SpeedLimitConfidence currConf) After a test is complete determine how condifent the client should be in it based on how different it is from the previous result.Call this method to end the limit testing.endLimitTesting(long downloadCapacityGuess, long uploadCapacityGuess) longlonglonglonglonglongbooleanShould return true if had a recent chocking ping.voidvoidinitPingSpaceMap(int maxGoodPing, int minBadPing) booleanbooleanReturn true if we are confidence testing the limits.booleanbooleanDetermine if we have low confidence in this limit.booleanprivate booleanThe criteria for download being unlimited is if the ConfigPanel has the "download == 0 " invalid input: '&'invalid input: '&' "type==fixed"booleanbooleanTrue if the upload bandwidth usage is HIGH or AT_LIMIT.booleanbooleanprotected voidvoidJust log this data until we decide if it is useful.private voidLog debug info needed during beta period.private voidlogPMData(long oRate, SpeedLimitConfidence oConf, long nRate, float nConf, String type) voidmodifyLimits(float signalStrength, float multiple, long currUpLimit, long currDownLimit) Does the same as createNewLimit except it drops the upload rate first when in download mode.voidnotifyDownload(SpeedManagerLimitEstimate estimate) voidIf we have a down-tick signal then resetTimer all the counters for increasing the limits.voidnotifyUpload(SpeedManagerLimitEstimate estimate) rampTestingLimit(long uploadLimit, long downloadLimit) Ramp the upload and download rates higher, so ping-times are relevant.voidreplaces - updateFromCOConfigManager()void(package private) void(package private) voidresetPinSearch(SpeedManagerLimitEstimate estimate) voidvoidsetCurrentTransferRates(long downRate, long upRate) voidsetDownloadBandwidthMode(long rate, long limit) voidsetDownloadLimitSettingMode(long currLimit) voidsetRefLimits(long uploadMax, long downloadMax) voidsetRefLimits(SpeedManagerLimitEstimate estUp, SpeedManagerLimitEstimate estDown) Make some choices about how usable the limits are before passing them on.voidsetUploadBandwidthMode(long rate, long limit) voidsetUploadLimitSettingMode(long currLimit) startLimitTesting(long currUploadLimit, long currDownloadLimit) Call this method to start the limit testing.private voidvoidvoidvoidupdateLimitTestingData(long downloadRate, long uploadRate) voidupdateLimitTestingPing(float lastMetric) New metric from the PingMapper is value between -1.0 and +1.0f.voidupdateLimitTestingPing(int lastMetric) Convert raw ping value to new metric.voidSplitting the limits our from other setting for SpeedManagerAlgorithmTI.void
-
Field Details
-
uploadLimitMax
private long uploadLimitMax -
uploadLimitMin
private long uploadLimitMin -
downloadLimitMax
private long downloadLimitMax -
downloadLimitMin
private long downloadLimitMin -
transferMode
-
uploadBandwidthStatus
-
downloadBandwidthStatus
-
uploadLimitSettingStatus
-
downloadLimitSettingStatus
-
uploadLimitConf
-
downloadLimitConf
-
clLastIncreaseTime
private long clLastIncreaseTime -
clFirstBadPingTime
private long clFirstBadPingTime -
currTestDone
private boolean currTestDone -
beginLimitTest
private boolean beginLimitTest -
highestUploadRate
private long highestUploadRate -
highestDownloadRate
private long highestDownloadRate -
preTestUploadCapacity
private long preTestUploadCapacity -
preTestUploadLimit
private long preTestUploadLimit -
preTestDownloadCapacity
private long preTestDownloadCapacity -
preTestDownloadLimit
private long preTestDownloadLimit -
UPLOAD_CONF_LIMIT_SETTING
- See Also:
-
DOWNLOAD_CONF_LIMIT_SETTING
- See Also:
-
UPLOAD_CHOKE_PING_COUNT
- See Also:
-
CONF_LIMIT_TEST_LENGTH
private static final long CONF_LIMIT_TEST_LENGTH- See Also:
-
isUploadMaxPinned
private boolean isUploadMaxPinned -
isDownloadMaxPinned
private boolean isDownloadMaxPinned -
uploadAtLimitStartTime
private long uploadAtLimitStartTime -
downloadAtLimitStartTime
private long downloadAtLimitStartTime -
uploadChokePingCount
private int uploadChokePingCount -
uploadPinCounter
private int uploadPinCounter -
TIME_AT_LIMIT_BEFORE_UNPINNING
private static final long TIME_AT_LIMIT_BEFORE_UNPINNING- See Also:
-
USED_UPLOAD_CAPACITY_DOWNLOAD_MODE
- See Also:
-
USED_UPLOAD_CAPACITY_SEEDING_MODE
- See Also:
-
percentUploadCapacityDownloadMode
private float percentUploadCapacityDownloadMode -
pingMapOfDownloadMode
PingSpaceMapper pingMapOfDownloadMode -
pingMapOfSeedingMode
PingSpaceMapper pingMapOfSeedingMode -
useVariancePingMap
boolean useVariancePingMap -
transientPingMap
SpeedManagerPingMapper transientPingMap -
longTermMonitor
-
slider
-
persistentMapListener
-
-
Constructor Details
-
SpeedLimitMonitor
-
-
Method Details
-
updateSettingsFromCOConfigManager
public void updateSettingsFromCOConfigManager()Splitting the limits our from other setting for SpeedManagerAlgorithmTI. -
updateFromCOConfigManager
public void updateFromCOConfigManager() -
readFromPersistentMap
public void readFromPersistentMap()replaces - updateFromCOConfigManager() -
saveToCOConfiguration
public void saveToCOConfiguration() -
logPMData
private void logPMData(long oRate, SpeedLimitConfidence oConf, long nRate, float nConf, String type) -
logPMDataEx
public void logPMDataEx() -
isSettingDownloadUnlimited
private boolean isSettingDownloadUnlimited()The criteria for download being unlimited is if the ConfigPanel has the "download == 0 " invalid input: '&'invalid input: '&' "type==fixed"- Returns:
- - true
-
setDownloadBandwidthMode
public void setDownloadBandwidthMode(long rate, long limit) -
setUploadBandwidthMode
public void setUploadBandwidthMode(long rate, long limit) -
setDownloadLimitSettingMode
public void setDownloadLimitSettingMode(long currLimit) -
setUploadLimitSettingMode
public void setUploadLimitSettingMode(long currLimit) -
getUploadMaxLimit
public long getUploadMaxLimit() -
getDownloadMaxLimit
public long getDownloadMaxLimit() -
getUploadMinLimit
public long getUploadMinLimit() -
getDownloadMinLimit
public long getDownloadMinLimit() -
getUploadConfidence
-
getDownloadConfidence
-
getDownloadBandwidthMode
-
getUploadBandwidthMode
-
getDownloadLimitSettingMode
-
getUploadLimitSettingMode
-
updateTransferMode
public void updateTransferMode() -
getTransferModeAsString
-
getTransferMode
-
bandwidthUsageLow
public boolean bandwidthUsageLow()Are both the upload and download bandwidths usages is low? Otherwise false.- Returns:
- -
-
bandwidthUsageMedium
public boolean bandwidthUsageMedium()- Returns:
- -
-
bandwidthUsageAtLimit
public boolean bandwidthUsageAtLimit()True if both are at limits.- Returns:
- - true only if both the upload and download usages are at the limits.
-
isUploadBandwidthUsageHigh
public boolean isUploadBandwidthUsageHigh()True if the upload bandwidth usage is HIGH or AT_LIMIT.- Returns:
- -
-
isEitherLimitUnpinned
public boolean isEitherLimitUnpinned() -
modifyLimits
public SMUpdate modifyLimits(float signalStrength, float multiple, long currUpLimit, long currDownLimit) Does the same as createNewLimit except it drops the upload rate first when in download mode.- Parameters:
signalStrength- -multiple- -currUpLimit- -currDownLimit- -- Returns:
- -
-
checkActiveProgressiveDownloadLimit
-
logPinningInfo
private void logPinningInfo()Log debug info needed during beta period. -
calculateNewUnpinnedLimits
- Parameters:
signalStrength- -- Returns:
- -
-
calculateUnpinnedStepSize
private long calculateUnpinnedStepSize(long currLimitMax) If setting is less then 100kBytes take 1 kByte steps. If setting is less then 500kBytes take 5 kByte steps. if setting is larger take 10 kBytes steps.- Parameters:
currLimitMax- - current limit setting.- Returns:
- - set size for next change.
-
checkForUnpinningCondition
public void checkForUnpinningCondition()Make a decision about unpinning either the upload or download limit. This is based on the time we are saturating the limit without a down-tick signal. -
notifyOfDownSignal
public void notifyOfDownSignal()If we have a down-tick signal then resetTimer all the counters for increasing the limits. -
resetPinSearch
void resetPinSearch() -
resetPinSearch
-
isConfTestingLimits
public boolean isConfTestingLimits()Return true if we are confidence testing the limits.- Returns:
- - SMUpdate
-
isDownloadConfidenceLow
public boolean isDownloadConfidenceLow()Determine if we have low confidence in this limit.- Returns:
- - true if the confidence setting is LOW or NONE. Otherwise return true.
-
isUploadConfidenceLow
public boolean isUploadConfidenceLow() -
isDownloadConfidenceAbsolute
public boolean isDownloadConfidenceAbsolute() -
isUploadConfidenceAbsolute
public boolean isUploadConfidenceAbsolute() -
updateLimitTestingData
public void updateLimitTestingData(long downloadRate, long uploadRate) - Parameters:
downloadRate- - currentUploadRate in bytes/secuploadRate- - currentUploadRate in bytes/sec
-
updateLimitTestingPing
public void updateLimitTestingPing(int lastMetric) Convert raw ping value to new metric.- Parameters:
lastMetric- -
-
updateLimitTestingPing
public void updateLimitTestingPing(float lastMetric) New metric from the PingMapper is value between -1.0 and +1.0f.- Parameters:
lastMetric- -
-
startLimitTesting
Call this method to start the limit testing.- Parameters:
currUploadLimit- -currDownloadLimit- -- Returns:
- - SMUpdate
-
rampTestingLimit
Ramp the upload and download rates higher, so ping-times are relevant.- Parameters:
uploadLimit- -downloadLimit- -- Returns:
- -
-
triggerLimitTestingFlag
public void triggerLimitTestingFlag() -
isStartLimitTestFlagSet
public boolean isStartLimitTestFlagSet() -
isConfLimitTestFinished
public boolean isConfLimitTestFinished() -
endLimitTesting
-
endLimitTesting
-
determineConfidenceLevel
After a test is complete determine how condifent the client should be in it based on how different it is from the previous result. If the new result is within 20% of the old result then give it a MED. If it is great then give it a LOW.- Returns:
- - what the new confidence interval should be.
-
areSettingsInSpec
public boolean areSettingsInSpec(long currUploadLimit, long currDownloadLimit) If the user changes the line capacity settings on the configuration panel and adjustment needs to occur even if the signal is NO-CHANGE-NEEDED. Test for that condition here.- Parameters:
currUploadLimit- - reported upload capacity from the adaptercurrDownloadLimit- - reported download capacity from the adapter.- Returns:
- - true if the "capacity" is lower then the current limit.
-
choseBestLimit
private long choseBestLimit(SpeedManagerLimitEstimate estimate, long currMaxLimit, SpeedLimitConfidence currConf) -
setRefLimits
Make some choices about how usable the limits are before passing them on.- Parameters:
estUp- -estDown- -
-
setRefLimits
public void setRefLimits(long uploadMax, long downloadMax) -
adjustLimitsToSpec
It is likely the user adjusted the "line speed capacity" on the configuration panel. We need to adjust the current limits down to adjust.- Parameters:
currUploadLimit- -currDownloadLimit- -- Returns:
- - Updates as needed.
-
log
-
initPingSpaceMap
public void initPingSpaceMap(int maxGoodPing, int minBadPing) -
initPingSpaceMap
public void initPingSpaceMap() -
betaLogPingMapperEstimates
public void betaLogPingMapperEstimates(String name, SpeedManagerLimitEstimate transEst, boolean hadChockPing, SpeedManagerLimitEstimate permEst, PingSpaceMapper downMode, PingSpaceMapper seedMode) This is a lot of data, but is important debug info.- Parameters:
name- -transEst- -hadChockPing- -permEst- -downMode- -seedMode- -
-
guessDownloadLimit
public long guessDownloadLimit() -
guessUploadLimit
public long guessUploadLimit() -
hadChockingPing
public boolean hadChockingPing()Should return true if had a recent chocking ping.- Returns:
- - true if
-
logPingMapData
public void logPingMapData()Just log this data until we decide if it is useful. -
setCurrentTransferRates
public void setCurrentTransferRates(long downRate, long upRate) -
resetPingSpace
public void resetPingSpace() -
addToPingMapData
public void addToPingMapData(int lastMetricValue) -
notifyUpload
- Specified by:
notifyUploadin interfacePSMonitorListener
-
notifyDownload
- Specified by:
notifyDownloadin interfacePSMonitorListener
-
tempLogEstimate
-