|
struct GNUNET_DEFRAGMENT_Context * | GNUNET_DEFRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats, uint16_t mtu, unsigned int num_msgs, void *cls, GNUNET_FRAGMENT_MessageProcessor proc, GNUNET_DEFRAGMENT_AckProcessor ackp) |
| Create a defragmentation context. More...
|
|
void | GNUNET_DEFRAGMENT_context_destroy (struct GNUNET_DEFRAGMENT_Context *dc) |
| Destroy the given defragmentation context. More...
|
|
static void | send_ack (void *cls) |
| Send acknowledgement to the other peer now. More...
|
|
static void | gsl_fit_mul (const double *x, const size_t xstride, const double *y, const size_t ystride, const size_t n, double *c1, double *cov_11, double *sumsq) |
| This function is from the GNU Scientific Library, linear/fit.c, Copyright (C) 2000 Brian Gough. More...
|
|
static struct GNUNET_TIME_Relative | estimate_latency (struct MessageContext *mc) |
| Estimate the latency between messages based on the most recent message time stamps. More...
|
|
static void | discard_oldest_mc (struct GNUNET_DEFRAGMENT_Context *dc) |
| Discard the message context that was inactive for the longest time. More...
|
|
int | GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc, const struct GNUNET_MessageHeader *msg) |
| We have received a fragment. More...
|
|
library to help defragment messages
- Author
- Christian Grothoff
Definition in file defragmentation.c.
static void send_ack |
( |
void * |
cls | ) |
|
|
static |
Send acknowledgement to the other peer now.
- Parameters
-
Definition at line 260 of file defragmentation.c.
References _, MessageContext::ack_task, GNUNET_DEFRAGMENT_Context::ackp, FragmentAcknowledgement::bits, MessageContext::bits, GNUNET_DEFRAGMENT_Context::cls, dc, MessageContext::dc, FragmentAcknowledgement::fragment_id, MessageContext::fragment_id, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_FRAGMENT_ACK, GNUNET_NO, GNUNET_STATISTICS_update(), FragmentAcknowledgement::header, MessageContext::last_duplicate, mc, GNUNET_MessageHeader::size, GNUNET_DEFRAGMENT_Context::stats, and GNUNET_MessageHeader::type.
Referenced by GNUNET_DEFRAGMENT_process_fragment().
272 _ (
"# acknowledgements sent for fragment"),
struct GNUNET_SCHEDULER_Task * ack_task
Task scheduled for transmitting the next ACK to the other peer.
uint64_t bits
Which fragments have we gotten yet? bits that are 1 indicate missing fragments.
void * cls
Closure for proc and ackp.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
#define GNUNET_MESSAGE_TYPE_FRAGMENT_ACK
Acknowledgement of a FRAGMENT of a larger message.
GNUNET_DEFRAGMENT_AckProcessor ackp
Function to call with acknowledgements.
Information we keep for one message that is being assembled.
uint32_t fragment_id
Unique ID for this message.
static struct GNUNET_TESTBED_Controller * mc
Handle to the master controller.
int16_t last_duplicate
Was the last fragment we got a duplicate?
struct GNUNET_DEFRAGMENT_Context * dc
Associated defragmentation context.
Defragmentation context (one per connection).
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
struct GNUNET_STATISTICS_Handle * stats
For statistics.
Message fragment acknowledgement.
static struct GNUNET_FS_DownloadContext * dc
static void gsl_fit_mul |
( |
const double * |
x, |
|
|
const size_t |
xstride, |
|
|
const double * |
y, |
|
|
const size_t |
ystride, |
|
|
const size_t |
n, |
|
|
double * |
c1, |
|
|
double * |
cov_11, |
|
|
double * |
sumsq |
|
) |
| |
|
static |
This function is from the GNU Scientific Library, linear/fit.c, Copyright (C) 2000 Brian Gough.
Definition at line 287 of file defragmentation.c.
References testconfigure::b.
Referenced by estimate_latency().
291 double m_x = 0, m_y = 0, m_dx2 = 0, m_dxdy = 0;
295 for (i = 0; i < n; i++)
297 m_x += (x[i * xstride] - m_x) / (i + 1.0);
298 m_y += (y[i * ystride] - m_y) / (i + 1.0);
301 for (i = 0; i < n; i++)
303 const double dx = x[i * xstride] - m_x;
304 const double dy = y[i * ystride] - m_y;
306 m_dx2 += (dx * dx - m_dx2) / (i + 1.0);
307 m_dxdy += (dx * dy - m_dxdy) / (i + 1.0);
313 double s2 = 0, d2 = 0;
314 double b = (m_x * m_y + m_dxdy) / (m_x * m_x + m_dx2);
320 for (i = 0; i < n; i++)
322 const double dx = x[i * xstride] - m_x;
323 const double dy = y[i * ystride] - m_y;
324 const double d = (m_y - b * m_x) + dy - b * dx;
331 *cov_11 = s2 * 1.0 / (n * (m_x * m_x + m_dx2));
Estimate the latency between messages based on the most recent message time stamps.
- Parameters
-
mc | context with time stamps |
- Returns
- average delay between time stamps (based on least-squares fit)
Definition at line 346 of file defragmentation.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_assert, GNUNET_TIME_UNIT_MICROSECONDS, gsl_fit_mul(), mc, GNUNET_TIME_Relative::rel_value_us, ret, and FragTimes::time.
Referenced by GNUNET_DEFRAGMENT_process_fragment().
360 for (i = 0; i < total; i++)
363 y[i] = (double) (first[i].time.abs_value_us - first[0].time.abs_value_us);
365 gsl_fit_mul (x, 1, y, 1, total, &c1, &cov11, &sumsq);
367 ret.rel_value_us = (uint64_t) c1;
368 if (0 ==
ret.rel_value_us)
unsigned int frag_times_start_offset
For the current ACK round, which is the first relevant offset in frag_times?
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void gsl_fit_mul(const double *x, const size_t xstride, const double *y, const size_t ystride, const size_t n, double *c1, double *cov_11, double *sumsq)
This function is from the GNU Scientific Library, linear/fit.c, Copyright (C) 2000 Brian Gough...
static int ret
Return value of the commandline.
Timestamps for fragments.
struct FragTimes frag_times[64]
When did we receive which fragment? Used to calculate the time we should send the ACK...
unsigned int frag_times_write_offset
Which offset whould we write the next frag value into in the frag_times array? All smaller entries ar...
#define GNUNET_TIME_UNIT_MICROSECONDS
One microsecond, our basic time unit.
Time for relative time used by GNUnet, in microseconds.
Discard the message context that was inactive for the longest time.
- Parameters
-
dc | defragmentation context |
Definition at line 380 of file defragmentation.c.
References GNUNET_TIME_Absolute::abs_value_us, MessageContext::ack_task, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_DEFRAGMENT_Context::head, MessageContext::last_update, GNUNET_DEFRAGMENT_Context::list_size, MessageContext::next, and GNUNET_DEFRAGMENT_Context::tail.
Referenced by GNUNET_DEFRAGMENT_process_fragment().
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct MessageContext * tail
Tail of list of messages we're defragmenting.
struct GNUNET_SCHEDULER_Task * ack_task
Task scheduled for transmitting the next ACK to the other peer.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TIME_Absolute last_update
Last time we received any update for this message (least-recently updated message will be discarded i...
uint64_t abs_value_us
The actual value.
unsigned int list_size
Current number of messages in the 'struct MessageContext' DLL (smaller or equal to 'num_msgs')...
struct MessageContext * head
Head of list of messages we're defragmenting.
Information we keep for one message that is being assembled.
struct MessageContext * next
This is a DLL.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.