diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-04-01 14:32:02 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-04-01 14:32:02 +0000 |
commit | 27dc5d0c078bd11124f79d8d4bf265b7c0341d16 (patch) | |
tree | 8fc28eb692512e991bc73a067e7a2bda62f0d889 | |
parent | f92658deef5b2c407ebf6047423811a0aa2e44e7 (diff) | |
download | gnunet-27dc5d0c078bd11124f79d8d4bf265b7c0341d16.tar.gz gnunet-27dc5d0c078bd11124f79d8d4bf265b7c0341d16.zip |
starting to import ressource costs
-rwxr-xr-x | src/transport/ats_benchmark.sh | 3 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport.c | 117 | ||||
-rw-r--r-- | src/transport/test_transport_ats.conf | 5 | ||||
-rw-r--r-- | src/transport/transport.h | 31 |
4 files changed, 111 insertions, 45 deletions
diff --git a/src/transport/ats_benchmark.sh b/src/transport/ats_benchmark.sh index bfcb45592..c91a7a86c 100755 --- a/src/transport/ats_benchmark.sh +++ b/src/transport/ats_benchmark.sh | |||
@@ -12,12 +12,13 @@ fi | |||
12 | 12 | ||
13 | for (( c=$start; c<=$end; c++ )) | 13 | for (( c=$start; c<=$end; c++ )) |
14 | do | 14 | do |
15 | rm -rf /tmp/test-gnunet-testing | ||
15 | killall -s 31 gnunet-service-arm 2> /dev/null | 16 | killall -s 31 gnunet-service-arm 2> /dev/null |
16 | killall -s 31 gnunet-service-transport 2> /dev/null | 17 | killall -s 31 gnunet-service-transport 2> /dev/null |
17 | killall -s 31 gnunet-service-statistics 2> /dev/null | 18 | killall -s 31 gnunet-service-statistics 2> /dev/null |
18 | killall -s 31 gnunet-service-resolver 2> /dev/null | 19 | killall -s 31 gnunet-service-resolver 2> /dev/null |
19 | killall -s 31 gnunet-service-core 2> /dev/null | 20 | killall -s 31 gnunet-service-core 2> /dev/null |
20 | killall -s 31 gnunet-service-peerinfo 2> /dev/null | 21 | killall -s 31 gnunet-service-peerinfo 2> /dev/null |
21 | sleep 1 | 22 | #sleep 1 |
22 | ./test_transport_ats $c | 23 | ./test_transport_ats $c |
23 | done | 24 | done |
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 996720d56..791d07e5a 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -5557,8 +5557,7 @@ struct ATS_mechanism | |||
5557 | struct ATS_peer * peer; | 5557 | struct ATS_peer * peer; |
5558 | int col_index; | 5558 | int col_index; |
5559 | int id; | 5559 | int id; |
5560 | double c_max; | 5560 | struct ATS_ressource_cost * rc; |
5561 | double c_1; | ||
5562 | }; | 5561 | }; |
5563 | 5562 | ||
5564 | struct ATS_peer | 5563 | struct ATS_peer |
@@ -5581,8 +5580,56 @@ struct ATS_result | |||
5581 | int solution; | 5580 | int solution; |
5582 | }; | 5581 | }; |
5583 | 5582 | ||
5583 | struct ATS_plugin | ||
5584 | { | ||
5585 | struct ATS_plugin * prev; | ||
5586 | struct ATS_plugin * next; | ||
5587 | char * short_name; | ||
5588 | struct ATS_ressource_cost * head; | ||
5589 | struct ATS_ressource_cost * tail; | ||
5590 | }; | ||
5584 | 5591 | ||
5585 | #define DEBUG_ATS GNUNET_NO | 5592 | struct ATS_ressource_cost |
5593 | { | ||
5594 | struct ATS_ressource_cost * prev; | ||
5595 | struct ATS_ressource_cost * next; | ||
5596 | int atsi_index; | ||
5597 | double c_r_max; | ||
5598 | double c_1; | ||
5599 | }; | ||
5600 | |||
5601 | |||
5602 | struct ATS_info | ||
5603 | { | ||
5604 | struct GNUNET_CONTAINER_MultiHashMap * peers; | ||
5605 | /** | ||
5606 | * Time of last execution | ||
5607 | */ | ||
5608 | struct GNUNET_TIME_Absolute last; | ||
5609 | /** | ||
5610 | * Minimum intervall between two executions | ||
5611 | */ | ||
5612 | struct GNUNET_TIME_Relative min_delta; | ||
5613 | /** | ||
5614 | * Regular intervall when execution is triggered | ||
5615 | */ | ||
5616 | struct GNUNET_TIME_Relative exec_intervall; | ||
5617 | /** | ||
5618 | * Maximum execution time per calculation | ||
5619 | */ | ||
5620 | struct GNUNET_TIME_Relative max_exec_duration; | ||
5621 | /** | ||
5622 | * Maximum number of LP iterations per calculation | ||
5623 | */ | ||
5624 | int max_iterations; | ||
5625 | |||
5626 | GNUNET_SCHEDULER_TaskIdentifier ats_task; | ||
5627 | |||
5628 | struct ATS_plugin * head; | ||
5629 | struct ATS_plugin * tail; | ||
5630 | }; | ||
5631 | |||
5632 | #define DEBUG_ATS GNUNET_YES | ||
5586 | #define VERBOSE_ATS GNUNET_NO | 5633 | #define VERBOSE_ATS GNUNET_NO |
5587 | 5634 | ||
5588 | /** solve the bandwidth distribution problem | 5635 | /** solve the bandwidth distribution problem |
@@ -5670,14 +5717,15 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub | |||
5670 | struct ForeignAddressList * a_next = r_next->addresses; | 5717 | struct ForeignAddressList * a_next = r_next->addresses; |
5671 | while (a_next != NULL) | 5718 | while (a_next != NULL) |
5672 | { | 5719 | { |
5673 | if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%i Peer: `%s' %x:\n", c_mechs, GNUNET_i2s(&next->id), | 5720 | //if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%i Peer: `%s' %x:\n", c_mechs, GNUNET_i2s(&next->id),a_next); |
5674 | a_next); | ||
5675 | mechanisms[c_mechs].addr = a_next; | 5721 | mechanisms[c_mechs].addr = a_next; |
5676 | mechanisms[c_mechs].col_index = c_mechs; | 5722 | mechanisms[c_mechs].col_index = c_mechs; |
5677 | mechanisms[c_mechs].peer = &peers[c_peers]; | 5723 | mechanisms[c_mechs].peer = &peers[c_peers]; |
5678 | mechanisms[c_mechs].next = NULL; | 5724 | mechanisms[c_mechs].next = NULL; |
5679 | mechanisms[c_mechs].plugin = r_next->plugin; | 5725 | mechanisms[c_mechs].plugin = r_next->plugin; |
5680 | 5726 | ||
5727 | //a_next.latency.rel_value; | ||
5728 | |||
5681 | GNUNET_CONTAINER_DLL_insert_tail(peers[c_peers].m_head, peers[c_peers].m_tail, &mechanisms[c_mechs]); | 5729 | GNUNET_CONTAINER_DLL_insert_tail(peers[c_peers].m_head, peers[c_peers].m_tail, &mechanisms[c_mechs]); |
5682 | c_mechs++; | 5730 | c_mechs++; |
5683 | a_next = a_next->next; | 5731 | a_next = a_next->next; |
@@ -6112,7 +6160,7 @@ void ats_calculate_bandwidth_distribution () | |||
6112 | if (delta.rel_value < ats->min_delta.rel_value) | 6160 | if (delta.rel_value < ats->min_delta.rel_value) |
6113 | { | 6161 | { |
6114 | #if DEBUG_ATS | 6162 | #if DEBUG_ATS |
6115 | GNUNET_log (GNUNET_ERROR_TYPE_BULK, "Minimum time between cycles not reached\n"); | 6163 | //GNUNET_log (GNUNET_ERROR_TYPE_BULK, "Minimum time between cycles not reached\n"); |
6116 | #endif | 6164 | #endif |
6117 | return; | 6165 | return; |
6118 | } | 6166 | } |
@@ -6188,6 +6236,7 @@ int ats_map_remove_peer (void *cls, | |||
6188 | } | 6236 | } |
6189 | 6237 | ||
6190 | 6238 | ||
6239 | |||
6191 | struct ATS_info * ats_init () | 6240 | struct ATS_info * ats_init () |
6192 | { | 6241 | { |
6193 | struct ATS_info * ats; | 6242 | struct ATS_info * ats; |
@@ -6202,15 +6251,36 @@ struct ATS_info * ats_init () | |||
6202 | ats->exec_intervall = ATS_EXEC_INTERVAL; | 6251 | ats->exec_intervall = ATS_EXEC_INTERVAL; |
6203 | ats->max_exec_duration = ATS_MAX_EXEC_DURATION; | 6252 | ats->max_exec_duration = ATS_MAX_EXEC_DURATION; |
6204 | ats->max_iterations = ATS_MAX_ITERATIONS; | 6253 | ats->max_iterations = ATS_MAX_ITERATIONS; |
6205 | |||
6206 | ats->ats_task = GNUNET_SCHEDULER_NO_TASK; | 6254 | ats->ats_task = GNUNET_SCHEDULER_NO_TASK; |
6207 | /* | ||
6208 | ats->ats_task = GNUNET_SCHEDULER_add_delayed (ats->reg_delta, | ||
6209 | &schedule_calculation, NULL); | ||
6210 | 6255 | ||
6211 | ats->ats_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 6256 | char * option = "GNUNET_TRANSPORT_ATS_COST_NETWORK_OVERHEAD"; |
6212 | &schedule_calculation, NULL); | 6257 | |
6213 | */ | 6258 | /* loading cost ressources */ |
6259 | char * section; | ||
6260 | struct TransportPlugin * cur = plugins; | ||
6261 | struct ATS_ressource_cost * rc; | ||
6262 | struct ATS_plugin * p; | ||
6263 | unsigned long long value; | ||
6264 | |||
6265 | while (cur != NULL) | ||
6266 | { | ||
6267 | if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Loading ressource cost %s for plugin `%s'\n", option, cur->short_name); | ||
6268 | p = GNUNET_malloc(sizeof (struct ATS_plugin)); | ||
6269 | GNUNET_CONTAINER_DLL_insert_tail(ats->head,ats->tail, p); | ||
6270 | |||
6271 | GNUNET_asprintf(§ion,"transport-%s",cur->short_name); | ||
6272 | p->short_name = strdup(cur->short_name); | ||
6273 | |||
6274 | if (GNUNET_CONFIGURATION_have_value(cfg,section, option)) | ||
6275 | { | ||
6276 | rc = GNUNET_malloc(sizeof (struct ATS_ressource_cost)); | ||
6277 | GNUNET_CONFIGURATION_get_value_number(cfg,section, option, &value); | ||
6278 | rc->atsi_index = GNUNET_TRANSPORT_ATS_COST_NETWORK_OVERHEAD; | ||
6279 | GNUNET_CONTAINER_DLL_insert_tail(p->head,p->tail, rc); | ||
6280 | } | ||
6281 | cur = cur->next; | ||
6282 | } | ||
6283 | |||
6214 | ats->ats_task = GNUNET_SCHEDULER_add_now(&ats_schedule_calculation, ats); | 6284 | ats->ats_task = GNUNET_SCHEDULER_add_now(&ats_schedule_calculation, ats); |
6215 | 6285 | ||
6216 | return ats; | 6286 | return ats; |
@@ -6226,6 +6296,24 @@ void ats_shutdown () | |||
6226 | GNUNET_SCHEDULER_cancel(ats->ats_task); | 6296 | GNUNET_SCHEDULER_cancel(ats->ats_task); |
6227 | ats->ats_task = GNUNET_SCHEDULER_NO_TASK; | 6297 | ats->ats_task = GNUNET_SCHEDULER_NO_TASK; |
6228 | 6298 | ||
6299 | struct ATS_plugin * p; | ||
6300 | struct ATS_ressource_cost * rc; | ||
6301 | |||
6302 | p = ats->head; | ||
6303 | { | ||
6304 | GNUNET_CONTAINER_DLL_remove (ats->head,ats->tail, p); | ||
6305 | rc = p->head; | ||
6306 | while (p != NULL) | ||
6307 | { | ||
6308 | GNUNET_CONTAINER_DLL_remove (p->head,p->tail, rc); | ||
6309 | GNUNET_free(rc); | ||
6310 | rc = p->head; | ||
6311 | } | ||
6312 | GNUNET_free(p->short_name); | ||
6313 | GNUNET_free(p); | ||
6314 | p = ats->head; | ||
6315 | } | ||
6316 | |||
6229 | GNUNET_CONTAINER_multihashmap_iterate (ats->peers,ats_map_remove_peer,NULL); | 6317 | GNUNET_CONTAINER_multihashmap_iterate (ats->peers,ats_map_remove_peer,NULL); |
6230 | GNUNET_CONTAINER_multihashmap_destroy (ats->peers); | 6318 | GNUNET_CONTAINER_multihashmap_destroy (ats->peers); |
6231 | GNUNET_free (ats); | 6319 | GNUNET_free (ats); |
@@ -6369,7 +6457,6 @@ run (void *cls, | |||
6369 | return; | 6457 | return; |
6370 | } | 6458 | } |
6371 | 6459 | ||
6372 | ats = ats_init(); | ||
6373 | max_connect_per_transport = (uint32_t) tneigh; | 6460 | max_connect_per_transport = (uint32_t) tneigh; |
6374 | peerinfo = GNUNET_PEERINFO_connect (cfg); | 6461 | peerinfo = GNUNET_PEERINFO_connect (cfg); |
6375 | if (peerinfo == NULL) | 6462 | if (peerinfo == NULL) |
@@ -6432,6 +6519,8 @@ run (void *cls, | |||
6432 | if (no_transports) | 6519 | if (no_transports) |
6433 | refresh_hello (); | 6520 | refresh_hello (); |
6434 | 6521 | ||
6522 | ats = ats_init(); | ||
6523 | |||
6435 | #if DEBUG_TRANSPORT | 6524 | #if DEBUG_TRANSPORT |
6436 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Transport service ready.\n")); | 6525 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Transport service ready.\n")); |
6437 | #endif | 6526 | #endif |
diff --git a/src/transport/test_transport_ats.conf b/src/transport/test_transport_ats.conf index 31a986195..b3a26caec 100644 --- a/src/transport/test_transport_ats.conf +++ b/src/transport/test_transport_ats.conf | |||
@@ -7,7 +7,7 @@ PORT = 2564 | |||
7 | 7 | ||
8 | [transport] | 8 | [transport] |
9 | PORT = 2565 | 9 | PORT = 2565 |
10 | PLUGINS = tcp | 10 | PLUGINS = tcp udp |
11 | #DEBUG = NO | 11 | #DEBUG = NO |
12 | #PREFIX = xterm -e xterm -T transport -e gdb -x cmd --args | 12 | #PREFIX = xterm -e xterm -T transport -e gdb -x cmd --args |
13 | #PREFIX = valgrind --tool=memcheck --log-file=logs%p | 13 | #PREFIX = valgrind --tool=memcheck --log-file=logs%p |
@@ -22,6 +22,9 @@ PORT = 2567 | |||
22 | [transport-tcp] | 22 | [transport-tcp] |
23 | PORT = 2568 | 23 | PORT = 2568 |
24 | 24 | ||
25 | [transport-tcp] | ||
26 | PORT = 2571 | ||
27 | |||
25 | [peerinfo] | 28 | [peerinfo] |
26 | PORT = 2569 | 29 | PORT = 2569 |
27 | 30 | ||
diff --git a/src/transport/transport.h b/src/transport/transport.h index f3e3b1c2c..4eb14c851 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h | |||
@@ -31,38 +31,11 @@ | |||
31 | #include "gnunet_transport_service.h" | 31 | #include "gnunet_transport_service.h" |
32 | 32 | ||
33 | /* Minimum time between to calculations*/ | 33 | /* Minimum time between to calculations*/ |
34 | #define ATS_MIN_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1) | 34 | #define ATS_MIN_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 1000) |
35 | #define ATS_EXEC_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2) | 35 | #define ATS_EXEC_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 1500) |
36 | #define ATS_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100) | 36 | #define ATS_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100) |
37 | #define ATS_MAX_ITERATIONS INT_MAX | 37 | #define ATS_MAX_ITERATIONS INT_MAX |
38 | 38 | ||
39 | struct ATS_info | ||
40 | { | ||
41 | struct GNUNET_CONTAINER_MultiHashMap * peers; | ||
42 | /** | ||
43 | * Time of last execution | ||
44 | */ | ||
45 | struct GNUNET_TIME_Absolute last; | ||
46 | /** | ||
47 | * Minimum intervall between two executions | ||
48 | */ | ||
49 | struct GNUNET_TIME_Relative min_delta; | ||
50 | /** | ||
51 | * Regular intervall when execution is triggered | ||
52 | */ | ||
53 | struct GNUNET_TIME_Relative exec_intervall; | ||
54 | /** | ||
55 | * Maximum execution time per calculation | ||
56 | */ | ||
57 | struct GNUNET_TIME_Relative max_exec_duration; | ||
58 | /** | ||
59 | * Maximum number of LP iterations per calculation | ||
60 | */ | ||
61 | int max_iterations; | ||
62 | |||
63 | GNUNET_SCHEDULER_TaskIdentifier ats_task; | ||
64 | }; | ||
65 | |||
66 | #define DEBUG_TRANSPORT GNUNET_NO | 39 | #define DEBUG_TRANSPORT GNUNET_NO |
67 | #define DEBUG_TRANSPORT_TIMEOUT GNUNET_NO | 40 | #define DEBUG_TRANSPORT_TIMEOUT GNUNET_NO |
68 | #define DEBUG_TRANSPORT_DISCONNECT GNUNET_NO | 41 | #define DEBUG_TRANSPORT_DISCONNECT GNUNET_NO |