GNUnet  0.10.x
Macros | Functions | Variables
gnunet-ats-solver-eval.c File Reference
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet-ats-solver-eval.h"
#include "gnunet-service-ats_normalization.h"
#include "gnunet-service-ats_preferences.c"
Include dependency graph for gnunet-ats-solver-eval.c:

Go to the source code of this file.

Macros

#define BIG_M_STRING   "unlimited"
 

Functions

static void end_now ()
 Do shutdown. More...
 
static char * print_generator_type (enum GeneratorType g)
 
static struct TestPeerfind_peer_by_id (int id)
 
static struct TestPeerfind_peer_by_pid (const struct GNUNET_PeerIdentity *pid)
 
static struct TestAddressfind_address_by_id (struct TestPeer *peer, int aid)
 
void GNUNET_ATS_solver_logging_now (struct LoggingHandle *l)
 Logging. More...
 
static void logging_task (void *cls)
 
struct LoggingHandleGNUNET_ATS_solver_logging_start (struct GNUNET_TIME_Relative freq)
 
void GNUNET_ATS_solver_logging_stop (struct LoggingHandle *l)
 
static struct LoggingFileHandlefind_logging_file_handle (struct LoggingFileHandle *lf_head, struct LoggingFileHandle *lf_tail, int peer_id, int address_id)
 
void GNUNET_ATS_solver_logging_write_to_disk (struct LoggingHandle *l, int add_time_stamp, char *output_dir)
 
void GNUNET_ATS_solver_logging_eval (struct LoggingHandle *l)
 
void GNUNET_ATS_solver_logging_free (struct LoggingHandle *l)
 
static double get_property (struct PropertyGenerator *pg)
 
static void set_prop_task (void *cls)
 
static struct PropertyGeneratorfind_prop_gen (unsigned int peer, unsigned int address, uint32_t ats_property)
 Set ats_property to 0 to find all pgs. More...
 
void GNUNET_ATS_solver_generate_property_stop (struct PropertyGenerator *pg)
 
struct PropertyGeneratorGNUNET_ATS_solver_generate_property_start (unsigned int peer, unsigned int address_id, struct TestPeer *test_peer, struct TestAddress *test_address, enum GeneratorType type, long int base_value, long int value_rate, struct GNUNET_TIME_Relative period, struct GNUNET_TIME_Relative frequency, uint32_t ats_property)
 Generate between the source master and the partner and set property with a value depending on the generator. More...
 
void GNUNET_ATS_solver_generate_property_stop_all ()
 Stop all preferences generators. More...
 
static double get_preference (struct PreferenceGenerator *pg)
 
static void set_feedback_task (void *cls)
 
static void set_pref_task (void *cls)
 
static struct PreferenceGeneratorfind_pref_gen (unsigned int peer, enum GNUNET_ATS_PreferenceKind kind)
 
void GNUNET_ATS_solver_generate_preferences_stop (struct PreferenceGenerator *pg)
 
static struct TestAddressfind_active_address (struct TestPeer *p)
 
struct PreferenceGeneratorGNUNET_ATS_solver_generate_preferences_start (unsigned int peer, unsigned int address_id, unsigned int client_id, enum GeneratorType type, long int base_value, long int value_rate, struct GNUNET_TIME_Relative period, struct GNUNET_TIME_Relative frequency, enum GNUNET_ATS_PreferenceKind kind, struct GNUNET_TIME_Relative feedback_frequency)
 Generate between the source master and the partner and set property with a value depending on the generator. More...
 
void GNUNET_ATS_solver_generate_preferences_stop_all ()
 Stop all preferences generators. More...
 
static const char * print_op (enum OperationType op)
 Experiments. More...
 
static struct Experimentcreate_experiment ()
 
static void free_experiment (struct Experiment *e)
 
static int load_op_add_address (struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
 
static int load_op_del_address (struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
 
static enum GNUNET_ATS_Property parse_preference_string (const char *str)
 
static int load_op_start_set_preference (struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
 
static int load_op_stop_set_preference (struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
 
static enum GNUNET_ATS_Property parse_property_string (const char *str)
 
static int load_op_start_set_property (struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
 
static int load_op_stop_set_property (struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
 
static int load_op_start_request (struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
 
static int load_op_stop_request (struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
 
static int load_episode (struct Experiment *e, struct Episode *cur, struct GNUNET_CONFIGURATION_Handle *cfg)
 
static int load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg)
 
static void timeout_experiment (void *cls)
 
struct ATS_Addresscreate_ats_address (const struct GNUNET_PeerIdentity *peer, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, uint32_t session_id, uint32_t network)
 
static void enforce_add_address (struct GNUNET_ATS_TEST_Operation *op)
 
static void enforce_del_address (struct GNUNET_ATS_TEST_Operation *op)
 
static void enforce_start_property (struct GNUNET_ATS_TEST_Operation *op)
 
static void enforce_stop_property (struct GNUNET_ATS_TEST_Operation *op)
 
static void enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op)
 
static void enforce_stop_preference (struct GNUNET_ATS_TEST_Operation *op)
 
static void enforce_start_request (struct GNUNET_ATS_TEST_Operation *op)
 
static void enforce_stop_request (struct GNUNET_ATS_TEST_Operation *op)
 
static void enforce_episode (struct Episode *ep)
 
static void timeout_episode (void *cls)
 
void GNUNET_ATS_solvers_experimentation_run (struct Experiment *e, GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb, GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb)
 
void GNUNET_ATS_solvers_experimentation_stop (struct Experiment *e)
 
struct ExperimentGNUNET_ATS_solvers_experimentation_load (char *filename)
 
static int free_all_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
 Solver. More...
 
void GNUNET_ATS_solvers_solver_stop (struct SolverHandle *sh)
 
unsigned int GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned long long *out_dest, unsigned long long *in_dest, int dest_length)
 Load quotas for networks from configuration. More...
 
static void solver_info_cb (void *cls, enum GAS_Solver_Operation op, enum GAS_Solver_Status stat, enum GAS_Solver_Additional_Information add)
 Information callback for the solver. More...
 
static void solver_bandwidth_changed_cb (void *cls, struct ATS_Address *address)
 
const double * get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id)
 
struct SolverHandleGNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type)
 
static void done ()
 
static void experiment_done_cb (struct Experiment *e, struct GNUNET_TIME_Relative duration, int success)
 
static void episode_done_cb (struct Episode *ep)
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 
int main (int argc, char *argv[])
 Main function of the benchmark. More...
 

Variables

struct GNUNET_STATISTICS_HandleGSA_stats
 Handle for statistics. More...
 
static struct Experimente
 
static struct LoggingHandlel
 
static struct SolverHandlesh
 
static struct TestPeerpeer_head
 
static struct TestPeerpeer_tail
 
static double default_properties [GNUNET_ATS_PropertyCount]
 
static double default_preferences [GNUNET_ATS_PreferenceCount]
 
static char * opt_exp_file
 cmd option -e: experiment file More...
 
static char * opt_solver
 
static int opt_log
 cmd option -l: enable logging More...
 
static int opt_save
 cmd option -p: enable plots More...
 
static int opt_verbose
 cmd option -v: verbose logs More...
 
static int opt_print
 cmd option -p: print logs More...
 
static int opt_disable_normalization
 cmd option -d: disable normalization More...
 
static int res
 
static struct PropertyGeneratorprop_gen_head
 Property Generators. More...
 
static struct PropertyGeneratorprop_gen_tail
 
static struct PreferenceGeneratorpref_gen_head
 Preference Generators. More...
 
static struct PreferenceGeneratorpref_gen_tail
 

Macro Definition Documentation

◆ BIG_M_STRING

#define BIG_M_STRING   "unlimited"

Definition at line 32 of file gnunet-ats-solver-eval.c.

Referenced by GNUNET_ATS_solvers_load_quotas().

Function Documentation

◆ end_now()

static void end_now ( )
static

Do shutdown.

Definition at line 3176 of file gnunet-ats-solver-eval.c.

References GNUNET_ATS_solvers_experimentation_stop(), and GNUNET_ATS_solvers_solver_stop().

Referenced by done(), GNUNET_ATS_solvers_solver_start(), and run().

3177 {
3178  if (NULL != e)
3179  {
3181  e = NULL;
3182  }
3183  if (NULL != sh)
3184  {
3186  sh = NULL;
3187  }
3188 }
void GNUNET_ATS_solvers_solver_stop(struct SolverHandle *sh)
static struct Experiment * e
static struct SolverHandle * sh
void GNUNET_ATS_solvers_experimentation_stop(struct Experiment *e)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_generator_type()

static char* print_generator_type ( enum GeneratorType  g)
static

Definition at line 92 of file gnunet-ats-solver-eval.c.

References GNUNET_ATS_TEST_TG_CONSTANT, GNUNET_ATS_TEST_TG_LINEAR, GNUNET_ATS_TEST_TG_RANDOM, and GNUNET_ATS_TEST_TG_SINUS.

Referenced by GNUNET_ATS_solver_generate_preferences_start(), and GNUNET_ATS_solver_generate_property_start().

93 {
94  switch (g) {
96  return "CONSTANT";
98  return "LINEAR";
100  return "RANDOM";
102  return "SINUS";
103  default:
104  return "INVALID";
105  break;
106  }
107 }
Here is the caller graph for this function:

◆ find_peer_by_id()

static struct TestPeer* find_peer_by_id ( int  id)
static

Definition at line 111 of file gnunet-ats-solver-eval.c.

References TestPeer::id, and TestPeer::next.

Referenced by enforce_add_address(), enforce_del_address(), enforce_start_preference(), enforce_start_property(), enforce_start_request(), enforce_stop_request(), GNUNET_ATS_solver_generate_preferences_start(), set_feedback_task(), set_pref_task(), and set_prop_task().

112 {
113  struct TestPeer *cur;
114  for (cur = peer_head; NULL != cur; cur = cur->next)
115  if (cur->id == id)
116  return cur;
117  return NULL;
118 }
long long unsigned int id
static struct TestPeer * peer_head
struct TestPeer * next
Here is the caller graph for this function:

◆ find_peer_by_pid()

static struct TestPeer* find_peer_by_pid ( const struct GNUNET_PeerIdentity pid)
static

Definition at line 121 of file gnunet-ats-solver-eval.c.

References GNUNET_memcmp, TestPeer::next, and TestPeer::peer_id.

Referenced by get_preferences_cb(), and solver_bandwidth_changed_cb().

122 {
123  struct TestPeer *cur;
124  for (cur = peer_head; NULL != cur; cur = cur->next)
125  if (0 == GNUNET_memcmp (&cur->peer_id, pid))
126  return cur;
127  return NULL;
128 }
struct GNUNET_PeerIdentity peer_id
static struct TestPeer * peer_head
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
struct TestPeer * next
Here is the caller graph for this function:

◆ find_address_by_id()

static struct TestAddress* find_address_by_id ( struct TestPeer peer,
int  aid 
)
static

Definition at line 131 of file gnunet-ats-solver-eval.c.

References TestPeer::addr_head, TestAddress::aid, and TestAddress::next.

Referenced by enforce_add_address(), enforce_del_address(), enforce_start_property(), and set_prop_task().

132 {
133  struct TestAddress *cur;
134  for (cur = peer->addr_head; NULL != cur; cur = cur->next)
135  if (cur->aid == aid)
136  return cur;
137  return NULL;
138 }
long long unsigned int aid
struct TestAddress * next
struct TestAddress * addr_head
Here is the caller graph for this function:

◆ GNUNET_ATS_solver_logging_now()

void GNUNET_ATS_solver_logging_now ( struct LoggingHandle l)

Logging.

Definition at line 145 of file gnunet-ats-solver-eval.c.

References GNUNET_TIME_Absolute::abs_value_us, LoggingAddress::active, ATS_Address::active, LoggingPeer::addr_head, TestPeer::addr_head, LoggingPeer::addr_tail, LoggingAddress::aid, TestAddress::aid, LoggingAddress::assigned_bw_in, ATS_Address::assigned_bw_in, LoggingAddress::assigned_bw_out, ATS_Address::assigned_bw_out, TestAddress::ats_addr, LoggingTimeStep::delta, GNUNET_ATS_print_preference_type(), GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_new, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_UNIT_ZERO, LoggingTimeStep::head, LoggingHandle::head, LoggingPeer::id, TestPeer::id, LoggingPeer::is_requested, TestPeer::is_requested, LoggingAddress::network, TestAddress::network, TestPeer::next, TestAddress::next, LoggingPeer::peer_id, TestPeer::peer_id, LoggingPeer::pref_abs, TestPeer::pref_abs, LoggingPeer::pref_norm, TestPeer::pref_norm, LoggingTimeStep::prev, LoggingAddress::prop_abs, TestAddress::prop_abs, LoggingAddress::prop_norm, TestAddress::prop_norm, GNUNET_TIME_Relative::rel_value_us, LoggingTimeStep::tail, LoggingHandle::tail, and LoggingTimeStep::timestamp.

Referenced by enforce_del_address(), enforce_stop_request(), logging_task(), and solver_bandwidth_changed_cb().

146 {
147  struct LoggingTimeStep *lts;
148  struct TestPeer *cur;
149  struct TestAddress *cur_addr;
150  struct LoggingPeer *log_p;
151  struct LoggingAddress *log_a;
152  int c;
153 
154  lts = GNUNET_new (struct LoggingTimeStep);
157  if (NULL == lts->prev)
159  else
161 
162  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Logging %llu, delta %llu\n",
164 
165 
166  /* Store logging data here */
167  for (cur = peer_head; NULL != cur; cur = cur->next)
168  {
170  "Logging peer id %llu\n", cur->id);
171 
172  log_p = GNUNET_new (struct LoggingPeer);
173  log_p->id = cur->id;
174  log_p->peer_id = cur->peer_id;
175  log_p->is_requested = cur->is_requested;
176  for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
177  {
178  log_p->pref_abs[c] = cur->pref_abs[c];
179  log_p->pref_norm[c] = cur->pref_norm[c];
181  "\t %s = %.2f %.2f [abs/rel]\n",
183  log_p->pref_abs[c], log_p->pref_norm[c]);
184  }
185  GNUNET_CONTAINER_DLL_insert_tail(lts->head, lts->tail, log_p);
186 
187  for (cur_addr = cur->addr_head; NULL != cur_addr; cur_addr = cur_addr->next)
188  {
190  "Logging peer id %llu address %llu\n",
191  cur->id, cur_addr->aid);
192  log_a = GNUNET_new (struct LoggingAddress);
193  log_a->aid = cur_addr->aid;
194  log_a->active = cur_addr->ats_addr->active;
195  log_a->network = cur_addr->network;
196  log_a->assigned_bw_in = cur_addr->ats_addr->assigned_bw_in;
197  log_a->assigned_bw_out = cur_addr->ats_addr->assigned_bw_out;
198  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
199  {
200  log_a->prop_abs[c] = cur_addr->prop_abs[c];
201  log_a->prop_norm[c] = cur_addr->prop_norm[c];
203  "\t %s = %.2f %.2f [abs/rel]\n",
204  GNUNET_ATS_print_property_type(c),
205  log_a->prop_abs[c],
206  log_a->prop_norm[c]);
207  }
208  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\t Active = %i\n", log_a->active);
209  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\t BW in = %llu\n", log_a->assigned_bw_in);
210  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "\t BW out = %llu\n", log_a->assigned_bw_out);
211 
212  GNUNET_CONTAINER_DLL_insert_tail (log_p->addr_head, log_p->addr_tail, log_a);
213  }
214  }
215 }
struct LoggingPeer * head
double prop_abs[GNUNET_ATS_PropertyCount]
struct LoggingTimeStep * tail
uint64_t rel_value_us
The actual value.
double pref_abs[GNUNET_ATS_PreferenceCount]
struct LoggingTimeStep * prev
int active
Is this the active address for this peer?
struct LoggingAddress * addr_tail
long long unsigned int aid
long long unsigned int id
struct GNUNET_PeerIdentity peer_id
struct LoggingTimeStep * head
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint64_t abs_value_us
The actual value.
struct ATS_Address * ats_addr
uint32_t assigned_bw_in
Inbound bandwidth assigned by solver.
struct LoggingPeer * tail
double pref_abs[GNUNET_ATS_PREFERENCE_END]
struct LoggingAddress * addr_head
double prop_norm[GNUNET_ATS_PropertyCount]
long long unsigned int aid
const char * GNUNET_ATS_print_preference_type(enum GNUNET_ATS_PreferenceKind type)
Convert a enum GNUNET_ATS_PreferenceType to a string.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
Entry for a benchmark peer.
static struct TestPeer * peer_head
struct GNUNET_TIME_Relative delta
struct GNUNET_TIME_Absolute timestamp
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
struct TestAddress * next
double prop_abs[GNUNET_ATS_PropertyCount]
uint32_t assigned_bw_out
Outbound bandwidth assigned by solver.
struct TestAddress * addr_head
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
#define GNUNET_log(kind,...)
struct TestPeer * next
double pref_norm[GNUNET_ATS_PREFERENCE_END]
double prop_norm[GNUNET_ATS_PropertyCount]
double pref_norm[GNUNET_ATS_PreferenceCount]
long long unsigned int id
struct GNUNET_PeerIdentity peer_id
Here is the call graph for this function:
Here is the caller graph for this function:

