aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-01-22 16:44:47 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-01-22 16:44:47 +0000
commit34d90ca2e70f82474be1df3b3002648951826d31 (patch)
treecf21590440a0fc48f8b48aae392b16c37e1938b9 /src
parent2b8cba84ce1af1c616c376f1f8565a8df869ccc2 (diff)
downloadgnunet-34d90ca2e70f82474be1df3b3002648951826d31.tar.gz
gnunet-34d90ca2e70f82474be1df3b3002648951826d31.zip
changes
Diffstat (limited to 'src')
-rw-r--r--src/ats/test_ats_simplistic_pref_aging.c83
1 files changed, 63 insertions, 20 deletions
diff --git a/src/ats/test_ats_simplistic_pref_aging.c b/src/ats/test_ats_simplistic_pref_aging.c
index 0ba1b2a21..9eb896ff5 100644
--- a/src/ats/test_ats_simplistic_pref_aging.c
+++ b/src/ats/test_ats_simplistic_pref_aging.c
@@ -105,9 +105,15 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
105 die_task = GNUNET_SCHEDULER_NO_TASK; 105 die_task = GNUNET_SCHEDULER_NO_TASK;
106 106
107 if (sched_ats != NULL) 107 if (sched_ats != NULL)
108 {
108 GNUNET_ATS_scheduling_done (sched_ats); 109 GNUNET_ATS_scheduling_done (sched_ats);
110 sched_ats = NULL;
111 }
109 if (perf_ats != NULL) 112 if (perf_ats != NULL)
113 {
110 GNUNET_ATS_performance_done (perf_ats); 114 GNUNET_ATS_performance_done (perf_ats);
115 perf_ats = NULL;
116 }
111 free_test_address (&test_addr[0]); 117 free_test_address (&test_addr[0]);
112 ret = GNUNET_SYSERR; 118 ret = GNUNET_SYSERR;
113} 119}
@@ -126,7 +132,9 @@ end ()
126 GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id); 132 GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
127 GNUNET_ATS_suggest_address_cancel (sched_ats, &p[1].id); 133 GNUNET_ATS_suggest_address_cancel (sched_ats, &p[1].id);
128 134
129 GNUNET_ATS_scheduling_done (sched_ats); 135 if (NULL != sched_ats)
136 GNUNET_ATS_scheduling_done (sched_ats);
137 if (NULL != perf_ats)
130 GNUNET_ATS_performance_done (perf_ats); 138 GNUNET_ATS_performance_done (perf_ats);
131 sched_ats = NULL; 139 sched_ats = NULL;
132 perf_ats = NULL; 140 perf_ats = NULL;
@@ -147,26 +155,39 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
147 static int sug_p0 = GNUNET_NO; 155 static int sug_p0 = GNUNET_NO;
148 static int sug_p1 = GNUNET_NO; 156 static int sug_p1 = GNUNET_NO;
149 157
158 static uint32_t p0_last_bandwidth_out;
159 static uint32_t p0_last_bandwidth_in;
160
161 static uint32_t p1_last_bandwidth_out;
162 static uint32_t p1_last_bandwidth_in;
163
164 uint32_t cur_bandwidth_out = ntohl (bandwidth_out.value__);
165 uint32_t cur_bandwidth_in = ntohl (bandwidth_in.value__);
166
150 if (0 == stage) 167 if (0 == stage)
151 { 168 {
152 /* Callback for initial suggestion */ 169 /* Callback for initial suggestion */
153 if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id))) 170 if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id)))
154 { 171 {
155 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer `%s': (in/out) %llu/%llu\n", 172 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer 0 `%s': (in/out) %llu/%llu\n",
156 stage, 173 stage,
157 GNUNET_i2s (&address->peer), 174 GNUNET_i2s (&address->peer),
158 ntohl (bandwidth_in.value__), 175 ntohl (bandwidth_in.value__),
159 ntohl (bandwidth_out.value__)); 176 ntohl (bandwidth_out.value__));
160 sug_p0 = GNUNET_YES; 177 sug_p0 = GNUNET_YES;
178 p0_last_bandwidth_out = ntohl(bandwidth_out.value__);
179 p0_last_bandwidth_in = ntohl(bandwidth_in.value__);
161 } 180 }
162 if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id))) 181 if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id)))
163 { 182 {
164 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer `%s': (in/out) %llu/%llu\n", 183 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer 1 `%s': (in/out) %llu/%llu\n",
165 stage, 184 stage,
166 GNUNET_i2s (&address->peer), 185 GNUNET_i2s (&address->peer),
167 ntohl (bandwidth_in.value__), 186 ntohl (bandwidth_in.value__),
168 ntohl (bandwidth_out.value__)); 187 ntohl (bandwidth_out.value__));
169 sug_p1 = GNUNET_YES; 188 sug_p1 = GNUNET_YES;
189 p1_last_bandwidth_out = ntohl(bandwidth_out.value__);
190 p1_last_bandwidth_in = ntohl(bandwidth_in.value__);
170 } 191 }
171 if ((GNUNET_YES == sug_p0) && (GNUNET_YES == sug_p1)) 192 if ((GNUNET_YES == sug_p0) && (GNUNET_YES == sug_p1))
172 { 193 {
@@ -184,25 +205,40 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
184 /* Callback due to preference change */ 205 /* Callback due to preference change */
185 if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id))) 206 if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id)))
186 { 207 {
187 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer `%s': (in/out) %llu/%llu\n", 208 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer 0 `%s': (in/out) %llu/%llu\n",
188 stage, 209 stage,
189 GNUNET_i2s (&address->peer), 210 GNUNET_i2s (&address->peer),
190 ntohl (bandwidth_in.value__), 211 ntohl (bandwidth_in.value__),
191 ntohl (bandwidth_out.value__)); 212 ntohl (bandwidth_out.value__));
192 sug_p0 = GNUNET_YES; 213 sug_p0 = GNUNET_YES;
214
215 /* Peer 0 should get more bandwidth */
216 if (cur_bandwidth_out <= p0_last_bandwidth_out)
217 GNUNET_break (0);
218 if (cur_bandwidth_in <= p0_last_bandwidth_in)
219 GNUNET_break (0);
220 p0_last_bandwidth_out = ntohl(bandwidth_out.value__);
221 p0_last_bandwidth_in = ntohl(bandwidth_in.value__);
193 } 222 }
194 if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id))) 223 if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id)))
195 { 224 {
196 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer `%s': (in/out) %llu/%llu\n", 225 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer 1 `%s': (in/out) %llu/%llu\n",
197 stage, 226 stage,
198 GNUNET_i2s (&address->peer), 227 GNUNET_i2s (&address->peer),
199 ntohl (bandwidth_in.value__), 228 ntohl (bandwidth_in.value__),
200 ntohl (bandwidth_out.value__)); 229 ntohl (bandwidth_out.value__));
201 sug_p1 = GNUNET_YES; 230 sug_p1 = GNUNET_YES;
231
232 /* Peer 1 should get less bandwidth */
233 if (cur_bandwidth_out >= p1_last_bandwidth_out)
234 GNUNET_break (0);
235 if (cur_bandwidth_in >= p1_last_bandwidth_in)
236 GNUNET_break (0);
237 p1_last_bandwidth_out = ntohl(bandwidth_out.value__);
238 p1_last_bandwidth_in = ntohl(bandwidth_in.value__);
202 } 239 }
203 if ((GNUNET_YES == sug_p0) && (GNUNET_YES == sug_p1)) 240 if ((GNUNET_YES == sug_p0) && (GNUNET_YES == sug_p1))
204 { 241 {
205 /* Changing preference for peer 0 */
206 stage ++; 242 stage ++;
207 sug_p0 = GNUNET_NO; 243 sug_p0 = GNUNET_NO;
208 sug_p1 = GNUNET_NO; 244 sug_p1 = GNUNET_NO;
@@ -214,35 +250,42 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
214 /* Callback due to preference aging */ 250 /* Callback due to preference aging */
215 if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id))) 251 if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id)))
216 { 252 {
217 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer `%s': (in/out) %llu/%llu\n", 253 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer 0 `%s': (in/out) %llu/%llu\n",
218 stage, 254 stage,
219 GNUNET_i2s (&address->peer), 255 GNUNET_i2s (&address->peer),
220 ntohl (bandwidth_in.value__), 256 ntohl (bandwidth_in.value__),
221 ntohl (bandwidth_out.value__)); 257 ntohl (bandwidth_out.value__));
222 sug_p0 = GNUNET_YES; 258 sug_p0 = GNUNET_YES;
259
260 /* Peer 0 should get less bandwidth */
261 if (cur_bandwidth_out <= p0_last_bandwidth_out)
262 GNUNET_break (0);
263 if (cur_bandwidth_in <= p0_last_bandwidth_in)
264 GNUNET_break (0);
265 p0_last_bandwidth_out = ntohl(bandwidth_out.value__);
266 p0_last_bandwidth_in = ntohl(bandwidth_in.value__);
223 } 267 }
224 if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id))) 268 if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id)))
225 { 269 {
226 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer `%s': (in/out) %llu/%llu\n", 270 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer 1 `%s': (in/out) %llu/%llu\n",
227 stage, 271 stage,
228 GNUNET_i2s (&address->peer), 272 GNUNET_i2s (&address->peer),
229 ntohl (bandwidth_in.value__), 273 ntohl (bandwidth_in.value__),
230 ntohl (bandwidth_out.value__)); 274 ntohl (bandwidth_out.value__));
231 sug_p1 = GNUNET_YES; 275 sug_p1 = GNUNET_YES;
276 /* Peer 1 should get more bandwidth */
277 if (cur_bandwidth_out <= p1_last_bandwidth_out)
278 GNUNET_break (0);
279 if (cur_bandwidth_in <= p1_last_bandwidth_in)
280 GNUNET_break (0);
281 p0_last_bandwidth_out = ntohl(bandwidth_out.value__);
282 p0_last_bandwidth_in = ntohl(bandwidth_in.value__);
232 } 283 }
233 }
234
235
236
237
238/*
239 stage ++;
240 if (3 == stage)
241 GNUNET_SCHEDULER_add_now (&end, NULL);
242*/
243
244
245 284
285 /* Done ! */
286 GNUNET_SCHEDULER_add_now (&end,NULL);
287 return;
288 }
246} 289}
247 290
248static void 291static void