aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-service-transport.c48
-rw-r--r--src/transport/test_transport_ats.c121
2 files changed, 145 insertions, 24 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 70a15775b..9edd38c28 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -5574,6 +5574,14 @@ struct ATS_peer
5574 int t; 5574 int t;
5575}; 5575};
5576 5576
5577struct ATS_result
5578{
5579 int c_mechs;
5580 int c_peers;
5581 int solution;
5582};
5583
5584
5577#define DEBUG_ATS GNUNET_NO 5585#define DEBUG_ATS GNUNET_NO
5578#define VERBOSE_ATS GNUNET_NO 5586#define VERBOSE_ATS GNUNET_NO
5579 5587
@@ -5585,9 +5593,10 @@ struct ATS_peer
5585 * @param R weight for relativity 5593 * @param R weight for relativity
5586 * @param v_b_min minimal bandwidth per peer 5594 * @param v_b_min minimal bandwidth per peer
5587 * @param v_n_min minimum number of connections 5595 * @param v_n_min minimum number of connections
5596 * @param res result struct
5588 * @return GNUNET_SYSERR if glpk is not available, number of mechanisms used 5597 * @return GNUNET_SYSERR if glpk is not available, number of mechanisms used
5589 */ 5598 */
5590static int ats_create_problem (int max_it, int max_dur , double D, double U, double R, int v_b_min, int v_n_min) 5599static int ats_create_problem (int max_it, int max_dur , double D, double U, double R, int v_b_min, int v_n_min, struct ATS_result *res)
5591{ 5600{
5592#if !HAVE_LIBGLPK 5601#if !HAVE_LIBGLPK
5593 if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "no glpk installed\n"); 5602 if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "no glpk installed\n");
@@ -5934,7 +5943,9 @@ static int ats_create_problem (int max_it, int max_dur , double D, double U, dou
5934 ia[array_index] = row_index; 5943 ia[array_index] = row_index;
5935 ja[array_index] = (2*c_mechs) + 2; 5944 ja[array_index] = (2*c_mechs) + 2;
5936 ar[array_index] = -1; 5945 ar[array_index] = -1;
5937 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); 5946#if VERBOSE_ATS
5947 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
5948#endif
5938 5949
5939 array_index++; 5950 array_index++;
5940 row_index ++; 5951 row_index ++;
@@ -6019,7 +6030,7 @@ static int ats_create_problem (int max_it, int max_dur , double D, double U, dou
6019 case GLP_EOBJLL : /* objective lower limit reached */ 6030 case GLP_EOBJLL : /* objective lower limit reached */
6020 case GLP_EOBJUL : /* objective upper limit reached */ 6031 case GLP_EOBJUL : /* objective upper limit reached */
6021 case GLP_EROOT : /* root LP optimum not provided */ 6032 case GLP_EROOT : /* root LP optimum not provided */
6022 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid Input data\n"); 6033 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid Input data: %i\n", result);
6023 break; 6034 break;
6024 6035
6025 break; 6036 break;
@@ -6027,7 +6038,7 @@ static int ats_create_problem (int max_it, int max_dur , double D, double U, dou
6027 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem has been solved\n"); 6038 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem has been solved\n");
6028 break; 6039 break;
6029 } 6040 }
6030 6041#if VERBOSE_ATS
6031 switch (solution) { 6042 switch (solution) {
6032 case GLP_UNDEF: 6043 case GLP_UNDEF:
6033 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MIP solution is undefined\n"); 6044 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MIP solution is undefined\n");
@@ -6057,11 +6068,17 @@ static int ats_create_problem (int max_it, int max_dur , double D, double U, dou
6057 old = debug_solution; 6068 old = debug_solution;
6058 GNUNET_asprintf(&debug_solution, "%s z = %g; \n", debug_solution, glp_get_obj_val(prob)); 6069 GNUNET_asprintf(&debug_solution, "%s z = %g; \n", debug_solution, glp_get_obj_val(prob));
6059 if (old!=NULL) GNUNET_free(old); 6070 if (old!=NULL) GNUNET_free(old);
6060 if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s \n",debug_solution); 6071 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s \n",debug_solution);
6072 GNUNET_free(debug_solution);
6073#endif
6074
6075 res->c_mechs = c_mechs;
6076 res->c_peers = c_peers;
6077 res->solution = solution;
6061 6078
6062 /* clean up */ 6079 /* clean up */
6063 6080
6064 GNUNET_free(debug_solution); 6081
6065 glp_delete_prob(prob); 6082 glp_delete_prob(prob);
6066 6083
6067 GNUNET_free (ja); 6084 GNUNET_free (ja);
@@ -6082,16 +6099,25 @@ void ats_benchmark (int peers, int transports, int start_peers, int end_peers)
6082 struct GNUNET_TIME_Absolute start; 6099 struct GNUNET_TIME_Absolute start;
6083 struct GNUNET_TIME_Relative duration; 6100 struct GNUNET_TIME_Relative duration;
6084 int c_mechs = 0; 6101 int c_mechs = 0;
6102 struct ATS_result result;
6085 6103
6086 if (glpk==GNUNET_YES) 6104 if (glpk==GNUNET_YES)
6087 { 6105 {
6088 start = GNUNET_TIME_absolute_get(); 6106 start = GNUNET_TIME_absolute_get();
6089 c_mechs = ats_create_problem(5000, 5000, 1.0, 1.0, 1.0, 1000, 5); 6107 c_mechs = ats_create_problem(5000, 5000, 1.0, 1.0, 1.0, 1000, 5, &result);
6090 if (c_mechs >= 0)
6091 {
6092 duration = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get()); 6108 duration = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get());
6093 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP execution time in [ms] for %i mechanisms: %llu\n", c_mechs, duration.rel_value); 6109 if (c_mechs > 0)
6094 //GNUNET_STATISTICS_set (stats, "ATS execution time 100 peers", duration.rel_value, GNUNET_NO); 6110 {
6111 if (DEBUG_ATS) {GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP execution time in [ms] for %i mechanisms: %llu\n", c_mechs, duration.rel_value);}
6112 GNUNET_STATISTICS_set (stats, "ATS duration", duration.rel_value, GNUNET_NO);
6113 GNUNET_STATISTICS_set (stats, "ATS mechanisms", result.c_mechs, GNUNET_NO);
6114 GNUNET_STATISTICS_set (stats, "ATS peers", result.c_peers, GNUNET_NO);
6115 GNUNET_STATISTICS_set (stats, "ATS solution", result.solution, GNUNET_NO);
6116 GNUNET_STATISTICS_set (stats, "ATS timestamp", start.abs_value, GNUNET_NO);
6117 }
6118 else if (c_mechs == 0)
6119 {
6120 if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP not executed: no addresses\n");
6095 } 6121 }
6096 else glpk = GNUNET_NO; 6122 else glpk = GNUNET_NO;
6097 } 6123 }
diff --git a/src/transport/test_transport_ats.c b/src/transport/test_transport_ats.c
index 9f4e8d05f..2880da8e5 100644
--- a/src/transport/test_transport_ats.c
+++ b/src/transport/test_transport_ats.c
@@ -25,11 +25,12 @@
25#include "gnunet_testing_lib.h" 25#include "gnunet_testing_lib.h"
26#include "gnunet_scheduler_lib.h" 26#include "gnunet_scheduler_lib.h"
27 27
28#define VERBOSE GNUNET_YES 28#define VERBOSE GNUNET_NO
29 29
30#define NUM_PEERS 2 30#define NUM_PEERS 11
31#define MEASUREMENTS 5
31 32
32#define DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) 33#define DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
33#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) 34#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
34 35
35 36
@@ -39,12 +40,27 @@ static int peers_left;
39 40
40static int failed_peers; 41static int failed_peers;
41 42
43static int measurement_started;
44
42static struct GNUNET_TESTING_PeerGroup *pg; 45static struct GNUNET_TESTING_PeerGroup *pg;
43 46
44static GNUNET_SCHEDULER_TaskIdentifier task; 47static GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
48static GNUNET_SCHEDULER_TaskIdentifier stats_task;
45 49
46struct GNUNET_TESTING_Daemon * master_deamon; 50struct GNUNET_TESTING_Daemon * master_deamon;
47 51
52struct GNUNET_STATISTICS_Handle * stats;
53
54struct ATS_result
55{
56 uint64_t timestamp;
57 int mechs;
58 int peers;
59 int solution;
60};
61
62//static int index;
63static struct ATS_result results[MEASUREMENTS];
48 64
49/** 65/**
50 * Check whether peers successfully shut down. 66 * Check whether peers successfully shut down.
@@ -71,26 +87,94 @@ shutdown_callback (void *cls, const char *emsg)
71 87
72static void shutdown_peers() 88static void shutdown_peers()
73{ 89{
90 if (shutdown_task != GNUNET_SCHEDULER_NO_TASK)
91 GNUNET_SCHEDULER_cancel(shutdown_task);
92 if (stats_task != GNUNET_SCHEDULER_NO_TASK)
93 GNUNET_SCHEDULER_cancel(stats_task);
94
74 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); 95 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
75} 96}
76 97
98int stats_cb (void *cls,
99 const char *subsystem,
100 const char *name,
101 uint64_t value,
102 int is_persistent)
103{
104 if ((measurement_started == GNUNET_NO) && (0 == strcmp (name, "ATS peers")) && (value == NUM_PEERS-1))
105 {
106 measurement_started = GNUNET_YES;
107 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
108 "All %llu peers connected\n", value);
109 }
110 if (measurement_started == GNUNET_YES)
111 {
112 if (0 == strcmp (name,"ATS timestamp"))
113 {
114 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
115 "ATS timestamp: %s %llu \n",name, value);
116 }
117 if (0 == strcmp (name,"ATS solution"))
118 {
119 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
120 "ATS solution: %s %llu \n",name, value);
121 }
122 if (0 == strcmp (name,"ATS peers"))
123 {
124 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
125 "ATS peers: %s %llu \n",name, value);
126 }
127 if (0 == strcmp (name,"ATS mechanisms"))
128 {
129 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
130 "ATS mechanisms: %s %llu \n",name, value);
131 }
132 if (0 == strcmp (name,"ATS duration"))
133 {
134 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
135 "ATS duration: %s %llu \n",name, value);
136 }
137 }
138
139 return GNUNET_OK;
140}
141
142
77void 143void
78delay_task (void *cls, 144stats_get_task (void *cls,
79 const struct GNUNET_SCHEDULER_TaskContext *tc) 145 const struct GNUNET_SCHEDULER_TaskContext *tc)
80{ 146{
81 task = GNUNET_SCHEDULER_NO_TASK; 147 stats_task = GNUNET_SCHEDULER_NO_TASK;
148 if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
149 return;
150
151 GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", TIMEOUT, NULL, &stats_cb, NULL);
152 GNUNET_STATISTICS_get (stats, "transport", "ATS solution", TIMEOUT, NULL, &stats_cb, NULL);
153 GNUNET_assert (NULL != GNUNET_STATISTICS_get (stats, "transport","ATS duration", TIMEOUT, NULL, &stats_cb, NULL));
154 GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL);
155 GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL);
156
157 stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), &stats_get_task, NULL);
158}
159
160void
161delay (void *cls,
162 const struct GNUNET_SCHEDULER_TaskContext *tc)
163{
164 shutdown_task = GNUNET_SCHEDULER_NO_TASK;
82 if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) 165 if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
83 return; 166 return;
84 167
85#if VERBOSE 168#if VERBOSE
86 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Delay over\n"); 169 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Delay over\n");
87#endif 170#endif
171 GNUNET_STATISTICS_destroy(stats, GNUNET_NO);
88 shutdown_peers (); 172 shutdown_peers ();
89} 173}
90 174
91static void connect_peers() 175static void connect_peers()
92{ 176{
93 task = GNUNET_SCHEDULER_add_delayed(DELAY, &delay_task, NULL); 177 shutdown_task = GNUNET_SCHEDULER_add_delayed(DELAY, &delay, NULL);
94 178
95} 179}
96 180
@@ -104,7 +188,13 @@ void daemon_connect_cb(void *cls,
104 struct GNUNET_TESTING_Daemon *second_daemon, 188 struct GNUNET_TESTING_Daemon *second_daemon,
105 const char *emsg) 189 const char *emsg)
106{ 190{
107 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected peer `%s' \n", GNUNET_i2s(first), GNUNET_i2s(second)); 191 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected peers `%s'<->`%s': `%s' \n", GNUNET_i2s(first), GNUNET_i2s(second), (emsg==NULL) ? "OK" : emsg);
192}
193
194void cont_cb (void *cls, int success)
195{
196 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
197 "STATS cont_cb: %i\n", success);
108} 198}
109 199
110static void 200static void
@@ -124,7 +214,7 @@ daemon_start_cb (void *cls,
124 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 214 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
125 "Too many peers failed, ending test!\n"); 215 "Too many peers failed, ending test!\n");
126 ok = 1; 216 ok = 1;
127 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); 217 shutdown_peers ();
128 } 218 }
129 return; 219 return;
130 } 220 }
@@ -132,13 +222,17 @@ daemon_start_cb (void *cls,
132 222
133 if (master_deamon == NULL) 223 if (master_deamon == NULL)
134 { 224 {
135 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Master peer `%s'\n", GNUNET_i2s(id)); 225 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Master peer `%s' '%s'\n", GNUNET_i2s(id), d->cfgfile);
226
136 master_deamon = d; 227 master_deamon = d;
228 stats = GNUNET_STATISTICS_create("transport", master_deamon->cfg);
229 GNUNET_assert (stats != NULL);
230 stats_task = GNUNET_SCHEDULER_add_now(&stats_get_task, NULL);
137 } 231 }
138 else 232 else
139 { 233 {
140 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer `%s'\n", GNUNET_i2s(id)); 234 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer `%s'\n", GNUNET_i2s(id), GNUNET_i2s(&master_deamon->id));
141 GNUNET_TESTING_daemons_connect(master_deamon, d, TIMEOUT, 10, GNUNET_YES,&daemon_connect_cb, NULL); 235 GNUNET_TESTING_daemons_connect(d, master_deamon, TIMEOUT, 0, GNUNET_YES,&daemon_connect_cb, NULL);
142 } 236 }
143 237
144 if (peers_left == 0) 238 if (peers_left == 0)
@@ -164,6 +258,7 @@ run (void *cls,
164 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 258 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
165{ 259{
166 ok = 1; 260 ok = 1;
261 measurement_started = GNUNET_NO;
167#if VERBOSE 262#if VERBOSE
168 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting %i peers.\n", NUM_PEERS); 263 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting %i peers.\n", NUM_PEERS);
169#endif 264#endif
@@ -183,7 +278,7 @@ check ()
183{ 278{
184 char *const argv[] = { "test-testing", 279 char *const argv[] = { "test-testing",
185 "-c", 280 "-c",
186 "test_testing_data.conf", 281 "test_transport_ats.conf",
187#if VERBOSE 282#if VERBOSE
188 "-L", "DEBUG", 283 "-L", "DEBUG",
189#endif 284#endif