GNUnet  0.10.x
Data Structures | Functions | Variables
gnunet-daemon-fsprofiler.c File Reference

daemon that publishes and downloads (random) files More...

#include "platform.h"
#include "gnunet_fs_service.h"
#include "gnunet_statistics_service.h"
Include dependency graph for gnunet-daemon-fsprofiler.c:

Go to the source code of this file.

Data Structures

struct  Pattern
 We use 'patterns' of the form (x,y,t) to specify desired download/publish activities of a peer. More...
 

Functions

static int parse_pattern (struct Pattern **head, struct Pattern **tail, const char *pattern)
 Parse a pattern string and store the corresponding 'struct Pattern' in the given head/tail. More...
 
static struct GNUNET_FS_Urimake_keywords (uint64_t kval)
 Create a KSK URI from a number. More...
 
static struct GNUNET_FS_FileInformationmake_file (uint64_t length, uint64_t kval, void *ctx)
 Create a file of the given length with a deterministic amount of data to be published under keyword 'kval'. More...
 
static void shutdown_task (void *cls)
 Task run during shutdown. More...
 
static void publish_stop_task (void *cls)
 Task run when a publish operation should be stopped. More...
 
static void download_stop_task (void *cls)
 Task run when a download operation should be stopped. More...
 
static void search_stop_task (void *cls)
 Task run when a download operation should be stopped. More...
 
static void * progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
 Notification of FS to a client about the progress of an operation. More...
 
static void start_publish (void *cls)
 Start publish operation. More...
 
static void start_download (void *cls)
 Start download operation. More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg_)
 Main function that will be run by the scheduler. More...
 
int main (int argc, char *const *argv)
 Program that performs various "random" FS activities. More...
 

Variables

static int global_ret
 Return value from 'main'. More...
 
static const struct GNUNET_CONFIGURATION_Handlecfg
 Configuration we use. More...
 
static struct GNUNET_STATISTICS_Handlestats_handle
 Handle to the statistics service. More...
 
static struct GNUNET_FS_Handlefs_handle
 Peer's FS handle. More...
 
static unsigned long long my_peerid
 Unique number for this peer in the testbed. More...
 
static unsigned long long anonymity_level
 Desired anonymity level. More...
 
static unsigned long long replication_level
 Desired replication level. More...
 
static char * publish_pattern
 String describing which publishing operations this peer should perform. More...
 
static struct Patternpublish_head
 Head of the DLL of publish patterns. More...
 
static struct Patternpublish_tail
 Tail of the DLL of publish patterns. More...
 
static char * download_pattern
 String describing which download operations this peer should perform. More...
 
static struct Patterndownload_head
 Head of the DLL of publish patterns. More...
 
static struct Patterndownload_tail
 Tail of the DLL of publish patterns. More...
 

Detailed Description

daemon that publishes and downloads (random) files

Author
Christian Grothoff

TODO:

Definition in file gnunet-daemon-fsprofiler.c.

Function Documentation

◆ parse_pattern()

static int parse_pattern ( struct Pattern **  head,
struct Pattern **  tail,
const char *  pattern 
)
static

Parse a pattern string and store the corresponding 'struct Pattern' in the given head/tail.

Parameters
headwhere to store the head
tailwhere to store the tail
patternpattern to parse
Returns
GNUNET_OK on success

Definition at line 175 of file gnunet-daemon-fsprofiler.c.

References Pattern::delay, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_OK, GNUNET_SYSERR, p, GNUNET_TIME_Relative::rel_value_us, t, Pattern::x, and Pattern::y.

Referenced by run().

178 {
179  struct Pattern *p;
180  unsigned long long x;
181  unsigned long long y;
182  unsigned long long t;
183 
184  while (3 == sscanf(pattern,
185  "(%llu,%llu,%llu)",
186  &x, &y, &t))
187  {
188  p = GNUNET_new(struct Pattern);
189  p->x = x;
190  p->y = y;
191  p->delay.rel_value_us = (uint64_t)t;
192  GNUNET_CONTAINER_DLL_insert(*head, *tail, p);
193  pattern = strstr(pattern, ")");
194  GNUNET_assert(NULL != pattern);
195  pattern++;
196  }
197  return (0 == strlen(pattern)) ? GNUNET_OK : GNUNET_SYSERR;
198 }
uint64_t rel_value_us
The actual value.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
unsigned long long y
Y-value.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TIME_Relative delay
With how much delay should this operation be started?
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct GNUNET_SCHEDULER_Task * t
Main task.
We use 'patterns' of the form (x,y,t) to specify desired download/publish activities of a peer...
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
unsigned long long x
X-value.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Here is the caller graph for this function:

