[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r32266 - gnunet/src/core
From: |
gnunet |
Subject: |
[GNUnet-SVN] r32266 - gnunet/src/core |
Date: |
Sun, 9 Feb 2014 20:15:47 +0100 |
Author: grothoff
Date: 2014-02-09 20:15:47 +0100 (Sun, 09 Feb 2014)
New Revision: 32266
Modified:
gnunet/src/core/gnunet-service-core_neighbours.c
gnunet/src/core/gnunet-service-core_neighbours.h
gnunet/src/core/gnunet-service-core_sessions.c
gnunet/src/core/gnunet-service-core_sessions.h
Log:
implement #3295: only transmit background traffic if there is excess bandwidth
Modified: gnunet/src/core/gnunet-service-core_neighbours.c
===================================================================
--- gnunet/src/core/gnunet-service-core_neighbours.c 2014-02-09 18:58:36 UTC
(rev 32265)
+++ gnunet/src/core/gnunet-service-core_neighbours.c 2014-02-09 19:15:47 UTC
(rev 32266)
@@ -105,6 +105,11 @@
*/
GNUNET_SCHEDULER_TaskIdentifier retry_plaintext_task;
+ /**
+ * #GNUNET_YES if this peer currently has excess bandwidth.
+ */
+ int has_excess_bandwidth;
+
};
@@ -213,13 +218,13 @@
n->th = NULL;
m = n->message_head;
- if (m == NULL)
+ if (NULL == m)
{
GNUNET_break (0);
return 0;
}
GNUNET_CONTAINER_DLL_remove (n->message_head, n->message_tail, m);
- if (buf == NULL)
+ if (NULL == buf)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transmission of message of type %u and size %u failed\n",
@@ -240,6 +245,7 @@
ntohs (((struct GNUNET_MessageHeader *) &m[1])->type),
(unsigned int) ret, GNUNET_i2s (&n->peer));
GNUNET_free (m);
+ n->has_excess_bandwidth = GNUNET_NO;
process_queue (n);
GNUNET_STATISTICS_update (GSC_stats,
gettext_noop
@@ -450,6 +456,54 @@
/**
+ * One of our neighbours has excess bandwidth,
+ * remember this.
+ *
+ * @param cls NULL
+ * @param pid identity of the peer with excess bandwidth
+ */
+static void
+handle_transport_notify_excess_bw (void *cls,
+ const struct GNUNET_PeerIdentity *pid)
+{
+ struct Neighbour *n;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %s has excess bandwidth available\n",
+ GNUNET_i2s (pid));
+ n = find_neighbour (pid);
+ if (NULL == n)
+ {
+ GNUNET_break (0);
+ return;
+ }
+ n->has_excess_bandwidth = GNUNET_YES;
+ GSC_SESSIONS_solicit (pid);
+}
+
+
+/**
+ * Check if the given neighbour has excess bandwidth available.
+ *
+ * @param target neighbour to check
+ * @return #GNUNET_YES if excess bandwidth is available, #GNUNET_NO if not
+ */
+int
+GSC_NEIGHBOURS_check_excess_bandwidth (const struct GNUNET_PeerIdentity
*target)
+{
+ struct Neighbour *n;
+
+ n = find_neighbour (target);
+ if (NULL == n)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ return n->has_excess_bandwidth;
+}
+
+
+/**
* Initialize neighbours subsystem.
*/
int
@@ -457,10 +511,11 @@
{
neighbours = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO);
transport =
- GNUNET_TRANSPORT_connect (GSC_cfg, &GSC_my_identity, NULL,
- &handle_transport_receive,
- &handle_transport_notify_connect,
- &handle_transport_notify_disconnect);
+ GNUNET_TRANSPORT_connect2 (GSC_cfg, &GSC_my_identity, NULL,
+ &handle_transport_receive,
+ &handle_transport_notify_connect,
+ &handle_transport_notify_disconnect,
+ &handle_transport_notify_excess_bw);
if (NULL == transport)
{
GNUNET_CONTAINER_multipeermap_destroy (neighbours);
Modified: gnunet/src/core/gnunet-service-core_neighbours.h
===================================================================
--- gnunet/src/core/gnunet-service-core_neighbours.h 2014-02-09 18:58:36 UTC
(rev 32265)
+++ gnunet/src/core/gnunet-service-core_neighbours.h 2014-02-09 19:15:47 UTC
(rev 32266)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
+ (C) 2009-2014 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -47,6 +47,16 @@
/**
+ * Check if the given neighbour has excess bandwidth available.
+ *
+ * @param target neighbour to check
+ * @return #GNUNET_YES if excess bandwidth is available, #GNUNET_NO if not
+ */
+int
+GSC_NEIGHBOURS_check_excess_bandwidth (const struct GNUNET_PeerIdentity
*target);
+
+
+/**
* Initialize neighbours subsystem.
*/
int
Modified: gnunet/src/core/gnunet-service-core_sessions.c
===================================================================
--- gnunet/src/core/gnunet-service-core_sessions.c 2014-02-09 18:58:36 UTC
(rev 32265)
+++ gnunet/src/core/gnunet-service-core_sessions.c 2014-02-09 19:15:47 UTC
(rev 32266)
@@ -508,13 +508,20 @@
enum GNUNET_CORE_Priority maxp;
enum GNUNET_CORE_Priority maxpc;
struct GSC_ClientActiveRequest *car;
+ int excess;
if (GNUNET_YES != session->ready_to_transmit)
return;
msize = 0;
min_deadline = GNUNET_TIME_UNIT_FOREVER_ABS;
- /* check 'ready' messages */
- maxp = GNUNET_CORE_PRIO_BACKGROUND;
+ /* if the peer has excess bandwidth, background traffic is allowed,
+ otherwise not */
+ excess = GSC_NEIGHBOURS_check_excess_bandwidth (&session->peer);
+ if (GNUNET_YES == excess)
+ maxp = GNUNET_CORE_PRIO_BACKGROUND;
+ else
+ maxp = GNUNET_CORE_PRIO_BEST_EFFORT;
+ /* determine highest priority of 'ready' messages we already solicited from
clients */
pos = session->sme_head;
while ((NULL != pos) &&
(msize + pos->size <= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE))
@@ -527,7 +534,12 @@
}
if (maxp < GNUNET_CORE_PRIO_CRITICAL_CONTROL)
{
- maxpc = GNUNET_CORE_PRIO_BACKGROUND;
+ /* if highest already solicited priority from clients is not critical,
+ check if there are higher-priority messages to be solicited from
clients */
+ if (GNUNET_YES == excess)
+ maxpc = GNUNET_CORE_PRIO_BACKGROUND;
+ else
+ maxpc = GNUNET_CORE_PRIO_BEST_EFFORT;
for (car = session->active_client_request_head; NULL != car; car =
car->next)
{
if (GNUNET_YES == car->was_solicited)
@@ -545,11 +557,15 @@
}
now = GNUNET_TIME_absolute_get ();
- if ((0 == msize) ||
- ((msize < GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE / 2) &&
- (min_deadline.abs_value_us > now.abs_value_us)))
+ if ( ( (GNUNET_YES == excess) ||
+ (maxpc >= GNUNET_CORE_PRIO_BEST_EFFORT) ) &&
+ ( (0 == msize) ||
+ ( (msize < GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE / 2) &&
+ (min_deadline.abs_value_us > now.abs_value_us))) )
{
- /* not enough ready yet, try to solicit more */
+ /* not enough ready yet (tiny message & cork possible), or no messages at
all,
+ and either excess bandwidth or best-effort or higher message waiting at
+ client; in this case, we try to solicit more */
solicit_messages (session,
msize);
if (msize > 0)
@@ -565,7 +581,8 @@
}
return;
}
- /* create plaintext buffer of all messages, encrypt and transmit */
+ /* create plaintext buffer of all messages (that fit), encrypt and
+ transmit */
{
static unsigned long long total_bytes;
static unsigned int total_msgs;
Modified: gnunet/src/core/gnunet-service-core_sessions.h
===================================================================
--- gnunet/src/core/gnunet-service-core_sessions.h 2014-02-09 18:58:36 UTC
(rev 32265)
+++ gnunet/src/core/gnunet-service-core_sessions.h 2014-02-09 19:15:47 UTC
(rev 32266)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
+ (C) 2009-2014 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r32266 - gnunet/src/core,
gnunet <=