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 3250 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().

3251 {
3252  if (NULL != e)
3253  {
3255  e = NULL;
3256  }
3257  if (NULL != sh)
3258  {
3260  sh = NULL;
3261  }
3262 }
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)
95  {
97  return "CONSTANT";
98 
100  return "LINEAR";
101 
103  return "RANDOM";
104 
106  return "SINUS";
107 
108  default:
109  return "INVALID";
110  break;
111  }
112 }
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 116 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().

117 {
118  struct TestPeer *cur;
119 
120  for (cur = peer_head; NULL != cur; cur = cur->next)
121  if (cur->id == id)
122  return cur;
123  return NULL;
124 }
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 127 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().

128 {
129  struct TestPeer *cur;
130 
131  for (cur = peer_head; NULL != cur; cur = cur->next)
132  if (0 == GNUNET_memcmp(&cur->peer_id, pid))
133  return cur;
134  return NULL;
135 }
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 138 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().

139 {
140  struct TestAddress *cur;
141 
142  for (cur = peer->addr_head; NULL != cur; cur = cur->next)
143  if (cur->aid == aid)
144  return cur;
145  return NULL;
146 }
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 153 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().

154 {
155  struct LoggingTimeStep *lts;
156  struct TestPeer *cur;
157  struct TestAddress *cur_addr;
158  struct LoggingPeer *log_p;
159  struct LoggingAddress *log_a;
160  int c;
161 
162  lts = GNUNET_new(struct LoggingTimeStep);
165  if (NULL == lts->prev)
167  else
169 
170  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Logging %llu, delta %llu\n",
172 
173 
174  /* Store logging data here */
175  for (cur = peer_head; NULL != cur; cur = cur->next)
176  {
178  "Logging peer id %llu\n", cur->id);
179 
180  log_p = GNUNET_new(struct LoggingPeer);
181  log_p->id = cur->id;
182  log_p->peer_id = cur->peer_id;
183  log_p->is_requested = cur->is_requested;
184  for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
185  {
186  log_p->pref_abs[c] = cur->pref_abs[c];
187  log_p->pref_norm[c] = cur->pref_norm[c];
189  "\t %s = %.2f %.2f [abs/rel]\n",
191  log_p->pref_abs[c], log_p->pref_norm[c]);
192  }
193  GNUNET_CONTAINER_DLL_insert_tail(lts->head, lts->tail, log_p);
194 
195  for (cur_addr = cur->addr_head; NULL != cur_addr; cur_addr = cur_addr->next)
196  {
198  "Logging peer id %llu address %llu\n",
199  cur->id, cur_addr->aid);
200  log_a = GNUNET_new(struct LoggingAddress);
201  log_a->aid = cur_addr->aid;
202  log_a->active = cur_addr->ats_addr->active;
203  log_a->network = cur_addr->network;
204  log_a->assigned_bw_in = cur_addr->ats_addr->assigned_bw_in;
205  log_a->assigned_bw_out = cur_addr->ats_addr->assigned_bw_out;
206  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
207  {
208  log_a->prop_abs[c] = cur_addr->prop_abs[c];
209  log_a->prop_norm[c] = cur_addr->prop_norm[c];
211  "\t %s = %.2f %.2f [abs/rel]\n",
212  GNUNET_ATS_print_property_type(c),
213  log_a->prop_abs[c],
214  log_a->prop_norm[c]);
215  }
216  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "\t Active = %i\n", log_a->active);
217  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "\t BW in = %llu\n", log_a->assigned_bw_in);
218  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "\t BW out = %llu\n", log_a->assigned_bw_out);
219 
221  }
222  }
223 }
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 227 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().

228 {
229  struct LoggingHandle *l = cls;
230 
231  l->logging_task = NULL;
234  &logging_task,
235  l);
236 }
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:1237
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 239 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, LoggingHandle::logging_task, and logging_task().

Referenced by run().

240 {
241  struct LoggingHandle *l;
242 
243  l = GNUNET_new(struct LoggingHandle);
244 
245  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Start logging every %s\n",
247  l->log_freq = freq;
249  return l;
250 }
static void logging_task(void *cls)
#define GNUNET_NO
Definition: gnunet_common.h:78
#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:1264
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:686
#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 253 of file gnunet-ats-solver-eval.c.

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

Referenced by done().

254 {
255  if (NULL != l->logging_task)
257 
258  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Stop logging\n");
259 
260  l->logging_task = NULL;
261 }
#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:956
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 264 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().

267 {
268  struct LoggingFileHandle *res;
269 
270  for (res = lf_head; NULL != res; res = res->next)
271  if ((res->pid == peer_id) && (res->aid == address_id))
272  return res;
273  return NULL;
274 }
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 277 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().

