GNUnet  0.11.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 176 of file gnunet-daemon-fsprofiler.c.

179 {
180  struct Pattern *p;
181  unsigned long long x;
182  unsigned long long y;
183  unsigned long long t;
184 
185  while (3 == sscanf (pattern,
186  "(%llu,%llu,%llu)",
187  &x, &y, &t))
188  {
189  p = GNUNET_new (struct Pattern);
190  p->x = x;
191  p->y = y;
192  p->delay.rel_value_us = (uint64_t) t;
194  pattern = strstr (pattern, ")");
195  GNUNET_assert (NULL != pattern);
196  pattern++;
197  }
198  return (0 == strlen (pattern)) ? GNUNET_OK : GNUNET_SYSERR;
199 }
static struct PendingResolutions * tail
Tail of list of pending resolution requests.
Definition: gnunet-ats.c:235
static struct PendingResolutions * head
Head of list of pending resolution requests.
Definition: gnunet-ats.c:230
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static struct GNUNET_SCHEDULER_Task * t
Main task.
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
We use 'patterns' of the form (x,y,t) to specify desired download/publish activities of a peer.
unsigned long long y
Y-value.
unsigned long long x
X-value.

References GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_OK, GNUNET_SYSERR, head, p, t, tail, Pattern::x, and Pattern::y.

Referenced by run().

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 209 of file gnunet-daemon-fsprofiler.c.

210 {
211  char kw[128];
212 
213  GNUNET_snprintf (kw, sizeof(kw),
214  "%llu", (unsigned long long) kval);
215  return GNUNET_FS_uri_ksk_create (kw, NULL);
216 }
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:1059
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.

References GNUNET_FS_uri_ksk_create(), and GNUNET_snprintf().

Referenced by make_file(), and start_download().

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 229 of file gnunet-daemon-fsprofiler.c.

