fixing resource leaks
[oweals/gnunet.git] / src / ats / gnunet-ats-solver-eval.h
index 0b30fead74356bcfcdaff9a27b72cb6f1064cbb9..ab62f50001ed1645021d616728907504d3a5c5fb 100644 (file)
@@ -23,6 +23,8 @@
  * @author Christian Grothoff
  * @author Matthias Wachs
  */
+#ifndef GNUNET_ATS_SOLVER_EVAL_H
+#define GNUNET_ATS_SOLVER_EVAL_H
 #include "platform.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_ats_plugin.h"
@@ -47,7 +49,71 @@ enum OperationType
   SOLVER_OP_START_SET_PROPERTY,
   SOLVER_OP_STOP_SET_PROPERTY,
   SOLVER_OP_START_SET_PREFERENCE,
-  SOLVER_OP_STOP_SET_PREFERENCE
+  SOLVER_OP_STOP_SET_PREFERENCE,
+  SOLVER_OP_START_REQUEST,
+  SOLVER_OP_STOP_REQUEST,
+};
+
+struct SolverHandle
+{
+  /**
+   * Solver plugin name
+   */
+  char *plugin;
+
+  /**
+   * Solver environment
+   */
+  struct GNUNET_ATS_PluginEnvironment env;
+
+  /**
+   * Solver handle
+   */
+  void *solver;
+
+  /**
+   * Address hashmap
+   */
+  struct GNUNET_CONTAINER_MultiPeerMap *addresses;
+};
+
+enum GNUNET_ATS_Solvers
+{
+  GNUNET_ATS_SOLVER_PROPORTIONAL,
+  GNUNET_ATS_SOLVER_MLP,
+  GNUNET_ATS_SOLVER_RIL,
+};
+
+
+struct LoggingTimeStep
+{
+  struct LoggingTimeStep *prev;
+  struct LoggingTimeStep *next;
+
+  struct GNUNET_TIME_Absolute timestamp;
+};
+
+
+struct TestPeer
+{
+  struct TestPeer *prev;
+  struct TestPeer *next;
+
+  int id;
+  struct GNUNET_PeerIdentity peer_id;
+
+  struct TestAddress *addr_head;
+  struct TestAddress *addr_tail;
+};
+
+
+struct TestAddress
+{
+  struct TestAddress *next;
+  struct TestAddress *prev;
+
+  int aid;
+  struct ATS_Address *ats_addr;
 };
 
 struct Episode;
@@ -70,19 +136,22 @@ struct GNUNET_ATS_TEST_Operation
 
   long long unsigned int address_id;
   long long unsigned int peer_id;
+  long long unsigned int client_id;
   long long unsigned int address_session;
   long long unsigned int address_network;
   char*address;
   char*plugin;
 
+
   long long unsigned int base_rate;
   long long unsigned int max_rate;
   struct GNUNET_TIME_Relative period;
   struct GNUNET_TIME_Relative frequency;
 
   enum OperationType type;
-  enum GeneratorType tg_type;
+  enum GeneratorType gen_type;
   enum GNUNET_ATS_PreferenceKind pref_type;
+  enum GNUNET_ATS_Property prop_type;
 };
 
 struct Episode
@@ -95,13 +164,20 @@ struct Episode
   struct GNUNET_ATS_TEST_Operation *tail;
 };
 
+struct LoggingHandle
+{
+  GNUNET_SCHEDULER_TaskIdentifier logging_task;
+  struct GNUNET_TIME_Relative log_freq;
+
+  struct LoggingTimeStep *head;
+
+  struct LoggingTimeStep *tail;
+};
 
 struct Experiment
 {
   char *name;
   char *cfg_file;
-  unsigned long long int num_masters;
-  unsigned long long int num_slaves;
   struct GNUNET_TIME_Relative log_freq;
   struct GNUNET_TIME_Relative max_duration;
   struct GNUNET_TIME_Relative total_duration;
@@ -119,246 +195,55 @@ struct Experiment
   GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb;
 };
 
-
-/**
- * A single logging time step for a partner
- */
-struct PartnerLoggingTimestep
+struct PreferenceGenerator
 {
-  /**
-   * Peer
-   */
-  struct BenchmarkPeer *slave;
-
-  /**
-   * Total number of messages this peer has sent
-   */
-  unsigned int total_messages_sent;
-
-  /**
-   * Total number of bytes this peer has sent
-   */
-  unsigned int total_bytes_sent;
-
-  /**
-   * Total number of messages this peer has received
-   */
-  unsigned int total_messages_received;
-
-  /**
-   * Total number of bytes this peer has received
-   */
-  unsigned int total_bytes_received;
-
-  /**
-   * Total outbound throughput for master in Bytes / s
-   */
-  unsigned int throughput_sent;
-
-  /**
-   * Total inbound throughput for master in Bytes / s
-   */
-  unsigned int throughput_recv;
-
-  /**
-   * Accumulated RTT for all messages
-   */
-  unsigned int total_app_rtt;
-
-  /**
-   * Current application level delay
-   */
-  unsigned int app_rtt;
-
-  /* Current ATS properties */
-
-  uint32_t ats_distance;
-
-  uint32_t ats_delay;
-
-  uint32_t bandwidth_in;
-
-  uint32_t bandwidth_out;
-
-  uint32_t ats_utilization_up;
-
-  uint32_t ats_utilization_down;
+  struct PreferenceGenerator *prev;
+  struct PreferenceGenerator *next;
 
-  uint32_t ats_network_type;
+  enum GeneratorType type;
 
-  uint32_t ats_cost_wan;
+  unsigned int peer;
+  unsigned int address_id;
+  unsigned int client_id;
 
-  uint32_t ats_cost_lan;
+  enum GNUNET_ATS_PreferenceKind kind;
 
-  uint32_t ats_cost_wlan;
+  long int base_value;
+  long int max_value;
+  struct GNUNET_TIME_Relative duration_period;
+  struct GNUNET_TIME_Relative frequency;
 
-  double pref_bandwidth;
-  double pref_delay;
+  GNUNET_SCHEDULER_TaskIdentifier set_task;
+  struct GNUNET_TIME_Absolute next_ping_transmission;
+  struct GNUNET_TIME_Absolute time_start;
 };
 
 
