diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-04-16 20:34:36 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-04-16 20:34:36 +0000 |
commit | f2a6d23481773c7a3b4422f3a346706e5f014543 (patch) | |
tree | 56adcc0acb243fe70cba48c4970213289e0f5b1d /src/ats | |
parent | d043dd0e4ca407081eaa1b9072b37b1d9e715813 (diff) | |
download | gnunet-f2a6d23481773c7a3b4422f3a346706e5f014543.tar.gz gnunet-f2a6d23481773c7a3b4422f3a346706e5f014543.zip |
- tmp commit
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/gnunet-service-ats_addresses_mlp.c | 4 | ||||
-rw-r--r-- | src/ats/perf_ats_mlp.c | 61 |
2 files changed, 56 insertions, 9 deletions
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index 57692440b..e111dae95 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c | |||
@@ -1341,13 +1341,12 @@ update_quality (struct GAS_MLP_Handle *mlp, struct ATS_Address * address) | |||
1341 | { | 1341 | { |
1342 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating quality metrics for peer `%s'\n", | 1342 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating quality metrics for peer `%s'\n", |
1343 | GNUNET_i2s (&address->peer)); | 1343 | GNUNET_i2s (&address->peer)); |
1344 | 1344 | GNUNET_assert (NULL != address->ats); | |
1345 | struct MLP_information *mlpi = address->mlp_information; | 1345 | struct MLP_information *mlpi = address->mlp_information; |
1346 | struct GNUNET_ATS_Information *ats = address->ats; | 1346 | struct GNUNET_ATS_Information *ats = address->ats; |
1347 | GNUNET_assert (mlpi != NULL); | 1347 | GNUNET_assert (mlpi != NULL); |
1348 | 1348 | ||
1349 | int c; | 1349 | int c; |
1350 | |||
1351 | for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++) | 1350 | for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++) |
1352 | { | 1351 | { |
1353 | int index = mlp_lookup_ats(address, mlp->q[c]); | 1352 | int index = mlp_lookup_ats(address, mlp->q[c]); |
@@ -1573,7 +1572,6 @@ GAS_mlp_address_update (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult | |||
1573 | 1572 | ||
1574 | GNUNET_CONTAINER_DLL_insert (peer->head, peer->tail, address); | 1573 | GNUNET_CONTAINER_DLL_insert (peer->head, peer->tail, address); |
1575 | } | 1574 | } |
1576 | |||
1577 | update_quality (mlp, address); | 1575 | update_quality (mlp, address); |
1578 | } | 1576 | } |
1579 | else | 1577 | else |
diff --git a/src/ats/perf_ats_mlp.c b/src/ats/perf_ats_mlp.c index 2daac4769..0d261374b 100644 --- a/src/ats/perf_ats_mlp.c +++ b/src/ats/perf_ats_mlp.c | |||
@@ -45,10 +45,31 @@ static int ret; | |||
45 | 45 | ||
46 | struct GNUNET_STATISTICS_Handle * stats; | 46 | struct GNUNET_STATISTICS_Handle * stats; |
47 | 47 | ||
48 | //struct GNUNET_CONTAINER_MultiHashMap * addresses; | 48 | struct GNUNET_CONTAINER_MultiHashMap * amap; |
49 | 49 | ||
50 | struct GAS_MLP_Handle *mlp; | 50 | struct GAS_MLP_Handle *mlp; |
51 | 51 | ||
52 | struct PeerContext | ||
53 | { | ||
54 | struct GNUNET_PeerIdentity id; | ||
55 | |||
56 | struct Address *addr; | ||
57 | }; | ||
58 | |||
59 | struct Address | ||
60 | { | ||
61 | char *plugin; | ||
62 | size_t plugin_len; | ||
63 | |||
64 | void *addr; | ||
65 | size_t addr_len; | ||
66 | |||
67 | struct GNUNET_ATS_Information *ats; | ||
68 | int ats_count; | ||
69 | |||
70 | void *session; | ||
71 | }; | ||
72 | |||
52 | static void | 73 | static void |
53 | check (void *cls, char *const *args, const char *cfgfile, | 74 | check (void *cls, char *const *args, const char *cfgfile, |
54 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 75 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
@@ -58,6 +79,10 @@ check (void *cls, char *const *args, const char *cfgfile, | |||
58 | ret = 1; | 79 | ret = 1; |
59 | return; | 80 | return; |
60 | #endif | 81 | #endif |
82 | unsigned int c = 0; | ||
83 | unsigned int c2 = 0; | ||
84 | unsigned int ca = 0; | ||
85 | //char * pid; | ||
61 | 86 | ||
62 | if (peers == 0) | 87 | if (peers == 0) |
63 | peers = DEF_PEERS; | 88 | peers = DEF_PEERS; |
@@ -66,18 +91,42 @@ check (void *cls, char *const *args, const char *cfgfile, | |||
66 | 91 | ||
67 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up %u peers with %u addresses per peer\n", peers, addresses); | 92 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up %u peers with %u addresses per peer\n", peers, addresses); |
68 | 93 | ||
69 | GNUNET_HashCode hash; | 94 | struct PeerContext p[peers]; |
70 | //memset (&hash, '\0', sizeof (GNUNET_HashCode)); | 95 | struct ATS_Address a[addresses * peers]; |
71 | //hash.bits[0] = 1; | 96 | |
72 | //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "peer %s\n", GNUNET_h2s_full (&hash)); | 97 | amap = GNUNET_CONTAINER_multihashmap_create(addresses * peers); |
73 | 98 | ||
74 | mlp = GAS_mlp_init (cfg, NULL, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS); | 99 | mlp = GAS_mlp_init (cfg, NULL, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS); |
75 | mlp->auto_solve = GNUNET_NO; | 100 | mlp->auto_solve = GNUNET_NO; |
76 | 101 | for (c=0; c < peers; c++) | |
102 | { | ||
103 | GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &p[c].id.hashPubKey); | ||
104 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "peer %s\n", GNUNET_h2s_full(&p[c].id.hashPubKey)); | ||
105 | |||
106 | for (c2=0; c2 < addresses; c2++) | ||
107 | { | ||
108 | a[ca].peer = p[c].id; | ||
109 | a[ca].plugin = strdup("test"); | ||
110 | a[ca].addr = GNUNET_HELLO_address_allocate(&a[ca].peer, a[ca].plugin, NULL, 0); | ||
111 | a[ca].addr_len = GNUNET_HELLO_address_get_size(a[ca].addr); | ||
112 | a[ca].ats = NULL; | ||
113 | ca++; | ||
114 | GAS_mlp_address_update(mlp, amap, &a[c2]); | ||
115 | } | ||
116 | } | ||
117 | |||
118 | GAS_mlp_solve_problem(mlp); | ||
77 | 119 | ||
78 | 120 | ||
79 | GAS_mlp_done (mlp); | 121 | GAS_mlp_done (mlp); |
80 | 122 | ||
123 | for (c2=0; c2 < (peers * addresses); c2++) | ||
124 | { | ||
125 | GNUNET_free (a[c2].plugin); | ||
126 | GNUNET_free (a[c2].addr); | ||
127 | // GAS_mlp_address_update(mlp, amap, &a[c2]); | ||
128 | } | ||
129 | |||
81 | ret = 0; | 130 | ret = 0; |
82 | return; | 131 | return; |
83 | } | 132 | } |