diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-01-21 16:15:23 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-01-21 16:15:23 +0000 |
commit | 2ee40d2f3c51cfe62c251fff7c14bdd438e80622 (patch) | |
tree | 86555cdcbd591f00700646b3c9dc674e1d8c094a | |
parent | 90336d964868e9d726b87ab2f60470e6b4063b20 (diff) | |
download | gnunet-2ee40d2f3c51cfe62c251fff7c14bdd438e80622.tar.gz gnunet-2ee40d2f3c51cfe62c251fff7c14bdd438e80622.zip |
improving test
-rw-r--r-- | src/ats/test_ats_simplistic_pref_aging.c | 100 |
1 files changed, 93 insertions, 7 deletions
diff --git a/src/ats/test_ats_simplistic_pref_aging.c b/src/ats/test_ats_simplistic_pref_aging.c index 0bd618189..0ba1b2a21 100644 --- a/src/ats/test_ats_simplistic_pref_aging.c +++ b/src/ats/test_ats_simplistic_pref_aging.c | |||
@@ -144,15 +144,104 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, | |||
144 | uint32_t ats_count) | 144 | uint32_t ats_count) |
145 | { | 145 | { |
146 | static int stage = 0; | 146 | static int stage = 0; |
147 | static int sug_p0 = GNUNET_NO; | ||
148 | static int sug_p1 = GNUNET_NO; | ||
149 | |||
150 | if (0 == stage) | ||
151 | { | ||
152 | /* Callback for initial suggestion */ | ||
153 | if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id))) | ||
154 | { | ||
155 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer `%s': (in/out) %llu/%llu\n", | ||
156 | stage, | ||
157 | GNUNET_i2s (&address->peer), | ||
158 | ntohl (bandwidth_in.value__), | ||
159 | ntohl (bandwidth_out.value__)); | ||
160 | sug_p0 = GNUNET_YES; | ||
161 | } | ||
162 | if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id))) | ||
163 | { | ||
164 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer `%s': (in/out) %llu/%llu\n", | ||
165 | stage, | ||
166 | GNUNET_i2s (&address->peer), | ||
167 | ntohl (bandwidth_in.value__), | ||
168 | ntohl (bandwidth_out.value__)); | ||
169 | sug_p1 = GNUNET_YES; | ||
170 | } | ||
171 | if ((GNUNET_YES == sug_p0) && (GNUNET_YES == sug_p1)) | ||
172 | { | ||
173 | /* Changing preference for peer 0 */ | ||
174 | stage ++; | ||
175 | GNUNET_ATS_change_preference (perf_ats, &p[0].id, GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END); | ||
176 | sug_p0 = GNUNET_NO; | ||
177 | sug_p1 = GNUNET_NO; | ||
178 | return; | ||
179 | } | ||
180 | |||
181 | } | ||
182 | if (1 == stage) | ||
183 | { | ||
184 | /* Callback due to preference change */ | ||
185 | if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id))) | ||
186 | { | ||
187 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer `%s': (in/out) %llu/%llu\n", | ||
188 | stage, | ||
189 | GNUNET_i2s (&address->peer), | ||
190 | ntohl (bandwidth_in.value__), | ||
191 | ntohl (bandwidth_out.value__)); | ||
192 | sug_p0 = GNUNET_YES; | ||
193 | } | ||
194 | if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id))) | ||
195 | { | ||
196 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer `%s': (in/out) %llu/%llu\n", | ||
197 | stage, | ||
198 | GNUNET_i2s (&address->peer), | ||
199 | ntohl (bandwidth_in.value__), | ||
200 | ntohl (bandwidth_out.value__)); | ||
201 | sug_p1 = GNUNET_YES; | ||
202 | } | ||
203 | if ((GNUNET_YES == sug_p0) && (GNUNET_YES == sug_p1)) | ||
204 | { | ||
205 | /* Changing preference for peer 0 */ | ||
206 | stage ++; | ||
207 | sug_p0 = GNUNET_NO; | ||
208 | sug_p1 = GNUNET_NO; | ||
209 | return; | ||
210 | } | ||
211 | } | ||
212 | if (2 == stage) | ||
213 | { | ||
214 | /* Callback due to preference aging */ | ||
215 | if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id))) | ||
216 | { | ||
217 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer `%s': (in/out) %llu/%llu\n", | ||
218 | stage, | ||
219 | GNUNET_i2s (&address->peer), | ||
220 | ntohl (bandwidth_in.value__), | ||
221 | ntohl (bandwidth_out.value__)); | ||
222 | sug_p0 = GNUNET_YES; | ||
223 | } | ||
224 | if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id))) | ||
225 | { | ||
226 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer `%s': (in/out) %llu/%llu\n", | ||
227 | stage, | ||
228 | GNUNET_i2s (&address->peer), | ||
229 | ntohl (bandwidth_in.value__), | ||
230 | ntohl (bandwidth_out.value__)); | ||
231 | sug_p1 = GNUNET_YES; | ||
232 | } | ||
233 | } | ||
147 | 234 | ||
148 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Callback for peer `%s': (in/out) %llu/%llu\n", | ||
149 | GNUNET_i2s (&address->peer), | ||
150 | ntohl (bandwidth_in.value__), | ||
151 | ntohl (bandwidth_out.value__)); | ||
152 | 235 | ||
236 | |||
237 | |||
238 | /* | ||
153 | stage ++; | 239 | stage ++; |
154 | if (3 == stage) | 240 | if (3 == stage) |
155 | GNUNET_SCHEDULER_add_now (&end, NULL); | 241 | GNUNET_SCHEDULER_add_now (&end, NULL); |
242 | */ | ||
243 | |||
244 | |||
156 | 245 | ||
157 | } | 246 | } |
158 | 247 | ||
@@ -274,9 +363,6 @@ run (void *cls, | |||
274 | test_hello_address[1].address_length = test_addr[1].addr_len; | 363 | test_hello_address[1].address_length = test_addr[1].addr_len; |
275 | GNUNET_ATS_address_add (sched_ats, &test_hello_address[1], test_session[1], test_ats_info, test_ats_count); | 364 | GNUNET_ATS_address_add (sched_ats, &test_hello_address[1], test_session[1], test_ats_info, test_ats_count); |
276 | 365 | ||
277 | GNUNET_ATS_change_preference (perf_ats, &p[1].id, GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END); | ||
278 | GNUNET_ATS_change_preference (perf_ats, &p[1].id, GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END); | ||
279 | |||
280 | GNUNET_ATS_suggest_address (sched_ats, &p[0].id); | 366 | GNUNET_ATS_suggest_address (sched_ats, &p[0].id); |
281 | GNUNET_ATS_suggest_address (sched_ats, &p[1].id); | 367 | GNUNET_ATS_suggest_address (sched_ats, &p[1].id); |
282 | } | 368 | } |