-/**
- * A single logging time step for a peer
- */
-struct PeerLoggingTimestep
-{
-  /**
-   * Next in DLL
-   */
-  struct PeerLoggingTimestep *next;
-
-  /**
-   * Prev in DLL
-   */
-  struct PeerLoggingTimestep *prev;
-
-  /**
-   * Logging timestamp
-   */
-  struct GNUNET_TIME_Absolute timestamp;
-
-  /**
-   * Total number of messages this peer has sent
-   */
-  unsigned int total_messages_sent;
-
-  /**
-   * Total number of bytes this peer has sent
-   */
-  unsigned int total_bytes_sent;
-
-  /**
-   * Total number of messages this peer has received
-   */
-  unsigned int total_messages_received;
-
-  /**
-   * Total number of bytes this peer has received
-   */
-  unsigned int total_bytes_received;
-
-  /**
-   * Total outbound throughput for master in Bytes / s
-   */
-  unsigned int total_throughput_send;
-
-  /**
-   * Total inbound throughput for master in Bytes / s
-   */
-  unsigned int total_throughput_recv;
-
-  /**
-   * Logs for slaves
-   */
-  struct PartnerLoggingTimestep *slaves_log;
-};
-
-/**
- * Entry for a benchmark peer
- */
-struct LoggingPeer
+struct PropertyGenerator
 {
-  /**
-   * Peer
-   */
-  struct BenchmarkPeer *peer;
+  struct PropertyGenerator *prev;
+  struct PropertyGenerator *next;
 
-  /**
-   * Start time
-   */
-  struct GNUNET_TIME_Absolute start;
-
-  /**
-   * DLL for logging entries: head
-   */
-  struct PeerLoggingTimestep *head;
-
-  /**
-   * DLL for logging entries: tail
-   */
-  struct PeerLoggingTimestep *tail;
-};
+  enum GeneratorType type;
 
+  unsigned int peer;
+  unsigned int address_id;
 
-struct LoggingHandle
-{
-  /**
-   * Logging task
-   */
-  GNUNET_SCHEDULER_TaskIdentifier log_task;
+  struct TestPeer *test_peer;
+  struct TestAddress *test_address;
+  uint32_t ats_property;
 
-  /**
-   * Reference to perf_ats' masters
-   */
-  int num_masters;
-  int num_slaves;
-  int running;
-  int verbose;
-  char *name;
+  long int base_value;
+  long int max_value;
+  struct GNUNET_TIME_Relative duration_period;
   struct GNUNET_TIME_Relative frequency;
 
-  /**
-   * Log structure of length num_peers
-   */
-  struct LoggingPeer *lp;
+  GNUNET_SCHEDULER_TaskIdentifier set_task;
+  struct GNUNET_TIME_Absolute next_ping_transmission;
+  struct GNUNET_TIME_Absolute time_start;
 };
 
 
-/**
- * Start logging
- *
- * @param log_frequency the logging frequency
- * @param testname the testname
- * @param masters the master peers used for benchmarking
- * @param num_master the number of master peers
- * @return the logging handle or NULL on error
- */
-struct LoggingHandle *
-GNUNET_ATS_TEST_logging_start(struct GNUNET_TIME_Relative log_frequency,
-    char *testname, struct BenchmarkPeer *masters, int num_masters, int num_slaves,
-    int verbose);
-
-/**
- * Stop logging
- *
- * @param l the logging handle
- */
-void
-GNUNET_ATS_TEST_logging_clean_up (struct LoggingHandle *l);
-
-/**
- * Stop logging
- *
- * @param l the logging handle
- */
-void
-GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l);
-
-/**
- * Log all data now
- *
- * @param l logging handle to use
- */
-void
-GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l);
-
-
-/**
- * Write logging data to file
- *
- * @param l logging handle to use
- * @param test_name name of the current test
- * @param plots create gnuplots: GNUNET_YES or GNUNET_NO
- */
-void
-GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l,
-    char *test_name, int plots);
-
-
-
-
-
-
 /* LEGACY */
 
 #if 0
@@ -415,7 +300,7 @@ typedef void (*GNUNET_ATS_TEST_TopologySetupDoneCallback) (void *cls,
  */
 typedef void
 (*GNUNET_ATS_TEST_LogRequest) (void *cls,
-    const struct GNUNET_HELLO_Address *address,
+    const struct GNUNET_HELLO_Address *address_id,
     int address_active,
     struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
     struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
@@ -927,4 +812,5 @@ GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file,
 void
 GNUNET_ATS_TEST_shutdown_topology (void);
 #endif
+#endif /* #ifndef GNUNET_ATS_SOLVER_EVAL_H */
 /* end of file ats-testing.h */