◆ make_keywords()

static struct GNUNET_FS_Uri* make_keywords ( uint64_t  kval)
static

Create a KSK URI from a number.

Parameters
kvalthe number
Returns
corresponding KSK URI

Definition at line 208 of file gnunet-daemon-fsprofiler.c.

References GNUNET_FS_uri_ksk_create(), and GNUNET_snprintf().

Referenced by make_file(), and start_download().

209 {
210  char kw[128];
211 
212  GNUNET_snprintf(kw, sizeof(kw),
213  "%llu", (unsigned long long)kval);
214  return GNUNET_FS_uri_ksk_create(kw, NULL);
215 }
int GNUNET_snprintf(char *buf, size_t size, const char *format,...)
Like snprintf, just aborts if the buffer is of insufficient size.
struct GNUNET_FS_Uri * GNUNET_FS_uri_ksk_create(const char *keywords, char **emsg)
Create an FS URI from a single user-supplied string of keywords.
Definition: fs_uri.c:1057
Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_file()

static struct GNUNET_FS_FileInformation* make_file ( uint64_t  length,
uint64_t  kval,
void *  ctx 
)
static

Create a file of the given length with a deterministic amount of data to be published under keyword 'kval'.

Parameters
lengthnumber of bytes in the file
kvalkeyword value and seed for the data of the file
ctxcontext to pass to 'fi'
Returns
file information handle for the file

Definition at line 228 of file gnunet-daemon-fsprofiler.c.

References anonymity_level, GNUNET_FS_BlockOptions::anonymity_level, GNUNET_FS_BlockOptions::content_priority, data, GNUNET_FS_BlockOptions::expiration_time, GNUNET_FS_file_information_create_from_data(), GNUNET_FS_uri_destroy(), GNUNET_malloc_large, GNUNET_memcpy, GNUNET_MIN, GNUNET_NO, GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_DAYS, GNUNET_FS_Uri::keywords, make_keywords(), replication_level, and GNUNET_FS_BlockOptions::replication_level.

Referenced by start_publish().

231 {
232  struct GNUNET_FS_FileInformation *fi;
233  struct GNUNET_FS_BlockOptions bo;
234  char *data;
235  struct GNUNET_FS_Uri *keywords;
236  unsigned long long i;
237  uint64_t xor;
238 
239  data = NULL; /* to make compilers happy */
240  if ((0 != length) &&
241  (NULL == (data = GNUNET_malloc_large((size_t)length))))
242  return NULL;
243  /* initialize data with 'unique' data only depending on 'kval' and 'size',
244  making sure that blocks do not repeat */
245  for (i = 0; i < length; i += 8)
246  {
247  xor = length ^ kval ^ (uint64_t)(i / 32 / 1024);
248  GNUNET_memcpy(&data[i], &xor, GNUNET_MIN(length - i, sizeof(uint64_t)));
249  }
251  bo.anonymity_level = (uint32_t)anonymity_level;
252  bo.content_priority = 128;
254  keywords = make_keywords(kval);
256  ctx,
257  length,
258  data, keywords,
259  NULL, GNUNET_NO, &bo);
260  GNUNET_FS_uri_destroy(keywords);
261  return fi;
262 }
struct GNUNET_TIME_Absolute expiration_time
At what time should the block expire? Data blocks (DBLOCKS and IBLOCKS) may still be used even if the...
static struct GNUNET_FS_Uri * make_keywords(uint64_t kval)
Create a KSK URI from a number.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:246
struct GNUNET_FS_FileInformation * GNUNET_FS_file_information_create_from_data(struct GNUNET_FS_Handle *h, void *client_info, uint64_t length, void *data, const struct GNUNET_FS_Uri *keywords, const struct GNUNET_CONTAINER_MetaData *meta, int do_index, const struct GNUNET_FS_BlockOptions *bo)
Create an entry for a file in a publish-structure.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_NO
Definition: gnunet_common.h:78
Information for a file or directory that is about to be published.
Definition: fs_api.h:219
#define GNUNET_malloc_large(size)
Wrapper around malloc.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
uint32_t anonymity_level
At which anonymity level should the block be shared? (0: no anonymity, 1: normal GAP, >1: with cover traffic).
static unsigned long long anonymity_level
Desired anonymity level.
static unsigned long long replication_level
Desired replication level.
char ** keywords
Keywords start with a &#39;+&#39; if they are mandatory (in which case the &#39;+&#39; is NOT part of the keyword) an...
Definition: fs_api.h:179
#define GNUNET_MIN(a, b)
Definition: gnunet_common.h:80
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:675
Settings for publishing a block (which may of course also apply to an entire directory or file)...
static struct GNUNET_FS_Handle * fs_handle
Peer&#39;s FS handle.
#define GNUNET_TIME_UNIT_DAYS
One day.
uint32_t replication_level
How often should we try to migrate the block to other peers? Only used if "CONTENT_PUSHING" is set to...
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:162
uint32_t content_priority
How important is it for us to store the block? If we run out of space, the highest-priority, non-expired blocks will be kept.
uint32_t data
The data value.
static struct GNUNET_FS_BlockOptions bo
Options we set for published blocks.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Task run during shutdown.