◆ logging_task()

static void logging_task ( void *  cls)
static

Definition at line 219 of file gnunet-ats-solver-eval.c.

References GNUNET_ATS_solver_logging_now(), GNUNET_SCHEDULER_add_delayed(), LoggingHandle::log_freq, and LoggingHandle::logging_task.

Referenced by GNUNET_ATS_solver_logging_start().

220 {
221  struct LoggingHandle *l = cls;
222 
223  l->logging_task = NULL;
226  &logging_task,
227  l);
228 }
static void logging_task(void *cls)
static struct LoggingHandle * l
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1246
void GNUNET_ATS_solver_logging_now(struct LoggingHandle *l)
Logging.
struct GNUNET_TIME_Relative log_freq
struct GNUNET_SCHEDULER_Task * logging_task
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_solver_logging_start()

struct LoggingHandle* GNUNET_ATS_solver_logging_start ( struct GNUNET_TIME_Relative  freq)

Definition at line 231 of file gnunet-ats-solver-eval.c.

References GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_relative_time_to_string(), l, LoggingHandle::log_freq, logging_task(), and LoggingHandle::logging_task.

Referenced by run().

232 {
233  struct LoggingHandle *l;
234  l = GNUNET_new (struct LoggingHandle);
235 
236  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start logging every %s\n",
238  l->log_freq = freq;
240  return l;
241 }
static void logging_task(void *cls)
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct LoggingHandle * l
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1273
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:727
#define GNUNET_log(kind,...)
struct GNUNET_TIME_Relative log_freq
struct GNUNET_SCHEDULER_Task * logging_task
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_solver_logging_stop()

void GNUNET_ATS_solver_logging_stop ( struct LoggingHandle l)

Definition at line 244 of file gnunet-ats-solver-eval.c.

References GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SCHEDULER_cancel(), and LoggingHandle::logging_task.

Referenced by done().

245 {
246  if (NULL != l->logging_task)
248 
249  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stop logging\n");
250 
251  l->logging_task = NULL;
252 }
#define GNUNET_log(kind,...)
struct GNUNET_SCHEDULER_Task * logging_task
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_logging_file_handle()

static struct LoggingFileHandle* find_logging_file_handle ( struct LoggingFileHandle lf_head,
struct LoggingFileHandle lf_tail,
int  peer_id,
int  address_id 
)
static

Definition at line 255 of file gnunet-ats-solver-eval.c.

References LoggingFileHandle::aid, LoggingFileHandle::next, LoggingFileHandle::pid, and res.

Referenced by GNUNET_ATS_solver_logging_write_to_disk().

258 {
259  struct LoggingFileHandle *res;
260 
261  for (res = lf_head; NULL != res; res = res->next)
262  if ((res->pid == peer_id) && (res->aid == address_id))
263  return res;
264  return NULL;
265 
266 }
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
long long unsigned int pid
struct LoggingFileHandle * next
static int res
long long unsigned int aid
Here is the caller graph for this function:

◆ GNUNET_ATS_solver_logging_write_to_disk()

void GNUNET_ATS_solver_logging_write_to_disk ( struct LoggingHandle l,
int  add_time_stamp,
char *  output_dir 
)

Definition at line 269 of file gnunet-ats-solver-eval.c.

