diff options
author | wachs <wachs@140774ce-b5e7-0310-ab8b-a85725594a96> | 2013-01-21 16:15:23 +0000 |
---|---|---|
committer | wachs <wachs@140774ce-b5e7-0310-ab8b-a85725594a96> | 2013-01-21 16:15:23 +0000 |
commit | 2d3e70e85d9b022c1cb4cb6b7b15a43a88791d29 (patch) | |
tree | 86555cdcbd591f00700646b3c9dc674e1d8c094a /src/ats | |
parent | a32d12ff43e95e4398c08fc2f475b1d69d9141bf (diff) |
improving test
git-svn-id: https://gnunet.org/svn/gnunet@25847 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src/ats')
-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 0bd6181897..0ba1b2a215 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, uint32_t ats_count) { static int stage = 0; + static int sug_p0 = GNUNET_NO; + static int sug_p1 = GNUNET_NO; + + if (0 == stage) + { + /* Callback for initial suggestion */ + if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id))) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer `%s': (in/out) %llu/%llu\n", + stage, + GNUNET_i2s (&address->peer), + ntohl (bandwidth_in.value__), + ntohl (bandwidth_out.value__)); + sug_p0 = GNUNET_YES; + } + if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id))) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer `%s': (in/out) %llu/%llu\n", + stage, + GNUNET_i2s (&address->peer), + ntohl (bandwidth_in.value__), + ntohl (bandwidth_out.value__)); + sug_p1 = GNUNET_YES; + } + if ((GNUNET_YES == sug_p0) && (GNUNET_YES == sug_p1)) + { + /* Changing preference for peer 0 */ + stage ++; + GNUNET_ATS_change_preference (perf_ats, &p[0].id, GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END); + sug_p0 = GNUNET_NO; + sug_p1 = GNUNET_NO; + return; + } + + } + if (1 == stage) + { + /* Callback due to preference change */ + if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id))) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer `%s': (in/out) %llu/%llu\n", + stage, + GNUNET_i2s (&address->peer), + ntohl (bandwidth_in.value__), + ntohl (bandwidth_out.value__)); + sug_p0 = GNUNET_YES; + } + if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id))) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer `%s': (in/out) %llu/%llu\n", + stage, + GNUNET_i2s (&address->peer), + ntohl (bandwidth_in.value__), + ntohl (bandwidth_out.value__)); + sug_p1 = GNUNET_YES; + } + if ((GNUNET_YES == sug_p0) && (GNUNET_YES == sug_p1)) + { + /* Changing preference for peer 0 */ + stage ++; + sug_p0 = GNUNET_NO; + sug_p1 = GNUNET_NO; + return; + } + } + if (2 == stage) + { + /* Callback due to preference aging */ + if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id))) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer `%s': (in/out) %llu/%llu\n", + stage, + GNUNET_i2s (&address->peer), + ntohl (bandwidth_in.value__), + ntohl (bandwidth_out.value__)); + sug_p0 = GNUNET_YES; + } + if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id))) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer `%s': (in/out) %llu/%llu\n", + stage, + GNUNET_i2s (&address->peer), + ntohl (bandwidth_in.value__), + ntohl (bandwidth_out.value__)); + sug_p1 = GNUNET_YES; + } + } - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Callback for peer `%s': (in/out) %llu/%llu\n", - GNUNET_i2s (&address->peer), - ntohl (bandwidth_in.value__), - ntohl (bandwidth_out.value__)); + + +/* stage ++; if (3 == stage) GNUNET_SCHEDULER_add_now (&end, NULL); +*/ + + } @@ -274,9 +363,6 @@ run (void *cls, test_hello_address[1].address_length = test_addr[1].addr_len; GNUNET_ATS_address_add (sched_ats, &test_hello_address[1], test_session[1], test_ats_info, test_ats_count); - GNUNET_ATS_change_preference (perf_ats, &p[1].id, GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END); - GNUNET_ATS_change_preference (perf_ats, &p[1].id, GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END); - GNUNET_ATS_suggest_address (sched_ats, &p[0].id); GNUNET_ATS_suggest_address (sched_ats, &p[1].id); } |