232 {
233  struct GNUNET_FS_FileInformation *fi;
234  struct GNUNET_FS_BlockOptions bo;
235  char *data;
236  struct GNUNET_FS_Uri *keywords;
237  unsigned long long i;
238  uint64_t xor;
239 
240  data = NULL; /* to make compilers happy */
241  if ((0 != length) &&
242  (NULL == (data = GNUNET_malloc_large ((size_t) length))))
243  return NULL;
244  /* initialize data with 'unique' data only depending on 'kval' and 'size',
245  making sure that blocks do not repeat */
246  for (i = 0; i < length; i += 8)
247  {
248  xor = length ^ kval ^ (uint64_t) (i / 32 / 1024);
249  GNUNET_memcpy (&data[i], &xor, GNUNET_MIN (length - i, sizeof(uint64_t)));
250  }
252  bo.anonymity_level = (uint32_t) anonymity_level;
253  bo.content_priority = 128;
255  keywords = make_keywords (kval);
257  ctx,
258  length,
259  data, keywords,
260  NULL, GNUNET_NO, &bo);
262  return fi;
263 }
static struct GNUNET_FS_Uri * make_keywords(uint64_t kval)
Create a KSK URI from a number.
static unsigned long long replication_level
Desired replication level.
static unsigned long long anonymity_level
Desired anonymity level.
static struct GNUNET_FS_Handle * fs_handle
Peer's FS handle.
uint32_t data
The data value.
static struct GNUNET_FS_BlockOptions bo
Options we set for published blocks.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_NO
Definition: gnunet_common.h:94
#define GNUNET_MIN(a, b)
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:678
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_malloc_large(size)
Wrapper around malloc.
#define GNUNET_TIME_UNIT_DAYS
One day.
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:181
Settings for publishing a block (which may of course also apply to an entire directory or file).
uint32_t anonymity_level
At which anonymity level should the block be shared? (0: no anonymity, 1: normal GAP,...
uint32_t content_priority
How important is it for us to store the block? If we run out of space, the highest-priority,...
uint32_t replication_level
How often should we try to migrate the block to other peers? Only used if "CONTENT_PUSHING" is set to...
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...
Information for a file or directory that is about to be published.
Definition: fs_api.h:227
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:166
char ** keywords
Keywords start with a '+' if they are mandatory (in which case the '+' is NOT part of the keyword) an...
Definition: fs_api.h:185

References anonymity_level, GNUNET_FS_BlockOptions::anonymity_level, bo, GNUNET_FS_BlockOptions::content_priority, ctx, data, GNUNET_FS_BlockOptions::expiration_time, fs_handle, 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().

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 272 of file gnunet-daemon-fsprofiler.c.

273 {
274  struct Pattern *p;
275 
276  while (NULL != (p = publish_head))
277  {
278  if (NULL != p->task)
279  GNUNET_SCHEDULER_cancel (p->task);
280  if (NULL != p->ctx)
281  GNUNET_FS_publish_stop (p->ctx);
283  GNUNET_free (p);
284  }
285  while (NULL != (p = download_head))
286  {
287  if (NULL != p->task)
288  GNUNET_SCHEDULER_cancel (p->task);
289  if (NULL != p->stask)
290  GNUNET_SCHEDULER_cancel (p->stask);
291  if (NULL != p->ctx)
293  if (NULL != p->sctx)
294  GNUNET_FS_search_stop (p->sctx);
296  GNUNET_free (p);
297  }
298  if (NULL != fs_handle)
299  {
301  fs_handle = NULL;
302  }
303  if (NULL != stats_handle)
304  {
306  stats_handle = NULL;
307  }
308 }
static struct Pattern * download_tail
Tail of the DLL of publish patterns.
static struct Pattern * publish_head
Head of the DLL of publish patterns.
static struct GNUNET_STATISTICS_Handle * stats_handle
Handle to the statistics service.
static struct Pattern * publish_tail
Tail of the DLL of publish patterns.
static struct Pattern * download_head
Head of the DLL of publish patterns.
@ GNUNET_YES
Definition: gnunet_common.h:97
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
void GNUNET_FS_search_stop(struct GNUNET_FS_SearchContext *sc)
Stop search for content.
Definition: fs_search.c:1778
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:2333
void GNUNET_FS_stop(struct GNUNET_FS_Handle *h)
Close our connection with the file-sharing service.
Definition: fs_api.c:3338
void GNUNET_FS_publish_stop(struct GNUNET_FS_PublishContext *pc)
Stop an upload.
Definition: fs_publish.c:1570
#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:972
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).

References download_head, download_tail, fs_handle, 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, publish_head, publish_tail, and stats_handle.

Referenced by run().

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 317 of file gnunet-daemon-fsprofiler.c.

318 {
319  struct Pattern *p = cls;
320 
321  p->task = NULL;
322  GNUNET_FS_publish_stop (p->ctx);
323 }

References GNUNET_FS_publish_stop(), and p.

Referenced by progress_cb().

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 332 of file gnunet-daemon-fsprofiler.c.

333 {
334  struct Pattern *p = cls;
335 
336  p->task = NULL;
338 }

References GNUNET_FS_download_stop(), GNUNET_YES, and p.

Referenced by progress_cb().

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 347 of file gnunet-daemon-fsprofiler.c.

348 {
349  struct Pattern *p = cls;
350 
351  p->stask = NULL;
352  GNUNET_FS_search_stop (p->sctx);
353 }

References GNUNET_FS_search_stop(), and p.

Referenced by progress_cb().

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 372 of file gnunet-daemon-fsprofiler.c.