References GNUNET_TIME_Absolute::abs_value_us, LoggingAddress::active, LoggingPeer::addr_head, LoggingFileHandle::aid, LoggingAddress::aid, LoggingAddress::assigned_bw_in, LoggingAddress::assigned_bw_out, cleanup(), LoggingTimeStep::delta, DIR_SEPARATOR_STR, LoggingFileHandle::f_hd, filename, find_logging_file_handle(), GNUNET_asprintf(), GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_DISK_directory_create_for_file(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_write(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_OPEN_TRUNCATE, GNUNET_DISK_PERM_GROUP_READ, GNUNET_DISK_PERM_OTHER_READ, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_strdup, GNUNET_TIME_absolute_get_difference(), GNUNET_YES, LoggingTimeStep::head, LoggingHandle::head, LoggingPeer::id, LoggingPeer::is_requested, Experiment::log_prefix, LoggingAddress::network, LoggingFileHandle::next, LoggingTimeStep::next, LoggingPeer::next, LoggingAddress::next, opt_solver, LoggingFileHandle::pid, LoggingPeer::pref_abs, LoggingPeer::pref_norm, LoggingAddress::prop_abs, LoggingAddress::prop_norm, GNUNET_TIME_Relative::rel_value_us, and LoggingTimeStep::timestamp.

Referenced by done().

271 {
272  struct LoggingTimeStep *lts;
273  struct LoggingPeer *log_p;
274  struct LoggingAddress *log_a;
275  struct LoggingFileHandle *lf_head;
276  struct LoggingFileHandle *lf_tail;
277  struct LoggingFileHandle *cur;
278  struct LoggingFileHandle *next;
279  char * filename;
280  char * datastring;
281  char * propstring;
282  char * propstring_tmp;
283  char * prefstring;
284  char * prefstring_tmp;
285  int c;
286  int use_dir;
287 
288  use_dir = GNUNET_NO;
289  if (NULL != output_dir)
290  {
292  {
293  fprintf (stderr, "Failed to create directory `%s'\n", output_dir);
294  return;
295  }
296  else
297  {
298  fprintf (stderr, "Created directory `%s'\n", output_dir);
299  use_dir = GNUNET_YES;
300  }
301  }
302 
303  lf_head = NULL;
304  lf_tail = NULL;
305 
306  for (lts = l->head; NULL != lts; lts = lts->next)
307  {
308 
309  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Writing log step %llu\n",
310  (long long unsigned int) lts->timestamp.abs_value_us);
311 
312  for (log_p = lts->head; NULL != log_p; log_p = log_p->next)
313  {
314  for (log_a = log_p->addr_head; NULL != log_a; log_a = log_a->next)
315  {
316 
317  cur = find_logging_file_handle (lf_head, lf_tail, log_p->id,
318  log_a->aid);
319  if (NULL == cur)
320  {
321  cur = GNUNET_new (struct LoggingFileHandle);
322  cur->aid = log_a->aid;
323  cur->pid = log_p->id;
324 
325  if (GNUNET_YES == add_time_stamp)
326  GNUNET_asprintf (&filename, "%s%s%s_%s_p%u_a%u_%llu.log",
327  (GNUNET_YES == use_dir) ? output_dir : "",
328  (GNUNET_YES == use_dir) ? DIR_SEPARATOR_STR : "",
329  e->log_prefix,
330  opt_solver,
331  cur->pid,
332  cur->aid,
334  else
335  GNUNET_asprintf (&filename, "%s%s%s_%s_p%u_a%u.log",
336  (GNUNET_YES == use_dir) ? output_dir : "",
337  (GNUNET_YES == use_dir) ? DIR_SEPARATOR_STR : "",
338  e->log_prefix,
339  opt_solver,
340  cur->pid,
341  cur->aid);
342 
343  fprintf (stderr, "Add writing log data for peer %llu address %llu to file `%s'\n",
344  cur->pid, cur->aid, filename);
345 
346 
347  cur->f_hd = GNUNET_DISK_file_open (filename,
355  if (NULL == cur->f_hd)
356  {
357  fprintf (stderr, "Cannot open `%s' to write log data!\n", filename);
358  GNUNET_free (filename);
359  GNUNET_free (cur);
360  goto cleanup;
361  }
362  GNUNET_free (filename);
363  GNUNET_CONTAINER_DLL_insert (lf_head, lf_tail, cur);
364 
365  GNUNET_asprintf(&datastring,"#time delta;log duration;peer_requested;addr net; addr_active; bw in; bw out; " \
366  "UTILIZATION_UP [abs/rel]; UTILIZATION_UP; UTILIZATION_DOWN; UTILIZATION_DOWN; " \
367  "UTILIZATION_PAYLOAD_UP; UTILIZATION_PAYLOAD_UP; UTILIZATION_PAYLOAD_DOWN; UTILIZATION_PAYLOAD_DOWN;"\
368  "DELAY; DELAY; " \
369  "DISTANCE ;DISTANCE ; COST_WAN; COST_WAN; COST_LAN; COST_LAN; " \
370  "COST_WLAN; COST_WLAN;COST_BT; COST_BT; PREF BW abs; PREF BW rel; PREF LATENCY abs; PREF LATENCY rel;\n");
371  GNUNET_DISK_file_write (cur->f_hd, datastring, strlen(datastring));
372  GNUNET_free (datastring);
373 
374  }
375 
376  prefstring = GNUNET_strdup("");
377  for (c = 1; c < GNUNET_ATS_PreferenceCount; c++)
378  {
379  /*
380  fprintf(stderr,"\t %s = %.2f %.2f [abs/rel]\n",
381  GNUNET_ATS_print_preference_type(c),
382  log_p->pref_abs[c], log_p->pref_norm[c]);
383  */
384  GNUNET_asprintf(&prefstring_tmp,"%s;%.3f;%.3f",
385  prefstring, log_p->pref_abs[c], log_p->pref_norm[c]);
386 
387 
388  GNUNET_free (prefstring);
389  prefstring = GNUNET_strdup(prefstring_tmp);
390  GNUNET_free (prefstring_tmp);
391  }
392 
393 
394  propstring = GNUNET_strdup("");
395  for (c = 1; c < GNUNET_ATS_PropertyCount; c++)
396  {
397  if (GNUNET_ATS_NETWORK_TYPE == c)
398  continue;
399  /*
400  fprintf(stderr, "\t %s = %.2f %.2f [abs/rel]\n",
401  GNUNET_ATS_print_property_type(c),
402  log_a->prop_abs[c], log_a->prop_norm[c]);*/
403  GNUNET_asprintf(&propstring_tmp,"%s%.3f;%.3f;",
404  propstring,
405  log_a->prop_abs[c],
406  log_a->prop_norm[c]);
407  GNUNET_free (propstring);
408  propstring = GNUNET_strdup(propstring_tmp);
409  GNUNET_free (propstring_tmp);
410  }
411  GNUNET_asprintf (&datastring, "%llu;%llu;%u;%u;%i;%u;%u;%s;%s\n",
413  lts->timestamp).rel_value_us / 1000, lts->delta,
414  log_p->is_requested, log_a->network, log_a->active,
415  log_a->assigned_bw_in, log_a->assigned_bw_out, propstring,
416  prefstring);
417 
418  GNUNET_DISK_file_write (cur->f_hd, datastring, strlen(datastring));
419  GNUNET_free (datastring);
420  GNUNET_free (prefstring);
421  GNUNET_free (propstring);
422  }
423  }
424  }
425 
426 cleanup:
427  next = lf_head;
428  for (cur = next; NULL != cur; cur = next)
429  {
430  next = cur->next;
431  GNUNET_CONTAINER_DLL_remove (lf_head, lf_tail, cur);
432  if (NULL != cur->f_hd)
434  GNUNET_free (cur);
435  }
436 
437 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct LoggingPeer * head
Create file if it doesn&#39;t exist.
int GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1817
uint64_t rel_value_us
The actual value.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
long long unsigned int aid
struct LoggingTimeStep * next
struct LoggingTimeStep * head
static struct Experiment * e
int GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
Definition: disk.c:833
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
long long unsigned int pid
struct LoggingAddress * next
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
uint64_t abs_value_us
The actual value.
static char * opt_solver
struct LoggingPeer * next
double pref_abs[GNUNET_ATS_PREFERENCE_END]
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
struct LoggingAddress * addr_head
static struct LoggingFileHandle * find_logging_file_handle(struct LoggingFileHandle *lf_head, struct LoggingFileHandle *lf_tail, int peer_id, int address_id)
struct LoggingFileHandle * next
double prop_norm[GNUNET_ATS_PropertyCount]
Truncate file if it exists.
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: disk.c:1049
static char * filename
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
Entry for a benchmark peer.
struct GNUNET_TIME_Relative delta
struct GNUNET_TIME_Absolute timestamp
struct GNUNET_DISK_FileHandle * f_hd
Everybody can read.
double prop_abs[GNUNET_ATS_PropertyCount]
#define GNUNET_log(kind,...)
long long unsigned int aid
Open the file for both reading and writing.
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end)
Compute the time difference between the given start and end times.
Definition: time.c:353
#define DIR_SEPARATOR_STR
Definition: plibc.h:632
double pref_norm[GNUNET_ATS_PREFERENCE_END]
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1673
#define GNUNET_free(ptr)
Wrapper around free.
long long unsigned int id
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_solver_logging_eval()

void GNUNET_ATS_solver_logging_eval ( struct LoggingHandle l)

Definition at line 440 of file gnunet-ats-solver-eval.c.

References GNUNET_TIME_Absolute::abs_value_us, LoggingAddress::active, LoggingPeer::addr_head, LoggingAddress::aid, LoggingAddress::assigned_bw_in, LoggingAddress::assigned_bw_out, LoggingTimeStep::delta, GNUNET_ATS_print_preference_type(), LoggingTimeStep::head, LoggingHandle::head, LoggingPeer::id, LoggingTimeStep::next, LoggingPeer::next, LoggingAddress::next, LoggingPeer::pref_abs, LoggingPeer::pref_norm, LoggingAddress::prop_abs, LoggingAddress::prop_norm, GNUNET_TIME_Relative::rel_value_us, and LoggingTimeStep::timestamp.

Referenced by done().

441 {
442  struct LoggingTimeStep *lts;
443  struct LoggingPeer *log_p;
444  struct LoggingAddress *log_a;
445  int c;
446 
447  for (lts = l->head; NULL != lts; lts = lts->next)
448  {
449  fprintf (stderr, "Log step %llu %llu: \n",
450  (long long unsigned int) lts->timestamp.abs_value_us,
451  (long long unsigned int) lts->delta.rel_value_us);
452 
453  for (log_p = lts->head; NULL != log_p; log_p = log_p->next)
454  {
455  fprintf (stderr,"\tLogging peer pid %llu\n", log_p->id);
456  for (c = 1; c < GNUNET_ATS_PreferenceCount; c++)
457  {
458  fprintf(stderr,"\t %s = %.2f %.2f [abs/rel]\n",
460  log_p->pref_abs[c], log_p->pref_norm[c]);
461  }
462 
463  for (log_a = log_p->addr_head; NULL != log_a; log_a = log_a->next)
464  {
465  fprintf (stderr, "\tPeer pid %llu address %llu: %u %u %u\n",
466  log_p->id, log_a->aid, log_a->active,
467  log_a->assigned_bw_in,
468  log_a->assigned_bw_out);
469 
470  for (c = 1; c < GNUNET_ATS_PropertyCount; c++)
471  {
472  if (GNUNET_ATS_NETWORK_TYPE == c)
473  continue;
474  fprintf(stderr, "\t %s = %.2f %.2f [abs/rel]\n",
475  GNUNET_ATS_print_property_type(c),
476  log_a->prop_abs[c], log_a->prop_norm[c]);
477  }
478  }
479  }
480  }
481 }
struct LoggingPeer * head
uint64_t rel_value_us
The actual value.
long long unsigned int aid
struct LoggingTimeStep * next
struct LoggingTimeStep * head
struct LoggingAddress * next
uint64_t abs_value_us
The actual value.
struct LoggingPeer * next
double pref_abs[GNUNET_ATS_PREFERENCE_END]
struct LoggingAddress * addr_head
double prop_norm[GNUNET_ATS_PropertyCount]
const char * GNUNET_ATS_print_preference_type(enum GNUNET_ATS_PreferenceKind type)
Convert a enum GNUNET_ATS_PreferenceType to a string.
Entry for a benchmark peer.
struct GNUNET_TIME_Relative delta
struct GNUNET_TIME_Absolute timestamp
double prop_abs[GNUNET_ATS_PropertyCount]
double pref_norm[GNUNET_ATS_PREFERENCE_END]
long long unsigned int id
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_solver_logging_free()

void GNUNET_ATS_solver_logging_free ( struct LoggingHandle l)

Definition at line 484 of file gnunet-ats-solver-eval.c.

References LoggingPeer::addr_head, LoggingPeer::addr_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_SCHEDULER_cancel(), LoggingTimeStep::head, LoggingHandle::head, LoggingHandle::logging_task, LoggingTimeStep::next, LoggingPeer::next, LoggingAddress::next, LoggingTimeStep::tail, and LoggingHandle::tail.

Referenced by done().

485 {
486  struct LoggingTimeStep *lts_cur;
487  struct LoggingTimeStep *lts_next;
488  struct LoggingPeer *log_p_cur;
489  struct LoggingPeer *log_p_next;
490  struct LoggingAddress *log_a_cur;
491  struct LoggingAddress *log_a_next;
492 
493  if (NULL != l->logging_task)
495  l->logging_task = NULL;
496 
497  lts_next = l->head;
498  while (NULL != (lts_cur = lts_next))
499  {
500  lts_next = lts_cur->next;
501 
502  log_p_next = lts_cur->head;
503  while (NULL != (log_p_cur = log_p_next))
504  {
505  log_p_next = log_p_cur->next;
506 
507  log_a_next = log_p_cur->addr_head;
508  while (NULL != (log_a_cur = log_a_next))
509  {
510  log_a_next = log_a_cur->next;
511 
512  GNUNET_CONTAINER_DLL_remove (log_p_cur->addr_head, log_p_cur->addr_tail, log_a_cur);
513  GNUNET_free (log_a_cur);
514  }
515 
516  GNUNET_CONTAINER_DLL_remove (lts_cur->head, lts_cur->tail, log_p_cur);
517  GNUNET_free (log_p_cur);
518  }
519 
520  GNUNET_CONTAINER_DLL_remove (l->head, l->tail, lts_cur);
521  GNUNET_free (lts_cur);
522  }
523 
524  GNUNET_free (l);
525 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct LoggingPeer * head
struct LoggingTimeStep * tail
struct LoggingAddress * addr_tail
struct LoggingTimeStep * next
struct LoggingTimeStep * head
struct LoggingAddress * next
struct LoggingPeer * tail
struct LoggingPeer * next
struct LoggingAddress * addr_head
Entry for a benchmark peer.
struct GNUNET_SCHEDULER_Task * logging_task
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_property()

static double get_property ( struct PropertyGenerator pg)
static

Definition at line 535 of file gnunet-ats-solver-eval.c.

References PropertyGenerator::base_value, PropertyGenerator::duration_period, GNUNET_ATS_TEST_TG_CONSTANT, GNUNET_ATS_TEST_TG_LINEAR, GNUNET_ATS_TEST_TG_RANDOM, GNUNET_ATS_TEST_TG_SINUS, GNUNET_break, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_TIME_absolute_get_duration(), PropertyGenerator::max_value, GNUNET_TIME_Relative::rel_value_us, PropertyGenerator::time_start, and PropertyGenerator::type.

Referenced by set_prop_task().

536 {
537  struct GNUNET_TIME_Relative time_delta;
538  double delta_value;
539  double pref_value;
540 
541  /* Calculate the current preference value */
542  switch (pg->type) {
544  pref_value = pg->base_value;
545  break;
548  /* Calculate point of time in the current period */
549  time_delta.rel_value_us = time_delta.rel_value_us %
551  delta_value = ((double) time_delta.rel_value_us /
553  if ((pg->max_value < pg->base_value) &&
554  ((pg->max_value - pg->base_value) > pg->base_value))
555  {
556  /* This will cause an underflow */
557  GNUNET_break (0);
558  }
559  pref_value = pg->base_value + delta_value;
560  break;
563  10000 * (pg->max_value - pg->base_value)) / 10000;
564  pref_value = pg->base_value + delta_value;
565  break;
568  /* Calculate point of time in the current period */
569  time_delta.rel_value_us = time_delta.rel_value_us %
571  if ((pg->max_value - pg->base_value) > pg->base_value)
572  {
573  /* This will cause an underflow for second half of sinus period,
574  * will be detected in general when experiments are loaded */
575  GNUNET_break (0);
576  }
577  delta_value = (pg->max_value - pg->base_value) *
578  sin ( (2 * M_PI) / ((double) pg->duration_period.rel_value_us) *
579  time_delta.rel_value_us);
580  pref_value = pg->base_value + delta_value;
581  break;
582  default:
583  pref_value = 0.0;
584  break;
585  }
586  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Current property value is %f\n",
587  pref_value);
588  return pref_value;
589 }
uint64_t rel_value_us
The actual value.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
enum GeneratorType type
struct GNUNET_TIME_Absolute time_start
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
#define GNUNET_log(kind,...)
struct GNUNET_TIME_Relative duration_period
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
Time for relative time used by GNUnet, in microseconds.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_prop_task()

static void set_prop_task ( void *  cls)
static

Definition at line 593 of file gnunet-ats-solver-eval.c.

References PropertyGenerator::address_id, SolverHandle::addresses, TestAddress::ats_addr, PropertyGenerator::ats_property, GNUNET_ATS_SolverFunctions::cls, find_address_by_id(), find_peer_by_id(), PropertyGenerator::frequency, GAS_normalization_update_property(), get_property(), GNUNET_break, GNUNET_CONTAINER_multipeermap_contains_value(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_YES, opt_disable_normalization, p, PropertyGenerator::peer, TestPeer::peer_id, TestAddress::prop_abs, TestAddress::prop_norm, GNUNET_ATS_SolverFunctions::s_address_update_property, GNUNET_ATS_SolverFunctions::s_bulk_start, GNUNET_ATS_SolverFunctions::s_bulk_stop, PropertyGenerator::set_task, SolverHandle::sf, PropertyGenerator::test_address, and PropertyGenerator::test_peer.

Referenced by GNUNET_ATS_solver_generate_property_start().

594 {
595  struct PropertyGenerator *pg = cls;
596  struct TestPeer *p;
597  struct TestAddress *a;
598  double prop_value;
599  struct GNUNET_ATS_Information atsi;
600 
601  pg->set_task = NULL;
602 
604  &pg->test_peer->peer_id, pg->test_address->ats_addr))
605  {
606  GNUNET_break (0);
608  "Setting property generation for unknown address [%u:%u]\n",
609  pg->peer, pg->address_id);
610  return;
611  }
612  if (NULL == (p = find_peer_by_id (pg->peer)))
613  {
614  GNUNET_break (0);
616  "Setting property generation for unknown peer %u\n",
617  pg->peer);
618  return;
619  }
620  if (NULL == (a = find_address_by_id (p, pg->address_id)))
621  {
622  GNUNET_break (0);
624  "Setting property generation for unknown peer %u\n",
625  pg->peer);
626  return;
627  }
628 
629  prop_value = get_property (pg);
630  a->prop_abs[pg->ats_property] = prop_value;
631 
633  "Setting property for peer [%u] address [%u] for %s to %f\n",
634  pg->peer, pg->address_id,
635  GNUNET_ATS_print_property_type (pg->ats_property), prop_value);
636 
637  atsi.type = htonl (pg->ats_property);
638  atsi.value = htonl ((uint32_t) prop_value);
639 
640  /* set performance here! */
641  sh->sf->s_bulk_start (sh->sf->cls);
643  {
644  a->prop_abs[pg->ats_property] = prop_value;
645  a->prop_norm[pg->ats_property] = prop_value;
647  pg->ats_property, prop_value, prop_value);
648  }
649  else
651  sh->sf->s_bulk_stop (sh->sf->cls);
652 
654  &set_prop_task, pg);
655 }
double prop_abs[GNUNET_ATS_PropertyCount]
long long unsigned int address_id
struct GNUNET_PeerIdentity peer_id
GAS_solver_address_property_changed s_address_update_property
Update the properties of an address in the solver.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct ATS_Address * ats_addr
void GAS_normalization_update_property(struct ATS_Address *address)
Update and normalize atsi performance information.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1246
struct GNUNET_SCHEDULER_Task * set_task
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static struct SolverHandle * sh
struct GNUNET_TIME_Relative frequency
struct TestAddress * test_address
static double get_property(struct PropertyGenerator *pg)
static int opt_disable_normalization
cmd option -d: disable normalization
void * cls
Closure to pass to all solver functions in this struct.
struct GNUNET_ATS_SolverFunctions * sf
Solver handle.
static void set_prop_task(void *cls)
GAS_solver_bulk_start s_bulk_start
Start a bulk operation.
int GNUNET_CONTAINER_multipeermap_contains_value(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Check if the map contains the given value under the given key.
long long unsigned int peer
#define GNUNET_log(kind,...)
static struct TestPeer * find_peer_by_id(int id)
struct TestPeer * test_peer
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_CONTAINER_MultiPeerMap * addresses
Address hashmap.
double prop_norm[GNUNET_ATS_PropertyCount]
GAS_solver_bulk_stop s_bulk_stop
Bulk operation done.
static struct TestAddress * find_address_by_id(struct TestPeer *peer, int aid)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_prop_gen()

static struct PropertyGenerator* find_prop_gen ( unsigned int  peer,
unsigned int  address,
uint32_t  ats_property 
)
static

Set ats_property to 0 to find all pgs.

Definition at line 662 of file gnunet-ats-solver-eval.c.

References PropertyGenerator::address_id, PropertyGenerator::ats_property, PropertyGenerator::next, and PropertyGenerator::peer.

Referenced by enforce_del_address(), enforce_start_property(), and enforce_stop_property().

664 {
665  struct PropertyGenerator *cur;
666  for (cur = prop_gen_head; NULL != cur; cur = cur->next)
667  if ((cur->peer == peer) && (cur->address_id == address))
668  {
669  if ((cur->ats_property == ats_property) || (0 == ats_property))
670  return cur;
671  }
672  return NULL;
673 }
long long unsigned int address_id
struct PropertyGenerator * next
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
long long unsigned int peer
static char * address
GNS address for this phone.
static struct PropertyGenerator * prop_gen_head
Property Generators.
Here is the caller graph for this function:

◆ GNUNET_ATS_solver_generate_property_stop()

void GNUNET_ATS_solver_generate_property_stop ( struct PropertyGenerator pg)

Definition at line 676 of file gnunet-ats-solver-eval.c.

References PropertyGenerator::address_id, PropertyGenerator::ats_property, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_SCHEDULER_cancel(), PropertyGenerator::peer, and PropertyGenerator::set_task.

Referenced by enforce_del_address(), enforce_start_property(), enforce_stop_property(), and GNUNET_ATS_solver_generate_property_stop_all().

677 {
679 
680  if (NULL != pg->set_task)
681  {
683  pg->set_task = NULL;
684  }
686  "Removing old up preference generator peer [%u] address [%u] `%s'\n",
687  pg->peer, pg->address_id,
688  GNUNET_ATS_print_property_type(pg->ats_property));
689 
690  GNUNET_free (pg);
691 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
long long unsigned int address_id
struct GNUNET_SCHEDULER_Task * set_task
static struct PropertyGenerator * prop_gen_tail
long long unsigned int peer
#define GNUNET_log(kind,...)
#define GNUNET_free(ptr)
Wrapper around free.
static struct PropertyGenerator * prop_gen_head
Property Generators.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_solver_generate_property_start()

struct PropertyGenerator* GNUNET_ATS_solver_generate_property_start ( unsigned int  peer,
unsigned int  address_id,
struct TestPeer test_peer,
struct TestAddress test_address,
enum GeneratorType  type,
long int  base_value,
long int  value_rate,
struct GNUNET_TIME_Relative  period,
struct GNUNET_TIME_Relative  frequency,
uint32_t  ats_property 
)

Generate between the source master and the partner and set property with a value depending on the generator.

Parameters
peersource
address_idpartner
test_peerthe peer
test_addressthe address
typetype of generator
base_valuebase value
value_ratemaximum value
periodduration of a period of generation (~ 1/frequency)
frequencyhow long to generate property
ats_propertyATS property to generate
Returns
the property generator

Definition at line 711 of file gnunet-ats-solver-eval.c.

References PropertyGenerator::address_id, PropertyGenerator::ats_property, PropertyGenerator::base_value, PropertyGenerator::duration_period, PropertyGenerator::frequency, GNUNET_ATS_TEST_TG_CONSTANT, GNUNET_ATS_TEST_TG_LINEAR, GNUNET_ATS_TEST_TG_RANDOM, GNUNET_ATS_TEST_TG_SINUS, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_new, GNUNET_SCHEDULER_add_now(), GNUNET_TIME_absolute_get(), PropertyGenerator::max_value, peer, PropertyGenerator::peer, print_generator_type(), set_prop_task(), PropertyGenerator::set_task, PropertyGenerator::test_address, test_address(), PropertyGenerator::test_peer, PropertyGenerator::time_start, type, and PropertyGenerator::type.

Referenced by enforce_start_property().

721 {
722  struct PropertyGenerator *pg;
723 
724  pg = GNUNET_new (struct PropertyGenerator);
726  pg->type = type;
727  pg->peer = peer;
729  pg->test_peer = test_peer;
730  pg->address_id = address_id;
732  pg->base_value = base_value;
733  pg->max_value = value_rate;
734  pg->duration_period = period;
735  pg->frequency = frequency;
737 
738  switch (type) {
741  "Setting up %s property generator peer [%u] address [%u] `%s'"\
742  "max %u Bips\n",
744  GNUNET_ATS_print_property_type (ats_property),
745  base_value);
746  break;
749  "Setting up %s property generator peer [%u] address [%u] `%s' " \
750  "min %u Bips max %u Bips\n",
752  GNUNET_ATS_print_property_type(ats_property),
753  base_value, value_rate);
754  break;
757  "Setting up %s property generator peer [%u] address [%u] `%s' "\
758  "baserate %u Bips, amplitude %u Bps\n",
760  GNUNET_ATS_print_property_type(ats_property),
761  base_value, value_rate);
762  break;
765  "Setting up %s property generator peer [%u] address [%u] `%s' "\
766  "min %u Bips max %u Bps\n",
768  GNUNET_ATS_print_property_type(ats_property),
769  base_value, value_rate);
770  break;
771  default:
772  break;
773  }
774 
776  return pg;
777 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
long long unsigned int address_id
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_SCHEDULER_Task * set_task
enum GeneratorType type
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1273
static char * print_generator_type(enum GeneratorType g)
static struct PropertyGenerator * prop_gen_tail
struct GNUNET_TIME_Relative frequency
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
struct TestAddress * test_address
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_TIME_Absolute time_start
static void set_prop_task(void *cls)
long long unsigned int peer
#define GNUNET_log(kind,...)
static int test_address(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Test for checking whether HELLO message is empty.
struct TestPeer * test_peer
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
struct GNUNET_TIME_Relative duration_period
static struct PropertyGenerator * prop_gen_head
Property Generators.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_solver_generate_property_stop_all()

void GNUNET_ATS_solver_generate_property_stop_all ( )

Stop all preferences generators.

Definition at line 784 of file gnunet-ats-solver-eval.c.

References GNUNET_ATS_solver_generate_property_stop(), PropertyGenerator::next, and prop_gen_head.

Referenced by done().

785 {
786  struct PropertyGenerator *cur;
787  struct PropertyGenerator *next;
788  next = prop_gen_head;
789  for (cur = next; NULL != cur; cur = next)
790  {
791  next = cur->next;
793  }
794 }
struct PropertyGenerator * next
void GNUNET_ATS_solver_generate_property_stop(struct PropertyGenerator *pg)
static struct PropertyGenerator * prop_gen_head
Property Generators.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_preference()

static double get_preference ( struct PreferenceGenerator pg)
static

Definition at line 805 of file gnunet-ats-solver-eval.c.

References PreferenceGenerator::base_value, PreferenceGenerator::duration_period, GNUNET_ATS_TEST_TG_CONSTANT, GNUNET_ATS_TEST_TG_LINEAR, GNUNET_ATS_TEST_TG_RANDOM, GNUNET_ATS_TEST_TG_SINUS, GNUNET_break, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_TIME_absolute_get_duration(), PreferenceGenerator::max_value, GNUNET_TIME_Relative::rel_value_us, PreferenceGenerator::time_start, and PreferenceGenerator::type.

Referenced by set_feedback_task(), and set_pref_task().

806 {
807  struct GNUNET_TIME_Relative time_delta;
808  double delta_value;
809  double pref_value;
810 
811  /* Calculate the current preference value */
812  switch (pg->type) {
814  pref_value = pg->base_value;
815  break;
818  /* Calculate point of time in the current period */
819  time_delta.rel_value_us = time_delta.rel_value_us %
821  delta_value = ((double) time_delta.rel_value_us /
823  if ((pg->max_value < pg->base_value) &&
824  ((pg->max_value - pg->base_value) > pg->base_value))
825  {
826  /* This will cause an underflow */
827  GNUNET_break (0);
828  }
829  pref_value = pg->base_value + delta_value;
830  break;
833  10000 * (pg->max_value - pg->base_value)) / 10000;
834  pref_value = pg->base_value + delta_value;
835  break;
838  /* Calculate point of time in the current period */
839  time_delta.rel_value_us = time_delta.rel_value_us %
841  if ((pg->max_value - pg->base_value) > pg->base_value)
842  {
843  /* This will cause an underflow for second half of sinus period,
844  * will be detected in general when experiments are loaded */
845  GNUNET_break (0);
846  }
847  delta_value = (pg->max_value - pg->base_value) *
848  sin ( (2 * M_PI) / ((double) pg->duration_period.rel_value_us) *
849  time_delta.rel_value_us);
850  pref_value = pg->base_value + delta_value;
851  break;
852  default:
853  pref_value = 0.0;
854  break;
855  }
856  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Current preference value is %f\n",
857  pref_value);
858  return pref_value;
859 }
struct GNUNET_TIME_Absolute time_start
uint64_t rel_value_us
The actual value.
struct GNUNET_TIME_Relative duration_period
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
#define GNUNET_log(kind,...)
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
Time for relative time used by GNUnet, in microseconds.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_feedback_task()

