36 #define LOG(kind, ...) \ 37 GNUNET_log_from (kind, "testbed-api-topology", __VA_ARGS__) 43 #define DEFAULT_RETRY_CNT 3 222 TOPOLOGYCONTEXT_TYPE_UNDERLAY = 0,
227 TOPOLOGYCONTEXT_TYPE_OVERLAY
365 "Error while establishing a link: %s -- Retrying\n",
384 while (NULL != (retry_entry = overlay->
rl_head))
386 link = retry_entry->
link;
452 while (NULL != (retry_entry = overlay->
rl_head))
487 case TOPOLOGYCONTEXT_TYPE_OVERLAY:
503 case TOPOLOGYCONTEXT_TYPE_UNDERLAY:
532 case TOPOLOGYCONTEXT_TYPE_OVERLAY:
543 case TOPOLOGYCONTEXT_TYPE_UNDERLAY:
572 case TOPOLOGYCONTEXT_TYPE_OVERLAY:
583 case TOPOLOGYCONTEXT_TYPE_UNDERLAY:
614 case TOPOLOGYCONTEXT_TYPE_OVERLAY:
625 case TOPOLOGYCONTEXT_TYPE_UNDERLAY:
654 unsigned int **rows_len)
657 unsigned int sq_floor;
659 unsigned int *_rows_len;
662 unsigned int _num_peers;
665 sq = sqrt (num_peers);
667 sq_floor = (
unsigned int) sq;
668 _rows = (sq_floor + 1);
670 for (y = 0; y < _rows - 1; y++)
671 _rows_len[y] = sq_floor;
672 _num_peers = sq_floor * sq_floor;
673 cnt = (_num_peers < 2) ? _num_peers : 2 * _num_peers;
676 while (_num_peers < num_peers)
679 _rows_len[_rows - 1] = ++x;
684 cnt += (x < 2) ? x : 2 * x;
685 cnt += (y < 2) ? y : 2 * y;
686 if (0 == _rows_len[_rows - 1])
690 if (NULL != rows_len)
691 *rows_len = _rows_len;
707 unsigned int *rows_len;
717 case TOPOLOGYCONTEXT_TYPE_OVERLAY:
727 case TOPOLOGYCONTEXT_TYPE_UNDERLAY:
739 for (y = 0; y < rows; y++)
741 for (x = 0; x < rows_len[y] - 1; x++)
743 make_link (cnt, offset + x, offset + x + 1, tc);
750 offset += rows_len[y];
752 for (x = 0; x < rows_len[0]; x++)
755 for (y = 0; y < rows - 1; y++)
757 if (x >= rows_len[y + 1])
760 make_link (cnt, offset + x, offset + rows_len[y] + x, tc);
761 offset += rows_len[y];
806 case TOPOLOGYCONTEXT_TYPE_OVERLAY:
826 case TOPOLOGYCONTEXT_TYPE_UNDERLAY:
846 for (cnt = 0; cnt <
links; cnt++)
855 while (A_rand == B_rand);
856 make_link (index + cnt, A_rand, B_rand, tc);
879 unsigned int etaboff;
883 unsigned int random_peer;
886 unsigned int redo_threshold;
892 case TOPOLOGYCONTEXT_TYPE_OVERLAY:
902 case TOPOLOGYCONTEXT_TYPE_UNDERLAY:
922 for (peer = 2; peer < tc->
num_peers; peer++)
926 for (cnt = 0; cnt <
GNUNET_MIN (peer, m); cnt++)
931 random_peer = etab[off];
932 if (cap < deg[random_peer])
934 if (++redo_threshold >
GNUNET_MAX (1, cap / 2))
938 for (cnt2 = 0; cnt2 < etaboff; cnt2++)
940 if (random_peer == etab[cnt2])
945 etab[cnt2 - off] = etab[cnt2];
951 for (cnt2 = 0; cnt2 < cnt; cnt2++)
952 if (random_peer == used[cnt2])
954 make_link (links + cnt, random_peer, peer, tc);
957 used[cnt] = random_peer;
959 for (cnt = 0; cnt <
GNUNET_MIN (peer, m); cnt++)
961 etab[etaboff++] = used[cnt];
962 etab[etaboff++] =
peer;
973 case TOPOLOGYCONTEXT_TYPE_OVERLAY:
984 case TOPOLOGYCONTEXT_TYPE_UNDERLAY:
1014 unsigned long int other_peer_id;
1033 _ (
"Topology file %s not found\n"),
1041 _ (
"Topology file %s has no data\n"),
1049 _ (
"Topology file %s cannot be read\n"),
1059 if (0 != isspace ((
unsigned char) data[offset]))
1067 buf = strchr (&data[offset],
':');
1071 _ (
"Failed to read peer index from toology file: %s"), filename);
1076 peer_id = (
unsigned int) strtoul (&data[offset], &end, 10);
1080 _ (
"Value in given topology file: %s out of range\n"), filename);
1083 if (&data[offset] == end)
1086 _ (
"Failed to read peer index from topology file: %s"), filename);
1092 _ (
"Topology file needs more peers than given ones\n"));
1095 state = OTHER_PEER_INDEX;
1096 offset += ((
unsigned int) (buf - &data[offset])) + 1;
1099 case OTHER_PEER_INDEX:
1101 other_peer_id = (
unsigned int) strtoul (&data[offset], &end, 10);
1105 _ (
"Value in given topology file: %s out of range\n"), filename);
1108 if (&data[offset] == end)
1111 _ (
"Failed to read peer index from topology file: %s"), filename);
1117 _ (
"Topology file needs more peers than given ones\n"));
1120 if (peer_id != other_peer_id)
1125 case TOPOLOGYCONTEXT_TYPE_OVERLAY:
1136 case TOPOLOGYCONTEXT_TYPE_UNDERLAY:
1148 offset += end - &data[offset];
1153 _ (
"Ignoring to connect peer %lu to peer %lu\n"),
1156 while ((
'\n' != data[offset]) && (
'|' != data[offset]) && (offset < fs))
1158 if ((offset < fs) &&
1159 (
'\n' == data[offset]))
1161 else if ((offset < fs) &&
1162 (
'|' == data[offset]))
1164 state = OTHER_PEER_INDEX;
1177 "Removing link data read from the file\n");
1181 case TOPOLOGYCONTEXT_TYPE_OVERLAY:
1191 case TOPOLOGYCONTEXT_TYPE_UNDERLAY:
1214 unsigned int offset;
1215 unsigned int neighbour;
1220 case TOPOLOGYCONTEXT_TYPE_OVERLAY:
1230 case TOPOLOGYCONTEXT_TYPE_UNDERLAY:
1240 for (cnt = 0; cnt < tc->
num_peers; cnt++)
1242 for (neighbour = 0; neighbour < tc->
num_peers; neighbour++)
1244 if (neighbour == cnt)
1343 tc->
type = TOPOLOGYCONTEXT_TYPE_OVERLAY;
1347 overlay->
op_cls = op_cls;
1393 cap = (uint16_t) va_arg (va,
unsigned int);
1394 m = (uint8_t) va_arg (va,
unsigned int);
1403 filename = va_arg (va,
const char *);
1419 switch (secondary_option)
1422 overlay->
retry_cnt = va_arg (va,
unsigned int);
1444 "Generated %u connections\n",
1446 if (NULL != max_connections)
1488 va_start (vargs, topo);
1491 comp_cb, comp_cb_cls,
1510 const char *topology_string)
1518 if (NULL != topology)
1577 memset (&tc, 0,
sizeof(tc));
1579 tc.
type = TOPOLOGYCONTEXT_TYPE_UNDERLAY;
1581 va_start (vargs, cls);
1622 filename = va_arg (vargs,
char *);
1632 cap = (uint16_t) va_arg (vargs,
unsigned int);
1633 m = (uint8_t) va_arg (vargs,
unsigned int);
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct RetryListEntry * next
the next pointer for the DLL
A clique (everyone connected to everyone else).
static void gen_topo_scale_free(struct TopologyContext *tc, uint16_t cap, uint8_t m)
Generates scale free network.
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.
Representation of an underlay link.
unsigned int nsuccess
Total successfully established overlay connections.
static int retry_entry(void *cls, const struct GNUNET_HashCode *key, void *entry)
Add entries to the message queue.
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.
int GNUNET_TESTBED_underlay_construct_(int num_peers, underlay_link_processor proc, void *cls,...)
Function to construct an underlay topology.
internal API to access the 'operations' subsystem
GNUNET_TESTBED_TopologyOption
Topologies and topology options supported for testbeds.
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...
static void gen_topo_star(struct TopologyContext *tc)
Generates star topology.
static int end
Set if we are to shutdown all services (including ARM).
Handle to interact with a GNUnet testbed controller.
struct TopologyContextOverlay overlay
Topology context information for overlay topology.
#define LOG(kind,...)
Generic loggins shorthand.
uint32_t loss
Loss in the link in percentage of message dropped.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_overlay_connect(void *op_cls, GNUNET_TESTBED_OperationCompletionCallback cb, void *cb_cls, struct GNUNET_TESTBED_Peer *p1, struct GNUNET_TESTBED_Peer *p2)
Both peers must have been started before calling this function.
struct RetryListEntry * rl_tail
DLL tail for retry list.
unsigned int num_peers
The number of peers.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
static unsigned long long max_connections
If there are at least this many connections, old ones will be removed.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
static void gen_topo_clique(struct TopologyContext *tc)
Generates clique topology.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an 'operation' to be performed.
struct UnderlayLink * link_array
The link array.
static int ret
Return value of the commandline.
unsigned int ncompleted
How many links have been completed.
static char * peer_id
Option –peer.
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.
unsigned int link_array_size
The size of the link array.
enum GNUNET_TESTBED_TopologyOption topology
The topology to generate.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Representation of an overlay link.
static void gen_topo_ring(struct TopologyContext *tc)
Generates ring topology.
static void gen_topo_line(struct TopologyContext *tc)
Generates line topology.
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
uint32_t bandwidth
Bandwidth of the link in bytes per second.
#define GNUNET_malloc_large(size)
Wrapper around malloc.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
uint32_t A
position of peer A's handle in peers array
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Opaque handle to an abstract operation to be executed by the testing framework.
void * op_cls
The operation closure.
enum TopologyContext::@59 type
The type of this context.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Read a topology from a given file.
struct TopologyContext * tc
The topology context this link is a part of.
struct GNUNET_TESTBED_Peer ** peers
The array of peers.
enum State state
current state of profiling
static struct GNUNET_OS_Process * p
Helper process we started.
GNUNET_TESTBED_TopologyCompletionCallback comp_cb
topology generation completion callback
#define GNUNET_realloc(ptr, size)
Wrapper around realloc.
How many times should the failed overlay connect operations be retried before giving up...
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.
uint16_t status
See PRISM_STATUS_*-constants.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
unsigned int retry_cnt
How many retries to do before we give up.
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
Topology context information for underlay topologies.
union TopologyContext::@60 u
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
unsigned int nfailures
Total failed overlay connections.
uint32_t A
position of peer A's handle in peers array
unsigned int nlinks
Number of links to try.
static void gen_topo_random(struct TopologyContext *tc, unsigned int links, int append)
Generates ring topology.
struct RetryListEntry * prev
the prev pointer for the DLL
The options should always end with this.
static const char * topology_strings[]
A array of names representing topologies.
void(* GNUNET_TESTBED_TopologyCompletionCallback)(void *cls, unsigned int nsuccess, unsigned int nfailures)
Callbacks of this type are called when topology configuration is completed.
uint32_t latency
Latency of the link in milliseconds.
static void gen_topo_from_file(struct TopologyContext *tc, const char *filename)
Generates topology from the given file.
struct OperationQueue * opq_parallel_topology_config_operations
Operation queue for simultaneous topology configuration operations.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
Small-world network (2d torus plus random links).
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
struct TopologyContextUnderlay underlay
Topology context information for underlay topology.
static unsigned int num_peers
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.
static struct GNUNET_FS_Handle * fs
Handle to FS service.
internal API to access the 'peers' subsystem
static struct GNUNET_CONTAINER_MultiPeerMap * links
Map from PIDs to struct VirtualLink entries describing links CORE knows to exist. ...
struct GNUNET_TESTBED_Operation * op
An operation corresponding to this link.
Interface for functions internally exported from testbed_api.c.
void * comp_cb_cls
The closure for the above callback.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_size(const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
Get the size of the file (or directory) of the given file (in bytes).
struct RetryListEntry * rl_head
DLL head for retry list.
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.
static void gen_topo_2dtorus(struct TopologyContext *tc)
Generates ring topology.
uint32_t B
position of peer B's handle in peers array
#define GNUNET_VA_ARG_ENUM(va, X)
wrap va_arg for enums
static struct CadetPeer * peers
Operation to get peer ids.
int(* underlay_link_processor)(void *cls, unsigned int A, unsigned int B, unsigned int bandwidth, unsigned int latency, unsigned int loss)
Functions of this type are called to process underlay link.
struct OverlayLink * link
The link to be retired.
uint32_t B
position of peer B's handle in peers array
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
struct OverlayLink * link_array
An array of links; this array is of size link_array_size.
A peer controlled by the testing framework.
uint32_t data
The data value.
static void opstart_overlay_configure_topology(void *cls)
Function called when a overlay connect operation is ready.
char * GNUNET_TESTBED_topology_to_str_(enum GNUNET_TESTBED_TopologyOption topology)
Returns the string corresponding to the given topology.
Context information for overlay topologies.
Context information for topology operations.
header for intra library exported functions
static void oprelease_overlay_configure_topology(void *cls)
Callback which will be called when overlay connect operation is released.
#define DEFAULT_RETRY_CNT
Default number of retires.
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory)...
#define GNUNET_malloc(size)
Wrapper around malloc.
ssize_t GNUNET_DISK_fn_read(const char *fn, void *result, size_t len)
Read the contents of a binary file into a buffer.
#define GNUNET_free(ptr)
Wrapper around free.
int GNUNET_TESTBED_topology_get_(enum GNUNET_TESTBED_TopologyOption *topology, const char *topology_string)
Get a topology from a string input.
static void make_link(unsigned int offset, uint32_t A, uint32_t B, struct TopologyContext *tc)
Populates the OverlayLink structure.
Small-world network (ring plus random links).