diff options
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 86212f9ab..7b8a9a327 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -37,6 +37,11 @@ | |||
37 | #include "gnunet_constants.h" | 37 | #include "gnunet_constants.h" |
38 | #include "transport.h" | 38 | #include "transport.h" |
39 | 39 | ||
40 | /** | ||
41 | * Experimental option to ignore SessionQuotaMessages from | ||
42 | * the other peer. | ||
43 | */ | ||
44 | #define IGNORE_INBOUND_QUOTA GNUNET_YES | ||
40 | 45 | ||
41 | /** | 46 | /** |
42 | * Size of the neighbour hash map. | 47 | * Size of the neighbour hash map. |
@@ -1177,7 +1182,8 @@ set_incoming_quota (struct NeighbourMapEntry *n, | |||
1177 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1182 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1178 | "Setting inbound quota of %u Bps for peer `%s' to all clients\n", | 1183 | "Setting inbound quota of %u Bps for peer `%s' to all clients\n", |
1179 | ntohl (quota.value__), GNUNET_i2s (&n->id)); | 1184 | ntohl (quota.value__), GNUNET_i2s (&n->id)); |
1180 | GNUNET_BANDWIDTH_tracker_update_quota (&n->in_tracker, quota); | 1185 | GNUNET_BANDWIDTH_tracker_update_quota (&n->in_tracker, |
1186 | quota); | ||
1181 | if (0 != ntohl (quota.value__)) | 1187 | if (0 != ntohl (quota.value__)) |
1182 | { | 1188 | { |
1183 | struct SessionQuotaMessage sqm; | 1189 | struct SessionQuotaMessage sqm; |
@@ -1223,6 +1229,8 @@ set_primary_address (struct NeighbourMapEntry *n, | |||
1223 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 1229 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
1224 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | 1230 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) |
1225 | { | 1231 | { |
1232 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_min; | ||
1233 | |||
1226 | if (session == n->primary_address.session) | 1234 | if (session == n->primary_address.session) |
1227 | { | 1235 | { |
1228 | GST_validation_set_address_use (n->primary_address.address, | 1236 | GST_validation_set_address_use (n->primary_address.address, |
@@ -1236,11 +1244,14 @@ set_primary_address (struct NeighbourMapEntry *n, | |||
1236 | if (n->primary_address.bandwidth_out.value__ != bandwidth_out.value__) | 1244 | if (n->primary_address.bandwidth_out.value__ != bandwidth_out.value__) |
1237 | { | 1245 | { |
1238 | n->primary_address.bandwidth_out = bandwidth_out; | 1246 | n->primary_address.bandwidth_out = bandwidth_out; |
1239 | // FIXME: this ignores n->neighbour_receive_quota! | 1247 | #if IGNORE_INBOUND_QUOTA |
1240 | // -> might get 'unusually' high quota on initial | 1248 | bandwidth_min = bandwidth_out; |
1241 | // connect | 1249 | #else |
1250 | bandwidth_min = GNUNET_BANDWIDTH_value_min (bandwidth_out, | ||
1251 | n->neighbour_receive_quota); | ||
1252 | #endif | ||
1242 | send_outbound_quota_to_clients (&address->peer, | 1253 | send_outbound_quota_to_clients (&address->peer, |
1243 | bandwidth_out); | 1254 | bandwidth_min); |
1244 | } | 1255 | } |
1245 | return; | 1256 | return; |
1246 | } | 1257 | } |
@@ -1277,11 +1288,14 @@ set_primary_address (struct NeighbourMapEntry *n, | |||
1277 | GNUNET_YES); | 1288 | GNUNET_YES); |
1278 | set_incoming_quota (n, | 1289 | set_incoming_quota (n, |
1279 | bandwidth_in); | 1290 | bandwidth_in); |
1280 | // FIXME: this ignores n->neighbour_receive_quota! | 1291 | #if IGNORE_INBOUND_QUOTA |
1281 | // -> might get 'unusually' high quota on initial | 1292 | bandwidth_min = bandwidth_out; |
1282 | // connect | 1293 | #else |
1294 | bandwidth_min = GNUNET_BANDWIDTH_value_min (bandwidth_out, | ||
1295 | n->neighbour_receive_quota); | ||
1296 | #endif | ||
1283 | send_outbound_quota_to_clients (&address->peer, | 1297 | send_outbound_quota_to_clients (&address->peer, |
1284 | bandwidth_out); | 1298 | bandwidth_min); |
1285 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1299 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1286 | "Neighbour `%s' switched to address `%s'\n", | 1300 | "Neighbour `%s' switched to address `%s'\n", |
1287 | GNUNET_i2s (&n->id), | 1301 | GNUNET_i2s (&n->id), |
@@ -2558,8 +2572,12 @@ try_run_fast_ats_update (const struct GNUNET_HELLO_Address *address, | |||
2558 | if (n->primary_address.bandwidth_out.value__ != bandwidth_out.value__) | 2572 | if (n->primary_address.bandwidth_out.value__ != bandwidth_out.value__) |
2559 | { | 2573 | { |
2560 | n->primary_address.bandwidth_out = bandwidth_out; | 2574 | n->primary_address.bandwidth_out = bandwidth_out; |
2575 | #if IGNORE_INBOUND_QUOTA | ||
2576 | bandwidth_min = bandwidth_out; | ||
2577 | #else | ||
2561 | bandwidth_min = GNUNET_BANDWIDTH_value_min (bandwidth_out, | 2578 | bandwidth_min = GNUNET_BANDWIDTH_value_min (bandwidth_out, |
2562 | n->neighbour_receive_quota); | 2579 | n->neighbour_receive_quota); |
2580 | #endif | ||
2563 | send_outbound_quota_to_clients (&address->peer, | 2581 | send_outbound_quota_to_clients (&address->peer, |
2564 | bandwidth_min); | 2582 | bandwidth_min); |
2565 | } | 2583 | } |
@@ -3696,9 +3714,12 @@ GST_neighbours_handle_quota_message (const struct GNUNET_PeerIdentity *peer, | |||
3696 | n->neighbour_receive_quota | 3714 | n->neighbour_receive_quota |
3697 | = GNUNET_BANDWIDTH_value_max (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, | 3715 | = GNUNET_BANDWIDTH_value_max (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, |
3698 | GNUNET_BANDWIDTH_value_init (ntohl (sqm->quota))); | 3716 | GNUNET_BANDWIDTH_value_init (ntohl (sqm->quota))); |
3699 | 3717 | #if IGNORE_INBOUND_QUOTA | |
3718 | bandwidth_min = n->primary_address.bandwidth_out; | ||
3719 | #else | ||
3700 | bandwidth_min = GNUNET_BANDWIDTH_value_min (n->primary_address.bandwidth_out, | 3720 | bandwidth_min = GNUNET_BANDWIDTH_value_min (n->primary_address.bandwidth_out, |
3701 | n->neighbour_receive_quota); | 3721 | n->neighbour_receive_quota); |
3722 | #endif | ||
3702 | send_outbound_quota_to_clients (peer, | 3723 | send_outbound_quota_to_clients (peer, |
3703 | bandwidth_min); | 3724 | bandwidth_min); |
3704 | } | 3725 | } |