374 {
375  struct Pattern *p;
376  const struct GNUNET_FS_Uri *uri;
377 
378  switch (info->status)
379  {
382  p = info->value.publish.cctx;
383  return p;
384 
386  p = info->value.publish.cctx;
387  return p;
388 
391  "Publishing failed\n");
393  "# failed publish operations", 1, GNUNET_NO);
394  p = info->value.publish.cctx;
396  return p;
397 
399  p = info->value.publish.cctx;
401  "# publishing time (ms)",
403  p->start_time).rel_value_us / 1000LL,
404  GNUNET_NO);
406  return p;
407 
409  p = info->value.publish.cctx;
410  p->ctx = NULL;
412  GNUNET_free (p);
413  return NULL;
414 
419  p = info->value.download.cctx;
420  return p;
421 
424  "Download failed\n");
426  "# failed downloads", 1, GNUNET_NO);
427  p = info->value.download.cctx;
429  return p;
430 
432  p = info->value.download.cctx;
434  "# download time (ms)",
436  p->start_time).rel_value_us / 1000LL,
437  GNUNET_NO);
439  return p;
440 
442  p = info->value.download.cctx;
443  p->ctx = NULL;
444  if (NULL == p->sctx)
445  {
447  GNUNET_free (p);
448  }
449  return NULL;
450 
453  p = info->value.search.cctx;
454  return p;
455 
457  p = info->value.search.cctx;
458  uri = info->value.search.specifics.result.uri;
460  return NULL; /* not what we want */
462  return NULL; /* not what we want */
464  "# search time (ms)",
466  p->start_time).rel_value_us / 1000LL,
467  GNUNET_NO);
468  p->start_time = GNUNET_TIME_absolute_get ();
470  NULL, NULL, NULL,
474  p,
475  NULL);
477  return NULL;
478 
481  return NULL; /* don't care */
482 
485  "Search failed\n");
487  "# failed searches", 1, GNUNET_NO);
488  p = info->value.search.cctx;
490  return p;
491 
493  p = info->value.search.cctx;
494  p->sctx = NULL;
495  if (NULL == p->ctx)
496  {
498  GNUNET_free (p);
499  }
500  return NULL;
501 
502  default:
503  /* unexpected event during profiling */
504  GNUNET_break (0);
505  return NULL;
506  }
507 }
static void publish_stop_task(void *cls)
Task run when a publish operation should be stopped.
static void search_stop_task(void *cls)
Task run when a download operation should be stopped.
static void download_stop_task(void *cls)
Task run when a download operation should be stopped.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
#define GNUNET_log(kind,...)
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:1370
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
int GNUNET_FS_uri_test_chk(const struct GNUNET_FS_Uri *uri)
Is this a file (or directory) URI?
Definition: fs_uri.c:1356
@ GNUNET_FS_DOWNLOAD_NO_TEMPORARIES
Do not append temporary data to the target file (for the IBlocks).
@ GNUNET_FS_STATUS_SEARCH_UPDATE
We have additional data about the quality or availability of a search result.
@ GNUNET_FS_STATUS_DOWNLOAD_INACTIVE
Notification that this download is no longer actively being pursued (back in the queue).
@ GNUNET_FS_STATUS_SEARCH_RESULT_NAMESPACE
We have discovered a new namespace.
@ GNUNET_FS_STATUS_DOWNLOAD_ERROR
Notification that this download encountered an error.
@ GNUNET_FS_STATUS_SEARCH_ERROR
Signals a problem with this search.
@ GNUNET_FS_STATUS_DOWNLOAD_COMPLETED
Notification that this download completed.
@ GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED
Event generated for each search result when the respective search is stopped.
@ GNUNET_FS_STATUS_PUBLISH_STOPPED
Notification that we have stopped the process of uploading a file structure; no further events will b...
@ GNUNET_FS_STATUS_PUBLISH_ERROR
Notification that an error was encountered sharing a file structure.
@ GNUNET_FS_STATUS_SEARCH_RESULT
This search has yielded a result.
@ GNUNET_FS_STATUS_PUBLISH_PROGRESS
Notification that we are making progress sharing a file structure.
@ GNUNET_FS_STATUS_DOWNLOAD_START
Notification that we have started this download.
@ GNUNET_FS_STATUS_DOWNLOAD_PROGRESS
Notification about progress with this download.
@ GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY
Notification that we are making progress sharing a directory.
@ GNUNET_FS_STATUS_PUBLISH_START
Notification that we have started to publish a file structure.
@ GNUNET_FS_STATUS_PUBLISH_COMPLETED
Notification that we completed sharing a file structure.
@ GNUNET_FS_STATUS_SEARCH_START
First event generated when a client requests a search to begin or when a namespace result automatical...
@ GNUNET_FS_STATUS_DOWNLOAD_ACTIVE
Notification that this download is now actively being pursued (as opposed to waiting in the queue).
@ GNUNET_FS_STATUS_DOWNLOAD_STOPPED
Notification that this download was stopped (final event with respect to this action).
@ GNUNET_FS_STATUS_SEARCH_STOPPED
Last message from a search; this signals that there will be no further events associated with this se...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
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:1296
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
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:263
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:86
struct GNUNET_FS_ProgressInfo::@25::GNUNET_FS_DownloadStatusEvent download
union GNUNET_FS_ProgressInfo::@25 value
Values that depend on the event type.
struct GNUNET_FS_ProgressInfo::@25::GNUNET_FS_SearchStatusEvent search
enum GNUNET_FS_Status status
Specific status code (determines the event type).
struct GNUNET_FS_ProgressInfo::@25::GNUNET_FS_PublishStatusEvent publish
uint64_t rel_value_us
The actual value.