279 {
280  struct LoggingTimeStep *lts;
281  struct LoggingPeer *log_p;
282  struct LoggingAddress *log_a;
283  struct LoggingFileHandle *lf_head;
284  struct LoggingFileHandle *lf_tail;
285  struct LoggingFileHandle *cur;
286  struct LoggingFileHandle *next;
287  char * filename;
288  char * datastring;
289  char * propstring;
290  char * propstring_tmp;
291  char * prefstring;
292  char * prefstring_tmp;
293  int c;
294  int use_dir;
295 
296  use_dir = GNUNET_NO;
297  if (NULL != output_dir)
298  {
300  {
301  fprintf(stderr, "Failed to create directory `%s'\n", output_dir);
302  return;
303  }
304  else
305  {
306  fprintf(stderr, "Created directory `%s'\n", output_dir);
307  use_dir = GNUNET_YES;
308  }
309  }
310 
311  lf_head = NULL;
312  lf_tail = NULL;
313 
314  for (lts = l->head; NULL != lts; lts = lts->next)
315  {
316  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Writing log step %llu\n",
317  (long long unsigned int)lts->timestamp.abs_value_us);
318 
319  for (log_p = lts->head; NULL != log_p; log_p = log_p->next)
320  {
321  for (log_a = log_p->addr_head; NULL != log_a; log_a = log_a->next)
322  {
323  cur = find_logging_file_handle(lf_head, lf_tail, log_p->id,
324  log_a->aid);
325  if (NULL == cur)
326  {
327  cur = GNUNET_new(struct LoggingFileHandle);
328  cur->aid = log_a->aid;
329  cur->pid = log_p->id;
330 
331  if (GNUNET_YES == add_time_stamp)
332  GNUNET_asprintf(&filename, "%s%s%s_%s_p%u_a%u_%llu.log",
333  (GNUNET_YES == use_dir) ? output_dir : "",
334  (GNUNET_YES == use_dir) ? DIR_SEPARATOR_STR : "",
335  e->log_prefix,
336  opt_solver,
337  cur->pid,
338  cur->aid,
340  else
341  GNUNET_asprintf(&filename, "%s%s%s_%s_p%u_a%u.log",
342  (GNUNET_YES == use_dir) ? output_dir : "",
343  (GNUNET_YES == use_dir) ? DIR_SEPARATOR_STR : "",
344  e->log_prefix,
345  opt_solver,
346  cur->pid,
347  cur->aid);
348 
349  fprintf(stderr, "Add writing log data for peer %llu address %llu to file `%s'\n",
350  cur->pid, cur->aid, filename);
351 
352 
353  cur->f_hd = GNUNET_DISK_file_open(filename,
361  if (NULL == cur->f_hd)
362  {
363  fprintf(stderr, "Cannot open `%s' to write log data!\n", filename);
364  GNUNET_free(filename);
365  GNUNET_free(cur);
366  goto cleanup;
367  }
368  GNUNET_free(filename);
369  GNUNET_CONTAINER_DLL_insert(lf_head, lf_tail, cur);
370 
371  GNUNET_asprintf(&datastring, "#time delta;log duration;peer_requested;addr net; addr_active; bw in; bw out; " \
372  "UTILIZATION_UP [abs/rel]; UTILIZATION_UP; UTILIZATION_DOWN; UTILIZATION_DOWN; " \
373  "UTILIZATION_PAYLOAD_UP; UTILIZATION_PAYLOAD_UP; UTILIZATION_PAYLOAD_DOWN; UTILIZATION_PAYLOAD_DOWN;" \
374  "DELAY; DELAY; " \
375  "DISTANCE ;DISTANCE ; COST_WAN; COST_WAN; COST_LAN; COST_LAN; " \
376  "COST_WLAN; COST_WLAN;COST_BT; COST_BT; PREF BW abs; PREF BW rel; PREF LATENCY abs; PREF LATENCY rel;\n");
377  GNUNET_DISK_file_write(cur->f_hd, datastring, strlen(datastring));
378  GNUNET_free(datastring);
379  }
380 
381  prefstring = GNUNET_strdup("");
382  for (c = 1; c < GNUNET_ATS_PreferenceCount; c++)
383  {
384  /*
385  fprintf(stderr,"\t %s = %.2f %.2f [abs/rel]\n",
386  GNUNET_ATS_print_preference_type(c),
387  log_p->pref_abs[c], log_p->pref_norm[c]);
388  */
389  GNUNET_asprintf(&prefstring_tmp, "%s;%.3f;%.3f",
390  prefstring, log_p->pref_abs[c], log_p->pref_norm[c]);
391 
392 
393  GNUNET_free(prefstring);
394  prefstring = GNUNET_strdup(prefstring_tmp);
395  GNUNET_free(prefstring_tmp);
396  }
397 
398 
399  propstring = GNUNET_strdup("");
400  for (c = 1; c < GNUNET_ATS_PropertyCount; c++)
401  {
402  if (GNUNET_ATS_NETWORK_TYPE == c)
403  continue;
404  /*
405  fprintf(stderr, "\t %s = %.2f %.2f [abs/rel]\n",
406  GNUNET_ATS_print_property_type(c),
407  log_a->prop_abs[c], log_a->prop_norm[c]);*/
408  GNUNET_asprintf(&propstring_tmp, "%s%.3f;%.3f;",
409  propstring,
410  log_a->prop_abs[c],
411  log_a->prop_norm[c]);
412  GNUNET_free(propstring);
413  propstring = GNUNET_strdup(propstring_tmp);
414  GNUNET_free(propstring_tmp);
415  }
416  GNUNET_asprintf(&datastring, "%llu;%llu;%u;%u;%i;%u;%u;%s;%s\n",
418  lts->timestamp).rel_value_us / 1000, lts->delta,
419  log_p->is_requested, log_a->network, log_a->active,
420  log_a->assigned_bw_in, log_a->assigned_bw_out, propstring,
421  prefstring);
422 
423  GNUNET_DISK_file_write(cur->f_hd, datastring, strlen(datastring));
424  GNUNET_free(datastring);
425  GNUNET_free(prefstring);
426  GNUNET_free(propstring);
427  }
428  }
429  }
430 
431 cleanup:
432  next = lf_head;
433  for (cur = next; NULL != cur; cur = next)
434  {
435  next = cur->next;
436  GNUNET_CONTAINER_DLL_remove(lf_head, lf_tail, cur);
437  if (NULL != cur->f_hd)
439  GNUNET_free(cur);
440  }
441 }
#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:1339
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:681
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#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:817
#define DIR_SEPARATOR_STR
Definition: platform.h:168
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:77
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
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:1262
#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 444 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().

445 {
446  struct LoggingTimeStep *lts;
447  struct LoggingPeer *log_p;
448  struct LoggingAddress *log_a;
449  int c;
450 
451  for (lts = l->head; NULL != lts; lts = lts->next)
452  {
453  fprintf(stderr, "Log step %llu %llu: \n",
454  (long long unsigned int)lts->timestamp.abs_value_us,
455  (long long unsigned int)lts->delta.rel_value_us);
456 
457  for (log_p = lts->head; NULL != log_p; log_p = log_p->next)
458  {
459  fprintf(stderr, "\tLogging peer pid %llu\n", log_p->id);
460  for (c = 1; c < GNUNET_ATS_PreferenceCount; c++)
461  {
462  fprintf(stderr, "\t %s = %.2f %.2f [abs/rel]\n",
464  log_p->pref_abs[c], log_p->pref_norm[c]);
465  }
466 
467  for (log_a = log_p->addr_head; NULL != log_a; log_a = log_a->next)
468  {
469  fprintf(stderr, "\tPeer pid %llu address %llu: %u %u %u\n",
470  log_p->id, log_a->aid, log_a->active,
471  log_a->assigned_bw_in,
472  log_a->assigned_bw_out);
473 
474  for (c = 1; c < GNUNET_ATS_PropertyCount; c++)
475  {
476  if (GNUNET_ATS_NETWORK_TYPE == c)
477  continue;
478  fprintf(stderr, "\t %s = %.2f %.2f [abs/rel]\n",
479  GNUNET_ATS_print_property_type(c),
480  log_a->prop_abs[c], log_a->prop_norm[c]);
481  }
482  }
483  }
484  }
485 }
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 488 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().

489 {
490  struct LoggingTimeStep *lts_cur;
491  struct LoggingTimeStep *lts_next;
492  struct LoggingPeer *log_p_cur;
493  struct LoggingPeer *log_p_next;
494  struct LoggingAddress *log_a_cur;
495  struct LoggingAddress *log_a_next;
496 
497  if (NULL != l->logging_task)
499  l->logging_task = NULL;
500 
501  lts_next = l->head;
502  while (NULL != (lts_cur = lts_next))
503  {
504  lts_next = lts_cur->next;
505 
506  log_p_next = lts_cur->head;
507  while (NULL != (log_p_cur = log_p_next))
508  {
509  log_p_next = log_p_cur->next;
510 
511  log_a_next = log_p_cur->addr_head;
512  while (NULL != (log_a_cur = log_a_next))
513  {
514  log_a_next = log_a_cur->next;
515 
516  GNUNET_CONTAINER_DLL_remove(log_p_cur->addr_head, log_p_cur->addr_tail, log_a_cur);
517  GNUNET_free(log_a_cur);
518  }
519 
520  GNUNET_CONTAINER_DLL_remove(lts_cur->head, lts_cur->tail, log_p_cur);
521  GNUNET_free(log_p_cur);
522  }
523 
524  GNUNET_CONTAINER_DLL_remove(l->head, l->tail, lts_cur);
525  GNUNET_free(lts_cur);
526  }
527 
528  GNUNET_free(l);
529 }
#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:956
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 539 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().

540 {
541  struct GNUNET_TIME_Relative time_delta;
542  double delta_value;
543  double pref_value;
544 
545  /* Calculate the current preference value */
546  switch (pg->type)
547  {
549  pref_value = pg->base_value;
550  break;
551 
554  /* Calculate point of time in the current period */
555  time_delta.rel_value_us = time_delta.rel_value_us %
557  delta_value = ((double)time_delta.rel_value_us /
559  if ((pg->max_value < pg->base_value) &&
560  ((pg->max_value - pg->base_value) > pg->base_value))
561  {
562  /* This will cause an underflow */
563  GNUNET_break(0);
564  }
565  pref_value = pg->base_value + delta_value;
566  break;
567 
570  10000 * (pg->max_value - pg->base_value)) / 10000;
571  pref_value = pg->base_value + delta_value;
572  break;
573 
576  /* Calculate point of time in the current period */
577  time_delta.rel_value_us = time_delta.rel_value_us %
579  if ((pg->max_value - pg->base_value) > pg->base_value)
580  {
581  /* This will cause an underflow for second half of sinus period,
582  * will be detected in general when experiments are loaded */
583  GNUNET_break(0);
584  }
585  delta_value = (pg->max_value - pg->base_value) *
586  sin((2 * M_PI) / ((double)pg->duration_period.rel_value_us) *
587  time_delta.rel_value_us);
588  pref_value = pg->base_value + delta_value;
589  break;
590 
591  default:
592  pref_value = 0.0;
593  break;
594  }
595  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Current property value is %f\n",
596  pref_value);
597  return pref_value;
598 }
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 602 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().