Parameters
clsunused

Definition at line 271 of file gnunet-daemon-fsprofiler.c.

References Pattern::ctx, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_FS_download_stop(), GNUNET_FS_publish_stop(), GNUNET_FS_search_stop(), GNUNET_FS_stop(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_destroy(), GNUNET_YES, p, Pattern::sctx, Pattern::stask, and Pattern::task.

Referenced by run().

272 {
273  struct Pattern *p;
274 
275  while (NULL != (p = publish_head))
276  {
277  if (NULL != p->task)
279  if (NULL != p->ctx)
282  GNUNET_free(p);
283  }
284  while (NULL != (p = download_head))
285  {
286  if (NULL != p->task)
288  if (NULL != p->stask)
290  if (NULL != p->ctx)
292  if (NULL != p->sctx)
295  GNUNET_free(p);
296  }
297  if (NULL != fs_handle)
298  {
300  fs_handle = NULL;
301  }
302  if (NULL != stats_handle)
303  {
305  stats_handle = NULL;
306  }
307 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_SCHEDULER_Task * stask
Secondary task to run the operation.
void GNUNET_FS_publish_stop(struct GNUNET_FS_PublishContext *pc)
Stop an upload.
Definition: fs_publish.c:1555
void * ctx
Execution context for the pattern (FS-handle to the operation).
static struct Pattern * download_head
Head of the DLL of publish patterns.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
void GNUNET_FS_stop(struct GNUNET_FS_Handle *h)
Close our connection with the file-sharing service.
Definition: fs_api.c:3215
We use &#39;patterns&#39; of the form (x,y,t) to specify desired download/publish activities of a peer...
static struct GNUNET_STATISTICS_Handle * stats_handle
Handle to the statistics service.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
struct GNUNET_SCHEDULER_Task * task
Task to run the operation.
void GNUNET_FS_download_stop(struct GNUNET_FS_DownloadContext *dc, int do_delete)
Stop a download (aborts if download is incomplete).
Definition: fs_download.c:2332
static struct GNUNET_FS_Handle * fs_handle
Peer&#39;s FS handle.
static struct Pattern * publish_head
Head of the DLL of publish patterns.
void * sctx
Secondary execution context for the pattern (FS-handle to the operation).
#define GNUNET_YES
Definition: gnunet_common.h:77
static struct Pattern * publish_tail
Tail of the DLL of publish patterns.
void GNUNET_FS_search_stop(struct GNUNET_FS_SearchContext *sc)
Stop search for content.
Definition: fs_search.c:1770
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
static struct Pattern * download_tail
Tail of the DLL of publish patterns.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ publish_stop_task()

static void publish_stop_task ( void *  cls)
static

Task run when a publish operation should be stopped.

Parameters
clsthe 'struct Pattern' of the publish operation to stop

Definition at line 316 of file gnunet-daemon-fsprofiler.c.

References Pattern::ctx, GNUNET_FS_publish_stop(), p, and Pattern::task.

Referenced by progress_cb().

317 {
318  struct Pattern *p = cls;
319 
320  p->task = NULL;
322 }
void GNUNET_FS_publish_stop(struct GNUNET_FS_PublishContext *pc)
Stop an upload.
Definition: fs_publish.c:1555
void * ctx
Execution context for the pattern (FS-handle to the operation).
We use &#39;patterns&#39; of the form (x,y,t) to specify desired download/publish activities of a peer...
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
struct GNUNET_SCHEDULER_Task * task
Task to run the operation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ download_stop_task()

static void download_stop_task ( void *  cls)
static

Task run when a download operation should be stopped.

Parameters
clsthe 'struct Pattern' of the download operation to stop

Definition at line 331 of file gnunet-daemon-fsprofiler.c.

References Pattern::ctx, GNUNET_FS_download_stop(), GNUNET_YES, p, and Pattern::task.

Referenced by progress_cb().

332 {
333  struct Pattern *p = cls;
334 
335  p->task = NULL;
337 }
void * ctx
Execution context for the pattern (FS-handle to the operation).
We use &#39;patterns&#39; of the form (x,y,t) to specify desired download/publish activities of a peer...
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
struct GNUNET_SCHEDULER_Task * task
Task to run the operation.
void GNUNET_FS_download_stop(struct GNUNET_FS_DownloadContext *dc, int do_delete)
Stop a download (aborts if download is incomplete).
Definition: fs_download.c:2332
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the call graph for this function:
Here is the caller graph for this function:

◆ search_stop_task()

static void search_stop_task ( void *  cls)
static

Task run when a download operation should be stopped.

Parameters
clsthe 'struct Pattern' of the download operation to stop

Definition at line 346 of file gnunet-daemon-fsprofiler.c.

References GNUNET_FS_search_stop(), p, Pattern::sctx, and Pattern::stask.

Referenced by progress_cb().

347 {
348  struct Pattern *p = cls;
349 
350  p->stask = NULL;
352 }
struct GNUNET_SCHEDULER_Task * stask
Secondary task to run the operation.
We use &#39;patterns&#39; of the form (x,y,t) to specify desired download/publish activities of a peer...
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
void * sctx
Secondary execution context for the pattern (FS-handle to the operation).
void GNUNET_FS_search_stop(struct GNUNET_FS_SearchContext *sc)
Stop search for content.
Definition: fs_search.c:1770
Here is the call graph for this function:
Here is the caller graph for this function:

◆ progress_cb()

static void* progress_cb ( void *  cls,
const struct GNUNET_FS_ProgressInfo info 
)
static

Notification of FS to a client about the progress of an operation.

Callbacks of this type will be used for uploads, downloads and searches. Some of the arguments depend a bit in their meaning on the context in which the callback is used.

Parameters
clsclosure
infodetails about the event, specifying the event type and various bits about the event
Returns
client-context (for the next progress call for this operation; should be set to NULL for SUSPEND and STOPPED events). The value returned will be passed to future callbacks in the respective field in the GNUNET_FS_ProgressInfo struct.

Definition at line 371 of file gnunet-daemon-fsprofiler.c.

References anonymity_level, Pattern::ctx, GNUNET_FS_ProgressInfo::download, download_stop_task(), GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_FS_DOWNLOAD_NO_TEMPORARIES, GNUNET_FS_download_start(), GNUNET_FS_STATUS_DOWNLOAD_ACTIVE, GNUNET_FS_STATUS_DOWNLOAD_COMPLETED, GNUNET_FS_STATUS_DOWNLOAD_ERROR, GNUNET_FS_STATUS_DOWNLOAD_INACTIVE, GNUNET_FS_STATUS_DOWNLOAD_PROGRESS, GNUNET_FS_STATUS_DOWNLOAD_START, GNUNET_FS_STATUS_DOWNLOAD_STOPPED, GNUNET_FS_STATUS_PUBLISH_COMPLETED, GNUNET_FS_STATUS_PUBLISH_ERROR, GNUNET_FS_STATUS_PUBLISH_PROGRESS, GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY, GNUNET_FS_STATUS_PUBLISH_START, GNUNET_FS_STATUS_PUBLISH_STOPPED, GNUNET_FS_STATUS_SEARCH_ERROR, GNUNET_FS_STATUS_SEARCH_RESULT, GNUNET_FS_STATUS_SEARCH_RESULT_NAMESPACE, GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED, GNUNET_FS_STATUS_SEARCH_START, GNUNET_FS_STATUS_SEARCH_STOPPED, GNUNET_FS_STATUS_SEARCH_UPDATE, GNUNET_FS_uri_chk_get_file_size(), GNUNET_FS_uri_test_chk(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, p, GNUNET_FS_ProgressInfo::publish, publish_stop_task(), GNUNET_TIME_Relative::rel_value_us, Pattern::sctx, GNUNET_FS_ProgressInfo::search, search_stop_task(), Pattern::start_time, Pattern::stask, GNUNET_FS_ProgressInfo::status, Pattern::task, uri, GNUNET_FS_ProgressInfo::value, and Pattern::y.

Referenced by run().

373 {
374  struct Pattern *p;
375  const struct GNUNET_FS_Uri *uri;
376 
377  switch (info->status)
378  {
381  p = info->value.publish.cctx;
382  return p;
383 
385  p = info->value.publish.cctx;
386  return p;
387 
390  "Publishing failed\n");
392  "# failed publish operations", 1, GNUNET_NO);
393  p = info->value.publish.cctx;
395  return p;
396 
398  p = info->value.publish.cctx;
400  "# publishing time (ms)",
402  GNUNET_NO);
404  return p;
405 
407  p = info->value.publish.cctx;
408  p->ctx = NULL;
410  GNUNET_free(p);
411  return NULL;
412 
417  p = info->value.download.cctx;
418  return p;
419 
422  "Download failed\n");
424  "# failed downloads", 1, GNUNET_NO);
425  p = info->value.download.cctx;
427  return p;
428 
430  p = info->value.download.cctx;
432  "# download time (ms)",
434  GNUNET_NO);
436  return p;
437 
439  p = info->value.download.cctx;
440  p->ctx = NULL;
441  if (NULL == p->sctx)
442  {
444  GNUNET_free(p);
445  }
446  return NULL;
447 
450  p = info->value.search.cctx;
451  return p;
452 
454  p = info->value.search.cctx;
455  uri = info->value.search.specifics.result.uri;
457  return NULL; /* not what we want */
458  if (p->y != GNUNET_FS_uri_chk_get_file_size(uri))
459  return NULL; /* not what we want */
461  "# search time (ms)",
463  GNUNET_NO);
466  NULL, NULL, NULL,
470  p,
471  NULL);
473  return NULL;
474 
477  return NULL; /* don't care */
478 
481  "Search failed\n");
483  "# failed searches", 1, GNUNET_NO);
484  p = info->value.search.cctx;
486  return p;
487 
489  p = info->value.search.cctx;
490  p->sctx = NULL;
491  if (NULL == p->ctx)
492  {
494  GNUNET_free(p);
495  }
496  return NULL;
497 
498  default:
499  /* unexpected event during profiling */
500  GNUNET_break(0);
501  return NULL;
502  }
503 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Notification that we have started this download.
struct GNUNET_SCHEDULER_Task * stask
Secondary task to run the operation.
struct GNUNET_FS_ProgressInfo::@28::@31 search
Values for all "GNUNET_FS_STATUS_SEARCH_*" events.
uint64_t rel_value_us
The actual value.
This search has yielded a result.
Last message from a search; this signals that there will be no further events associated with this se...
Notification that we are making progress sharing a file structure.
void * ctx
Execution context for the pattern (FS-handle to the operation).
Event generated for each search result when the respective search is stopped.
unsigned long long y
Y-value.
static struct Pattern * download_head
Head of the DLL of publish patterns.
struct GNUNET_FS_ProgressInfo::@28::@30 download
Values for all "GNUNET_FS_STATUS_DOWNLOAD_*" events.
First event generated when a client requests a search to begin or when a namespace result automatical...
#define GNUNET_NO
Definition: gnunet_common.h:78
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
We have discovered a new namespace.
We use &#39;patterns&#39; of the form (x,y,t) to specify desired download/publish activities of a peer...
struct GNUNET_FS_DownloadContext * GNUNET_FS_download_start(struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, const struct GNUNET_CONTAINER_MetaData *meta, const char *filename, const char *tempname, uint64_t offset, uint64_t length, uint32_t anonymity, enum GNUNET_FS_DownloadOptions options, void *cctx, struct GNUNET_FS_DownloadContext *parent)
Download parts of a file.
Definition: fs_download.c:2145
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Notification that we have stopped the process of uploading a file structure; no futher events will be...
Do not append temporary data to the target file (for the IBlocks).
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
Notification that we have started to publish a file structure.
static unsigned long long anonymity_level
Desired anonymity level.
static void publish_stop_task(void *cls)
Task run when a publish operation should be stopped.
Notification that this download completed.
static struct GNUNET_STATISTICS_Handle * stats_handle
Handle to the statistics service.
union GNUNET_FS_ProgressInfo::@28 value
Values that depend on the event type.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
Notification that we are making progress sharing a directory.
struct GNUNET_SCHEDULER_Task * task
Task to run the operation.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1264
enum GNUNET_FS_Status status
Specific status code (determines the event type).
struct GNUNET_FS_ProgressInfo::@28::@29 publish
Values for all "GNUNET_FS_STATUS_PUBLISH_*" events.
struct GNUNET_TIME_Absolute start_time
When did the operation start?
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
int GNUNET_FS_uri_test_chk(const struct GNUNET_FS_Uri *uri)
Is this a file (or directory) URI?
Definition: fs_uri.c:1354
Notification that this download is no longer actively being pursued (back in the queue).
Notification about progress with this download.
Notification that this download is now actively being pursued (as opposed to waiting in the queue)...
Notification that we completed sharing a file structure.
static struct GNUNET_FS_Handle * fs_handle
Peer&#39;s FS handle.
static struct Pattern * publish_head
Head of the DLL of publish patterns.
static void download_stop_task(void *cls)
Task run when a download operation should be stopped.
Notification that an error was encountered sharing a file structure.
static void search_stop_task(void *cls)
Task run when a download operation should be stopped.
uint64_t GNUNET_FS_uri_chk_get_file_size(const struct GNUNET_FS_Uri *uri)
What is the size of the file that this URI refers to?
Definition: fs_uri.c:1368
void * sctx
Secondary execution context for the pattern (FS-handle to the operation).
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:162
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
#define GNUNET_log(kind,...)
Signals a problem with this search.
We have additional data about the quality or availability of a search result.
#define GNUNET_YES
Definition: gnunet_common.h:77
static struct Pattern * publish_tail
Tail of the DLL of publish patterns.
Notification that this download was stopped (final event with respect to this action).
Notification that this download encountered an error.
#define GNUNET_free(ptr)
Wrapper around free.
static struct Pattern * download_tail
Tail of the DLL of publish patterns.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_publish()

