Class 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.
    • Field Detail

      • lastDownloadBitsPerSec

        int lastDownloadBitsPerSec
      • lastUploadBitsPerSec

        int lastUploadBitsPerSec
      • goodPingInMilliSec

        final int goodPingInMilliSec
      • badPingInMilliSec

        final int badPingInMilliSec
      • totalPointsInMap

        int totalPointsInMap
    • Constructor Detail

      • PingSpaceMapper

        public PingSpaceMapper​(int _goodPingInMilliSec,
                               int _badPingInMilliSec)
        Create a grid and define good and bad ping times.
        Parameters:
        _goodPingInMilliSec - -
        _badPingInMilliSec - -
    • 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.
      • 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:
        -