603 {
604  struct PropertyGenerator *pg = cls;
605  struct TestPeer *p;
606  struct TestAddress *a;
607  double prop_value;
608  struct GNUNET_ATS_Information atsi;
609 
610  pg->set_task = NULL;
611 
613  &pg->test_peer->peer_id, pg->test_address->ats_addr))
614  {
615  GNUNET_break(0);
617  "Setting property generation for unknown address [%u:%u]\n",
618  pg->peer, pg->address_id);
619  return;
620  }
621  if (NULL == (p = find_peer_by_id(pg->peer)))
622  {
623  GNUNET_break(0);
625  "Setting property generation for unknown peer %u\n",
626  pg->peer);
627  return;
628  }
629  if (NULL == (a = find_address_by_id(p, pg->address_id)))
630  {
631  GNUNET_break(0);
633  "Setting property generation for unknown peer %u\n",
634  pg->peer);
635  return;
636  }
637 
638  prop_value = get_property(pg);
639  a->prop_abs[pg->ats_property] = prop_value;
640 
642  "Setting property for peer [%u] address [%u] for %s to %f\n",
643  pg->peer, pg->address_id,
644  GNUNET_ATS_print_property_type(pg->ats_property), prop_value);
645 
646  atsi.type = htonl(pg->ats_property);
647  atsi.value = htonl((uint32_t)prop_value);
648 
649  /* set performance here! */
650  sh->sf->s_bulk_start(sh->sf->cls);
652  {
653  a->prop_abs[pg->ats_property] = prop_value;
654  a->prop_norm[pg->ats_property] = prop_value;
656  pg->ats_property, prop_value, prop_value);
657  }
658  else
660  sh->sf->s_bulk_stop(sh->sf->cls);
661 
663  &set_prop_task, pg);
664 }
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:78
#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:1237
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:77
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 671 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().

673 {
674  struct PropertyGenerator *cur;
675 
676  for (cur = prop_gen_head; NULL != cur; cur = cur->next)
677  if ((cur->peer == peer) && (cur->address_id == address))
678  {
679  if ((cur->ats_property == ats_property) || (0 == ats_property))
680  return cur;
681  }
682  return NULL;
683 }
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 686 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().

687 {
689 
690  if (NULL != pg->set_task)
691  {
693  pg->set_task = NULL;
694  }
696  "Removing old up preference generator peer [%u] address [%u] `%s'\n",
697  pg->peer, pg->address_id,
698  GNUNET_ATS_print_property_type(pg->ats_property));
699 
700  GNUNET_free(pg);
701 }
#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:956
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 721 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().

731 {
732  struct PropertyGenerator *pg;
733 
734  pg = GNUNET_new(struct PropertyGenerator);
736  pg->type = type;
737  pg->peer = peer;
739  pg->test_peer = test_peer;
740  pg->address_id = address_id;
742  pg->base_value = base_value;
743  pg->max_value = value_rate;
744  pg->duration_period = period;
745  pg->frequency = frequency;
747 
748  switch (type)
749  {
752  "Setting up %s property generator peer [%u] address [%u] `%s'" \
753  "max %u Bips\n",
755  GNUNET_ATS_print_property_type(ats_property),
756  base_value);
757  break;
758 
761  "Setting up %s property generator peer [%u] address [%u] `%s' " \
762  "min %u Bips max %u Bips\n",
764  GNUNET_ATS_print_property_type(ats_property),
765  base_value, value_rate);
766  break;
767 
770  "Setting up %s property generator peer [%u] address [%u] `%s' " \
771  "baserate %u Bips, amplitude %u Bps\n",
773  GNUNET_ATS_print_property_type(ats_property),
774  base_value, value_rate);
775  break;
776 
779  "Setting up %s property generator peer [%u] address [%u] `%s' " \
780  "min %u Bips max %u Bps\n",
782  GNUNET_ATS_print_property_type(ats_property),
783  base_value, value_rate);
784  break;
785 
786  default:
787  break;
788  }
789 
791  return pg;
792 }
#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:1264
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 799 of file gnunet-ats-solver-eval.c.

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

Referenced by done().

800 {
801  struct PropertyGenerator *cur;
802  struct PropertyGenerator *next;
803 
804  next = prop_gen_head;
805  for (cur = next; NULL != cur; cur = next)
806  {
807  next = cur->next;
809  }
810 }
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 821 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().

822 {
823  struct GNUNET_TIME_Relative time_delta;
824  double delta_value;
825  double pref_value;
826 
827  /* Calculate the current preference value */
828  switch (pg->type)
829  {
831  pref_value = pg->base_value;
832  break;
833 
836  /* Calculate point of time in the current period */
837  time_delta.rel_value_us = time_delta.rel_value_us %
839  delta_value = ((double)time_delta.rel_value_us /
841  if ((pg->max_value < pg->base_value) &&
842  ((pg->max_value - pg->base_value) > pg->base_value))
843  {
844  /* This will cause an underflow */
845  GNUNET_break(0);
846  }
847  pref_value = pg->base_value + delta_value;
848  break;
849 
852  10000 * (pg->max_value - pg->base_value)) / 10000;
853  pref_value = pg->base_value + delta_value;
854  break;
855 
858  /* Calculate point of time in the current period */
859  time_delta.rel_value_us = time_delta.rel_value_us %
861  if ((pg->max_value - pg->base_value) > pg->base_value)
862  {
863  /* This will cause an underflow for second half of sinus period,
864  * will be detected in general when experiments are loaded */
865  GNUNET_break(0);
866  }
867  delta_value = (pg->max_value - pg->base_value) *
868  sin((2 * M_PI) / ((double)pg->duration_period.rel_value_us) *
869  time_delta.rel_value_us);
870  pref_value = pg->base_value + delta_value;
871  break;
872 
873  default:
874  pref_value = 0.0;
875  break;
876  }
877  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Current preference value is %f\n",
878  pref_value);
879  return pref_value;
880 }
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 884 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().

885 {
886  struct PreferenceGenerator *pg = cls;
887  struct TestPeer *p;
888  double feedback;
889  uint32_t bw_acc_out;
890  uint32_t bw_acc_in;
891  uint32_t delay_acc_in;
892  struct GNUNET_TIME_Relative dur;
893  double p_new;
894 
895  pg->feedback_task = NULL;
896 
897  if (NULL == (p = find_peer_by_id(pg->peer)))
898  {
899  GNUNET_break(0);
901  "Setting feedback for unknown peer %u\n", pg->peer);
902  return;
903  }
904 
905  switch (pg->kind)
906  {
909  bw_acc_in = dur.rel_value_us * pg->last_assigned_bw_in + pg->feedback_bw_in_acc;
910  pg->feedback_bw_in_acc = 0;
911 
912  bw_acc_out = dur.rel_value_us * pg->last_assigned_bw_out + pg->feedback_bw_out_acc;
913  p_new = get_preference(pg);
914  feedback = (p_new / pg->pref_bw_old) * (bw_acc_in + bw_acc_out) /
916 
917  break;
918 
921  delay_acc_in = dur.rel_value_us * pg->last_delay_value + pg->feedback_delay_acc;
922  pg->feedback_delay_acc = 0;
923 
924  p_new = get_preference(pg);
925  feedback = (p_new / pg->pref_latency_old) * (delay_acc_in) /
927 
928  break;
929 
930  default:
931  GNUNET_break(0);
932  feedback = 0.0;
933  break;
934  }
936  "Giving feedback for peer [%u] for client %p pref %s of %.3f\n",
937  pg->peer, NULL + (pg->client_id),
939  feedback);
940 
941  sh->sf->s_feedback(sh->sf->cls, NULL + (pg->client_id), &p->peer_id,
942  pg->feedback_frequency, pg->kind, feedback);
944 
945 
946  pg->feedback_bw_out_acc = 0;
947  pg->feedback_bw_in_acc = 0;
949 
950  pg->feedback_delay_acc = 0;
952 
953 
955  &set_feedback_task, pg);
956 }
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:1237
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 960 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().