static void start_publish ( void *  cls)
static

Start publish operation.

Parameters
clsthe 'struct Pattern' specifying the operation to perform

Definition at line 512 of file gnunet-daemon-fsprofiler.c.

References Pattern::ctx, GNUNET_FS_PUBLISH_OPTION_NONE, GNUNET_FS_publish_start(), GNUNET_TIME_absolute_get(), make_file(), p, Pattern::start_time, Pattern::task, Pattern::x, and Pattern::y.

Referenced by run().

513 {
514  struct Pattern *p = cls;
515  struct GNUNET_FS_FileInformation *fi;
516 
517  p->task = NULL;
518  fi = make_file(p->x, p->y, p);
521  fi,
522  NULL, NULL, NULL,
524 }
static struct GNUNET_FS_FileInformation * make_file(uint64_t length, uint64_t kval, void *ctx)
Create a file of the given length with a deterministic amount of data to be published under keyword &#39;...
void * ctx
Execution context for the pattern (FS-handle to the operation).
struct GNUNET_FS_PublishContext * GNUNET_FS_publish_start(struct GNUNET_FS_Handle *h, struct GNUNET_FS_FileInformation *fi, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, const char *nid, const char *nuid, enum GNUNET_FS_PublishOptions options)
Publish a file or directory.
Definition: fs_publish.c:1428
unsigned long long y
Y-value.
Information for a file or directory that is about to be published.
Definition: fs_api.h:219
We use &#39;patterns&#39; of the form (x,y,t) to specify desired download/publish activities of a peer...
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
struct GNUNET_SCHEDULER_Task * task
Task to run the operation.
unsigned long long x
X-value.
struct GNUNET_TIME_Absolute start_time
When did the operation start?
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
static struct GNUNET_FS_Handle * fs_handle
Peer&#39;s FS handle.
No options (use defaults for everything).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_download()

