aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-01-13 14:49:41 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-01-13 14:49:41 +0000
commit6e19faa688d79c28b21d2e7382019148421dabf5 (patch)
tree60a152f7635245f3e1f65b53b13128834b627ce5
parent20405bfe92a2e63315e93f9f12ab1dffa696644e (diff)
downloadgnunet-6e19faa688d79c28b21d2e7382019148421dabf5.tar.gz
gnunet-6e19faa688d79c28b21d2e7382019148421dabf5.zip
- more
-rw-r--r--src/ats/gnunet-service-ats_addresses.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c
index a5480e50e..019f0aceb 100644
--- a/src/ats/gnunet-service-ats_addresses.c
+++ b/src/ats/gnunet-service-ats_addresses.c
@@ -37,8 +37,17 @@
37 37
38enum ATS_Mode 38enum ATS_Mode
39{ 39{
40 SIMPLE, 40 /**
41 MLP 41 * Assign each peer an equal amount of bandwidth (bw)
42 *
43 * bw_per_peer = bw_total / #active addresses
44 */
45 SIMPLE,
46
47 /**
48 * Use MLP solver to assign bandwidth
49 */
50 MLP
42}; 51};
43 52
44static struct GNUNET_CONTAINER_MultiHashMap *addresses; 53static struct GNUNET_CONTAINER_MultiHashMap *addresses;
@@ -51,6 +60,7 @@ static unsigned int active_addr_count;
51 60
52static int ats_mode; 61static int ats_mode;
53 62
63
54/** 64/**
55 * Update a bandwidth assignment for a peer. This trivial method currently 65 * Update a bandwidth assignment for a peer. This trivial method currently
56 * simply assigns the same share to all active connections. 66 * simply assigns the same share to all active connections.
@@ -65,6 +75,8 @@ update_bw_it (void *cls, const GNUNET_HashCode * key, void *value)
65{ 75{
66 struct ATS_Address *aa = value; 76 struct ATS_Address *aa = value;
67 77
78
79 /* Simple method */
68 if (GNUNET_YES != aa->active) 80 if (GNUNET_YES != aa->active)
69 return GNUNET_OK; 81 return GNUNET_OK;
70 GNUNET_assert (active_addr_count > 0); 82 GNUNET_assert (active_addr_count > 0);
@@ -159,6 +171,12 @@ destroy_address (struct ATS_Address *addr)
159 GNUNET_CONTAINER_multihashmap_remove (addresses, 171 GNUNET_CONTAINER_multihashmap_remove (addresses,
160 &addr->peer.hashPubKey, 172 &addr->peer.hashPubKey,
161 addr)); 173 addr));
174
175#if HAVE_LIBGLPK
176 if (ats_mode == MLP)
177 GAS_mlp_address_delete (addresses, addr);
178#endif
179
162 if (GNUNET_YES == addr->active) 180 if (GNUNET_YES == addr->active)
163 { 181 {
164 active_addr_count--; 182 active_addr_count--;
@@ -354,12 +372,21 @@ destroy_by_session_id (void *cls, const GNUNET_HashCode * key, void *value)
354 372
355 /* session == 0 and addrlen == 0 : destroy address */ 373 /* session == 0 and addrlen == 0 : destroy address */
356 if (aa->addr_len == 0) 374 if (aa->addr_len == 0)
375 {
357 (void) destroy_address (aa); 376 (void) destroy_address (aa);
377 }
378 else
379 {
380 /* session was set to 0, update address */
381#if HAVE_LIBGLPK
382 if (ats_mode == MLP)
383 GAS_mlp_address_update (addresses, aa);
384#endif
385 }
358 386
359 return GNUNET_OK; 387 return GNUNET_OK;
360} 388}
361 389
362
363void 390void
364GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer, 391GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer,
365 const char *plugin_name, const void *plugin_addr, 392 const char *plugin_name, const void *plugin_addr,