- fix doxygen
[oweals/gnunet.git] / src / ats / gnunet-service-ats_addresses_mlp.h
index d4ae089b42b97b0619e2998c0c7211d3356e64f5..8f60a8598954d9968ec34ad77acc4af11df187b5 100644 (file)
@@ -36,6 +36,8 @@
 
 #define DEBUG_MLP GNUNET_EXTRA_LOGGING
 
+#define MLP_AVERAGING_QUEUE_LENGTH 3
+
 #define MLP_MAX_EXEC_DURATION   GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3)
 #define MLP_MAX_ITERATIONS      INT_MAX
 
@@ -61,6 +63,13 @@ struct ATS_Peer
   struct ATS_Address *tail;
 };
 
+struct ATS_PreferedAddress
+{
+  uint32_t bandwidth_out;
+  uint32_t bandwidth_in;
+  struct ATS_Address *address;
+};
+
 /**
  * MLP Handle
  */
@@ -112,6 +121,13 @@ struct GAS_MLP_Handle
    */
   unsigned int max_iterations;
 
+  /**
+   * Solve the problem automatically when updates occur?
+   * Default: GNUNET_YES
+   * Can be disabled for test and measurements
+   */
+  int auto_solve;
+
   /* state information */
 
   /**
@@ -216,6 +232,13 @@ struct GAS_MLP_Handle
   /* number of quality metrics */
   int m_q;
 
+  /* ATS network quotas */
+  int c_quota[GNUNET_ATS_NetworkTypeCount];
+  int r_quota[GNUNET_ATS_NetworkTypeCount];
+  int quota_index [GNUNET_ATS_NetworkTypeCount];
+  unsigned long long quota_out[GNUNET_ATS_NetworkTypeCount];
+  unsigned long long quota_in[GNUNET_ATS_NetworkTypeCount];
+
   /* ATS ressource costs
    *
    * array with GNUNET_ATS_QualityPropertiesCount elements
@@ -244,6 +267,10 @@ struct GAS_MLP_Handle
  */
 struct MLP_information
 {
+  double b;
+
+  int n;
+
   /* bandwidth column index */
   signed int c_b;
 
@@ -257,6 +284,18 @@ struct MLP_information
 
   /* constraint 3: minimum bandwidth */
   unsigned int r_c3;
+
+  /* Quality information row indices */
+  unsigned int r_q[GNUNET_ATS_QualityPropertiesCount];
+
+  /* Quality information */
+  double q[GNUNET_ATS_QualityPropertiesCount][MLP_AVERAGING_QUEUE_LENGTH];
+
+  /* Quality information averaged */
+  double q_averaged[GNUNET_ATS_QualityPropertiesCount];
+
+  /* Averaging index */
+  int q_avg_i[GNUNET_ATS_QualityPropertiesCount];
 };
 
 
@@ -275,6 +314,15 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
               struct GNUNET_TIME_Relative max_duration,
               unsigned int max_iterations);
 
+/**
+ * Solves the MLP problem on demand
+ *
+ * @param mlp the MLP Handle
+ * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure
+ */
+int
+GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp);
+
 
 /**
  * Updates a single address in the MLP problem
@@ -314,7 +362,7 @@ GAS_mlp_address_delete (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult
  * @param mlp the MLP Handle
  * @param peer the peer
  * @param kind the kind to change the preference
- * @param float the score
+ * @param score the score
  */
 void
 GAS_mlp_address_change_preference (struct GAS_MLP_Handle *mlp,
@@ -323,6 +371,19 @@ GAS_mlp_address_change_preference (struct GAS_MLP_Handle *mlp,
                                    float score);
 
 
+/**
+ * Get the preferred address for a specific peer
+ *
+ * @param mlp the MLP Handle
+ * @param addresses address hashmap
+ * @param peer the peer
+ * @return suggested address
+ */
+struct ATS_PreferedAddress *
+GAS_mlp_get_preferred_address (struct GAS_MLP_Handle *mlp,
+                               struct GNUNET_CONTAINER_MultiHashMap * addresses,
+                               const struct GNUNET_PeerIdentity *peer);
+
 /**
  * Shutdown the MLP problem solving component
  */