// Path: measures/src/main/java/io/apisense/network/Measurement.java
// public abstract class Measurement {
//   public final String taskName;
// 
//   protected Measurement(String taskName) {
//     this.taskName = taskName;
//   }
// 
//   /**
//    * Ensure that the measurement is asynchronously called in an {@link ExecutorService}.
//    *
//    * @param callback The {@link MeasurementCallback} used
//    *                 for reporting success or failure of this measurement.
//    */
//   public final void call(MeasurementCallback callback) {
//     AsyncTask.execute(new MeasurementExecutor(this, callback));
//   }
// 
//   /**
//    * Actual, synchronous, process of a measurement.
//    * This method has to be called from another thread than the UI one.
//    *
//    * @return The results of this measurement.
//    * @throws MeasurementError If anything goes wrong during measurement.
//    */
//   public abstract MeasurementResult execute() throws MeasurementError;
// }
// 
// Path: measures/src/main/java/io/apisense/network/MeasurementError.java
// public class MeasurementError extends Exception {
//   public final String taskName;
// 
//   public MeasurementError(String taskName, String reason) {
//     super(reason);
//     this.taskName = taskName;
//   }
// 
//   public MeasurementError(String taskName, String reason, Throwable e) {
//     super(reason, e);
//     this.taskName = taskName;
//   }
// 
//   public MeasurementError(String taskName, Exception e) {
//     this(taskName, e.getMessage(), e);
//   }
// }


import android.support.annotation.NonNull;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;
import io.apisense.network.Measurement;
import io.apisense.network.MeasurementError;
package io.apisense.network.udp;




/**
 * Abstract class containing common code used for UDP upload and download tests
 */
public abstract class UDPBurstTask extends Measurement {
  protected static final int DEFAULT_PORT = 31341;

  /**
   * round-trip delay, in msec.
   */
  protected static final int RCV_TIMEOUT = 2000;

  protected long startTimeTask; //time in milliseconds
  protected long endTimeTask; //time in milliseconds

  protected UDPBurstConfig config;


  public UDPBurstTask(String taskName, UDPBurstConfig udpBurstConfig) {
    super(taskName);
    this.config = udpBurstConfig;
  }

  /**
   * Wait for the socket to retrieve a response to the previous burst.
   *
   * @param sock The socket to listen through.
   * @return An {@link UDPPacket} containing the response.
   * @throws MeasurementError If any error occurred during measurement.
   */
  @NonNull
// Path: measures/src/main/java/io/apisense/network/Measurement.java
// public abstract class Measurement {
//   public final String taskName;
// 
//   protected Measurement(String taskName) {
//     this.taskName = taskName;
//   }
// 
//   /**
//    * Ensure that the measurement is asynchronously called in an {@link ExecutorService}.
//    *
//    * @param callback The {@link MeasurementCallback} used
//    *                 for reporting success or failure of this measurement.
//    */
//   public final void call(MeasurementCallback callback) {
//     AsyncTask.execute(new MeasurementExecutor(this, callback));
//   }
// 
//   /**
//    * Actual, synchronous, process of a measurement.
//    * This method has to be called from another thread than the UI one.
//    *
//    * @return The results of this measurement.
//    * @throws MeasurementError If anything goes wrong during measurement.
//    */
//   public abstract MeasurementResult execute() throws MeasurementError;
// }
// 
// Path: measures/src/main/java/io/apisense/network/MeasurementError.java
// public class MeasurementError extends Exception {
//   public final String taskName;
// 
//   public MeasurementError(String taskName, String reason) {
//     super(reason);
//     this.taskName = taskName;
//   }
// 
//   public MeasurementError(String taskName, String reason, Throwable e) {
//     super(reason, e);
//     this.taskName = taskName;
//   }
// 
//   public MeasurementError(String taskName, Exception e) {
//     this(taskName, e.getMessage(), e);
//   }
// }


// Path: measures/src/main/java/io/apisense/network/udp/UDPBurstTask.java
import android.support.annotation.NonNull;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;
import io.apisense.network.Measurement;
import io.apisense.network.MeasurementError;

package io.apisense.network.udp;




/**
 * Abstract class containing common code used for UDP upload and download tests
 */
public abstract class UDPBurstTask extends Measurement {
  protected static final int DEFAULT_PORT = 31341;

  /**
   * round-trip delay, in msec.
   */
  protected static final int RCV_TIMEOUT = 2000;

  protected long startTimeTask; //time in milliseconds
  protected long endTimeTask; //time in milliseconds

  protected UDPBurstConfig config;


  public UDPBurstTask(String taskName, UDPBurstConfig udpBurstConfig) {
    super(taskName);
    this.config = udpBurstConfig;
  }

  /**
   * Wait for the socket to retrieve a response to the previous burst.
   *
   * @param sock The socket to listen through.
   * @return An {@link UDPPacket} containing the response.
   * @throws MeasurementError If any error occurred during measurement.
   */
  @NonNull
  protected UDPPacket retrieveResponseDatagram(DatagramSocket sock) throws MeasurementError {