static void set_feedback_task ( void *  cls)
static

Definition at line 863 of file gnunet-ats-solver-eval.c.

References PreferenceGenerator::client_id, GNUNET_ATS_SolverFunctions::cls, PreferenceGenerator::feedback_bw_in_acc, PreferenceGenerator::feedback_bw_out_acc, PreferenceGenerator::feedback_delay_acc, PreferenceGenerator::feedback_frequency, PreferenceGenerator::feedback_last, PreferenceGenerator::feedback_last_bw_update, PreferenceGenerator::feedback_last_delay_update, PreferenceGenerator::feedback_task, find_peer_by_id(), get_preference(), GNUNET_ATS_PREFERENCE_BANDWIDTH, GNUNET_ATS_PREFERENCE_LATENCY, GNUNET_ATS_print_preference_type(), GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), PreferenceGenerator::kind, PreferenceGenerator::last_assigned_bw_in, PreferenceGenerator::last_assigned_bw_out, PreferenceGenerator::last_delay_value, p, PreferenceGenerator::peer, TestPeer::peer_id, PreferenceGenerator::pref_bw_old, PreferenceGenerator::pref_latency_old, GNUNET_TIME_Relative::rel_value_us, GNUNET_ATS_SolverFunctions::s_feedback, and SolverHandle::sf.

Referenced by GNUNET_ATS_solver_generate_preferences_start().

864 {
865  struct PreferenceGenerator *pg = cls;
866  struct TestPeer *p;
867  double feedback;
868  uint32_t bw_acc_out;
869  uint32_t bw_acc_in;
870  uint32_t delay_acc_in;
871  struct GNUNET_TIME_Relative dur;
872  double p_new;
873 
874  pg->feedback_task = NULL;
875 
876  if (NULL == (p = find_peer_by_id (pg->peer)))
877  {
878  GNUNET_break (0);
880  "Setting feedback for unknown peer %u\n", pg->peer);
881  return;
882  }
883 
884  switch (pg->kind)
885  {
888  bw_acc_in = dur.rel_value_us *pg->last_assigned_bw_in + pg->feedback_bw_in_acc;
889  pg->feedback_bw_in_acc = 0;
890 
891  bw_acc_out = dur.rel_value_us *pg->last_assigned_bw_out + pg->feedback_bw_out_acc;
892  p_new = get_preference (pg);
893  feedback = (p_new / pg->pref_bw_old) * (bw_acc_in + bw_acc_out) /
895 
896  break;
899  delay_acc_in =dur.rel_value_us *pg->last_delay_value + pg->feedback_delay_acc;
900  pg->feedback_delay_acc = 0;
901 
902  p_new = get_preference (pg);
903  feedback = (p_new / pg->pref_latency_old) * (delay_acc_in) /
905 
906  break;
907  default:
908  GNUNET_break (0);
909  feedback = 0.0;
910  break;
911  }
913  "Giving feedback for peer [%u] for client %p pref %s of %.3f\n",
914  pg->peer, NULL + (pg->client_id),
916  feedback);
917 
918  sh->sf->s_feedback (sh->sf->cls, NULL + (pg->client_id), &p->peer_id,
919  pg->feedback_frequency, pg->kind, feedback);
921 
922 
923  pg->feedback_bw_out_acc = 0;
924  pg->feedback_bw_in_acc = 0;
926 
927  pg->feedback_delay_acc = 0;
929 
930 
932  &set_feedback_task, pg);
933 }
static void set_feedback_task(void *cls)
uint64_t rel_value_us
The actual value.
long long unsigned int peer
struct GNUNET_PeerIdentity peer_id
GAS_solver_address_feedback_preference s_feedback
Give feedback about the current assignment.
struct GNUNET_TIME_Absolute feedback_last_delay_update
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
enum GNUNET_ATS_PreferenceKind kind
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1246
struct GNUNET_TIME_Absolute feedback_last_bw_update
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static struct SolverHandle * sh
const char * GNUNET_ATS_print_preference_type(enum GNUNET_ATS_PreferenceKind type)
Convert a enum GNUNET_ATS_PreferenceType to a string.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
void * cls
Closure to pass to all solver functions in this struct.
Change the peer&#39;s latency value to the given amount.
struct GNUNET_TIME_Absolute feedback_last
struct GNUNET_ATS_SolverFunctions * sf
Solver handle.
struct GNUNET_SCHEDULER_Task * feedback_task
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
static double get_preference(struct PreferenceGenerator *pg)
#define GNUNET_log(kind,...)
Change the peer&#39;s bandwidth value (value per byte of bandwidth in the goal function) to the given amo...
static struct TestPeer * find_peer_by_id(int id)
struct GNUNET_TIME_Relative feedback_frequency
Time for relative time used by GNUnet, in microseconds.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_pref_task()

static void set_pref_task ( void *  cls)
static

Definition at line 937 of file gnunet-ats-solver-eval.c.

References PreferenceGenerator::client_id, GNUNET_ATS_SolverFunctions::cls, find_peer_by_id(), PreferenceGenerator::frequency, get_preference(), GNUNET_ATS_PREFERENCE_BANDWIDTH, GNUNET_ATS_PREFERENCE_LATENCY, GNUNET_ATS_print_preference_type(), GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SCHEDULER_add_delayed(), GNUNET_YES, PreferenceGenerator::kind, opt_disable_normalization, p, PreferenceGenerator::peer, TestPeer::peer_id, TestPeer::pref_abs, PreferenceGenerator::pref_bw_old, PreferenceGenerator::pref_latency_old, TestPeer::pref_norm, GNUNET_ATS_SolverFunctions::s_pref, PreferenceGenerator::set_task, SolverHandle::sf, and update_preference().

Referenced by GNUNET_ATS_solver_generate_preferences_start().

938 {
939  struct PreferenceGenerator *pg = cls;
940  struct TestPeer *p;
941  double pref_value;
942  pg->set_task = NULL;
943 
944  if (NULL == (p = find_peer_by_id (pg->peer)))
945  {
946  GNUNET_break (0);
948  "Setting preference for unknown peer %u\n", pg->peer);
949  return;
950  }
951 
952  pref_value = get_preference (pg);
953  switch (pg->kind) {
955  pg->pref_bw_old = pref_value;
956  break;
958  pg->pref_latency_old = pref_value;
959  break;
960  default:
961  break;
962  }
963 
964  p->pref_abs[pg->kind] = pref_value;
965 
967  "Setting preference for peer [%u] for client %p pref %s to %f\n",
968  pg->peer, NULL + (pg->client_id),
969  GNUNET_ATS_print_preference_type (pg->kind), pref_value);
970 
972  {
973  p->pref_abs[pg->kind] = pref_value;
974  p->pref_norm[pg->kind] = pref_value;
975  sh->sf->s_pref (sh->sf->cls, &p->peer_id, pg->kind, pref_value);
976  }
977  else
978  update_preference (NULL + (pg->client_id),
979  &p->peer_id,
980  pg->kind,
981  pref_value);
982 
984  &set_pref_task,
985  pg);
986 }
double pref_abs[GNUNET_ATS_PreferenceCount]
long long unsigned int peer
struct GNUNET_PeerIdentity peer_id
static void update_preference(struct GNUNET_SERVICE_Client *client, const struct GNUNET_PeerIdentity *peer, enum GNUNET_ATS_PreferenceKind kind, float score_abs)
Update the absolute preference and calculate the new relative preference value.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
enum GNUNET_ATS_PreferenceKind kind
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1246
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static struct SolverHandle * sh
const char * GNUNET_ATS_print_preference_type(enum GNUNET_ATS_PreferenceKind type)
Convert a enum GNUNET_ATS_PreferenceType to a string.
GAS_solver_address_change_preference s_pref
Change relative preference for quality in solver.
struct GNUNET_SCHEDULER_Task * set_task
static int opt_disable_normalization
cmd option -d: disable normalization
void * cls
Closure to pass to all solver functions in this struct.
Change the peer&#39;s latency value to the given amount.
struct GNUNET_ATS_SolverFunctions * sf
Solver handle.
struct GNUNET_TIME_Relative frequency
static double get_preference(struct PreferenceGenerator *pg)
#define GNUNET_log(kind,...)
Change the peer&#39;s bandwidth value (value per byte of bandwidth in the goal function) to the given amo...
static struct TestPeer * find_peer_by_id(int id)
#define GNUNET_YES
Definition: gnunet_common.h:80
static void set_pref_task(void *cls)
double pref_norm[GNUNET_ATS_PreferenceCount]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_pref_gen()

static struct PreferenceGenerator* find_pref_gen ( unsigned int  peer,
enum GNUNET_ATS_PreferenceKind  kind 
)
static

Definition at line 990 of file gnunet-ats-solver-eval.c.

References GNUNET_ATS_PREFERENCE_END, PreferenceGenerator::kind, PreferenceGenerator::next, and PreferenceGenerator::peer.

Referenced by enforce_start_preference(), and enforce_stop_preference().

991 {
992  struct PreferenceGenerator *cur;
993  for (cur = pref_gen_head; NULL != cur; cur = cur->next)
994  if (cur->peer == peer)
995  {
996  if ((cur->kind == kind) || (GNUNET_ATS_PREFERENCE_END == kind))
997  return cur;
998  }
999  return NULL;
1000 }
struct PreferenceGenerator * next
long long unsigned int peer
End of preference list.
enum GNUNET_ATS_PreferenceKind kind
static struct PreferenceGenerator * pref_gen_head
Preference Generators.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
Here is the caller graph for this function:

◆ GNUNET_ATS_solver_generate_preferences_stop()

void GNUNET_ATS_solver_generate_preferences_stop ( struct PreferenceGenerator pg)

Definition at line 1003 of file gnunet-ats-solver-eval.c.

