[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r6167 - in GNUnet/src: applications/fs/gap include server
From: |
gnunet |
Subject: |
[GNUnet-SVN] r6167 - in GNUnet/src: applications/fs/gap include server |
Date: |
Wed, 6 Feb 2008 00:42:26 -0700 (MST) |
Author: grothoff
Date: 2008-02-06 00:42:25 -0700 (Wed, 06 Feb 2008)
New Revision: 6167
Modified:
GNUnet/src/applications/fs/gap/TODO
GNUnet/src/include/gnunet_core.h
GNUnet/src/server/connection.c
GNUnet/src/server/connection.h
Log:
downstream bandwidth reservation
Modified: GNUnet/src/applications/fs/gap/TODO
===================================================================
--- GNUnet/src/applications/fs/gap/TODO 2008-02-06 07:24:38 UTC (rev 6166)
+++ GNUnet/src/applications/fs/gap/TODO 2008-02-06 07:42:25 UTC (rev 6167)
@@ -1,9 +1,9 @@
CORRECTNESS:
-1) (periodic?) clean up of stale data in plan.c datastructures -- easy --- 45
minutes
+1) (periodic?) clean up of stale data in plan.c datastructures
+ -- use core's new disconnect notification!
PERFORMANCE:
-1) core reservation of response bandwidth --- medium --- 60 minutes
-2) core notification of P2P-level disconnect (to call cleanup functions!)
+1) core reservation of response bandwidth
HARD STUFF:
Modified: GNUnet/src/include/gnunet_core.h
===================================================================
--- GNUnet/src/include/gnunet_core.h 2008-02-06 07:24:38 UTC (rev 6166)
+++ GNUnet/src/include/gnunet_core.h 2008-02-06 07:42:25 UTC (rev 6167)
@@ -446,14 +446,10 @@
* @param amount how many bytes should we expect to receive?
* (negative amounts can be used to undo a (recent)
* reservation request
- * @param timeframe in what time interval should the other
- * peer be able to transmit the amount? Use zero
- * when undoing a reservation
* @return amount that could actually be reserved
*/
- int (*reserve_downstream_bandwidth)(const GNUNET_NodeIteratorCallback * peer,
- int amount,
- GNUNET_CronTime timeframe);
+ int (*reserve_downstream_bandwidth)(const GNUNET_PeerIdentity * peer,
+ int amount);
/**
* Offer the core a session for communication with the
Modified: GNUnet/src/server/connection.c
===================================================================
--- GNUnet/src/server/connection.c 2008-02-06 07:24:38 UTC (rev 6166)
+++ GNUnet/src/server/connection.c 2008-02-06 07:42:25 UTC (rev 6167)
@@ -233,13 +233,13 @@
* Type of the linked list of send callbacks (to
* implement a round-robbin invocation chain).
*/
-typedef struct SendCallbackList__
+struct SendCallbackList
{
/**
* Did we say that this is a linked list?
*/
- struct SendCallbackList__ *next;
+ struct SendCallbackList *next;
/**
* The callback method.
@@ -260,7 +260,7 @@
*/
unsigned int priority;
-} SendCallbackList;
+};
struct DisconnectNotificationList {
@@ -273,13 +273,6 @@
};
-typedef struct fENHWrap
-{
- GNUNET_NodeIteratorCallback method;
- void *arg;
-} fENHWrap;
-
-
/**
* The other side has decided to terminate the connection. This
* message MAY be send if the other node decides to be nice. It is
@@ -492,6 +485,18 @@
/* *********** inbound bandwidth accounting ******** */
/**
+ * How much downstream capacity of this peer
+ * has been reserved for our traffic?
+ */
+ long long available_downstream;
+
+ /**
+ * When did we last update the reserved downstream
+ * availability data?
+ */
+ GNUNET_CronTime last_reservation_update;
+
+ /**
* how much traffic (bytes) did we receive on this connection since
* the last update-round?
*/
@@ -602,7 +607,7 @@
/**
* Send callbacks for making better use of noise padding...
*/
-static SendCallbackList * scl_head;
+static struct SendCallbackList * scl_head;
/**
* Callbacks for disconnect notifications.
@@ -729,6 +734,7 @@
initBufferEntry ()
{
BufferEntry *be;
+ GNUNET_CronTime now;
be = GNUNET_malloc (sizeof (BufferEntry));
memset (be, 0, sizeof (BufferEntry));
@@ -746,7 +752,9 @@
be->max_transmitted_limit = MIN_BPM_PER_PEER;
be->lastSendAttempt = 0; /* never */
be->inSendBuffer = GNUNET_NO;
- be->last_bps_update = GNUNET_get_time (); /* now */
+ now = GNUNET_get_time ();
+ be->last_bps_update = now;
+ be->last_reservation_update = now;
return be;
}
@@ -1628,7 +1636,7 @@
unsigned int j;
unsigned int p;
unsigned int rsi;
- SendCallbackList *pos;
+ struct SendCallbackList *pos;
GNUNET_TransportPacket_HEADER *p2pHdr;
unsigned int priority;
char *plaintextMsg;
@@ -1874,6 +1882,8 @@
stats->change (stat_transmitted, p);
be->available_send_window -= p;
be->lastSequenceNumberSend++;
+ GNUNET_CORE_connection_reserve_downstream_bandwidth(&be->session.sender,
+ 0);
if (be->idealized_limit > be->max_transmitted_limit)
be->max_transmitted_limit = be->idealized_limit;
else /* age */
@@ -2150,6 +2160,12 @@
return count;
}
+struct fENHWrap
+{
+ GNUNET_NodeIteratorCallback method;
+ void *arg;
+};
+
/**
* Little helper function for GNUNET_CORE_connection_iterate_peers.
*
@@ -2160,9 +2176,8 @@
static void
fENHCallback (BufferEntry * be, void *arg)
{
- fENHWrap *wrap;
+ struct fENHWrap *wrap = arg;
- wrap = (fENHWrap *) arg;
if (wrap->method != NULL)
wrap->method (&be->session.sender, wrap->arg);
}
@@ -2530,7 +2545,11 @@
/* in the first round we cap by 2* previous utilization */
firstRound = GNUNET_YES;
for (u = 0; u < activePeerCount; u++)
- entries[u]->idealized_limit = 0;
+ {
+
GNUNET_CORE_connection_reserve_downstream_bandwidth(&entries[u]->session.sender,
+ 0);
+ entries[u]->idealized_limit = 0;
+ }
while ((schedulableBandwidth > activePeerCount * 100) &&
(activePeerCount > 0) && (didAssign == GNUNET_YES))
{
@@ -2910,7 +2929,7 @@
/* create some traffic by force! */
char *msgBuf;
unsigned int mSize;
- SendCallbackList *pos;
+ struct SendCallbackList *pos;
unsigned int hSize;
hSize = root->available_send_window;
@@ -3734,7 +3753,7 @@
{
unsigned int i;
BufferEntry *be;
- SendCallbackList *scl;
+ struct SendCallbackList *scl;
ENTRY ();
GNUNET_GC_detach_change_listener (cfg, &connectionConfigChangeCallback,
@@ -3808,7 +3827,7 @@
GNUNET_CORE_connection_iterate_peers (GNUNET_NodeIteratorCallback method,
void *arg)
{
- fENHWrap wrap;
+ struct fENHWrap wrap;
int ret;
ENTRY ();
@@ -3904,12 +3923,12 @@
GNUNET_BufferFillCallback
callback)
{
- SendCallbackList *scl;
- SendCallbackList *pos;
- SendCallbackList *prev;
+ struct SendCallbackList *scl;
+ struct SendCallbackList *pos;
+ struct SendCallbackList *prev;
ENTRY ();
- scl = GNUNET_malloc (sizeof (SendCallbackList));
+ scl = GNUNET_malloc (sizeof (struct SendCallbackList));
scl->minimumPadding = minimumPadding;
scl->callback = callback;
scl->priority = priority;
@@ -3951,8 +3970,8 @@
GNUNET_BufferFillCallback
callback)
{
- SendCallbackList *pos;
- SendCallbackList *prev;
+ struct SendCallbackList *pos;
+ struct SendCallbackList *prev;
ENTRY ();
prev = NULL;
@@ -4404,11 +4423,38 @@
* @return amount that could actually be reserved
*/
int
-GNUNET_CORE_connection_reserve_downstream_bandwidth(const
GNUNET_NodeIteratorCallback * peer,
- int amount,
- GNUNET_CronTime timeframe)
+GNUNET_CORE_connection_reserve_downstream_bandwidth(const GNUNET_PeerIdentity
* peer,
+ int amount)
{
- return 0; /* not implemented */
+ BufferEntry * be;
+ unsigned long long available;
+ GNUNET_CronTime now;
+ GNUNET_CronTime delta;
+
+ GNUNET_mutex_lock(lock);
+ be = lookForHost(peer);
+ if ( (be == NULL) ||
+ (be->status != STAT_UP) )
+ {
+ GNUNET_mutex_unlock(lock);
+ return 0; /* not connected */
+ }
+ now = GNUNET_get_time();
+ delta = now - be->last_reservation_update;
+ available = be->available_downstream + be->idealized_limit * delta /
GNUNET_CRON_MINUTES;
+ if (amount < 0)
+ available -= amount;
+ if (available > be->idealized_limit * MAX_BUF_FACT)
+ available = be->idealized_limit * MAX_BUF_FACT;
+ if ( (amount > 0) &&
+ (available < amount) )
+ amount = (int) available;
+ if (amount > 0)
+ available -= amount;
+ be->last_reservation_update = now;
+ be->available_downstream = available;
+ GNUNET_mutex_unlock(lock);
+ return available;
}
void __attribute__ ((constructor)) GNUNET_CORE_connection_ltdl_init ()
Modified: GNUnet/src/server/connection.h
===================================================================
--- GNUnet/src/server/connection.h 2008-02-06 07:24:38 UTC (rev 6166)
+++ GNUnet/src/server/connection.h 2008-02-06 07:42:25 UTC (rev 6167)
@@ -373,14 +373,10 @@
* @param amount how many bytes should we expect to receive?
* (negative amounts can be used to undo a (recent)
* reservation request
- * @param timeframe in what time interval should the other
- * peer be able to transmit the amount? Use zero
- * when undoing a reservation
* @return amount that could actually be reserved
*/
-int GNUNET_CORE_connection_reserve_downstream_bandwidth(const
GNUNET_NodeIteratorCallback * peer,
- int amount,
- GNUNET_CronTime
timeframe);
+int GNUNET_CORE_connection_reserve_downstream_bandwidth(const
GNUNET_PeerIdentity * peer,
+ int amount);
#endif
/* end of connection.h */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r6167 - in GNUnet/src: applications/fs/gap include server,
gnunet <=