References anonymity_level, GNUNET_FS_ProgressInfo::download, download_head, download_stop_task(), download_tail, fs_handle, 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_head, publish_stop_task(), publish_tail, GNUNET_TIME_Relative::rel_value_us, GNUNET_FS_ProgressInfo::search, search_stop_task(), stats_handle, GNUNET_FS_ProgressInfo::status, uri, and GNUNET_FS_ProgressInfo::value.

Referenced by run().

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 516 of file gnunet-daemon-fsprofiler.c.

517 {
518  struct Pattern *p = cls;
519  struct GNUNET_FS_FileInformation *fi;
520 
521  p->task = NULL;
522  fi = make_file (p->x, p->y, p);
523  p->start_time = GNUNET_TIME_absolute_get ();
525  fi,
526  NULL, NULL, NULL,
528 }
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 '...
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:1442
@ GNUNET_FS_PUBLISH_OPTION_NONE
No options (use defaults for everything).

References fs_handle, GNUNET_FS_PUBLISH_OPTION_NONE, GNUNET_FS_publish_start(), GNUNET_TIME_absolute_get(), make_file(), and p.

Referenced by run().

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 537 of file gnunet-daemon-fsprofiler.c.

538 {
539  struct Pattern *p = cls;
540  struct GNUNET_FS_Uri *keywords;
541 
542  p->task = NULL;
543  keywords = make_keywords (p->x);
544  p->start_time = GNUNET_TIME_absolute_get ();
548  p);
549 }
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:1619
@ GNUNET_FS_SEARCH_OPTION_NONE
No options (use defaults for everything).

References anonymity_level, fs_handle, GNUNET_FS_SEARCH_OPTION_NONE, GNUNET_FS_search_start(), GNUNET_TIME_absolute_get(), GNUNET_FS_Uri::keywords, make_keywords(), and p.

Referenced by run().

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 561 of file gnunet-daemon-fsprofiler.c.

