[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r15913 - gnunet/src/fragmentation
From: |
gnunet |
Subject: |
[GNUnet-SVN] r15913 - gnunet/src/fragmentation |
Date: |
Sat, 9 Jul 2011 18:48:59 +0200 |
Author: grothoff
Date: 2011-07-09 18:48:59 +0200 (Sat, 09 Jul 2011)
New Revision: 15913
Modified:
gnunet/src/fragmentation/defragmentation_new.c
Log:
data structures
Modified: gnunet/src/fragmentation/defragmentation_new.c
===================================================================
--- gnunet/src/fragmentation/defragmentation_new.c 2011-07-09 16:31:09 UTC
(rev 15912)
+++ gnunet/src/fragmentation/defragmentation_new.c 2011-07-09 16:48:59 UTC
(rev 15913)
@@ -26,9 +26,98 @@
#include "gnunet_fragmentation_lib.h"
#include "fragmentation.h"
+
/**
- * Defragmentation context.
+ * Timestamps for fragments.
*/
+struct FragTimes
+{
+ /**
+ * The time the fragment was received.
+ */
+ GNUNET_TIME_Absolute time;
+
+ /**
+ * Number of the bit for the fragment (in [0,..,63]).
+ */
+ unsigned int bit;
+};
+
+
+/**
+ * Information we keep for one message that is being assembled.
+ */
+struct MessageContext
+{
+ /**
+ * This is a DLL.
+ */
+ struct MessageContext *next;
+
+ /**
+ * This is a DLL.
+ */
+ struct MessageContext *prev;
+
+ /**
+ * Pointer to the assembled message, allocated at the
+ * end of this struct.
+ */
+ const struct GNUNET_MessageHeader *msg;
+
+ /**
+ * Last time we received any update for this message
+ * (least-recently updated message will be discarded
+ * if we hit the queue size).
+ */
+ struct GNUNET_TIME_Absolute last_update;
+
+ /**
+ * Task scheduled for transmitting the next ACK to the
+ * other peer.
+ */
+ struct GNUNET_SCHEDULER_TaskIdentifier ack_task;
+
+ /**
+ * When did we receive which fragment? Used to calculate
+ * the time we should send the ACK.
+ */
+ struct FragTimes frag_times[64];
+
+ /**
+ * Which fragments have we gotten yet? bits that are 1
+ * indicate missing fragments.
+ */
+ uint64_t bits;
+
+ /**
+ * Unique ID for this message.
+ */
+ uint32_t fragment_id;
+
+ /**
+ * For the current ACK round, which is the first relevant
+ * offset in 'frag_times'?
+ */
+ unsigned int frag_times_start_offset;
+
+ /**
+ * Which offset whould we write the next frag value into
+ * in the 'frag_times' array? All smaller entries are valid.
+ */
+ unsigned int frag_times_write_offset;
+
+ /**
+ * Total size of the message that we are assembling.
+ */
+ uint16_t total_size;
+
+};
+
+
+/**
+ * Defragmentation context (one per connection).
+ */
struct GNUNET_DEFRAGMENT_Context
{
@@ -43,6 +132,16 @@
void *cls;
/**
+ * Head of list of messages we're defragmenting.
+ */
+ struct MessageContext *head;
+
+ /**
+ * Tail of list of messages we're defragmenting.
+ */
+ struct MessageContext *tail;
+
+ /**
* Function to call with defragmented messages.
*/
GNUNET_FRAGMENT_MessageProcessor proc;
@@ -51,6 +150,26 @@
* Function to call with acknowledgements.
*/
GNUNET_FRAGMENT_MessageProcessor ackp;
+
+ /**
+ * Running average of the latency (delay between messages) for this
+ * connection.
+ */
+ struct GNUNET_TIME_Relative latency;
+
+ /**
+ * num_msgs how many fragmented messages
+ * to we defragment at most at the same time?
+ */
+ unsigned int num_msgs;
+
+ /**
+ * Current number of messages in the 'struct MessageContext'
+ * DLL (smaller or equal to 'num_msgs').
+ */
+ unsigned int list_size;
+
+
};
@@ -58,6 +177,8 @@
* Create a defragmentation context.
*
* @param stats statistics context
+ * @param num_msgs how many fragmented messages
+ * to we defragment at most at the same time?
* @param cls closure for proc and ackp
* @param proc function to call with defragmented messages
* @param ackp function to call with acknowledgements (to send
@@ -66,6 +187,7 @@
*/
struct GNUNET_DEFRAGMENT_Context *
GNUNET_DEFRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats,
+ unsigned int num_msgs,
void *cls,
GNUNET_FRAGMENT_MessageProcessor proc,
GNUNET_FRAGMENT_MessageProcessor ackp)
@@ -77,6 +199,8 @@
dc->cls = cls;
dc->proc = proc;
dc->ackp = ackp;
+ dc->num_msgs = num_msgs;
+ dc->latency = GNUNET_TIME_UNIT_SECONDS; /* start with likely overestimate */
return dc;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r15913 - gnunet/src/fragmentation,
gnunet <=