961 {
962  struct PreferenceGenerator *pg = cls;
963  struct TestPeer *p;
964  double pref_value;
965 
966  pg->set_task = NULL;
967 
968  if (NULL == (p = find_peer_by_id(pg->peer)))
969  {
970  GNUNET_break(0);
972  "Setting preference for unknown peer %u\n", pg->peer);
973  return;
974  }
975 
976  pref_value = get_preference(pg);
977  switch (pg->kind)
978  {
980  pg->pref_bw_old = pref_value;
981  break;
982 
984  pg->pref_latency_old = pref_value;
985  break;
986 
987  default:
988  break;
989  }
990 
991  p->pref_abs[pg->kind] = pref_value;
992 
994  "Setting preference for peer [%u] for client %p pref %s to %f\n",
995  pg->peer, NULL + (pg->client_id),
996  GNUNET_ATS_print_preference_type(pg->kind), pref_value);
997 
999  {
1000  p->pref_abs[pg->kind] = pref_value;
1001  p->pref_norm[pg->kind] = pref_value;
1002  sh->sf->s_pref(sh->sf->cls, &p->peer_id, pg->kind, pref_value);
1003  }
1004  else
1005  update_preference(NULL + (pg->client_id),
1006  &p->peer_id,
1007  pg->kind,
1008  pref_value);
1009 
1011  &set_pref_task,
1012  pg);
1013 }
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:1237
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:77
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 1017 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().

1018 {
1019  struct PreferenceGenerator *cur;
1020 
1021  for (cur = pref_gen_head; NULL != cur; cur = cur->next)
1022  if (cur->peer == peer)
1023  {
1024  if ((cur->kind == kind) || (GNUNET_ATS_PREFERENCE_END == kind))
1025  return cur;
1026  }
1027  return NULL;
1028 }
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 1031 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().

1032 {
1034 
1035  if (NULL != pg->feedback_task)
1036  {
1038  pg->feedback_task = NULL;
1039  }
1040 
1041  if (NULL != pg->set_task)
1042  {
1044  pg->set_task = NULL;
1045  }
1047  "Removing old up preference generator peer [%u] `%s'\n",
1049 
1050  GNUNET_free(pg);
1051 }
#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:956
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 1055 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().

1056 {
1057  struct TestAddress *cur;
1058 
1059  for (cur = p->addr_head; NULL != cur; cur = cur->next)
1060  if (GNUNET_YES == cur->ats_addr->active)
1061  return cur;
1062  return NULL;
1063 }
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:77
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 1083 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().

1093 {
1094  struct PreferenceGenerator *pg;
1095  struct TestPeer *p;
1096 
1097  if (NULL == (p = find_peer_by_id(peer)))
1098  {
1099  GNUNET_break(0);
1101  "Starting preference for unknown peer %u\n", peer);
1102  return NULL;
1103  }
1104 
1105  pg = GNUNET_new(struct PreferenceGenerator);
1107  pg->type = type;
1108  pg->peer = peer;
1109  pg->client_id = client_id;
1110  pg->kind = kind;
1111  pg->base_value = base_value;
1112  pg->max_value = value_rate;
1113  pg->duration_period = period;
1114  pg->frequency = frequency;
1116  pg->feedback_frequency = feedback_frequency;
1117 
1118  switch (type)
1119  {
1122  "Setting up %s preference generator peer [%u] `%s' max %u Bips\n",
1125  base_value);
1126  break;
1127 
1130  "Setting up %s preference generator peer [%u] `%s' min %u Bips max %u Bips\n",
1132  base_value, value_rate);
1133  break;
1134 
1137  "Setting up %s preference generator peer [%u] `%s' baserate %u Bips, amplitude %u Bps\n",
1139  base_value, value_rate);
1140  break;
1141 
1144  "Setting up %s preference generator peer [%u] `%s' min %u Bips max %u Bps\n",
1146  base_value, value_rate);
1147  break;
1148 
1149  default:
1150  break;
1151  }
1152 
1154  if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != feedback_frequency.rel_value_us)
1155  {
1156  struct TestAddress * addr = find_active_address(p);
1157 
1160  pg->feedback_bw_in_acc = 0;
1161  pg->feedback_bw_out_acc = 0;
1162  pg->last_delay_value = addr->prop_norm[GNUNET_ATS_QUALITY_NET_DELAY];
1163  pg->feedback_delay_acc = 0;
1164 
1168  pg->feedback_task = GNUNET_SCHEDULER_add_delayed(feedback_frequency,
1169  &set_feedback_task, pg);
1170  }
1171 
1172  return pg;
1173 }
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:1237
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:1264
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 1181 of file gnunet-ats-solver-eval.c.

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

Referenced by done().

1182 {
1183  struct PreferenceGenerator *cur;
1184  struct PreferenceGenerator *next;
1185 
1186  next = pref_gen_head;
1187  for (cur = next; NULL != cur; cur = next)
1188  {
1189  next = cur->next;
1191  }
1192 }
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 1200 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().

1201 {
1202  switch (op)
1203  {
1204  case SOLVER_OP_ADD_ADDRESS:
1205  return "ADD_ADDRESS";
1206 
1207  case SOLVER_OP_DEL_ADDRESS:
1208  return "DEL_ADDRESS";
1209 
1211  return "START_SET_PREFERENCE";
1212 
1214  return "STOP_STOP_PREFERENCE";
1215 
1217  return "START_SET_PROPERTY";
1218 
1220  return "STOP_SET_PROPERTY";
1221 
1223  return "START_REQUEST";
1224 
1226  return "STOP_REQUEST";
1227 
1228  default:
1229  break;
1230  }
1231  return "";
1232 }
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 1236 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().

1237 {
1238  struct Experiment *e;
1239 
1240  e = GNUNET_new(struct Experiment);
1241  e->name = NULL;
1242  e->start = NULL;
1244  return e;
1245 }
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 1249 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().

1250 {
1251  struct Episode *cur;
1252  struct Episode *next;
1253  struct GNUNET_ATS_TEST_Operation *cur_o;
1254  struct GNUNET_ATS_TEST_Operation *next_o;
1255 
1256  next = e->start;
1257  for (cur = next; NULL != cur; cur = next)
1258  {
1259  next = cur->next;
1260 
1261  next_o = cur->head;
1262  for (cur_o = next_o; NULL != cur_o; cur_o = next_o)
1263  {
1264  next_o = cur_o->next;
1265  GNUNET_free_non_null(cur_o->address);
1266  GNUNET_free_non_null(cur_o->plugin);
1267  GNUNET_free(cur_o);
1268  }
1269  GNUNET_free(cur);
1270  }
1271 
1276  GNUNET_free(e);
1277 }
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 1281 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().

