All Known Implementing Classes:
BandwidthManager, Peer, PeerCoordinator, WebPeer

public interface BandwidthListener
Bandwidth and bandwidth limits.

Maintain three bandwidth estimators: Sent, received, and requested.

  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    void
    downloaded(int size)
    Called when bytes are unconditionally received.
    long
    Returns the current download bandwidth limit in bytes per second.
    long
    Returns the average download rate in bytes per second.
    long
    Returns the current upload bandwidth limit in bytes per second.
    long
    Returns the average upload rate in bytes per second.
    boolean
    Checks if the current download bandwidth is over the limit.
    boolean
    Checks if the current upload bandwidth is over the limit.
    boolean
    shouldRequest(Peer peer, int size)
    Checks if we should request the given number of bytes from a peer.
    boolean
    shouldSend(int size)
    Checks if we should send the given number of bytes.
    void
    uploaded(int size)
    Called when bytes are unconditionally sent.
  • Method Details

    • getUploadRate

      long getUploadRate()
      Returns the average upload rate in bytes per second.
      Returns:
      the average upload rate in Bps
    • getDownloadRate

      long getDownloadRate()
      Returns the average download rate in bytes per second.
      Returns:
      the average download rate in Bps
    • uploaded

      void uploaded(int size)
      Called when bytes are unconditionally sent.
      Parameters:
      size - the number of bytes sent
    • downloaded

      void downloaded(int size)
      Called when bytes are unconditionally received.
      Parameters:
      size - the number of bytes received
    • shouldSend

      boolean shouldSend(int size)
      Checks if we should send the given number of bytes. Do NOT call uploaded(int) if this returns true.
      Parameters:
      size - the number of bytes to send
      Returns:
      true if the bytes should be sent, false otherwise
    • shouldRequest

      boolean shouldRequest(Peer peer, int size)
      Checks if we should request the given number of bytes from a peer.
      Parameters:
      peer - the peer the bytes would be requested from
      size - the number of bytes to request
      Returns:
      true if the request should be made, false otherwise
    • getUpBWLimit

      long getUpBWLimit()
      Returns the current upload bandwidth limit in bytes per second.
      Returns:
      the upload limit in Bps
    • getDownBWLimit

      long getDownBWLimit()
      Returns the current download bandwidth limit in bytes per second.
      Returns:
      the download limit in Bps
    • overUpBWLimit

      boolean overUpBWLimit()
      Checks if the current upload bandwidth is over the limit.
      Returns:
      true if over the upload limit, false otherwise
    • overDownBWLimit

      boolean overDownBWLimit()
      Checks if the current download bandwidth is over the limit.
      Returns:
      true if over the download limit, false otherwise