static void start_download ( void *  cls)
static

Start download operation.

Parameters
clsthe 'struct Pattern' specifying the operation to perform

Definition at line 533 of file gnunet-daemon-fsprofiler.c.

References anonymity_level, GNUNET_FS_SEARCH_OPTION_NONE, GNUNET_FS_search_start(), GNUNET_TIME_absolute_get(), GNUNET_FS_Uri::keywords, make_keywords(), p, Pattern::sctx, Pattern::start_time, Pattern::task, and Pattern::x.

Referenced by run().

534 {
535  struct Pattern *p = cls;
536  struct GNUNET_FS_Uri *keywords;
537 
538  p->task = NULL;
539  keywords = make_keywords(p->x);
541  p->sctx = GNUNET_FS_search_start(fs_handle, keywords,
544  p);
545 }
No options (use defaults for everything).
static struct GNUNET_FS_Uri * make_keywords(uint64_t kval)
Create a KSK URI from a number.
We use &#39;patterns&#39; of the form (x,y,t) to specify desired download/publish activities of a peer...
static unsigned long long anonymity_level
Desired anonymity level.
char ** keywords
Keywords start with a &#39;+&#39; if they are mandatory (in which case the &#39;+&#39; is NOT part of the keyword) an...
Definition: fs_api.h:179
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
struct GNUNET_SCHEDULER_Task * task
Task to run the operation.
struct GNUNET_FS_SearchContext * GNUNET_FS_search_start(struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, uint32_t anonymity, enum GNUNET_FS_SearchOptions options, void *cctx)
Start search for content.
Definition: fs_search.c:1611
unsigned long long x
X-value.
struct GNUNET_TIME_Absolute start_time
When did the operation start?
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
static struct GNUNET_FS_Handle * fs_handle
Peer&#39;s FS handle.
void * sctx
Secondary execution context for the pattern (FS-handle to the operation).
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:162
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle cfg_ 
)
static