1286 {
1287  char *op_name;
1288  char *op_network;
1289 
1290  /* peer pid */
1291  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1293  sec_name, op_name, &o->peer_id))
1294  {
1295  fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1296  op_counter, "ADD_ADDRESS", op_name);
1297  GNUNET_free(op_name);
1298  return GNUNET_SYSERR;
1299  }
1300  GNUNET_free(op_name);
1301 
1302  /* address pid */
1303  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1305  sec_name, op_name, &o->address_id))
1306  {
1307  fprintf(stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1308  op_counter, "ADD_ADDRESS", op_name);
1309  GNUNET_free(op_name);
1310  return GNUNET_SYSERR;
1311  }
1312  GNUNET_free(op_name);
1313 
1314  /* plugin */
1315  GNUNET_asprintf(&op_name, "op-%u-plugin", op_counter);
1317  sec_name, op_name, &o->plugin))
1318  {
1319  fprintf(stderr, "Missing plugin in operation %u `%s' in episode `%s'\n",
1320  op_counter, "ADD_ADDRESS", op_name);
1321  GNUNET_free(op_name);
1322  return GNUNET_SYSERR;
1323  }
1324  GNUNET_free(op_name);
1325 
1326  /* address */
1327  GNUNET_asprintf(&op_name, "op-%u-address", op_counter);
1329  sec_name, op_name, &o->address))
1330  {
1331  fprintf(stderr, "Missing address in operation %u `%s' in episode `%s'\n",
1332  op_counter, "ADD_ADDRESS", op_name);
1333  GNUNET_free(op_name);
1334  return GNUNET_SYSERR;
1335  }
1336  GNUNET_free(op_name);
1337 
1338  /* session */
1339  GNUNET_asprintf(&op_name, "op-%u-address-session", op_counter);
1341  sec_name, op_name, &o->address_session))
1342  {
1343  fprintf(stderr, "Missing address-session in operation %u `%s' in episode `%s'\n",
1344  op_counter, "ADD_ADDRESS", op_name);
1345  GNUNET_free(op_name);
1346  return GNUNET_SYSERR;
1347  }
1348  GNUNET_free(op_name);
1349 
1350  /* network */
1351  GNUNET_asprintf(&op_name, "op-%u-address-network", op_counter);
1353  sec_name, op_name, &op_network))
1354  {
1355  fprintf(stderr, "Missing address-network in operation %u `%s' in episode `%s'\n",
1356  op_counter, "ADD_ADDRESS", op_name);
1357  GNUNET_free(op_name);
1358  return GNUNET_SYSERR;
1359  }
1360  else
1361  {
1362  GNUNET_STRINGS_utf8_toupper(op_network, op_network);
1363  if (0 == strcmp(op_network, "UNSPECIFIED"))
1364  {
1366  }
1367  else if (0 == strcmp(op_network, "LOOPBACK"))
1368  {
1370  }
1371  else if (0 == strcmp(op_network, "LAN"))
1372  {
1374  }
1375  else if (0 == strcmp(op_network, "WAN"))
1376  {
1378  }
1379  else if (0 == strcmp(op_network, "WLAN"))
1380  {
1382  }
1383  else if (0 == strcmp(op_network, "BT"))
1384  {
1386  }
1387  else
1388  {
1389  fprintf(stderr, "Invalid address-network in operation %u `%s' in episode `%s': `%s'\n",
1390  op_counter, "ADD_ADDRESS", op_name, op_network);
1391  GNUNET_free(op_network);
1392  GNUNET_free(op_name);
1393  return GNUNET_SYSERR;
1394  }
1395  }
1396  GNUNET_free(op_network);
1397  GNUNET_free(op_name);
1398 
1400  "Found operation %s: [%llu:%llu] address `%s' plugin `%s' \n",
1401  "ADD_ADDRESS", o->peer_id, o->address_id, o->address, o->plugin);
1402 
1403  return GNUNET_OK;
1404 }
Local area network.
Definition: gnunet_nt_lib.h:49
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:54
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
Wireless LAN (i.e.
Definition: gnunet_nt_lib.h:59
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
Bluetooth LAN.
Definition: gnunet_nt_lib.h:64
void GNUNET_STRINGS_utf8_toupper(const char *input, char *output)
Convert the utf-8 input string to upper case.
Definition: strings.c:577
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:76
Loopback (same host).
Definition: gnunet_nt_lib.h:44
#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:39
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 1408 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().

1413 {
1414  char *op_name;
1415 
1416  //char *op_network;
1417 
1418  /* peer pid */
1419  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1421  sec_name, op_name, &o->peer_id))
1422  {
1423  fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1424  op_counter, "DEL_ADDRESS", op_name);
1425  GNUNET_free(op_name);
1426  return GNUNET_SYSERR;
1427  }
1428  GNUNET_free(op_name);
1429 
1430  /* address pid */
1431  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1433  sec_name, op_name, &o->address_id))
1434  {
1435  fprintf(stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1436  op_counter, "DEL_ADDRESS", op_name);
1437  GNUNET_free(op_name);
1438  return GNUNET_SYSERR;
1439  }
1440  GNUNET_free(op_name);
1441 
1442 #if 0
1443  /* plugin */
1444  GNUNET_asprintf(&op_name, "op-%u-plugin", op_counter);
1446  sec_name, op_name, &o->plugin))
1447  {
1448  fprintf(stderr, "Missing plugin in operation %u `%s' in episode `%s'\n",
1449  op_counter, "DEL_ADDRESS", op_name);
1450  GNUNET_free(op_name);
1451  return GNUNET_SYSERR;
1452  }
1453  GNUNET_free(op_name);
1454 
1455  /* address */
1456  GNUNET_asprintf(&op_name, "op-%u-address", op_counter);
1458  sec_name, op_name, &o->address))
1459  {
1460  fprintf(stderr, "Missing address in operation %u `%s' in episode `%s'\n",
1461  op_counter, "DEL_ADDRESS", op_name);
1462  GNUNET_free(op_name);
1463  return GNUNET_SYSERR;
1464  }
1465  GNUNET_free(op_name);
1466 
1467  /* session */
1468  GNUNET_asprintf(&op_name, "op-%u-address-session", op_counter);
1470  sec_name, op_name, &o->address_session))
1471  {
1472  fprintf(stderr, "Missing address-session in operation %u `%s' in episode `%s'\n",
1473  op_counter, "DEL_ADDRESS", op_name);
1474  GNUNET_free(op_name);
1475  return GNUNET_SYSERR;
1476  }
1477  GNUNET_free(op_name);
1478 #endif
1479 
1481  "Found operation %s: [%llu:%llu] address `%s' plugin `%s' \n",
1482  "DEL_ADDRESS", o->peer_id, o->address_id, o->address, o->plugin);
1483 
1484  return GNUNET_OK;
1485 }
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:75
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:76
#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 1489 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().

