topology-generation functions More...
#include "platform.h"
#include "gnunet_testbed_service.h"
#include "testbed_api.h"
#include "testbed_api_peers.h"
#include "testbed_api_operations.h"
#include "testbed_api_topology.h"
Go to the source code of this file.
Data Structures | |
struct | OverlayLink |
Representation of an overlay link. More... | |
struct | UnderlayLink |
Representation of an underlay link. More... | |
struct | RetryListEntry |
struct | TopologyContextOverlay |
Context information for overlay topologies. More... | |
struct | TopologyContextUnderlay |
Topology context information for underlay topologies. More... | |
struct | TopologyContext |
Context information for topology operations. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "testbed-api-topology", __VA_ARGS__) |
Generic loggins shorthand. More... | |
#define | DEFAULT_RETRY_CNT 3 |
Default number of retires. More... | |
Functions | |
static void | overlay_link_completed (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg) |
Callback to be called when an overlay_link operation complete. More... | |
static void | opstart_overlay_configure_topology (void *cls) |
Function called when a overlay connect operation is ready. More... | |
static void | oprelease_overlay_configure_topology (void *cls) |
Callback which will be called when overlay connect operation is released. More... | |
static void | make_link (unsigned int offset, uint32_t A, uint32_t B, struct TopologyContext *tc) |
Populates the OverlayLink structure. More... | |
static void | gen_topo_line (struct TopologyContext *tc) |
Generates line topology. More... | |
static void | gen_topo_star (struct TopologyContext *tc) |
Generates star topology. More... | |
static void | gen_topo_ring (struct TopologyContext *tc) |
Generates ring topology. More... | |
unsigned int | GNUNET_TESTBED_2dtorus_calc_links (unsigned int num_peers, unsigned int *rows, unsigned int **rows_len) |
Returns the number of links that are required to generate a 2d torus for the given number of peers. More... | |
static void | gen_topo_2dtorus (struct TopologyContext *tc) |
Generates ring topology. More... | |
static void | gen_topo_random (struct TopologyContext *tc, unsigned int links, int append) |
Generates ring topology. More... | |
static void | gen_topo_scale_free (struct TopologyContext *tc, uint16_t cap, uint8_t m) |
Generates scale free network. More... | |
static void | gen_topo_from_file (struct TopologyContext *tc, const char *filename) |
Generates topology from the given file. More... | |
static void | gen_topo_clique (struct TopologyContext *tc) |
Generates clique topology. More... | |
struct GNUNET_TESTBED_Operation * | GNUNET_TESTBED_underlay_configure_topology_va (void *op_cls, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, enum GNUNET_TESTBED_TopologyOption topo, va_list ap) |
Configure overall network topology to have a particular shape. More... | |
struct GNUNET_TESTBED_Operation * | GNUNET_TESTBED_underlay_configure_topology (void *op_cls, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, enum GNUNET_TESTBED_TopologyOption topo,...) |
Configure overall network topology to have a particular shape. More... | |
struct GNUNET_TESTBED_Operation * | GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, unsigned int *max_connections, GNUNET_TESTBED_TopologyCompletionCallback comp_cb, void *comp_cb_cls, enum GNUNET_TESTBED_TopologyOption topo, va_list va) |
All peers must have been started before calling this function. More... | |
struct GNUNET_TESTBED_Operation * | GNUNET_TESTBED_overlay_configure_topology (void *op_cls, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, unsigned int *max_connections, GNUNET_TESTBED_TopologyCompletionCallback comp_cb, void *comp_cb_cls, enum GNUNET_TESTBED_TopologyOption topo,...) |
All peers must have been started before calling this function. More... | |
int | GNUNET_TESTBED_topology_get_ (enum GNUNET_TESTBED_TopologyOption *topology, const char *topology_string) |
Get a topology from a string input. More... | |
char * | GNUNET_TESTBED_topology_to_str_ (enum GNUNET_TESTBED_TopologyOption topology) |
Returns the string corresponding to the given topology. More... | |
int | GNUNET_TESTBED_underlay_construct_ (int num_peers, underlay_link_processor proc, void *cls,...) |
Function to construct an underlay topology. More... | |
Variables | |
static const char * | topology_strings [] |
A array of names representing topologies. More... | |
topology-generation functions
Definition in file testbed_api_topology.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "testbed-api-topology", __VA_ARGS__) |
Generic loggins shorthand.
Definition at line 36 of file testbed_api_topology.c.
#define DEFAULT_RETRY_CNT 3 |
Default number of retires.
Definition at line 43 of file testbed_api_topology.c.
|
static |
Callback to be called when an overlay_link operation complete.
cls | element of the link_op array which points to the corresponding operation |
op | the operation that has been finished |
emsg | error message in case the operation has failed; will be NULL if operation has executed successfully. |
Definition at line 344 of file testbed_api_topology.c.
References OverlayLink::A, OverlayLink::B, TopologyContextOverlay::comp_cb, TopologyContextOverlay::comp_cb_cls, GNUNET_assert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_new, GNUNET_TESTBED_operation_done(), GNUNET_TESTBED_overlay_connect(), RetryListEntry::link, LOG, TopologyContextOverlay::ncompleted, TopologyContextOverlay::nfailures, TopologyContextOverlay::nlinks, TopologyContextOverlay::nsuccess, op, OverlayLink::op, TopologyContextOverlay::op_cls, TopologyContextOverlay::peers, TopologyContextOverlay::retry_cnt, retry_entry(), TopologyContextOverlay::rl_head, TopologyContextOverlay::rl_tail, OverlayLink::tc, and tc.
Referenced by opstart_overlay_configure_topology().
|
static |
Function called when a overlay connect operation is ready.
cls | the Topology context |
Definition at line 416 of file testbed_api_topology.c.
References OverlayLink::A, OverlayLink::B, GNUNET_assert, GNUNET_TESTBED_overlay_connect(), TopologyContextOverlay::link_array, TopologyContextOverlay::nlinks, OverlayLink::op, TopologyContextOverlay::op_cls, overlay_link_completed(), p, TopologyContextOverlay::peers, and tc.
Referenced by GNUNET_TESTBED_overlay_configure_topology_va().
|
static |
Callback which will be called when overlay connect operation is released.
cls | the Topology context |
Definition at line 443 of file testbed_api_topology.c.
References GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_TESTBED_operation_done(), TopologyContextOverlay::link_array, OverlayLink::op, p, retry_entry(), TopologyContextOverlay::rl_head, TopologyContextOverlay::rl_tail, and tc.
Referenced by GNUNET_TESTBED_overlay_configure_topology_va().
|
static |
Populates the OverlayLink structure.
offset | the offset of the link array to use |
A | the peer A. Should be different from B |
B | the peer B. Should be different from A |
tc | the TopologyContext |
Definition at line 479 of file testbed_api_topology.c.
References OverlayLink::A, UnderlayLink::A, OverlayLink::B, UnderlayLink::B, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, TopologyContextOverlay::link_array, TopologyContextUnderlay::link_array, LOG, OverlayLink::op, OverlayLink::tc, and tc.
Referenced by gen_topo_2dtorus(), gen_topo_clique(), gen_topo_from_file(), gen_topo_line(), gen_topo_random(), gen_topo_ring(), gen_topo_scale_free(), and gen_topo_star().
|
static |
Generates line topology.
tc | the topology context |
Definition at line 525 of file testbed_api_topology.c.
References GNUNET_new_array, TopologyContextOverlay::link_array, TopologyContextUnderlay::link_array, make_link(), and tc.
Referenced by gen_topo_ring(), GNUNET_TESTBED_overlay_configure_topology_va(), and GNUNET_TESTBED_underlay_construct_().
|
static |
Generates star topology.
tc | the topology context |
Definition at line 565 of file testbed_api_topology.c.
References GNUNET_new_array, TopologyContextOverlay::link_array, TopologyContextUnderlay::link_array, make_link(), and tc.
Referenced by GNUNET_TESTBED_overlay_configure_topology_va(), and GNUNET_TESTBED_underlay_construct_().
|
static |
Generates ring topology.
tc | the topology context |
Definition at line 608 of file testbed_api_topology.c.
References gen_topo_line(), GNUNET_realloc, TopologyContextOverlay::link_array, TopologyContextUnderlay::link_array, make_link(), and tc.
Referenced by GNUNET_TESTBED_overlay_configure_topology_va(), and GNUNET_TESTBED_underlay_construct_().
unsigned int GNUNET_TESTBED_2dtorus_calc_links | ( | unsigned int | num_peers, |
unsigned int * | rows, | ||
unsigned int ** | rows_len | ||
) |
Returns the number of links that are required to generate a 2d torus for the given number of peers.
Also returns the arrangement (number of rows and the length of each row)
num_peers | number of peers |
rows | number of rows in the 2d torus. Can be NULL. |
rows_len | the length of each row. This array will be allocated fresh. The caller should free it. Can be NULL. |
Definition at line 641 of file testbed_api_topology.c.
References GNUNET_free, GNUNET_malloc, consensus-simulation::int, and num_peers.
Referenced by gen_topo_2dtorus().
|
static |
Generates ring topology.
tc | the topology context |
Definition at line 692 of file testbed_api_topology.c.
References GNUNET_assert, GNUNET_free, GNUNET_malloc, GNUNET_TESTBED_2dtorus_calc_links(), TopologyContextOverlay::link_array, TopologyContextUnderlay::link_array, make_link(), and tc.
Referenced by GNUNET_TESTBED_overlay_configure_topology_va(), and GNUNET_TESTBED_underlay_construct_().
|
static |
Generates ring topology.
tc | the topology context |
links | the number of random links to establish |
append | GNUNET_YES to add links to existing link array; GNUNET_NO to create a new link array |
Definition at line 771 of file testbed_api_topology.c.
References GNUNET_assert, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_malloc, GNUNET_realloc, GNUNET_YES, TopologyContextOverlay::link_array, TopologyContextUnderlay::link_array, links, make_link(), and tc.
Referenced by GNUNET_TESTBED_overlay_configure_topology_va(), and GNUNET_TESTBED_underlay_construct_().
|
static |
Generates scale free network.
Its construction is described in:
"Emergence of Scaling in Random Networks." Science 286, 509-512, 1999.
tc | the topology context |
cap | maximum allowed node degree |
m | number of edges to establish for a new node when it is added to the network |
Definition at line 860 of file testbed_api_topology.c.
References GNUNET_assert, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u64(), GNUNET_free, GNUNET_malloc, GNUNET_malloc_large, GNUNET_MAX, GNUNET_MIN, GNUNET_realloc, TopologyContextOverlay::link_array, TopologyContextUnderlay::link_array, links, m, make_link(), peer, and tc.
Referenced by GNUNET_TESTBED_overlay_configure_topology_va(), and GNUNET_TESTBED_underlay_construct_().
|
static |
Generates topology from the given file.
tc | the topology context |
filename | the filename of the file containing topology data |
We read the peer index
We read the other peer indices
Definition at line 993 of file testbed_api_topology.c.
References _, buf, data, end, filename, fs, GNUNET_DISK_file_size(), GNUNET_DISK_file_test(), GNUNET_DISK_fn_read(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_malloc, GNUNET_OK, GNUNET_realloc, GNUNET_SYSERR, GNUNET_YES, consensus-simulation::int, TopologyContextOverlay::link_array, TopologyContextUnderlay::link_array, LOG, make_link(), peer_id, state, status, and tc.
Referenced by GNUNET_TESTBED_overlay_configure_topology_va(), and GNUNET_TESTBED_underlay_construct_().
|
static |
Generates clique topology.
tc | the topology context |
Definition at line 1199 of file testbed_api_topology.c.
References GNUNET_new_array, TopologyContextOverlay::link_array, TopologyContextUnderlay::link_array, make_link(), and tc.
Referenced by GNUNET_TESTBED_overlay_configure_topology_va(), and GNUNET_TESTBED_underlay_construct_().
int GNUNET_TESTBED_topology_get_ | ( | enum GNUNET_TESTBED_TopologyOption * | topology, |
const char * | topology_string | ||
) |
Get a topology from a string input.
topology | where to write the retrieved topology |
topology_string | The string to attempt to get a configuration value from |
Definition at line 1446 of file testbed_api_topology.c.
References GNUNET_assert, GNUNET_NO, GNUNET_TESTBED_TOPOLOGY_OPTION_END, GNUNET_YES, topology, and topology_strings.
Referenced by GNUNET_TESTBED_run(), and run().
char* GNUNET_TESTBED_topology_to_str_ | ( | enum GNUNET_TESTBED_TopologyOption | topology | ) |
Returns the string corresponding to the given topology.
topology | the topology |
Definition at line 1474 of file testbed_api_topology.c.
References GNUNET_strdup, GNUNET_TESTBED_TOPOLOGY_OPTION_END, topology, and topology_strings.
int GNUNET_TESTBED_underlay_construct_ | ( | int | num_peers, |
underlay_link_processor | proc, | ||
void * | cls, | ||
... | |||
) |
Function to construct an underlay topology.
num_peers | the number of peers for which the topology should be generated |
proc | the underlay link processor callback. Will be called for each underlay link generated unless a previous call to this callback returned GNUNET_SYSERR. Cannot be NULL. |
cls | closure for proc |
... | variable arguments denoting the topology and its parameters. They should start with the type of topology to generate followed by their options. |
Definition at line 1499 of file testbed_api_topology.c.
References UnderlayLink::A, UnderlayLink::B, UnderlayLink::bandwidth, filename, gen_topo_2dtorus(), gen_topo_clique(), gen_topo_from_file(), gen_topo_line(), gen_topo_random(), gen_topo_ring(), gen_topo_scale_free(), gen_topo_star(), GNUNET_assert, GNUNET_free, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_TESTBED_TOPOLOGY_2D_TORUS, GNUNET_TESTBED_TOPOLOGY_CLIQUE, GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI, GNUNET_TESTBED_TOPOLOGY_FROM_FILE, GNUNET_TESTBED_TOPOLOGY_LINE, GNUNET_TESTBED_TOPOLOGY_RING, GNUNET_TESTBED_TOPOLOGY_SCALE_FREE, GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD, GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING, GNUNET_TESTBED_TOPOLOGY_STAR, GNUNET_VA_ARG_ENUM, GNUNET_YES, UnderlayLink::latency, TopologyContextUnderlay::link_array, UnderlayLink::loss, m, num_peers, ret, tc, and topology.
Referenced by run().
|
static |
A array of names representing topologies.
Should be in sync with enum GNUNET_TESTBED_TopologyOption
Definition at line 259 of file testbed_api_topology.c.
Referenced by GNUNET_TESTBED_topology_get_(), and GNUNET_TESTBED_topology_to_str_().