References PreferenceGenerator::feedback_task, GNUNET_ATS_print_preference_type(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_SCHEDULER_cancel(), PreferenceGenerator::kind, PreferenceGenerator::peer, and PreferenceGenerator::set_task.

Referenced by enforce_start_preference(), enforce_stop_preference(), and GNUNET_ATS_solver_generate_preferences_stop_all().

1004 {
1006 
1007  if (NULL != pg->feedback_task)
1008  {
1010  pg->feedback_task = NULL;
1011  }
1012 
1013  if (NULL != pg->set_task)
1014  {
1016  pg->set_task = NULL;
1017  }
1019  "Removing old up preference generator peer [%u] `%s'\n",
1021 
1022  GNUNET_free (pg);
1023 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
long long unsigned int peer
enum GNUNET_ATS_PreferenceKind kind
const char * GNUNET_ATS_print_preference_type(enum GNUNET_ATS_PreferenceKind type)
Convert a enum GNUNET_ATS_PreferenceType to a string.
struct GNUNET_SCHEDULER_Task * set_task
static struct PreferenceGenerator * pref_gen_head
Preference Generators.
struct GNUNET_SCHEDULER_Task * feedback_task
#define GNUNET_log(kind,...)
static struct PreferenceGenerator * pref_gen_tail
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_active_address()

static struct TestAddress* find_active_address ( struct TestPeer p)
static

Definition at line 1027 of file gnunet-ats-solver-eval.c.

References ATS_Address::active, TestPeer::addr_head, TestAddress::ats_addr, GNUNET_YES, and TestAddress::next.

Referenced by GNUNET_ATS_solver_generate_preferences_start().

1028 {
1029  struct TestAddress *cur;
1030  for (cur = p->addr_head; NULL != cur; cur = cur->next)
1031  if (GNUNET_YES == cur->ats_addr->active)
1032  return cur;
1033  return NULL;
1034 }
int active
Is this the active address for this peer?
struct ATS_Address * ats_addr
struct TestAddress * next
struct TestAddress * addr_head
#define GNUNET_YES
Definition: gnunet_common.h:80
Here is the caller graph for this function:

◆ GNUNET_ATS_solver_generate_preferences_start()

struct PreferenceGenerator* GNUNET_ATS_solver_generate_preferences_start ( unsigned int  peer,
unsigned int  address_id,
unsigned int  client_id,
enum GeneratorType  type,
long int  base_value,
long int  value_rate,
struct GNUNET_TIME_Relative  period,
struct GNUNET_TIME_Relative  frequency,
enum GNUNET_ATS_PreferenceKind  kind,
struct GNUNET_TIME_Relative  feedback_frequency 
)

Generate between the source master and the partner and set property with a value depending on the generator.

Parameters
peersource
address_idpartner
client_idthe client
typetype of generator
base_valuebase value
value_ratemaximum value
periodduration of a period of generation (~ 1/frequency)
frequencyhow long to generate property
kindATS preference to generate
feedback_frequencyhow often to give feedback
Returns
the preference generator

Definition at line 1054 of file gnunet-ats-solver-eval.c.

References TestPeer::assigned_bw_in, TestPeer::assigned_bw_out, PreferenceGenerator::base_value, PreferenceGenerator::client_id, PreferenceGenerator::duration_period, PreferenceGenerator::feedback_bw_in_acc, PreferenceGenerator::feedback_bw_out_acc, PreferenceGenerator::feedback_delay_acc, PreferenceGenerator::feedback_frequency, PreferenceGenerator::feedback_last, PreferenceGenerator::feedback_last_bw_update, PreferenceGenerator::feedback_last_delay_update, PreferenceGenerator::feedback_task, find_active_address(), find_peer_by_id(), PreferenceGenerator::frequency, GNUNET_ATS_print_preference_type(), GNUNET_ATS_TEST_TG_CONSTANT, GNUNET_ATS_TEST_TG_LINEAR, GNUNET_ATS_TEST_TG_RANDOM, GNUNET_ATS_TEST_TG_SINUS, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_new, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_FOREVER_REL, PreferenceGenerator::kind, PreferenceGenerator::last_assigned_bw_in, PreferenceGenerator::last_assigned_bw_out, PreferenceGenerator::last_delay_value, PreferenceGenerator::max_value, p, peer, PreferenceGenerator::peer, print_generator_type(), TestAddress::prop_norm, GNUNET_TIME_Relative::rel_value_us, set_feedback_task(), set_pref_task(), PreferenceGenerator::set_task, PreferenceGenerator::time_start, type, and PreferenceGenerator::type.

Referenced by enforce_start_preference().

1064 {
1065  struct PreferenceGenerator *pg;
1066  struct TestPeer *p;
1067 
1068  if (NULL == (p = find_peer_by_id (peer)))
1069  {
1070  GNUNET_break (0);
1072  "Starting preference for unknown peer %u\n", peer);
1073  return NULL;
1074  }
1075 
1076  pg = GNUNET_new (struct PreferenceGenerator);
1078  pg->type = type;
1079  pg->peer = peer;
1080  pg->client_id = client_id;
1081  pg->kind = kind;
1082  pg->base_value = base_value;
1083  pg->max_value = value_rate;
1084  pg->duration_period = period;
1085  pg->frequency = frequency;
1087  pg->feedback_frequency = feedback_frequency;
1088 
1089  switch (type) {
1092  "Setting up %s preference generator peer [%u] `%s' max %u Bips\n",
1095  base_value);
1096  break;
1099  "Setting up %s preference generator peer [%u] `%s' min %u Bips max %u Bips\n",
1101  base_value, value_rate);
1102  break;
1105  "Setting up %s preference generator peer [%u] `%s' baserate %u Bips, amplitude %u Bps\n",
1107  base_value, value_rate);
1108  break;
1111  "Setting up %s preference generator peer [%u] `%s' min %u Bips max %u Bps\n",
1113  base_value, value_rate);
1114  break;
1115  default:
1116  break;
1117  }
1118 
1120  if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != feedback_frequency.rel_value_us)
1121  {
1122  struct TestAddress * addr = find_active_address(p);
1123 
1126  pg->feedback_bw_in_acc = 0;
1127  pg->feedback_bw_out_acc = 0;
1128  pg->last_delay_value = addr->prop_norm[GNUNET_ATS_QUALITY_NET_DELAY];
1129  pg->feedback_delay_acc = 0;
1130 
1134  pg->feedback_task = GNUNET_SCHEDULER_add_delayed (feedback_frequency,
1135  &set_feedback_task, pg);
1136  }
1137 
1138  return pg;
1139 }
struct GNUNET_TIME_Absolute time_start
static void set_feedback_task(void *cls)
uint64_t rel_value_us
The actual value.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
long long unsigned int peer
struct GNUNET_TIME_Relative duration_period
struct GNUNET_TIME_Absolute feedback_last_delay_update
static struct TestAddress * find_active_address(struct TestPeer *p)
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
enum GNUNET_ATS_PreferenceKind kind
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1246
struct GNUNET_TIME_Absolute feedback_last_bw_update
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1273
static char * print_generator_type(enum GeneratorType g)
uint32_t assigned_bw_in
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
const char * GNUNET_ATS_print_preference_type(enum GNUNET_ATS_PreferenceKind type)
Convert a enum GNUNET_ATS_PreferenceType to a string.
struct GNUNET_SCHEDULER_Task * set_task
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
static struct PreferenceGenerator * pref_gen_head
Preference Generators.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_TIME_Absolute feedback_last
struct GNUNET_SCHEDULER_Task * feedback_task
struct GNUNET_TIME_Relative frequency
#define GNUNET_log(kind,...)
uint32_t assigned_bw_out
static struct TestPeer * find_peer_by_id(int id)
static struct PreferenceGenerator * pref_gen_tail
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
static void set_pref_task(void *cls)
struct GNUNET_TIME_Relative feedback_frequency
double prop_norm[GNUNET_ATS_PropertyCount]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_solver_generate_preferences_stop_all()

void GNUNET_ATS_solver_generate_preferences_stop_all ( )

Stop all preferences generators.

Definition at line 1147 of file gnunet-ats-solver-eval.c.

References GNUNET_ATS_solver_generate_preferences_stop(), PreferenceGenerator::next, and pref_gen_head.

Referenced by done().

1148 {
1149  struct PreferenceGenerator *cur;
1150  struct PreferenceGenerator *next;
1151  next = pref_gen_head;
1152  for (cur = next; NULL != cur; cur = next)
1153  {
1154  next = cur->next;
1156  }
1157 }
void GNUNET_ATS_solver_generate_preferences_stop(struct PreferenceGenerator *pg)
struct PreferenceGenerator * next
static struct PreferenceGenerator * pref_gen_head
Preference Generators.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_op()

static const char* print_op ( enum OperationType  op)
static

Experiments.

Definition at line 1165 of file gnunet-ats-solver-eval.c.

References SOLVER_OP_ADD_ADDRESS, SOLVER_OP_DEL_ADDRESS, SOLVER_OP_START_REQUEST, SOLVER_OP_START_SET_PREFERENCE, SOLVER_OP_START_SET_PROPERTY, SOLVER_OP_STOP_REQUEST, SOLVER_OP_STOP_SET_PREFERENCE, and SOLVER_OP_STOP_SET_PROPERTY.

Referenced by enforce_episode().

1166 {
1167  switch (op) {
1168  case SOLVER_OP_ADD_ADDRESS:
1169  return "ADD_ADDRESS";
1170  case SOLVER_OP_DEL_ADDRESS:
1171  return "DEL_ADDRESS";
1173  return "START_SET_PREFERENCE";
1175  return "STOP_STOP_PREFERENCE";
1177  return "START_SET_PROPERTY";
1179  return "STOP_SET_PROPERTY";
1181  return "START_REQUEST";
1183  return "STOP_REQUEST";
1184  default:
1185  break;
1186  }
1187  return "";
1188 }
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
Here is the caller graph for this function:

◆ create_experiment()

static struct Experiment* create_experiment ( )
static

Definition at line 1192 of file gnunet-ats-solver-eval.c.

References e, GNUNET_new, GNUNET_TIME_UNIT_ZERO, Experiment::name, Experiment::start, and Experiment::total_duration.

Referenced by GNUNET_ATS_solvers_experimentation_load().

1193 {
1194  struct Experiment *e;
1195  e = GNUNET_new (struct Experiment);
1196  e->name = NULL;
1197  e->start = NULL;
1199  return e;
1200 }
struct Episode * start
struct GNUNET_TIME_Relative total_duration
static struct Experiment * e
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
Here is the caller graph for this function:

◆ free_experiment()

static void free_experiment ( struct Experiment e)
static

Definition at line 1204 of file gnunet-ats-solver-eval.c.

References GNUNET_ATS_TEST_Operation::address, Experiment::cfg_file, GNUNET_free, GNUNET_free_non_null, Episode::head, Experiment::log_output_dir, Experiment::log_prefix, Experiment::name, GNUNET_ATS_TEST_Operation::next, Episode::next, GNUNET_ATS_TEST_Operation::plugin, and Experiment::start.

Referenced by GNUNET_ATS_solvers_experimentation_load(), and GNUNET_ATS_solvers_experimentation_stop().

1205 {
1206  struct Episode *cur;
1207  struct Episode *next;
1208  struct GNUNET_ATS_TEST_Operation *cur_o;
1209  struct GNUNET_ATS_TEST_Operation *next_o;
1210 
1211  next = e->start;
1212  for (cur = next; NULL != cur; cur = next)
1213  {
1214  next = cur->next;
1215 
1216  next_o = cur->head;
1217  for (cur_o = next_o; NULL != cur_o; cur_o = next_o)
1218  {
1219  next_o = cur_o->next;
1220  GNUNET_free_non_null (cur_o->address);
1221  GNUNET_free_non_null (cur_o->plugin);
1222  GNUNET_free (cur_o);
1223  }
1224  GNUNET_free (cur);
1225  }
1226 
1231  GNUNET_free (e);
1232 }
struct GNUNET_ATS_TEST_Operation * next
struct Episode * start
struct Episode * next
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
An operation in an experiment.
struct GNUNET_ATS_TEST_Operation * head
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ load_op_add_address()

static int load_op_add_address ( struct GNUNET_ATS_TEST_Operation o,
struct Episode e,
int  op_counter,
char *  sec_name,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Definition at line 1236 of file gnunet-ats-solver-eval.c.

References GNUNET_ATS_TEST_Operation::address, GNUNET_ATS_TEST_Operation::address_id, GNUNET_ATS_TEST_Operation::address_network, GNUNET_ATS_TEST_Operation::address_session, GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_NT_BT, GNUNET_NT_LAN, GNUNET_NT_LOOPBACK, GNUNET_NT_UNSPECIFIED, GNUNET_NT_WAN, GNUNET_NT_WLAN, GNUNET_OK, GNUNET_STRINGS_utf8_toupper(), GNUNET_SYSERR, GNUNET_ATS_TEST_Operation::peer_id, and GNUNET_ATS_TEST_Operation::plugin.

Referenced by load_episode().

1241 {
1242  char *op_name;
1243  char *op_network;
1244 
1245  /* peer pid */
1246  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1248  sec_name, op_name, &o->peer_id))
1249  {
1250  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1251  op_counter, "ADD_ADDRESS", op_name);
1252  GNUNET_free (op_name);
1253  return GNUNET_SYSERR;
1254  }
1255  GNUNET_free (op_name);
1256 
1257  /* address pid */
1258  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1260  sec_name, op_name, &o->address_id))
1261  {
1262  fprintf (stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1263  op_counter, "ADD_ADDRESS", op_name);
1264  GNUNET_free (op_name);
1265  return GNUNET_SYSERR;
1266  }
1267  GNUNET_free (op_name);
1268 
1269  /* plugin */
1270  GNUNET_asprintf(&op_name, "op-%u-plugin", op_counter);
1272  sec_name, op_name, &o->plugin))
1273  {
1274  fprintf (stderr, "Missing plugin in operation %u `%s' in episode `%s'\n",
1275  op_counter, "ADD_ADDRESS", op_name);
1276  GNUNET_free (op_name);
1277  return GNUNET_SYSERR;
1278  }
1279  GNUNET_free (op_name);
1280 
1281  /* address */
1282  GNUNET_asprintf(&op_name, "op-%u-address", op_counter);
1284  sec_name, op_name, &o->address))
1285  {
1286  fprintf (stderr, "Missing address in operation %u `%s' in episode `%s'\n",
1287  op_counter, "ADD_ADDRESS", op_name);
1288  GNUNET_free (op_name);
1289  return GNUNET_SYSERR;
1290  }
1291  GNUNET_free (op_name);
1292 
1293  /* session */
1294  GNUNET_asprintf(&op_name, "op-%u-address-session", op_counter);
1296  sec_name, op_name, &o->address_session))
1297  {
1298  fprintf (stderr, "Missing address-session in operation %u `%s' in episode `%s'\n",
1299  op_counter, "ADD_ADDRESS", op_name);
1300  GNUNET_free (op_name);
1301  return GNUNET_SYSERR;
1302  }
1303  GNUNET_free (op_name);
1304 
1305  /* network */
1306  GNUNET_asprintf(&op_name, "op-%u-address-network", op_counter);
1308  sec_name, op_name, &op_network))
1309  {
1310  fprintf (stderr, "Missing address-network in operation %u `%s' in episode `%s'\n",
1311  op_counter, "ADD_ADDRESS", op_name);
1312  GNUNET_free (op_name);
1313  return GNUNET_SYSERR;
1314  }
1315  else
1316  {
1317  GNUNET_STRINGS_utf8_toupper (op_network,op_network);
1318  if (0 == strcmp(op_network, "UNSPECIFIED"))
1319  {
1321  }
1322  else if (0 == strcmp(op_network, "LOOPBACK"))
1323  {
1325  }
1326  else if (0 == strcmp(op_network, "LAN"))
1327  {
1329  }
1330  else if (0 == strcmp(op_network, "WAN"))
1331  {
1333  }
1334  else if (0 == strcmp(op_network, "WLAN"))
1335  {
1337  }
1338  else if (0 == strcmp(op_network, "BT"))
1339  {
1341  }
1342  else
1343  {
1344  fprintf (stderr, "Invalid address-network in operation %u `%s' in episode `%s': `%s'\n",
1345  op_counter, "ADD_ADDRESS", op_name, op_network);
1346  GNUNET_free (op_network);
1347  GNUNET_free (op_name);
1348  return GNUNET_SYSERR;
1349  }
1350  }
1351  GNUNET_free (op_network);
1352  GNUNET_free (op_name);
1353 
1355  "Found operation %s: [%llu:%llu] address `%s' plugin `%s' \n",
1356  "ADD_ADDRESS", o->peer_id, o->address_id, o->address, o->plugin);
1357 
1358  return GNUNET_OK;
1359 }
Local area network.
Definition: gnunet_nt_lib.h:50
long long unsigned int peer_id
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
Wide area network (i.e.
Definition: gnunet_nt_lib.h:55
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
Wireless LAN (i.e.
Definition: gnunet_nt_lib.h:60
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
Bluetooth LAN.
Definition: gnunet_nt_lib.h:65
void GNUNET_STRINGS_utf8_toupper(const char *input, char *output)
Convert the utf-8 input string to upper case.
Definition: strings.c:580
long long unsigned int address_id
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
Loopback (same host).
Definition: gnunet_nt_lib.h:45
#define GNUNET_log(kind,...)
long long unsigned int address_session
#define GNUNET_free(ptr)
Wrapper around free.
Category of last resort.
Definition: gnunet_nt_lib.h:40
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_op_del_address()

static int load_op_del_address ( struct GNUNET_ATS_TEST_Operation o,
struct Episode e,
int  op_counter,
char *  sec_name,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Definition at line 1363 of file gnunet-ats-solver-eval.c.

References GNUNET_ATS_TEST_Operation::address, GNUNET_ATS_TEST_Operation::address_id, GNUNET_ATS_TEST_Operation::address_session, GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_SYSERR, GNUNET_ATS_TEST_Operation::peer_id, and GNUNET_ATS_TEST_Operation::plugin.

Referenced by load_episode().

1368 {
1369  char *op_name;
1370  //char *op_network;
1371 
1372  /* peer pid */
1373  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1375  sec_name, op_name, &o->peer_id))
1376  {
1377  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1378  op_counter, "DEL_ADDRESS", op_name);
1379  GNUNET_free (op_name);
1380  return GNUNET_SYSERR;
1381  }
1382  GNUNET_free (op_name);
1383 
1384  /* address pid */
1385  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1387  sec_name, op_name, &o->address_id))
1388  {
1389  fprintf (stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1390  op_counter, "DEL_ADDRESS", op_name);
1391  GNUNET_free (op_name);
1392  return GNUNET_SYSERR;
1393  }
1394  GNUNET_free (op_name);
1395 
1396 #if 0
1397  /* plugin */
1398  GNUNET_asprintf(&op_name, "op-%u-plugin", op_counter);
1400  sec_name, op_name, &o->plugin))
1401  {
1402  fprintf (stderr, "Missing plugin in operation %u `%s' in episode `%s'\n",
1403  op_counter, "DEL_ADDRESS", op_name);
1404  GNUNET_free (op_name);
1405  return GNUNET_SYSERR;
1406  }
1407  GNUNET_free (op_name);
1408 
1409  /* address */
1410  GNUNET_asprintf(&op_name, "op-%u-address", op_counter);
1412  sec_name, op_name, &o->address))
1413  {
1414  fprintf (stderr, "Missing address in operation %u `%s' in episode `%s'\n",
1415  op_counter, "DEL_ADDRESS", op_name);
1416  GNUNET_free (op_name);
1417  return GNUNET_SYSERR;
1418  }
1419  GNUNET_free (op_name);
1420 
1421  /* session */
1422  GNUNET_asprintf(&op_name, "op-%u-address-session", op_counter);
1424  sec_name, op_name, &o->address_session))
1425  {
1426  fprintf (stderr, "Missing address-session in operation %u `%s' in episode `%s'\n",
1427  op_counter, "DEL_ADDRESS", op_name);
1428  GNUNET_free (op_name);
1429  return GNUNET_SYSERR;
1430  }
1431  GNUNET_free (op_name);
1432 #endif
1433 
1435  "Found operation %s: [%llu:%llu] address `%s' plugin `%s' \n",
1436  "DEL_ADDRESS", o->peer_id, o->address_id, o->address, o->plugin);
1437 
1438  return GNUNET_OK;
1439 }
long long unsigned int peer_id
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
long long unsigned int address_id
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
#define GNUNET_log(kind,...)
long long unsigned int address_session
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_preference_string()