1490 {
1491  int c = 0;
1492  char *props[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceTypeString;
1493 
1494  for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
1495  if (0 == strcmp(str, props[c]))
1496  return c;
1497  return 0;
1498 }
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 1502 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().

1507 {
1508  char *op_name;
1509  char *type;
1510  char *pref;
1511 
1512  /* peer pid */
1513  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1515  sec_name, op_name, &o->peer_id))
1516  {
1517  fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1518  op_counter, "START_SET_PREFERENCE", op_name);
1519  GNUNET_free(op_name);
1520  return GNUNET_SYSERR;
1521  }
1522  GNUNET_free(op_name);
1523 
1524  /* address pid */
1525  GNUNET_asprintf(&op_name, "op-%u-client-id", op_counter);
1527  sec_name, op_name, &o->client_id))
1528  {
1529  fprintf(stderr, "Missing client-id in operation %u `%s' in episode `%s'\n",
1530  op_counter, "START_SET_PREFERENCE", op_name);
1531  GNUNET_free(op_name);
1532  return GNUNET_SYSERR;
1533  }
1534  GNUNET_free(op_name);
1535 
1536  /* generator */
1537  GNUNET_asprintf(&op_name, "op-%u-gen-type", op_counter);
1539  sec_name, op_name, &type)))
1540  {
1541  fprintf(stderr, "Missing type in operation %u `%s' in episode `%s'\n",
1542  op_counter, "START_SET_PREFERENCE", op_name);
1543  GNUNET_free(op_name);
1544  return GNUNET_SYSERR;
1545  }
1546 
1547  /* Load arguments for set_rate, start_send, set_preference */
1548  if (0 == strcmp(type, "constant"))
1549  {
1551  }
1552  else if (0 == strcmp(type, "linear"))
1553  {
1555  }
1556  else if (0 == strcmp(type, "sinus"))
1557  {
1559  }
1560  else if (0 == strcmp(type, "random"))
1561  {
1563  }
1564  else
1565  {
1566  fprintf(stderr, "Invalid generator type %u `%s' in episode %u\n",
1567  op_counter, op_name, e->id);
1568  GNUNET_free(type);
1569  GNUNET_free(op_name);
1570  return GNUNET_SYSERR;
1571  }
1572  GNUNET_free(type);
1573  GNUNET_free(op_name);
1574 
1575 
1576  /* Get base rate */
1577  GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter);
1579  sec_name, op_name, &o->base_rate))
1580  {
1581  fprintf(stderr, "Missing base rate in operation %u `%s' in episode %u\n",
1582  op_counter, op_name, e->id);
1583  GNUNET_free(op_name);
1584  return GNUNET_SYSERR;
1585  }
1586  GNUNET_free(op_name);
1587 
1588 
1589  /* Get max rate */
1590  GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter);
1592  sec_name, op_name, &o->max_rate))
1593  {
1594  if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
1597  {
1598  fprintf(stderr, "Missing max rate in operation %u `%s' in episode %u\n",
1599  op_counter, op_name, e->id);
1600  GNUNET_free(op_name);
1601  return GNUNET_SYSERR;
1602  }
1603  }
1604  GNUNET_free(op_name);
1605 
1606  /* Get period */
1607  GNUNET_asprintf(&op_name, "op-%u-period", op_counter);
1609  sec_name, op_name, &o->period))
1610  {
1611  o->period = e->duration;
1612  }
1613  GNUNET_free(op_name);
1614 
1615  /* Get frequency */
1616  GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter);
1618  sec_name, op_name, &o->frequency))
1619  {
1620  fprintf(stderr, "Missing frequency in operation %u `%s' in episode %u\n",
1621  op_counter, op_name, e->id);
1622  GNUNET_free(op_name);
1623  return GNUNET_SYSERR;
1624  }
1625  GNUNET_free(op_name);
1626 
1627  /* Get preference */
1628  GNUNET_asprintf(&op_name, "op-%u-pref", op_counter);
1630  sec_name, op_name, &pref))
1631  {
1632  fprintf(stderr, "Missing preference in operation %u `%s' in episode %u\n",
1633  op_counter, op_name, e->id);
1634  GNUNET_free(op_name);
1635  return GNUNET_SYSERR;
1636  }
1637 
1638  if (0 == (o->pref_type = parse_preference_string(pref)))
1639  {
1640  fprintf(stderr, "Invalid preference in operation %u `%s' in episode %u\n",
1641  op_counter, op_name, e->id);
1642  GNUNET_free(op_name);
1643  GNUNET_free(pref);
1644  return GNUNET_SYSERR;
1645  }
1646  GNUNET_free(pref);
1647  GNUNET_free(op_name);
1648 
1649  /* Get feedback delay */
1650  GNUNET_asprintf(&op_name, "op-%u-feedback_delay", op_counter);
1652  sec_name, op_name, &o->feedback_delay))
1653  {
1654  fprintf(stderr, "Using feedback delay %llu in operation %u `%s' in episode %u\n",
1655  (long long unsigned int)o->feedback_delay.rel_value_us,
1656  op_counter, op_name, e->id);
1657  }
1658  else
1660  GNUNET_free(op_name);
1661 
1663  "Found operation %s: [%llu:%llu]: %s = %llu\n",
1664  "START_SET_PREFERENCE", o->peer_id, o->address_id,
1666 
1667  return GNUNET_OK;
1668 }
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:75
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:76
#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 1672 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().

1677 {
1678  char *op_name;
1679  char *pref;
1680 
1681  /* peer pid */
1682  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1684  sec_name, op_name, &o->peer_id))
1685  {
1686  fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1687  op_counter, "STOP_SET_PREFERENCE", op_name);
1688  GNUNET_free(op_name);
1689  return GNUNET_SYSERR;
1690  }
1691  GNUNET_free(op_name);
1692 
1693  /* address pid */
1694  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1696  sec_name, op_name, &o->address_id))
1697  {
1698  fprintf(stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1699  op_counter, "STOP_SET_PREFERENCE", op_name);
1700  GNUNET_free(op_name);
1701  return GNUNET_SYSERR;
1702  }
1703  GNUNET_free(op_name);
1704 
1705  /* Get preference */
1706  GNUNET_asprintf(&op_name, "op-%u-pref", op_counter);
1708  sec_name, op_name, &pref))
1709  {
1710  fprintf(stderr, "Missing preference in operation %u `%s' in episode `%s'\n",
1711  op_counter, "STOP_SET_PREFERENCE", op_name);
1712  GNUNET_free(op_name);
1713  return GNUNET_SYSERR;
1714  }
1715 
1716  if (0 == (o->pref_type = parse_preference_string(pref)))
1717  {
1718  fprintf(stderr, "Invalid preference in operation %u `%s' in episode %u\n",
1719  op_counter, op_name, e->id);
1720  GNUNET_free(op_name);
1721  GNUNET_free(pref);
1722  return GNUNET_SYSERR;
1723  }
1724  GNUNET_free(pref);
1725  GNUNET_free(op_name);
1726 
1728  "Found operation %s: [%llu:%llu]: %s\n",
1729  "STOP_SET_PREFERENCE", o->peer_id, o->address_id,
1731  return GNUNET_OK;
1732 }
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:75
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:76
#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 1736 of file gnunet-ats-solver-eval.c.

Referenced by load_op_start_set_property(), and load_op_stop_set_property().

1737 {
1738  enum GNUNET_ATS_Property c;
1739 
1740  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
1741  if (0 == strcmp(str,
1742  GNUNET_ATS_print_property_type(c)))
1743  return c;
1744  return 0;
1745 }
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 1749 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().