Main function that will be run by the scheduler.

Parameters
clsclosure
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
cfg_configuration

Definition at line 557 of file gnunet-daemon-fsprofiler.c.

References anonymity_level, Pattern::delay, download_pattern, global_ret, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_ERROR_TYPE_ERROR, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM, GNUNET_FS_OPTIONS_END, GNUNET_FS_OPTIONS_REQUEST_PARALLELISM, GNUNET_FS_start(), GNUNET_log, GNUNET_log_config_missing(), GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_snprintf(), GNUNET_STATISTICS_create(), GNUNET_strdup, GNUNET_SYSERR, my_peerid, Pattern::next, p, parse_pattern(), progress_cb(), publish_pattern, replication_level, shutdown_task(), start_download(), start_publish(), and Pattern::task.

Referenced by main().

560 {
561  char myoptname[128];
562  struct Pattern *p;
563 
564  cfg = cfg_;
565  /* Scheduled the task to clean up when shutdown is called */
567  NULL);
568 
569  if (GNUNET_OK !=
571  "TESTBED", "PEERID",
572  &my_peerid))
573  {
575  "TESTBED", "PEERID");
578  return;
579  }
580  if (GNUNET_OK !=
582  "FSPROFILER", "ANONYMITY_LEVEL",
583  &anonymity_level))
584  anonymity_level = 1;
585  if (GNUNET_OK !=
587  "FSPROFILER", "REPLICATION_LEVEL",
589  replication_level = 1;
590  GNUNET_snprintf(myoptname, sizeof(myoptname),
591  "DOWNLOAD-PATTERN-%u", my_peerid);
592  if (GNUNET_OK !=
594  "FSPROFILER", myoptname,
597  GNUNET_snprintf(myoptname, sizeof(myoptname),
598  "PUBLISH-PATTERN-%u", my_peerid);
599  if (GNUNET_OK !=
601  "FSPROFILER", myoptname,
602  &publish_pattern))
604  if ((GNUNET_OK !=
606  &download_tail,
607  download_pattern)) ||
608  (GNUNET_OK !=
610  &publish_tail,
611  publish_pattern)))
612  {
614  return;
615  }
616 
617  stats_handle = GNUNET_STATISTICS_create("fsprofiler", cfg);
618  fs_handle =
620  "fsprofiler",
621  &progress_cb, NULL,
626  if (NULL == fs_handle)
627  {
628  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Could not acquire FS handle. Exiting.\n");
631  return;
632  }
633  for (p = publish_head; NULL != p; p = p->next)
635  &start_publish, p);
636  for (p = download_head; NULL != p; p = p->next)
638  &start_download, p);
639 }
static void * progress_cb(void *cls, const struct GNUNET_FS_ProgressInfo *info)
Notification of FS to a client about the progress of an operation.
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...)
Like snprintf, just aborts if the buffer is of insufficient size.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1284
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
static char * download_pattern
String describing which download operations this peer should perform.
struct GNUNET_TIME_Relative delay
With how much delay should this operation be started?
static struct Pattern * download_head
Head of the DLL of publish patterns.
Last option in the VARARG list.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static int global_ret
Return value from &#39;main&#39;.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:517
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we use.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
We use &#39;patterns&#39; of the form (x,y,t) to specify desired download/publish activities of a peer...
struct GNUNET_FS_Handle * GNUNET_FS_start(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *client_name, GNUNET_FS_ProgressCallback upcb, void *upcb_cls, enum GNUNET_FS_Flags flags,...)
Setup a connection to the file-sharing service.
Definition: fs_api.c:3140
No special flags set.
static unsigned long long anonymity_level
Desired anonymity level.
struct Pattern * next
Kept in a DLL.
static unsigned long long replication_level
Desired replication level.
static struct GNUNET_STATISTICS_Handle * stats_handle
Handle to the statistics service.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1237
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
struct GNUNET_SCHEDULER_Task * task
Task to run the operation.
static unsigned long long my_peerid
Unique number for this peer in the testbed.
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Select the desired amount of parallelism (this option should be followed by an "unsigned int" giving ...
static struct GNUNET_FS_Handle * fs_handle
Peer&#39;s FS handle.
Maximum number of requests that should be pending at a given point in time (invidivual downloads may ...
static struct Pattern * publish_head
Head of the DLL of publish patterns.
static int parse_pattern(struct Pattern **head, struct Pattern **tail, const char *pattern)
Parse a pattern string and store the corresponding &#39;struct Pattern&#39; in the given head/tail.
static void start_download(void *cls)
Start download operation.
#define GNUNET_log(kind,...)
static struct Pattern * publish_tail
Tail of the DLL of publish patterns.
static char * publish_pattern
String describing which publishing operations this peer should perform.
static void start_publish(void *cls)
Start publish operation.
static void shutdown_task(void *cls)
Task run during shutdown.
static struct Pattern * download_tail
Tail of the DLL of publish patterns.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *const *  argv 
)

Program that performs various "random" FS activities.

Parameters
argcnumber of arguments from the command line
argvcommand line arguments
Returns
0 ok, 1 on error

Definition at line 650 of file gnunet-daemon-fsprofiler.c.

References gettext_noop, global_ret, GNUNET_GETOPT_OPTION_END, GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_STRINGS_get_utf8_args(), and run().

651 {
652  static const struct GNUNET_GETOPT_CommandLineOption options[] = {
654  };
655 
656  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv))
657  return 2;
658  return (GNUNET_OK ==
659  GNUNET_PROGRAM_run(argc, argv, "gnunet-daemon-fsprofiler",
661  ("Daemon to use file-sharing to measure its performance."),
662  options, &run, NULL)) ? global_ret : 1;
663 }
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1439
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
Definition of a command line option.
static int global_ret
Return value from &#39;main&#39;.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg_)
Main function that will be run by the scheduler.
int GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:367
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

