diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-07-14 17:45:16 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-07-14 17:45:16 +0000 |
commit | c5678b2b20d198c2e7715a509d990619dc73c144 (patch) | |
tree | 724825082b25fe34b5fadf17e7838675e0c6b97d /src/transport/plugin_transport_udp_new.c | |
parent | 750ebd3d6008e2ccff7acd4dd48cd88e1756c2b6 (diff) | |
download | gnunet-c5678b2b20d198c2e7715a509d990619dc73c144.tar.gz gnunet-c5678b2b20d198c2e7715a509d990619dc73c144.zip |
reliable udp
Diffstat (limited to 'src/transport/plugin_transport_udp_new.c')
-rw-r--r-- | src/transport/plugin_transport_udp_new.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/transport/plugin_transport_udp_new.c b/src/transport/plugin_transport_udp_new.c index c5b14813b..4f57c6942 100644 --- a/src/transport/plugin_transport_udp_new.c +++ b/src/transport/plugin_transport_udp_new.c | |||
@@ -236,6 +236,11 @@ struct Plugin | |||
236 | struct GNUNET_SERVER_MessageStreamTokenizer *mst; | 236 | struct GNUNET_SERVER_MessageStreamTokenizer *mst; |
237 | 237 | ||
238 | /** | 238 | /** |
239 | * Bandwidth tracker to limit global UDP traffic. | ||
240 | */ | ||
241 | struct GNUNET_BANDWIDTH_Tracker tracker; | ||
242 | |||
243 | /** | ||
239 | * Address we were told to bind to exclusively (IPv4). | 244 | * Address we were told to bind to exclusively (IPv4). |
240 | */ | 245 | */ |
241 | char *bind4_address; | 246 | char *bind4_address; |
@@ -266,6 +271,11 @@ struct Plugin | |||
266 | struct GNUNET_NETWORK_Handle *sockv6; | 271 | struct GNUNET_NETWORK_Handle *sockv6; |
267 | 272 | ||
268 | /** | 273 | /** |
274 | * expected delay for ACKs | ||
275 | */ | ||
276 | struct GNUNET_TIME_Relative last_expected_delay; | ||
277 | |||
278 | /** | ||
269 | * Port we listen on. | 279 | * Port we listen on. |
270 | */ | 280 | */ |
271 | uint16_t port; | 281 | uint16_t port; |
@@ -314,7 +324,7 @@ udp_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) | |||
314 | GNUNET_CONTAINER_multihashmap_remove (plugin->sessions, | 324 | GNUNET_CONTAINER_multihashmap_remove (plugin->sessions, |
315 | &target->hashPubKey, | 325 | &target->hashPubKey, |
316 | session)); | 326 | session)); |
317 | (void) GNUNET_FRAGMENT_context_destroy (session->frag); | 327 | plugin->last_expected_delay = GNUNET_FRAGMENT_context_destroy (session->frag); |
318 | session->cont (session->cont_cls, target, GNUNET_SYSERR); | 328 | session->cont (session->cont_cls, target, GNUNET_SYSERR); |
319 | GNUNET_free (session); | 329 | GNUNET_free (session); |
320 | } | 330 | } |
@@ -518,8 +528,8 @@ udp_plugin_send (void *cls, | |||
518 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 528 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
519 | peer_session->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats, | 529 | peer_session->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats, |
520 | UDP_MTU, | 530 | UDP_MTU, |
521 | NULL /* tracker; FIXME: add later to limit send rate... */, | 531 | &plugin->tracker, |
522 | GNUNET_TIME_UNIT_SECONDS /* expected delay for ACKs */, | 532 | plugin->last_expected_delay, |
523 | &udp->header, | 533 | &udp->header, |
524 | &send_fragment, | 534 | &send_fragment, |
525 | peer_session); | 535 | peer_session); |
@@ -1313,6 +1323,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1313 | socklen_t addrlens[2]; | 1323 | socklen_t addrlens[2]; |
1314 | socklen_t addrlen; | 1324 | socklen_t addrlen; |
1315 | unsigned int tries; | 1325 | unsigned int tries; |
1326 | unsigned long long udp_max_bps; | ||
1316 | 1327 | ||
1317 | if (GNUNET_OK != | 1328 | if (GNUNET_OK != |
1318 | GNUNET_CONFIGURATION_get_value_number (env->cfg, | 1329 | GNUNET_CONFIGURATION_get_value_number (env->cfg, |
@@ -1323,6 +1334,12 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1323 | if (GNUNET_OK != | 1334 | if (GNUNET_OK != |
1324 | GNUNET_CONFIGURATION_get_value_number (env->cfg, | 1335 | GNUNET_CONFIGURATION_get_value_number (env->cfg, |
1325 | "transport-udp", | 1336 | "transport-udp", |
1337 | "MAX_BPS", | ||
1338 | &udp_max_bps)) | ||
1339 | udp_max_bps = 1024 * 1024 * 100; /* 100 MB/s == infinity for practical purposes */ | ||
1340 | if (GNUNET_OK != | ||
1341 | GNUNET_CONFIGURATION_get_value_number (env->cfg, | ||
1342 | "transport-udp", | ||
1326 | "ADVERTISED_PORT", | 1343 | "ADVERTISED_PORT", |
1327 | &aport)) | 1344 | &aport)) |
1328 | aport = port; | 1345 | aport = port; |
@@ -1339,6 +1356,10 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1339 | memset (&serverAddrv4, 0, sizeof (serverAddrv4)); | 1356 | memset (&serverAddrv4, 0, sizeof (serverAddrv4)); |
1340 | 1357 | ||
1341 | plugin = GNUNET_malloc (sizeof (struct Plugin)); | 1358 | plugin = GNUNET_malloc (sizeof (struct Plugin)); |
1359 | GNUNET_BANDWIDTH_tracker_init (&plugin->tracker, | ||
1360 | GNUNET_BANDWIDTH_value_init ((uint32_t) udp_max_bps), | ||
1361 | 30); | ||
1362 | plugin->last_expected_delay = GNUNET_TIME_UNIT_SECONDS; | ||
1342 | plugin->port = port; | 1363 | plugin->port = port; |
1343 | plugin->aport = aport; | 1364 | plugin->aport = aport; |
1344 | plugin->env = env; | 1365 | plugin->env = env; |