static enum GNUNET_ATS_Property parse_preference_string ( const char *  str)
static

Definition at line 1443 of file gnunet-ats-solver-eval.c.

References GNUNET_ATS_PreferenceTypeString, and props.

Referenced by load_op_start_set_preference(), and load_op_stop_set_preference().

1444 {
1445  int c = 0;
1446  char *props[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceTypeString;
1447 
1448  for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
1449  if (0 == strcmp(str, props[c]))
1450  return c;
1451  return 0;
1452 }
struct LinkProperty * props
list of link properties
#define GNUNET_ATS_PreferenceTypeString
ATS preference types as string array initializer.
Here is the caller graph for this function:

◆ load_op_start_set_preference()

static int load_op_start_set_preference ( struct GNUNET_ATS_TEST_Operation o,
struct Episode e,
int  op_counter,
char *  sec_name,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Definition at line 1456 of file gnunet-ats-solver-eval.c.

References GNUNET_ATS_TEST_Operation::address_id, GNUNET_ATS_TEST_Operation::base_rate, GNUNET_ATS_TEST_Operation::client_id, Episode::duration, GNUNET_ATS_TEST_Operation::feedback_delay, GNUNET_ATS_TEST_Operation::frequency, GNUNET_ATS_TEST_Operation::gen_type, GNUNET_asprintf(), GNUNET_ATS_print_preference_type(), GNUNET_ATS_TEST_TG_CONSTANT, GNUNET_ATS_TEST_TG_LINEAR, GNUNET_ATS_TEST_TG_RANDOM, GNUNET_ATS_TEST_TG_SINUS, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, Episode::id, GNUNET_ATS_TEST_Operation::max_rate, parse_preference_string(), GNUNET_ATS_TEST_Operation::peer_id, GNUNET_ATS_TEST_Operation::period, GNUNET_ATS_TEST_Operation::pref_type, GNUNET_TIME_Relative::rel_value_us, and type.

Referenced by load_episode().

1461 {
1462  char *op_name;
1463  char *type;
1464  char *pref;
1465 
1466  /* peer pid */
1467  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1469  sec_name, op_name, &o->peer_id))
1470  {
1471  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1472  op_counter, "START_SET_PREFERENCE", op_name);
1473  GNUNET_free (op_name);
1474  return GNUNET_SYSERR;
1475  }
1476  GNUNET_free (op_name);
1477 
1478  /* address pid */
1479  GNUNET_asprintf(&op_name, "op-%u-client-id", op_counter);
1481  sec_name, op_name, &o->client_id))
1482  {
1483  fprintf (stderr, "Missing client-id in operation %u `%s' in episode `%s'\n",
1484  op_counter, "START_SET_PREFERENCE", op_name);
1485  GNUNET_free (op_name);
1486  return GNUNET_SYSERR;
1487  }
1488  GNUNET_free (op_name);
1489 
1490  /* generator */
1491  GNUNET_asprintf(&op_name, "op-%u-gen-type", op_counter);
1493  sec_name, op_name, &type)) )
1494  {
1495  fprintf (stderr, "Missing type in operation %u `%s' in episode `%s'\n",
1496  op_counter, "START_SET_PREFERENCE", op_name);
1497  GNUNET_free (op_name);
1498  return GNUNET_SYSERR;
1499  }
1500 
1501  /* Load arguments for set_rate, start_send, set_preference */
1502  if (0 == strcmp (type, "constant"))
1503  {
1505  }
1506  else if (0 == strcmp (type, "linear"))
1507  {
1509  }
1510  else if (0 == strcmp (type, "sinus"))
1511  {
1513  }
1514  else if (0 == strcmp (type, "random"))
1515  {
1517  }
1518  else
1519  {
1520  fprintf (stderr, "Invalid generator type %u `%s' in episode %u\n",
1521  op_counter, op_name, e->id);
1522  GNUNET_free (type);
1523  GNUNET_free (op_name);
1524  return GNUNET_SYSERR;
1525  }
1526  GNUNET_free (type);
1527  GNUNET_free (op_name);
1528 
1529 
1530  /* Get base rate */
1531  GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter);
1533  sec_name, op_name, &o->base_rate))
1534  {
1535  fprintf (stderr, "Missing base rate in operation %u `%s' in episode %u\n",
1536  op_counter, op_name, e->id);
1537  GNUNET_free (op_name);
1538  return GNUNET_SYSERR;
1539  }
1540  GNUNET_free (op_name);
1541 
1542 
1543  /* Get max rate */
1544  GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter);
1546  sec_name, op_name, &o->max_rate))
1547  {
1548  if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
1551  {
1552  fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n",
1553  op_counter, op_name, e->id);
1554  GNUNET_free (op_name);
1555  return GNUNET_SYSERR;
1556  }
1557  }
1558  GNUNET_free (op_name);
1559 
1560  /* Get period */
1561  GNUNET_asprintf(&op_name, "op-%u-period", op_counter);
1563  sec_name, op_name, &o->period))
1564  {
1565  o->period = e->duration;
1566  }
1567  GNUNET_free (op_name);
1568 
1569  /* Get frequency */
1570  GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter);
1572  sec_name, op_name, &o->frequency))
1573  {
1574  fprintf (stderr, "Missing frequency in operation %u `%s' in episode %u\n",
1575  op_counter, op_name, e->id);
1576  GNUNET_free (op_name);
1577  return GNUNET_SYSERR;
1578  }
1579  GNUNET_free (op_name);
1580 
1581  /* Get preference */
1582  GNUNET_asprintf(&op_name, "op-%u-pref", op_counter);
1584  sec_name, op_name, &pref))
1585  {
1586  fprintf (stderr, "Missing preference in operation %u `%s' in episode %u\n",
1587  op_counter, op_name, e->id);
1588  GNUNET_free (op_name);
1589  return GNUNET_SYSERR;
1590  }
1591 
1592  if (0 == (o->pref_type = parse_preference_string(pref)))
1593  {
1594  fprintf (stderr, "Invalid preference in operation %u `%s' in episode %u\n",
1595  op_counter, op_name, e->id);
1596  GNUNET_free (op_name);
1597  GNUNET_free (pref);
1598  return GNUNET_SYSERR;
1599  }
1600  GNUNET_free (pref);
1601  GNUNET_free (op_name);
1602 
1603  /* Get feedback delay */
1604  GNUNET_asprintf(&op_name, "op-%u-feedback_delay", op_counter);
1606  sec_name, op_name, &o->feedback_delay))
1607  {
1608  fprintf (stderr, "Using feedback delay %llu in operation %u `%s' in episode %u\n",
1609  (long long unsigned int) o->feedback_delay.rel_value_us,
1610  op_counter, op_name, e->id);
1611  }
1612  else
1614  GNUNET_free (op_name);
1615 
1617  "Found operation %s: [%llu:%llu]: %s = %llu\n",
1618  "START_SET_PREFERENCE", o->peer_id, o->address_id,
1620 
1621  return GNUNET_OK;
1622 }
int GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
long long unsigned int peer_id
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
uint64_t rel_value_us
The actual value.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
struct GNUNET_TIME_Relative period
long long unsigned int client_id
static enum GNUNET_ATS_Property parse_preference_string(const char *str)
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
long long unsigned int base_rate
enum GNUNET_ATS_PreferenceKind pref_type
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
long long unsigned int address_id
const char * GNUNET_ATS_print_preference_type(enum GNUNET_ATS_PreferenceKind type)
Convert a enum GNUNET_ATS_PreferenceType to a string.
struct GNUNET_TIME_Relative duration
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
#define GNUNET_log(kind,...)
struct GNUNET_TIME_Relative feedback_delay
struct GNUNET_TIME_Relative frequency
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
long long unsigned int max_rate
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_op_stop_set_preference()

static int load_op_stop_set_preference ( struct GNUNET_ATS_TEST_Operation o,
struct Episode e,
int  op_counter,
char *  sec_name,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Definition at line 1626 of file gnunet-ats-solver-eval.c.

References GNUNET_ATS_TEST_Operation::address_id, GNUNET_asprintf(), GNUNET_ATS_print_preference_type(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_SYSERR, Episode::id, parse_preference_string(), GNUNET_ATS_TEST_Operation::peer_id, and GNUNET_ATS_TEST_Operation::pref_type.

Referenced by load_episode().

1631 {
1632  char *op_name;
1633  char *pref;
1634 
1635  /* peer pid */
1636  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1638  sec_name, op_name, &o->peer_id))
1639  {
1640  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1641  op_counter, "STOP_SET_PREFERENCE", op_name);
1642  GNUNET_free (op_name);
1643  return GNUNET_SYSERR;
1644  }
1645  GNUNET_free (op_name);
1646 
1647  /* address pid */
1648  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1650  sec_name, op_name, &o->address_id))
1651  {
1652  fprintf (stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1653  op_counter, "STOP_SET_PREFERENCE", op_name);
1654  GNUNET_free (op_name);
1655  return GNUNET_SYSERR;
1656  }
1657  GNUNET_free (op_name);
1658 
1659  /* Get preference */
1660  GNUNET_asprintf(&op_name, "op-%u-pref", op_counter);
1662  sec_name, op_name, &pref))
1663  {
1664  fprintf (stderr, "Missing preference in operation %u `%s' in episode `%s'\n",
1665  op_counter, "STOP_SET_PREFERENCE", op_name);
1666  GNUNET_free (op_name);
1667  return GNUNET_SYSERR;
1668  }
1669 
1670  if (0 == (o->pref_type = parse_preference_string(pref)))
1671  {
1672  fprintf (stderr, "Invalid preference in operation %u `%s' in episode %u\n",
1673  op_counter, op_name, e->id);
1674  GNUNET_free (op_name);
1675  GNUNET_free (pref);
1676  return GNUNET_SYSERR;
1677  }
1678  GNUNET_free (pref);
1679  GNUNET_free (op_name);
1680 
1682  "Found operation %s: [%llu:%llu]: %s\n",
1683  "STOP_SET_PREFERENCE", o->peer_id, o->address_id,
1685  return GNUNET_OK;
1686 }
long long unsigned int peer_id
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
static enum GNUNET_ATS_Property parse_preference_string(const char *str)
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
enum GNUNET_ATS_PreferenceKind pref_type
long long unsigned int address_id
const char * GNUNET_ATS_print_preference_type(enum GNUNET_ATS_PreferenceKind type)
Convert a enum GNUNET_ATS_PreferenceType to a string.
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
#define GNUNET_log(kind,...)
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_property_string()

static enum GNUNET_ATS_Property parse_property_string ( const char *  str)
static

Definition at line 1690 of file gnunet-ats-solver-eval.c.

Referenced by load_op_start_set_property(), and load_op_stop_set_property().

1691 {
1692  enum GNUNET_ATS_Property c;
1693 
1694  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
1695  if (0 == strcmp(str,
1696  GNUNET_ATS_print_property_type (c)))
1697  return c;
1698  return 0;
1699 }
Here is the caller graph for this function:

◆ load_op_start_set_property()