Variable Documentation

◆ global_ret

int global_ret
static

Return value from 'main'.

Definition at line 93 of file gnunet-daemon-fsprofiler.c.

Referenced by main(), and run().

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg
static

Configuration we use.

Definition at line 98 of file gnunet-daemon-fsprofiler.c.

◆ stats_handle

struct GNUNET_STATISTICS_Handle* stats_handle
static

Handle to the statistics service.

Definition at line 103 of file gnunet-daemon-fsprofiler.c.

◆ fs_handle

struct GNUNET_FS_Handle* fs_handle
static

Peer's FS handle.

Definition at line 108 of file gnunet-daemon-fsprofiler.c.

◆ my_peerid

unsigned long long my_peerid
static

Unique number for this peer in the testbed.

Definition at line 113 of file gnunet-daemon-fsprofiler.c.

Referenced by run().

◆ anonymity_level

unsigned long long anonymity_level
static

Desired anonymity level.

Definition at line 118 of file gnunet-daemon-fsprofiler.c.

Referenced by make_file(), progress_cb(), run(), and start_download().

◆ replication_level

unsigned long long replication_level
static

Desired replication level.

Definition at line 123 of file gnunet-daemon-fsprofiler.c.

Referenced by make_file(), and run().

◆ publish_pattern

char* publish_pattern
static