1754 {
1755  char *op_name;
1756  char *type;
1757  char *prop;
1758 
1759  /* peer pid */
1760  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1762  sec_name, op_name, &o->peer_id))
1763  {
1764  fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1765  op_counter, "START_SET_PROPERTY", op_name);
1766  GNUNET_free(op_name);
1767  return GNUNET_SYSERR;
1768  }
1769  GNUNET_free(op_name);
1770 
1771  /* address pid */
1772  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1774  sec_name, op_name, &o->address_id))
1775  {
1776  fprintf(stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1777  op_counter, "START_SET_PROPERTY", op_name);
1778  GNUNET_free(op_name);
1779  return GNUNET_SYSERR;
1780  }
1781  GNUNET_free(op_name);
1782 
1783  /* generator */
1784  GNUNET_asprintf(&op_name, "op-%u-gen-type", op_counter);
1786  sec_name, op_name, &type)))
1787  {
1788  fprintf(stderr, "Missing type in operation %u `%s' in episode `%s'\n",
1789  op_counter, "START_SET_PROPERTY", op_name);
1790  GNUNET_free(op_name);
1791  return GNUNET_SYSERR;
1792  }
1793 
1794  /* Load arguments for set_rate, start_send, set_preference */
1795  if (0 == strcmp(type, "constant"))
1796  {
1798  }
1799  else if (0 == strcmp(type, "linear"))
1800  {
1802  }
1803  else if (0 == strcmp(type, "sinus"))
1804  {
1806  }
1807  else if (0 == strcmp(type, "random"))
1808  {
1810  }
1811  else
1812  {
1813  fprintf(stderr, "Invalid generator type %u `%s' in episode %u\n",
1814  op_counter, op_name, e->id);
1815  GNUNET_free(type);
1816  GNUNET_free(op_name);
1817  return GNUNET_SYSERR;
1818  }
1819  GNUNET_free(type);
1820  GNUNET_free(op_name);
1821 
1822 
1823  /* Get base rate */
1824  GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter);
1826  sec_name, op_name, &o->base_rate))
1827  {
1828  fprintf(stderr, "Missing base rate in operation %u `%s' in episode %u\n",
1829  op_counter, op_name, e->id);
1830  GNUNET_free(op_name);
1831  return GNUNET_SYSERR;
1832  }
1833  GNUNET_free(op_name);
1834 
1835 
1836  /* Get max rate */
1837  GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter);
1839  sec_name, op_name, &o->max_rate))
1840  {
1841  if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
1844  {
1845  fprintf(stderr, "Missing max rate in operation %u `%s' in episode %u\n",
1846  op_counter, op_name, e->id);
1847  GNUNET_free(op_name);
1848  return GNUNET_SYSERR;
1849  }
1850  }
1851  GNUNET_free(op_name);
1852 
1853  /* Get period */
1854  GNUNET_asprintf(&op_name, "op-%u-period", op_counter);
1856  sec_name, op_name, &o->period))
1857  {
1858  o->period = e->duration;
1859  }
1860  GNUNET_free(op_name);
1861 
1862  /* Get frequency */
1863  GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter);
1865  sec_name, op_name, &o->frequency))
1866  {
1867  fprintf(stderr, "Missing frequency in operation %u `%s' in episode %u\n",
1868  op_counter, op_name, e->id);
1869  GNUNET_free(op_name);
1870  return GNUNET_SYSERR;
1871  }
1872  GNUNET_free(op_name);
1873 
1874  /* Get preference */
1875  GNUNET_asprintf(&op_name, "op-%u-property", op_counter);
1877  sec_name, op_name, &prop))
1878  {
1879  fprintf(stderr, "Missing property in operation %u `%s' in episode %u\n",
1880  op_counter, op_name, e->id);
1881  GNUNET_free(op_name);
1882  GNUNET_free_non_null(prop);
1883  return GNUNET_SYSERR;
1884  }
1885 
1886  if (0 == (o->prop_type = parse_property_string(prop)))
1887  {
1888  fprintf(stderr, "Invalid property in operation %u `%s' in episode %u\n",
1889  op_counter, op_name, e->id);
1890  GNUNET_free(op_name);
1891  GNUNET_free(prop);
1892  return GNUNET_SYSERR;
1893  }
1894 
1895  GNUNET_free(prop);
1896  GNUNET_free(op_name);
1897 
1899  "Found operation %s: [%llu:%llu] %s = %llu\n",
1900  "START_SET_PROPERTY", o->peer_id, o->address_id,
1901  GNUNET_ATS_print_property_type(o->prop_type), o->base_rate);
1902 
1903  return GNUNET_OK;
1904 }
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:75
#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:76
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 1907 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().

1912 {
1913  char *op_name;
1914  char *pref;
1915 
1916  /* peer pid */
1917  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1919  sec_name, op_name, &o->peer_id))
1920  {
1921  fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1922  op_counter, "STOP_SET_PROPERTY", op_name);
1923  GNUNET_free(op_name);
1924  return GNUNET_SYSERR;
1925  }
1926  GNUNET_free(op_name);
1927 
1928  /* address pid */
1929  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1931  sec_name, op_name, &o->address_id))
1932  {
1933  fprintf(stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1934  op_counter, "STOP_SET_PROPERTY", op_name);
1935  GNUNET_free(op_name);
1936  return GNUNET_SYSERR;
1937  }
1938  GNUNET_free(op_name);
1939 
1940  /* Get property */
1941  GNUNET_asprintf(&op_name, "op-%u-property", op_counter);
1943  sec_name, op_name, &pref))
1944  {
1945  fprintf(stderr, "Missing property in operation %u `%s' in episode `%s'\n",
1946  op_counter, "STOP_SET_PROPERTY", op_name);
1947  GNUNET_free(op_name);
1948  GNUNET_free_non_null(pref);
1949  return GNUNET_SYSERR;
1950  }
1951 
1952  if (0 == (o->prop_type = parse_property_string(pref)))
1953  {
1954  fprintf(stderr, "Invalid property in operation %u `%s' in episode %u\n",
1955  op_counter, op_name, e->id);
1956  GNUNET_free(op_name);
1957  GNUNET_free_non_null(pref);
1958  return GNUNET_SYSERR;
1959  }
1960 
1961  GNUNET_free(pref);
1962  GNUNET_free(op_name);
1963 
1965  "Found operation %s: [%llu:%llu] %s\n",
1966  "STOP_SET_PROPERTY", o->peer_id, o->address_id,
1967  GNUNET_ATS_print_property_type(o->prop_type));
1968 
1969  return GNUNET_OK;
1970 }
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:75
#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:76
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 1974 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().

1979 {
1980  char *op_name;
1981 
1982  /* peer pid */
1983  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1985  sec_name, op_name, &o->peer_id))
1986  {
1987  fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1988  op_counter, "START_REQUEST", op_name);
1989  GNUNET_free(op_name);
1990  return GNUNET_SYSERR;
1991  }
1992  GNUNET_free(op_name);
1993  return GNUNET_OK;
1994 }
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:75
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
#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 1997 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().

2002 {
2003  char *op_name;
2004 
2005  /* peer pid */
2006  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
2008  sec_name, op_name, &o->peer_id))
2009  {
2010  fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
2011  op_counter, "STOP_REQUEST", op_name);
2012  GNUNET_free(op_name);
2013  return GNUNET_SYSERR;
2014  }
2015  GNUNET_free(op_name);
2016  return GNUNET_OK;
2017 }
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:75
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
#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 2021 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().

2023 {
2024  struct GNUNET_ATS_TEST_Operation *o;
2025  char *sec_name;
2026  char *op_name;
2027  char *op;
2028  int op_counter = 0;
2029  int res;
2030 
2031  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "=== Parsing episode %u\n", cur->id);
2032  GNUNET_asprintf(&sec_name, "episode-%u", cur->id);
2033 
2034  while (1)
2035  {
2036  /* Load operation */
2037  GNUNET_asprintf(&op_name, "op-%u-operation", op_counter);
2039  sec_name, op_name, &op))
2040  {
2041  GNUNET_free(op_name);
2042  break;
2043  }
2045  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "==== Parsing operation %u: `%s'\n",
2046  cur->id, op_name);
2047 
2048  /* operations = set_rate, start_send, stop_send, set_preference */
2049  if (0 == strcmp(op, "address_add"))
2050  {
2052  res = load_op_add_address(o, cur,
2053  op_counter, sec_name, cfg);
2054  }
2055  else if (0 == strcmp(op, "address_del"))
2056  {
2058  res = load_op_del_address(o, cur,
2059  op_counter, sec_name, cfg);
2060  }
2061  else if (0 == strcmp(op, "start_set_property"))
2062  {
2064  res = load_op_start_set_property(o, cur,
2065  op_counter, sec_name, cfg);
2066  }
2067  else if (0 == strcmp(op, "stop_set_property"))
2068  {
2070  res = load_op_stop_set_property(o, cur,
2071  op_counter, sec_name, cfg);
2072  }
2073  else if (0 == strcmp(op, "start_set_preference"))
2074  {
2076  res = load_op_start_set_preference(o, cur,
2077  op_counter, sec_name, cfg);
2078  }
2079  else if (0 == strcmp(op, "stop_set_preference"))
2080  {
2082  res = load_op_stop_set_preference(o, cur,
2083  op_counter, sec_name, cfg);
2084  }
2085  else if (0 == strcmp(op, "start_request"))
2086  {
2088  res = load_op_start_request(o, cur,
2089  op_counter, sec_name, cfg);
2090  }
2091  else if (0 == strcmp(op, "stop_request"))
2092  {
2094  res = load_op_stop_request(o, cur,
2095  op_counter, sec_name, cfg);
2096  }
2097  else
2098  {
2099  fprintf(stderr, "Invalid operation %u `%s' in episode %u\n",
2100  op_counter, op, cur->id);
2101  res = GNUNET_SYSERR;
2102  }
2103 
2104  GNUNET_free(op);
2105  GNUNET_free(op_name);
2106 
2107  if (GNUNET_SYSERR == res)
2108  {
2109  GNUNET_free(o);
2110  GNUNET_free(sec_name);
2111  return GNUNET_SYSERR;
2112  }
2113 
2115  op_counter++;
2116  }
2117  GNUNET_free(sec_name);
2118  return GNUNET_OK;
2119 }
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:75
#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:76
#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 2122 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().