564 {
565  char myoptname[128];
566  struct Pattern *p;
567 
568  cfg = cfg_;
569  /* Scheduled the task to clean up when shutdown is called */
571  NULL);
572 
573  if (GNUNET_OK !=
575  "TESTBED", "PEERID",
576  &my_peerid))
577  {
579  "TESTBED", "PEERID");
582  return;
583  }
584  if (GNUNET_OK !=
586  "FSPROFILER", "ANONYMITY_LEVEL",
587  &anonymity_level))
588  anonymity_level = 1;
589  if (GNUNET_OK !=
591  "FSPROFILER", "REPLICATION_LEVEL",
593  replication_level = 1;
594  GNUNET_snprintf (myoptname, sizeof(myoptname),
595  "DOWNLOAD-PATTERN-%llu", my_peerid);
596  if (GNUNET_OK !=
598  "FSPROFILER", myoptname,
601  GNUNET_snprintf (myoptname, sizeof(myoptname),
602  "PUBLISH-PATTERN-%llu", my_peerid);
603  if (GNUNET_OK !=
605  "FSPROFILER", myoptname,
606  &publish_pattern))
608  if ((GNUNET_OK !=
610  &download_tail,
611  download_pattern)) ||
612  (GNUNET_OK !=
614  &publish_tail,
615  publish_pattern)))
616  {
618  return;
619  }
620 
621  stats_handle = GNUNET_STATISTICS_create ("fsprofiler", cfg);
622  fs_handle =
624  "fsprofiler",
625  &progress_cb, NULL,
630  if (NULL == fs_handle)
631  {
633  "Could not acquire FS handle. Exiting.\n");
636  return;
637  }
638  for (p = publish_head; NULL != p; p = p->next)
639  p->task = GNUNET_SCHEDULER_add_delayed (p->delay,
640  &start_publish, p);
641  for (p = download_head; NULL != p; p = p->next)
642  p->task = GNUNET_SCHEDULER_add_delayed (p->delay,
643  &start_download, p);
644 }
static char * publish_pattern
String describing which publishing operations this peer should perform.
static int global_ret
Return value from 'main'.
static char * download_pattern
String describing which download operations this peer should perform.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we use.
static void shutdown_task(void *cls)
Task run during shutdown.
static void start_download(void *cls)
Start download operation.
static unsigned long long my_peerid
Unique number for this peer in the testbed.
static void * progress_cb(void *cls, const struct GNUNET_FS_ProgressInfo *info)
Notification of FS to a client about the progress of an operation.
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.
static void start_publish(void *cls)
Start publish operation.
enum GNUNET_GenericReturnValue 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.
enum GNUNET_GenericReturnValue 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.
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:3263
@ GNUNET_FS_FLAGS_NONE
No special flags set.
@ GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM
Select the desired amount of parallelism (this option should be followed by an "unsigned int" giving ...
@ GNUNET_FS_OPTIONS_END
Last option in the VARARG list.
@ GNUNET_FS_OPTIONS_REQUEST_PARALLELISM
Maximum number of requests that should be pending at a given point in time (invidivual downloads may ...
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:531
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,...
Definition: scheduler.c:1331
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:1269
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.

References anonymity_level, cfg, download_head, download_pattern, download_tail, fs_handle, 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, p, parse_pattern(), progress_cb(), publish_head, publish_pattern, publish_tail, replication_level, shutdown_task(), start_download(), start_publish(), and stats_handle.

Referenced by main().

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 655 of file gnunet-daemon-fsprofiler.c.

656 {
657  static const struct GNUNET_GETOPT_CommandLineOption options[] = {
659  };
660 
661  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
662  return 2;
663  return (GNUNET_OK ==
664  GNUNET_PROGRAM_run (argc, argv, "gnunet-daemon-fsprofiler",
666  (
667  "Daemon to use file-sharing to measure its performance."),
668  options, &run, NULL)) ? global_ret : 1;
669 }
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define gettext_noop(String)
Definition: gettext.h:69
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.
enum GNUNET_GenericReturnValue 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,...
Definition: program.c:364
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1209
Definition of a command line option.

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

Here is the call graph for this function:

Variable Documentation

◆ global_ret

int global_ret
static

Return value from 'main'.

Definition at line 94 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 99 of file gnunet-daemon-fsprofiler.c.

Referenced by run().

◆ stats_handle

struct GNUNET_STATISTICS_Handle* stats_handle
static

Handle to the statistics service.

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

Referenced by progress_cb(), run(), and shutdown_task().

◆ fs_handle

struct GNUNET_FS_Handle* fs_handle
static

Peer's FS handle.

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

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

◆ my_peerid

unsigned long long my_peerid
static

Unique number for this peer in the testbed.

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

Referenced by run().

◆ anonymity_level

unsigned long long anonymity_level
static

Desired anonymity level.

Definition at line 119 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 124 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 133 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 138 of file gnunet-daemon-fsprofiler.c.

Referenced by progress_cb(), run(), and shutdown_task().

◆ publish_tail

struct Pattern* publish_tail
static

Tail of the DLL of publish patterns.

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

Referenced by progress_cb(), run(), and shutdown_task().

◆ 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 153 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 158 of file gnunet-daemon-fsprofiler.c.

Referenced by progress_cb(), run(), and shutdown_task().

◆ download_tail

struct Pattern* download_tail
static

Tail of the DLL of publish patterns.

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

Referenced by progress_cb(), run(), and shutdown_task().