String describing which publishing operations this peer should perform.

The format is "(SIZE,SEED,TIME)*", for example: "(1,5,0)(7,3,13)" means to publish a file with 1 byte and seed/keyword 5 immediately and another file with 7 bytes and seed/keyword 3 after 13 ms.

Definition at line 132 of file gnunet-daemon-fsprofiler.c.

Referenced by run().

◆ publish_head

struct Pattern* publish_head
static

Head of the DLL of publish patterns.

Definition at line 137 of file gnunet-daemon-fsprofiler.c.

◆ publish_tail

struct Pattern* publish_tail
static

Tail of the DLL of publish patterns.

Definition at line 142 of file gnunet-daemon-fsprofiler.c.

◆ download_pattern

char* download_pattern
static

String describing which download operations this peer should perform.

The format is "(KEYWORD,SIZE,DELAY)*"; for example, "(1,7,3)(3,8,8)" means to download one file of 7 bytes under keyword "1" starting the search after 3 ms; and another one of 8 bytes under keyword '3' starting after 8 ms. The file size is used to determine which search result(s) should be used or ignored.

Definition at line 152 of file gnunet-daemon-fsprofiler.c.

Referenced by run().

◆ download_head

struct Pattern* download_head
static

Head of the DLL of publish patterns.

Definition at line 157 of file gnunet-daemon-fsprofiler.c.

◆ download_tail

struct Pattern* download_tail
static

Tail of the DLL of publish patterns.

Definition at line 162 of file gnunet-daemon-fsprofiler.c.