2123 {
2124  int e_counter = 0;
2125  char *sec_name;
2126  struct GNUNET_TIME_Relative e_duration;
2127  struct Episode *cur;
2128  struct Episode *last;
2129 
2130  e_counter = 0;
2131  last = NULL;
2132  while (1)
2133  {
2134  GNUNET_asprintf(&sec_name, "episode-%u", e_counter);
2136  sec_name, "duration", &e_duration))
2137  {
2138  GNUNET_free(sec_name);
2139  break;
2140  }
2141 
2142  cur = GNUNET_new(struct Episode);
2143  cur->duration = e_duration;
2144  cur->id = e_counter;
2145 
2146  if (GNUNET_OK != load_episode(e, cur, cfg))
2147  {
2148  GNUNET_free(sec_name);
2149  GNUNET_free(cur);
2150  return GNUNET_SYSERR;
2151  }
2152 
2153  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Found episode %u with duration %s \n",
2154  e_counter,
2156 
2157  /* Update experiment */
2158  e->num_episodes++;
2160  /* Put in linked list */
2161  if (NULL == last)
2162  e->start = cur;
2163  else
2164  last->next = cur;
2165 
2166  GNUNET_free(sec_name);
2167  e_counter++;
2168  last = cur;
2169  }
2170  return e_counter;
2171 }
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:75
#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:686
struct GNUNET_TIME_Relative duration
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
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:577
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
#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 2175 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().

2176 {
2177  struct Experiment *e = cls;
2178 
2179  e->experiment_timeout_task = NULL;
2180  fprintf(stderr, "Experiment timeout!\n");
2181 
2182  if (NULL != e->episode_timeout_task)
2183  {
2185  e->episode_timeout_task = NULL;
2186  }
2187 
2189  GNUNET_SYSERR);
2190 }
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:76
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:956
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 2193 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().

2199 {
2200  struct ATS_Address *aa = NULL;
2201 
2202  aa = GNUNET_malloc(sizeof(struct ATS_Address) + plugin_addr_len + strlen(plugin_name) + 1);
2203  aa->atsi = GNUNET_new(struct GNUNET_ATS_Information);
2204  aa->atsi[0].type = htonl(GNUNET_ATS_NETWORK_TYPE);
2205  aa->atsi[0].value = htonl(network);
2206  aa->atsi_count = 1;
2207 
2208  aa->peer = *peer;
2209  aa->addr_len = plugin_addr_len;
2210  aa->addr = &aa[1];
2211  aa->plugin = (char *)&aa[1] + plugin_addr_len;
2212  GNUNET_memcpy(&aa[1], plugin_addr, plugin_addr_len);
2213  GNUNET_memcpy(aa->plugin, plugin_name, strlen(plugin_name) + 1);
2214  aa->session_id = session_id;
2215 
2216  return aa;
2217 }
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).
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
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.
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 2222 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().

2223 {
2224  struct TestPeer *p;
2225  struct TestAddress *a;
2226  int c;
2227 
2228  if (NULL == (p = find_peer_by_id(op->peer_id)))
2229  {
2230  p = GNUNET_new(struct TestPeer);
2231  p->id = op->peer_id;
2232  p->assigned_bw_in = 0;
2233  p->assigned_bw_out = 0;
2234  memset(&p->peer_id, op->peer_id, sizeof(p->peer_id));
2235  for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
2236  {
2239  }
2240 
2242  }
2243 
2244  if (NULL != (find_address_by_id(p, op->address_id)))
2245  {
2246  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Duplicate address %u for peer %u\n",
2247  op->address_id, op->peer_id);
2248  return;
2249  }
2250 
2251  a = GNUNET_new(struct TestAddress);
2252  a->aid = op->address_id;
2253  a->network = op->address_network;
2254  a->ats_addr = create_ats_address(&p->peer_id, op->plugin, op->address,
2255  strlen(op->address) + 1, op->address_session, op->address_network);
2256  memset(&p->peer_id, op->peer_id, sizeof(p->peer_id));
2258 
2259  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
2261 
2264 
2265  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Adding address %u for peer %u in network `%s'\n",
2267 
2268  sh->sf->s_add(sh->sf->cls, a->ats_addr, op->address_network);
2269 }
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 2273 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().

2274 {
2275  struct TestPeer *p;
2276  struct TestAddress *a;
2277  struct PropertyGenerator *pg;
2278 
2279  if (NULL == (p = find_peer_by_id(op->peer_id)))
2280  {
2281  GNUNET_break(0);
2283  "Deleting address for unknown peer %u\n", op->peer_id);
2284  return;
2285  }
2286 
2287  if (NULL == (a = find_address_by_id(p, op->address_id)))
2288  {
2289  GNUNET_break(0);
2291  "Deleting address for unknown peer %u\n", op->peer_id);
2292  return;
2293  }
2294 
2295  while (NULL != (pg = find_prop_gen(p->id, a->aid, 0)))
2296  {
2298  }
2299 
2302  &p->peer_id,
2303  a->ats_addr));
2305  "Removing address %u for peer %u\n",
2306  op->address_id,
2307  op->peer_id);
2308 
2309  sh->sf->s_del(sh->sf->cls, a->ats_addr);
2310 
2311  if (NULL != l)
2312  {
2314  }
2316 
2317  GNUNET_free_non_null(a->ats_addr->atsi);
2318  GNUNET_free(a->ats_addr);
2319  GNUNET_free(a);
2320 }
#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:77
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 2323 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().

2324 {
2325  struct PropertyGenerator *pg;
2326  struct TestPeer *p;
2327  struct TestAddress *a;
2328 
2329  if (NULL != (pg = find_prop_gen(op->peer_id, op->address_id, op->prop_type)))
2330  {
2332  GNUNET_free(pg);
2333  }
2334 
2335  if (NULL == (p = find_peer_by_id(op->peer_id)))
2336  {
2337  GNUNET_break(0);
2339  "Starting property generation for unknown peer %u\n", op->peer_id);
2340  return;
2341  }
2342 
2343  if (NULL == (a = find_address_by_id(p, op->address_id)))
2344  {
2345  GNUNET_break(0);
2347  "Setting property for unknown address %u\n", op->peer_id);
2348  return;
2349  }
2350 
2352  op->address_id,
2353  p, a,
2354  op->gen_type,
2355  op->base_rate,
2356  op->max_rate,
2357  op->period,
2358  op->frequency,
2359  op->prop_type);
2360 }
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 2363 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().

2364 {
2365  struct PropertyGenerator *pg = find_prop_gen(op->peer_id, op->address_id,
2366  op->prop_type);
2367 
2368  if (NULL != pg)
2369  {
2371  "Stopping preference generation for peer %u address %u\n", op->peer_id,
2372  op->address_id);
2374  }
2375  else
2376  {
2378  "Cannot find preference generator for peer %u address %u\n",
2379  op->peer_id, op->address_id);
2380  GNUNET_break(0);
2381  }
2382 }
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 2385 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().

2386 {
2387  struct PreferenceGenerator *pg;
2388 
2389  if (NULL != (pg = find_pref_gen(op->peer_id, op->pref_type)))
2390  {
2392  GNUNET_free(pg);
2393  }
2394 
2395  if (NULL == (find_peer_by_id(op->peer_id)))
2396  {
2397  GNUNET_break(0);
2399  "Starting preference generation for unknown peer %u\n", op->peer_id);
2400  return;
2401  }
2402 
2404  op->address_id,
2405  op->client_id,
2406  op->gen_type,
2407  op->base_rate,
2408  op->max_rate,
2409  op->period,
2410  op->frequency,
2411  op->pref_type,
2412  op->frequency);
2413 }
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