From: Christian Grothoff Date: Thu, 14 Jul 2011 17:45:16 +0000 (+0000) Subject: reliable udp X-Git-Tag: initial-import-from-subversion-38251~17866 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c5678b2b20d198c2e7715a509d990619dc73c144;p=oweals%2Fgnunet.git reliable udp --- diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index fce9f3296..1eb4b249c 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am @@ -187,9 +187,10 @@ libgnunet_plugin_transport_wlan_la_LDFLAGS = \ $(GN_PLUGIN_LDFLAGS) libgnunet_plugin_transport_udp_la_SOURCES = \ - plugin_transport_udp.c + plugin_transport_udp_new.c libgnunet_plugin_transport_udp_la_LIBADD = \ $(top_builddir)/src/hello/libgnunethello.la \ + $(top_builddir)/src/fragmentation/libgnunetfragmentation.la \ $(top_builddir)/src/statistics/libgnunetstatistics.la \ $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ $(top_builddir)/src/nat/libgnunetnat.la \ 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 @@ -235,6 +235,11 @@ struct Plugin */ struct GNUNET_SERVER_MessageStreamTokenizer *mst; + /** + * Bandwidth tracker to limit global UDP traffic. + */ + struct GNUNET_BANDWIDTH_Tracker tracker; + /** * Address we were told to bind to exclusively (IPv4). */ @@ -265,6 +270,11 @@ struct Plugin */ struct GNUNET_NETWORK_Handle *sockv6; + /** + * expected delay for ACKs + */ + struct GNUNET_TIME_Relative last_expected_delay; + /** * Port we listen on. */ @@ -314,7 +324,7 @@ udp_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) GNUNET_CONTAINER_multihashmap_remove (plugin->sessions, &target->hashPubKey, session)); - (void) GNUNET_FRAGMENT_context_destroy (session->frag); + plugin->last_expected_delay = GNUNET_FRAGMENT_context_destroy (session->frag); session->cont (session->cont_cls, target, GNUNET_SYSERR); GNUNET_free (session); } @@ -518,8 +528,8 @@ udp_plugin_send (void *cls, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); peer_session->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats, UDP_MTU, - NULL /* tracker; FIXME: add later to limit send rate... */, - GNUNET_TIME_UNIT_SECONDS /* expected delay for ACKs */, + &plugin->tracker, + plugin->last_expected_delay, &udp->header, &send_fragment, peer_session); @@ -1313,6 +1323,7 @@ libgnunet_plugin_transport_udp_init (void *cls) socklen_t addrlens[2]; socklen_t addrlen; unsigned int tries; + unsigned long long udp_max_bps; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (env->cfg, @@ -1320,6 +1331,12 @@ libgnunet_plugin_transport_udp_init (void *cls) "PORT", &port)) port = 2086; + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (env->cfg, + "transport-udp", + "MAX_BPS", + &udp_max_bps)) + udp_max_bps = 1024 * 1024 * 100; /* 100 MB/s == infinity for practical purposes */ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-udp", @@ -1339,6 +1356,10 @@ libgnunet_plugin_transport_udp_init (void *cls) memset (&serverAddrv4, 0, sizeof (serverAddrv4)); plugin = GNUNET_malloc (sizeof (struct Plugin)); + GNUNET_BANDWIDTH_tracker_init (&plugin->tracker, + GNUNET_BANDWIDTH_value_init ((uint32_t) udp_max_bps), + 30); + plugin->last_expected_delay = GNUNET_TIME_UNIT_SECONDS; plugin->port = port; plugin->aport = aport; plugin->env = env;