static int load_op_start_set_property ( struct GNUNET_ATS_TEST_Operation o,
struct Episode e,
int  op_counter,
char *  sec_name,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Definition at line 1703 of file gnunet-ats-solver-eval.c.

References GNUNET_ATS_TEST_Operation::address_id, GNUNET_ATS_TEST_Operation::base_rate, Episode::duration, GNUNET_ATS_TEST_Operation::frequency, GNUNET_ATS_TEST_Operation::gen_type, GNUNET_asprintf(), GNUNET_ATS_TEST_TG_CONSTANT, GNUNET_ATS_TEST_TG_LINEAR, GNUNET_ATS_TEST_TG_RANDOM, GNUNET_ATS_TEST_TG_SINUS, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_free_non_null, GNUNET_log, GNUNET_OK, GNUNET_SYSERR, Episode::id, GNUNET_ATS_TEST_Operation::max_rate, parse_property_string(), GNUNET_ATS_TEST_Operation::peer_id, GNUNET_ATS_TEST_Operation::period, and type.

Referenced by load_episode().

1708 {
1709  char *op_name;
1710  char *type;
1711  char *prop;
1712 
1713  /* peer pid */
1714  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1716  sec_name, op_name, &o->peer_id))
1717  {
1718  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1719  op_counter, "START_SET_PROPERTY", op_name);
1720  GNUNET_free (op_name);
1721  return GNUNET_SYSERR;
1722  }
1723  GNUNET_free (op_name);
1724 
1725  /* address pid */
1726  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1728  sec_name, op_name, &o->address_id))
1729  {
1730  fprintf (stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1731  op_counter, "START_SET_PROPERTY", op_name);
1732  GNUNET_free (op_name);
1733  return GNUNET_SYSERR;
1734  }
1735  GNUNET_free (op_name);
1736 
1737  /* generator */
1738  GNUNET_asprintf(&op_name, "op-%u-gen-type", op_counter);
1740  sec_name, op_name, &type)) )
1741  {
1742  fprintf (stderr, "Missing type in operation %u `%s' in episode `%s'\n",
1743  op_counter, "START_SET_PROPERTY", op_name);
1744  GNUNET_free (op_name);
1745  return GNUNET_SYSERR;
1746  }
1747 
1748  /* Load arguments for set_rate, start_send, set_preference */
1749  if (0 == strcmp (type, "constant"))
1750  {
1752  }
1753  else if (0 == strcmp (type, "linear"))
1754  {
1756  }
1757  else if (0 == strcmp (type, "sinus"))
1758  {
1760  }
1761  else if (0 == strcmp (type, "random"))
1762  {
1764  }
1765  else
1766  {
1767  fprintf (stderr, "Invalid generator type %u `%s' in episode %u\n",
1768  op_counter, op_name, e->id);
1769  GNUNET_free (type);
1770  GNUNET_free (op_name);
1771  return GNUNET_SYSERR;
1772  }
1773  GNUNET_free (type);
1774  GNUNET_free (op_name);
1775 
1776 
1777  /* Get base rate */
1778  GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter);
1780  sec_name, op_name, &o->base_rate))
1781  {
1782  fprintf (stderr, "Missing base rate in operation %u `%s' in episode %u\n",
1783  op_counter, op_name, e->id);
1784  GNUNET_free (op_name);
1785  return GNUNET_SYSERR;
1786  }
1787  GNUNET_free (op_name);
1788 
1789 
1790  /* Get max rate */
1791  GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter);
1793  sec_name, op_name, &o->max_rate))
1794  {
1795  if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
1798  {
1799  fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n",
1800  op_counter, op_name, e->id);
1801  GNUNET_free (op_name);
1802  return GNUNET_SYSERR;
1803  }
1804  }
1805  GNUNET_free (op_name);
1806 
1807  /* Get period */
1808  GNUNET_asprintf(&op_name, "op-%u-period", op_counter);
1810  sec_name, op_name, &o->period))
1811  {
1812  o->period = e->duration;
1813  }
1814  GNUNET_free (op_name);
1815 
1816  /* Get frequency */
1817  GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter);
1819  sec_name, op_name, &o->frequency))
1820  {
1821  fprintf (stderr, "Missing frequency in operation %u `%s' in episode %u\n",
1822  op_counter, op_name, e->id);
1823  GNUNET_free (op_name);
1824  return GNUNET_SYSERR;
1825  }
1826  GNUNET_free (op_name);
1827 
1828  /* Get preference */
1829  GNUNET_asprintf(&op_name, "op-%u-property", op_counter);
1831  sec_name, op_name, &prop))
1832  {
1833  fprintf (stderr, "Missing property in operation %u `%s' in episode %u\n",
1834  op_counter, op_name, e->id);
1835  GNUNET_free (op_name);
1836  GNUNET_free_non_null (prop);
1837  return GNUNET_SYSERR;
1838  }
1839 
1840  if (0 == (o->prop_type = parse_property_string(prop)))
1841  {
1842  fprintf (stderr, "Invalid property in operation %u `%s' in episode %u\n",
1843  op_counter, op_name, e->id);
1844  GNUNET_free (op_name);
1845  GNUNET_free (prop);
1846  return GNUNET_SYSERR;
1847  }
1848 
1849  GNUNET_free (prop);
1850  GNUNET_free (op_name);
1851 
1853  "Found operation %s: [%llu:%llu] %s = %llu\n",
1854  "START_SET_PROPERTY", o->peer_id, o->address_id,
1855  GNUNET_ATS_print_property_type (o->prop_type), o->base_rate);
1856 
1857  return GNUNET_OK;
1858 }
int GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
long long unsigned int peer_id
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
struct GNUNET_TIME_Relative period
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
long long unsigned int base_rate
long long unsigned int address_id
struct GNUNET_TIME_Relative duration
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static enum GNUNET_ATS_Property parse_property_string(const char *str)
#define GNUNET_log(kind,...)
struct GNUNET_TIME_Relative frequency
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
long long unsigned int max_rate
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_op_stop_set_property()

static int load_op_stop_set_property ( struct GNUNET_ATS_TEST_Operation o,
struct Episode e,
int  op_counter,
char *  sec_name,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Definition at line 1861 of file gnunet-ats-solver-eval.c.

References GNUNET_ATS_TEST_Operation::address_id, GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_free_non_null, GNUNET_log, GNUNET_OK, GNUNET_SYSERR, Episode::id, parse_property_string(), and GNUNET_ATS_TEST_Operation::peer_id.

Referenced by load_episode().

1866 {
1867  char *op_name;
1868  char *pref;
1869 
1870  /* peer pid */
1871  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1873  sec_name, op_name, &o->peer_id))
1874  {
1875  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1876  op_counter, "STOP_SET_PROPERTY", op_name);
1877  GNUNET_free (op_name);
1878  return GNUNET_SYSERR;
1879  }
1880  GNUNET_free (op_name);
1881 
1882  /* address pid */
1883  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1885  sec_name, op_name, &o->address_id))
1886  {
1887  fprintf (stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1888  op_counter, "STOP_SET_PROPERTY", op_name);
1889  GNUNET_free (op_name);
1890  return GNUNET_SYSERR;
1891  }
1892  GNUNET_free (op_name);
1893 
1894  /* Get property */
1895  GNUNET_asprintf(&op_name, "op-%u-property", op_counter);
1897  sec_name, op_name, &pref))
1898  {
1899  fprintf (stderr, "Missing property in operation %u `%s' in episode `%s'\n",
1900  op_counter, "STOP_SET_PROPERTY", op_name);
1901  GNUNET_free (op_name);
1902  GNUNET_free_non_null (pref);
1903  return GNUNET_SYSERR;
1904  }
1905 
1906  if (0 == (o->prop_type = parse_property_string(pref)))
1907  {
1908  fprintf (stderr, "Invalid property in operation %u `%s' in episode %u\n",
1909  op_counter, op_name, e->id);
1910  GNUNET_free (op_name);
1911  GNUNET_free_non_null (pref);
1912  return GNUNET_SYSERR;
1913  }
1914 
1915  GNUNET_free (pref);
1916  GNUNET_free (op_name);
1917 
1919  "Found operation %s: [%llu:%llu] %s\n",
1920  "STOP_SET_PROPERTY", o->peer_id, o->address_id,
1921  GNUNET_ATS_print_property_type (o->prop_type));
1922 
1923  return GNUNET_OK;
1924 }
long long unsigned int peer_id
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
long long unsigned int address_id
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static enum GNUNET_ATS_Property parse_property_string(const char *str)
#define GNUNET_log(kind,...)
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_op_start_request()

static int load_op_start_request ( struct GNUNET_ATS_TEST_Operation o,
struct Episode e,
int  op_counter,
char *  sec_name,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Definition at line 1928 of file gnunet-ats-solver-eval.c.

References GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_free, GNUNET_OK, GNUNET_SYSERR, and GNUNET_ATS_TEST_Operation::peer_id.

Referenced by load_episode().

1933 {
1934  char *op_name;
1935 
1936  /* peer pid */
1937  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1939  sec_name, op_name, &o->peer_id))
1940  {
1941  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1942  op_counter, "START_REQUEST", op_name);
1943  GNUNET_free (op_name);
1944  return GNUNET_SYSERR;
1945  }
1946  GNUNET_free (op_name);
1947  return GNUNET_OK;
1948 }
long long unsigned int peer_id
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_op_stop_request()

static int load_op_stop_request ( struct GNUNET_ATS_TEST_Operation o,
struct Episode e,
int  op_counter,
char *  sec_name,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Definition at line 1951 of file gnunet-ats-solver-eval.c.

References GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_free, GNUNET_OK, GNUNET_SYSERR, and GNUNET_ATS_TEST_Operation::peer_id.

Referenced by load_episode().

1956 {
1957  char *op_name;
1958 
1959  /* peer pid */
1960  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1962  sec_name, op_name, &o->peer_id))
1963  {
1964  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1965  op_counter, "STOP_REQUEST", op_name);
1966  GNUNET_free (op_name);
1967  return GNUNET_SYSERR;
1968  }
1969  GNUNET_free (op_name);
1970  return GNUNET_OK;
1971 }
long long unsigned int peer_id
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_episode()

static int load_episode ( struct Experiment e,
struct Episode cur,
struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Definition at line 1975 of file gnunet-ats-solver-eval.c.

References GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_OK, GNUNET_SYSERR, Episode::head, Episode::id, load_op_add_address(), load_op_del_address(), load_op_start_request(), load_op_start_set_preference(), load_op_start_set_property(), load_op_stop_request(), load_op_stop_set_preference(), load_op_stop_set_property(), op, res, SOLVER_OP_ADD_ADDRESS, SOLVER_OP_DEL_ADDRESS, SOLVER_OP_START_REQUEST, SOLVER_OP_START_SET_PREFERENCE, SOLVER_OP_START_SET_PROPERTY, SOLVER_OP_STOP_REQUEST, SOLVER_OP_STOP_SET_PREFERENCE, SOLVER_OP_STOP_SET_PROPERTY, Episode::tail, and GNUNET_ATS_TEST_Operation::type.

Referenced by load_episodes().

1977 {
1978  struct GNUNET_ATS_TEST_Operation *o;
1979  char *sec_name;
1980  char *op_name;
1981  char *op;
1982  int op_counter = 0;
1983  int res;
1984  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Parsing episode %u\n",cur->id);
1985  GNUNET_asprintf(&sec_name, "episode-%u", cur->id);
1986 
1987  while (1)
1988  {
1989  /* Load operation */
1990  GNUNET_asprintf(&op_name, "op-%u-operation", op_counter);
1992  sec_name, op_name, &op))
1993  {
1994  GNUNET_free (op_name);
1995  break;
1996  }
1998  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "==== Parsing operation %u: `%s'\n",
1999  cur->id, op_name);
2000 
2001  /* operations = set_rate, start_send, stop_send, set_preference */
2002  if (0 == strcmp (op, "address_add"))
2003  {
2005  res = load_op_add_address (o, cur,
2006  op_counter, sec_name, cfg);
2007  }
2008  else if (0 == strcmp (op, "address_del"))
2009  {
2011  res = load_op_del_address (o, cur,
2012  op_counter, sec_name, cfg);
2013  }
2014  else if (0 == strcmp (op, "start_set_property"))
2015  {
2017  res = load_op_start_set_property (o, cur,
2018  op_counter, sec_name, cfg);
2019  }
2020  else if (0 == strcmp (op, "stop_set_property"))
2021  {
2023  res = load_op_stop_set_property (o, cur,
2024  op_counter, sec_name, cfg);
2025  }
2026  else if (0 == strcmp (op, "start_set_preference"))
2027  {
2029  res = load_op_start_set_preference (o, cur,
2030  op_counter, sec_name, cfg);
2031  }
2032  else if (0 == strcmp (op, "stop_set_preference"))
2033  {
2035  res = load_op_stop_set_preference (o, cur,
2036  op_counter, sec_name, cfg);
2037  }
2038  else if (0 == strcmp (op, "start_request"))
2039  {
2041  res = load_op_start_request (o, cur,
2042  op_counter, sec_name, cfg);
2043  }
2044  else if (0 == strcmp (op, "stop_request"))
2045  {
2047  res = load_op_stop_request(o, cur,
2048  op_counter, sec_name, cfg);
2049  }
2050  else
2051  {
2052  fprintf (stderr, "Invalid operation %u `%s' in episode %u\n",
2053  op_counter, op, cur->id);
2054  res = GNUNET_SYSERR;
2055  }
2056 
2057  GNUNET_free (op);
2058  GNUNET_free (op_name);
2059 
2060  if (GNUNET_SYSERR == res)
2061  {
2062  GNUNET_free (o);
2063  GNUNET_free (sec_name);
2064  return GNUNET_SYSERR;
2065  }
2066 
2068  op_counter++;
2069  }
2070  GNUNET_free (sec_name);
2071  return GNUNET_OK;
2072 }
static int load_op_start_set_property(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
static int load_op_stop_set_property(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
static int load_op_stop_set_preference(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
static int load_op_start_request(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
static int load_op_add_address(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
static int res
static int load_op_stop_request(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
An operation in an experiment.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
static int load_op_start_set_preference(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
struct GNUNET_ATS_TEST_Operation * head
struct GNUNET_ATS_TEST_Operation * tail
static int load_op_del_address(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
#define GNUNET_log(kind,...)
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_episodes()

static int load_episodes ( struct Experiment e,
struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Definition at line 2075 of file gnunet-ats-solver-eval.c.

References Episode::duration, GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_OK, GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_relative_add(), GNUNET_YES, Episode::id, load_episode(), Episode::next, Experiment::num_episodes, Experiment::start, and Experiment::total_duration.

Referenced by GNUNET_ATS_solvers_experimentation_load().

2076 {
2077  int e_counter = 0;
2078  char *sec_name;
2079  struct GNUNET_TIME_Relative e_duration;
2080  struct Episode *cur;
2081  struct Episode *last;
2082 
2083  e_counter = 0;
2084  last = NULL;
2085  while (1)
2086  {
2087  GNUNET_asprintf(&sec_name, "episode-%u", e_counter);
2089  sec_name, "duration", &e_duration))
2090  {
2091  GNUNET_free (sec_name);
2092  break;
2093  }
2094 
2095  cur = GNUNET_new (struct Episode);
2096  cur->duration = e_duration;
2097  cur->id = e_counter;
2098 
2099  if (GNUNET_OK != load_episode (e, cur, cfg))
2100  {
2101  GNUNET_free (sec_name);
2102  GNUNET_free (cur);
2103  return GNUNET_SYSERR;
2104  }
2105 
2106  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Found episode %u with duration %s \n",
2107  e_counter,
2109 
2110  /* Update experiment */
2111  e->num_episodes ++;
2113  /* Put in linked list */
2114  if (NULL == last)
2115  e->start = cur;
2116  else
2117  last->next = cur;
2118 
2119  GNUNET_free (sec_name);
2120  e_counter ++;
2121  last = cur;
2122  }
2123  return e_counter;
2124 }
struct Episode * start
int GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
struct Episode * next
struct GNUNET_TIME_Relative total_duration
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
unsigned int num_episodes
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:727
struct GNUNET_TIME_Relative duration
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static int load_episode(struct Experiment *e, struct Episode *cur, struct GNUNET_CONFIGURATION_Handle *cfg)
struct GNUNET_TIME_Relative GNUNET_TIME_relative_add(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Add relative times together.
Definition: time.c:576
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:80
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ timeout_experiment()

static void timeout_experiment ( void *  cls)
static

Definition at line 2128 of file gnunet-ats-solver-eval.c.

References Experiment::e_done_cb, Experiment::episode_timeout_task, Experiment::experiment_timeout_task, GNUNET_SCHEDULER_cancel(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_duration(), and Experiment::start_time.

Referenced by GNUNET_ATS_solvers_experimentation_run().

2129 {
2130  struct Experiment *e = cls;
2131 
2132  e->experiment_timeout_task = NULL;
2133  fprintf (stderr, "Experiment timeout!\n");
2134 
2135  if (NULL != e->episode_timeout_task)
2136  {
2138  e->episode_timeout_task = NULL;
2139  }
2140 
2142  GNUNET_SYSERR);
2143 }
GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb
static struct Experiment * e
struct GNUNET_SCHEDULER_Task * experiment_timeout_task
struct GNUNET_SCHEDULER_Task * episode_timeout_task
struct GNUNET_TIME_Absolute start_time
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_ats_address()

struct ATS_Address* create_ats_address ( const struct GNUNET_PeerIdentity peer,
const char *  plugin_name,
const void *  plugin_addr,
size_t  plugin_addr_len,
uint32_t  session_id,
uint32_t  network 
)

Definition at line 2146 of file gnunet-ats-solver-eval.c.

References ATS_Address::addr, ATS_Address::addr_len, ATS_Address::atsi_count, GNUNET_malloc, GNUNET_memcpy, GNUNET_new, peer, ATS_Address::peer, ATS_Address::plugin, session_id, and ATS_Address::session_id.

Referenced by enforce_add_address().

2152 {
2153  struct ATS_Address *aa = NULL;
2154 
2155  aa = GNUNET_malloc (sizeof (struct ATS_Address) + plugin_addr_len + strlen (plugin_name) + 1);
2156  aa->atsi = GNUNET_new (struct GNUNET_ATS_Information);
2157  aa->atsi[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
2158  aa->atsi[0].value = htonl (network);
2159  aa->atsi_count = 1;
2160 
2161  aa->peer = *peer;
2162  aa->addr_len = plugin_addr_len;
2163  aa->addr = &aa[1];
2164  aa->plugin = (char *) &aa[1] + plugin_addr_len;
2165  GNUNET_memcpy (&aa[1], plugin_addr, plugin_addr_len);
2166  GNUNET_memcpy (aa->plugin, plugin_name, strlen (plugin_name) + 1);
2167  aa->session_id = session_id;
2168 
2169  return aa;
2170 }
uint32_t session_id
Session ID, can never be 0.
struct GNUNET_PeerIdentity peer
Peer ID this address is for.
const void * addr
Address (in plugin-specific binary format).
static struct GNUNET_HashCode session_id
char * plugin
Plugin name.
size_t addr_len
Address length, number of bytes in addr.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_memcpy(dst, src, n)
static char * plugin_name
Solver plugin name as string.
Address with additional information.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
uint32_t atsi_count
ATS performance information for this address, size of the atsi array.
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the caller graph for this function:

◆ enforce_add_address()

static void enforce_add_address ( struct GNUNET_ATS_TEST_Operation op)
static

Definition at line 2175 of file gnunet-ats-solver-eval.c.

References TestPeer::addr_head, TestPeer::addr_tail, GNUNET_ATS_TEST_Operation::address, GNUNET_ATS_TEST_Operation::address_id, GNUNET_ATS_TEST_Operation::address_network, GNUNET_ATS_TEST_Operation::address_session, SolverHandle::addresses, TestAddress::aid, TestPeer::assigned_bw_in, TestPeer::assigned_bw_out, TestAddress::ats_addr, GNUNET_ATS_SolverFunctions::cls, create_ats_address(), DEFAULT_ABS_PREFERENCE, DEFAULT_REL_PREFERENCE, DEFAULT_REL_QUALITY, find_address_by_id(), find_peer_by_id(), GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_put(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_new, GNUNET_NT_to_string(), TestPeer::id, TestAddress::network, p, TestPeer::peer_id, GNUNET_ATS_TEST_Operation::peer_id, GNUNET_ATS_TEST_Operation::plugin, TestPeer::pref_abs, TestPeer::pref_norm, TestAddress::prop_norm, GNUNET_ATS_SolverFunctions::s_add, and SolverHandle::sf.

Referenced by enforce_episode().

2176 {
2177  struct TestPeer *p;
2178  struct TestAddress *a;
2179  int c;
2180 
2181  if (NULL == (p = find_peer_by_id (op->peer_id)))
2182  {
2183  p = GNUNET_new (struct TestPeer);
2184  p->id = op->peer_id;
2185  p->assigned_bw_in = 0;
2186  p->assigned_bw_out = 0;
2187  memset (&p->peer_id, op->peer_id, sizeof (p->peer_id));
2188  for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
2189  {
2192  }
2193 
2195  }
2196 
2197  if (NULL != (find_address_by_id (p, op->address_id)))
2198  {
2199  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Duplicate address %u for peer %u\n",
2200  op->address_id, op->peer_id);
2201  return;
2202  }
2203 
2204  a = GNUNET_new (struct TestAddress);
2205  a->aid = op->address_id;
2206  a->network = op->address_network;
2207  a->ats_addr = create_ats_address (&p->peer_id, op->plugin, op->address,
2208  strlen (op->address) + 1, op->address_session, op->address_network);
2209  memset (&p->peer_id, op->peer_id, sizeof (p->peer_id));
2211 
2212  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
2214 
2217 
2218  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Adding address %u for peer %u in network `%s'\n",
2220 
2221  sh->sf->s_add (sh->sf->cls, a->ats_addr, op->address_network);
2222 
2223 }
GAS_solver_address_add s_add
Add a new address for a peer to the solver.
long long unsigned int peer_id
const char * GNUNET_NT_to_string(enum GNUNET_NetworkType net)
Convert a enum GNUNET_NetworkType to a string.
Definition: nt.c:43
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
double pref_abs[GNUNET_ATS_PreferenceCount]
#define DEFAULT_REL_QUALITY
Value we return for a normalized quality score if we have no data.
long long unsigned int id
struct GNUNET_PeerIdentity peer_id
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct TestPeer * peer_tail
struct TestAddress * addr_tail
struct ATS_Address * ats_addr
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static struct SolverHandle * sh
struct ATS_Address * create_ats_address(const struct GNUNET_PeerIdentity *peer, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, uint32_t session_id, uint32_t network)
long long unsigned int aid
uint32_t assigned_bw_in
long long unsigned int address_id
static struct TestPeer * peer_head
void * cls
Closure to pass to all solver functions in this struct.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define DEFAULT_REL_PREFERENCE
Default relative preference value we assume if we know nothing.
struct GNUNET_ATS_SolverFunctions * sf
Solver handle.
Allow multiple values with the same key.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct TestAddress * addr_head
#define GNUNET_log(kind,...)
uint32_t assigned_bw_out
static struct TestPeer * find_peer_by_id(int id)
#define DEFAULT_ABS_PREFERENCE
Default preference value we assume if we know nothing.
struct GNUNET_CONTAINER_MultiPeerMap * addresses
Address hashmap.
double prop_norm[GNUNET_ATS_PropertyCount]
long long unsigned int address_session
static struct TestAddress * find_address_by_id(struct TestPeer *peer, int aid)
double pref_norm[GNUNET_ATS_PreferenceCount]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ enforce_del_address()

static void enforce_del_address ( struct GNUNET_ATS_TEST_Operation op)
static

Definition at line 2227 of file gnunet-ats-solver-eval.c.

References TestPeer::addr_head, TestPeer::addr_tail, GNUNET_ATS_TEST_Operation::address_id, SolverHandle::addresses, TestAddress::aid, TestAddress::ats_addr, GNUNET_ATS_SolverFunctions::cls, find_address_by_id(), find_peer_by_id(), find_prop_gen(), GNUNET_assert, GNUNET_ATS_solver_generate_property_stop(), GNUNET_ATS_solver_logging_now(), GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_free_non_null, GNUNET_log, GNUNET_YES, TestPeer::id, p, TestPeer::peer_id, GNUNET_ATS_TEST_Operation::peer_id, GNUNET_ATS_SolverFunctions::s_del, and SolverHandle::sf.

Referenced by enforce_episode().

2228 {
2229  struct TestPeer *p;
2230  struct TestAddress *a;
2231  struct PropertyGenerator *pg;
2232 
2233  if (NULL == (p = find_peer_by_id (op->peer_id)))
2234  {
2235  GNUNET_break (0);
2237  "Deleting address for unknown peer %u\n", op->peer_id);
2238  return;
2239  }
2240 
2241  if (NULL == (a =find_address_by_id (p, op->address_id)))
2242  {
2243  GNUNET_break (0);
2245  "Deleting address for unknown peer %u\n", op->peer_id);
2246  return;
2247  }
2248 
2249  while (NULL != (pg = find_prop_gen (p->id, a->aid, 0)))
2250  {
2252  }
2253 
2256  &p->peer_id,
2257  a->ats_addr));
2259  "Removing address %u for peer %u\n",
2260  op->address_id,
2261  op->peer_id);
2262 
2263  sh->sf->s_del (sh->sf->cls, a->ats_addr);
2264 
2265  if (NULL != l)
2266  {
2268  }
2270 
2271  GNUNET_free_non_null(a->ats_addr->atsi);
2272  GNUNET_free (a->ats_addr);
2273  GNUNET_free (a);
2274 
2275 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
long long unsigned int peer_id
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
long long unsigned int id
struct GNUNET_PeerIdentity peer_id
int GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
struct TestAddress * addr_tail
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct ATS_Address * ats_addr
static struct LoggingHandle * l
static struct PropertyGenerator * find_prop_gen(unsigned int peer, unsigned int address, uint32_t ats_property)
Set ats_property to 0 to find all pgs.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
void GNUNET_ATS_solver_logging_now(struct LoggingHandle *l)
Logging.
static struct SolverHandle * sh
GAS_solver_address_delete s_del
Delete an address in the solver.
long long unsigned int aid
void GNUNET_ATS_solver_generate_property_stop(struct PropertyGenerator *pg)
long long unsigned int address_id
void * cls
Closure to pass to all solver functions in this struct.
struct GNUNET_ATS_SolverFunctions * sf
Solver handle.
struct TestAddress * addr_head
#define GNUNET_log(kind,...)
static struct TestPeer * find_peer_by_id(int id)
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_CONTAINER_MultiPeerMap * addresses
Address hashmap.
static struct TestAddress * find_address_by_id(struct TestPeer *peer, int aid)
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ enforce_start_property()

static void enforce_start_property ( struct GNUNET_ATS_TEST_Operation op)
static

Definition at line 2278 of file gnunet-ats-solver-eval.c.

References GNUNET_ATS_TEST_Operation::address_id, GNUNET_ATS_TEST_Operation::base_rate, find_address_by_id(), find_peer_by_id(), find_prop_gen(), GNUNET_ATS_TEST_Operation::frequency, GNUNET_ATS_TEST_Operation::gen_type, GNUNET_ATS_solver_generate_property_start(), GNUNET_ATS_solver_generate_property_stop(), GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_ATS_TEST_Operation::max_rate, p, GNUNET_ATS_TEST_Operation::peer_id, and GNUNET_ATS_TEST_Operation::period.

Referenced by enforce_episode().

2279 {
2280  struct PropertyGenerator *pg;
2281  struct TestPeer *p;
2282  struct TestAddress *a;
2283 
2284  if (NULL != (pg = find_prop_gen (op->peer_id, op->address_id, op->prop_type)))
2285  {
2287  GNUNET_free (pg);
2288  }
2289 
2290  if (NULL == (p = find_peer_by_id (op->peer_id)))
2291  {
2292  GNUNET_break (0);
2294  "Starting property generation for unknown peer %u\n", op->peer_id);
2295  return;
2296  }
2297 
2298  if (NULL == (a = find_address_by_id (p, op->address_id)))
2299  {
2300  GNUNET_break (0);
2302  "Setting property for unknown address %u\n", op->peer_id);
2303  return;
2304  }
2305 
2307  op->address_id,
2308  p, a,
2309  op->gen_type,
2310  op->base_rate,
2311  op->max_rate,
2312  op->period,
2313  op->frequency,
2314  op->prop_type);
2315 }
long long unsigned int peer_id
struct PropertyGenerator * GNUNET_ATS_solver_generate_property_start(unsigned int peer, unsigned int address_id, struct TestPeer *test_peer, struct TestAddress *test_address, enum GeneratorType type, long int base_value, long int value_rate, struct GNUNET_TIME_Relative period, struct GNUNET_TIME_Relative frequency, uint32_t ats_property)
Generate between the source master and the partner and set property with a value depending on the gen...
struct GNUNET_TIME_Relative period
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct PropertyGenerator * find_prop_gen(unsigned int peer, unsigned int address, uint32_t ats_property)
Set ats_property to 0 to find all pgs.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
long long unsigned int base_rate
void GNUNET_ATS_solver_generate_property_stop(struct PropertyGenerator *pg)
long long unsigned int address_id
#define GNUNET_log(kind,...)
static struct TestPeer * find_peer_by_id(int id)
struct GNUNET_TIME_Relative frequency
long long unsigned int max_rate
static struct TestAddress * find_address_by_id(struct TestPeer *peer, int aid)
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ enforce_stop_property()

static void enforce_stop_property ( struct GNUNET_ATS_TEST_Operation op)
static

Definition at line 2318 of file gnunet-ats-solver-eval.c.

References GNUNET_ATS_TEST_Operation::address_id, find_prop_gen(), GNUNET_ATS_solver_generate_property_stop(), GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, and GNUNET_ATS_TEST_Operation::peer_id.

Referenced by enforce_episode().

2319 {
2320  struct PropertyGenerator *pg = find_prop_gen(op->peer_id, op->address_id,
2321  op->prop_type);
2322  if (NULL != pg)
2323  {
2325  "Stopping preference generation for peer %u address %u\n", op->peer_id,
2326  op->address_id);
2328  }
2329  else
2330  {
2332  "Cannot find preference generator for peer %u address %u\n",
2333  op->peer_id, op->address_id);
2334  GNUNET_break (0);
2335  }
2336 }
long long unsigned int peer_id
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct PropertyGenerator * find_prop_gen(unsigned int peer, unsigned int address, uint32_t ats_property)
Set ats_property to 0 to find all pgs.
void GNUNET_ATS_solver_generate_property_stop(struct PropertyGenerator *pg)
long long unsigned int address_id
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ enforce_start_preference()

static void enforce_start_preference ( struct GNUNET_ATS_TEST_Operation op)
static

Definition at line 2339 of file gnunet-ats-solver-eval.c.

References GNUNET_ATS_TEST_Operation::address_id, GNUNET_ATS_TEST_Operation::base_rate, GNUNET_ATS_TEST_Operation::client_id, find_peer_by_id(), find_pref_gen(), GNUNET_ATS_TEST_Operation::frequency, GNUNET_ATS_TEST_Operation::gen_type, GNUNET_ATS_solver_generate_preferences_start(), GNUNET_ATS_solver_generate_preferences_stop(), GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_ATS_TEST_Operation::max_rate, GNUNET_ATS_TEST_Operation::peer_id, GNUNET_ATS_TEST_Operation::period, and GNUNET_ATS_TEST_Operation::pref_type.

Referenced by enforce_episode().

2340 {
2341  struct PreferenceGenerator *pg;
2342  if (NULL != (pg = find_pref_gen (op->peer_id, op->pref_type)))
2343  {
2345  GNUNET_free (pg);
2346  }
2347 
2348  if (NULL == (find_peer_by_id (op->peer_id)))
2349  {
2350  GNUNET_break (0);
2352  "Starting preference generation for unknown peer %u\n", op->peer_id);
2353  return;
2354  }
2355 
2357  op->address_id,
2358  op->client_id,
2359  op->gen_type,
2360  op->base_rate,
2361  op->max_rate,
2362  op->period,
2363  op->frequency,
2364  op->pref_type,
2365  op->frequency);
2366 }
void GNUNET_ATS_solver_generate_preferences_stop(struct PreferenceGenerator *pg)
long long unsigned int peer_id
struct GNUNET_TIME_Relative period
long long unsigned int client_id
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
long long unsigned int base_rate
enum GNUNET_ATS_PreferenceKind pref_type
long long unsigned int address_id
struct PreferenceGenerator * GNUNET_ATS_solver_generate_preferences_start(unsigned int peer, unsigned int address_id, unsigned int client_id, enum GeneratorType type, long int base_value, long int value_rate, struct GNUNET_TIME_Relative period, struct GNUNET_TIME_Relative frequency, enum GNUNET_ATS_PreferenceKind kind, struct GNUNET_TIME_Relative feedback_frequency)
Generate between the source master and the partner and set property with a value depending on the gen...
static struct PreferenceGenerator * find_pref_gen(unsigned int peer, enum GNUNET_ATS_PreferenceKind kind)
#define GNUNET_log(kind,...)
static struct TestPeer * find_peer_by_id(int id)
struct GNUNET_TIME_Relative frequency
long long unsigned int max_rate
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ enforce_stop_preference()

static void enforce_stop_preference ( struct GNUNET_ATS_TEST_Operation op)
static

Definition at line 2369 of file gnunet-ats-solver-eval.c.

References GNUNET_ATS_TEST_Operation::address_id, find_pref_gen(), GNUNET_ATS_solver_generate_preferences_stop(), GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_ATS_TEST_Operation::peer_id, and GNUNET_ATS_TEST_Operation::pref_type.

Referenced by enforce_episode().

2370 {
2371  struct PreferenceGenerator *pg = find_pref_gen(op->peer_id,
2372  op->pref_type);
2373  if (NULL != pg)
2374  {
2376  "Stopping property generation for peer %u address %u\n", op->peer_id,
2377  op->address_id);
2379  }
2380  else
2381  {
2383