39 #define LOG(kind, ...) \ 40 GNUNET_log_from (kind, "testbed-api-testbed", __VA_ARGS__) 46 LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) 51 #define DEFAULT_SETUP_TIMEOUT 300 57 #define TESTBED_CONFIG_SECTION "testbed" 63 #define SCALE_FREE_CAP "SCALE_FREE_TOPOLOGY_CAP" 69 #define SCALE_FREE_M "SCALE_FREE_TOPOLOGY_M" 340 return *((uint32_t *) &rcop);
469 if (NULL != rc->
cproc)
473 for (hid = 0; hid < rc->
num_hosts; hid++)
519 for (nhost = 0; nhost < rc->
num_hosts; nhost++)
582 if ((NULL == rc->
cproc)
586 if (NULL != rc->
peers)
593 if (NULL == rc->
peers)
600 DEBUG (
"Shutting down peers\n");
633 "Shutdown postponed as there are %u operations currently active\n",
672 DEBUG (
"Starting Peers\n");
674 for (peer = 0; peer < rc->
num_peers; peer++)
752 unsigned int nfailures)
777 DEBUG (
"Creating peers\n");
783 for (peer = 0; peer < rc->
num_peers; peer++)
818 rcop =
event->op_cls;
822 "Linking controllers failed. Exiting"));
925 unsigned long long number;
932 cap = (
unsigned int) number;
946 (
unsigned int) number,
962 "Not generating a topology. Check number of peers\n");
965 DEBUG (
"Creating overlay topology\n");
999 _ (
"Host registration failed for a host. Error: %s\n"), emsg);
1023 DEBUG (
"All hosts successfully registered\n");
1025 for (slave = 0; slave < rc->
num_hosts; slave++)
1065 _ (
"Controller crash detected. Shutting down.\n"));
1103 const struct sockaddr *addr,
const struct sockaddr *broadcast_addr,
1104 const struct sockaddr *netmask, socklen_t addrlen)
1107 char hostip[NI_MAXHOST];
1110 if (
sizeof(
struct sockaddr_in) != addrlen)
1113 getnameinfo (addr, addrlen, hostip, NI_MAXHOST, NULL, 0, NI_NUMERICHOST))
1158 _ (
"Testbed cannot be started on localhost\n"));
1171 old_hosts = rc->
hosts;
1184 for (nhost = 0; nhost < rc->
num_hosts; nhost++)
1194 if (NULL == rc->
cproc)
1214 _ (
"Shutting down testbed due to timeout while setup.\n"));
1261 unsigned long long number;
1274 _ (
"No hosts loaded from LoadLeveler. Need at least one host\n"));
1278 if (NULL != host_filename)
1286 _ (
"No hosts loaded. Need at least one host\n"));
1303 "OVERLAY_TOPOLOGY", &topology))
1312 "Specified topology must be supported by testbed"));
1323 "OVERLAY_RANDOM_LINKS",
1330 "OVERLAY_RANDOM_LINKS");
1333 if (number > UINT32_MAX)
1345 "OVERLAY_TOPOLOGY_FILE",
1350 "OVERLAY_TOPOLOGY_FILE");
1365 if (UINT16_MAX < number)
1368 _ (
"Maximum number of edges a peer can have in a scale free topology" 1369 " cannot be more than %u. Given `%s = %llu'"), UINT16_MAX,
1382 if (UINT8_MAX < number)
1385 _ (
"The number of edges that can established when adding a new node" 1386 " to scale free topology cannot be more than %u. Given `%s = %llu'"),
1401 "OVERLAY_RANDOM_LINKS"))
1403 "Ignoring value of `OVERLAY_RANDOM_LINKS' in given configuration\n");
1410 for (nhost = 0; nhost < rc->
num_hosts; nhost++)
1420 for (nhost = 0; nhost < rc->
num_hosts; nhost++)
1456 if (NULL != rc->
hosts)
1458 for (hid = 0; hid < rc->
num_hosts; hid++)
1459 if (NULL != rc->
hosts[hid])
1463 if (NULL != rc->
cfg)
static void start_peers_task(void *cls)
Task for starting peers.
void GNUNET_TESTBED_cancel_registration(struct GNUNET_TESTBED_HostRegistrationHandle *handle)
Cancel the pending registration.
Context information for the operation we start.
unsigned int index
Index of the host in the run context's hosts array.
void GNUNET_TESTBED_controller_disconnect(struct GNUNET_TESTBED_Controller *c)
Stop the given controller (also will terminate all peers and controllers dependent on this controller...
enum State state
State of this context.
unsigned int links_succeeded
the number of overlay link connection attempts that succeeded
struct GNUNET_TESTBED_HostHabitableCheckHandle * GNUNET_TESTBED_is_host_habitable(const struct GNUNET_TESTBED_Host *host, const struct GNUNET_CONFIGURATION_Handle *config, GNUNET_TESTBED_HostHabitableCallback cb, void *cb_cls)
Checks whether a host can be used to start testbed service.
static void timeout_task(void *cls)
Task run upon timeout while setting up the testbed.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
GNUNET_TESTBED_TopologyOption
Topologies and topology options supported for testbeds.
struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run of a timeout.
Handle to interact with a GNUnet testbed controller.
void * cc_cls
The pointer to the controller callback.
void GNUNET_TESTBED_is_host_habitable_cancel(struct GNUNET_TESTBED_HostHabitableCheckHandle *handle)
Function to cancel a request started using GNUNET_TESTBED_is_host_habitable()
unsigned int links_failed
the number of overlay link connection attempts that failed
static void test_master(void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **started_peers, unsigned int links_succeeded, unsigned int links_failed)
Signature of a main function for a testcase.
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.
static void event_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event)
Signature of the event handler function called by the respective event controller.
TESTBED_opcq_empty_cb opcq_empty_cb
If this callback is not NULL, schedule it as a task when opc_map gets empty.
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MulitHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_TESTBED_Operation * op
The testbed operation handle.
struct GNUNET_CONTAINER_MultiHashMap32 * rcop_map
A hashmap for operations started by us.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_HostRegistrationHandle * reg_handle
Host registration handle.
struct GNUNET_TESTBED_RunHandle * rc
Context information for GNUNET_TESTBED_run()
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_controller_link(void *op_cls, struct GNUNET_TESTBED_Controller *master, struct GNUNET_TESTBED_Host *delegated_host, struct GNUNET_TESTBED_Host *slave_host, int is_subordinate)
Create a link from slave controller to delegated controller.
static void wait_op_completion(void *cls)
This callback will be called when all the operations are completed (done/cancelled) ...
#define GNUNET_TIME_UNIT_SECONDS
One second.
All peers are disconnected.
unsigned int num_oc
Expected overlay connects.
void GNUNET_TESTBED_controller_stop(struct GNUNET_TESTBED_ControllerProc *cproc)
Stop the controller process (also will terminate all peers and controllers dependent on this controll...
static void insert_rcop(struct GNUNET_TESTBED_RunHandle *rc, struct RunContextOperation *rcop)
Insert an RunContextOperation into the rcop_map of the given RunContext.
struct GNUNET_TESTBED_ControllerProc * cproc
The handle to the controller process.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_peer_start(void *op_cls, struct GNUNET_TESTBED_Peer *peer, GNUNET_TESTBED_PeerChurnCallback pcc, void *pcc_cls)
Start the given peer.
static struct RunContextOperation * search_rcop(struct GNUNET_TESTBED_RunHandle *rc, struct GNUNET_TESTBED_Operation *op)
Initiate a search for the given operation in the rcop_map.
char * trusted_ip
The trusted IP string.
Context for host compability checks.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define TESTBED_CONFIG_SECTION
Configuration section for testbed.
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.
struct GNUNET_TESTBED_Controller * c
The controller handle.
void(* GNUNET_TESTBED_ControllerCallback)(void *cls, const struct GNUNET_TESTBED_EventInformation *event)
Signature of the event handler function called by the respective event controller.
unsigned int num_peers
number of peers to start
#define DEFAULT_SETUP_TIMEOUT
The default setup timeout in seconds.
enum GNUNET_TESTBED_TopologyOption topology
The topology to generate.
static void interrupt(void *cls)
Task run upon interrupts (SIGINT, SIGTERM) and upon scheduler shutdown.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
void GNUNET_OS_network_interfaces_list(GNUNET_OS_NetworkInterfaceProcessor proc, void *proc_cls)
Enumerate all network interfaces.
int GNUNET_CONTAINER_multihashmap32_get_multiple(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, GNUNET_CONTAINER_MulitHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
void GNUNET_log_config_invalid(enum GNUNET_ErrorType kind, const char *section, const char *option, const char *required)
Log error message about invalid configuration option value.
The testbed run is ready and the master callback can be called now.
Opaque handle to a host running experiments managed by the testing framework.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
struct GNUNET_TIME_Absolute pstart_time
Profiling start time.
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.
Handle for controller process.
struct GNUNET_SCHEDULER_Task * interrupt_task
Task run upon shutdown interrupts.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
void(* GNUNET_TESTBED_TestMaster)(void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, unsigned int links_succeeded, unsigned int links_failed)
Signature of a main function for a testcase.
int GNUNET_CONTAINER_multihashmap32_put(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Opaque handle to an abstract operation to be executed by the testing framework.
struct GNUNET_TESTBED_Host * h
Handle to the host on which the controller runs.
static uint32_t rcop_key(void *rcop)
Return a 32-bit key from a pointer.
Read a topology from a given file.
#define SCALE_FREE_M
Option string for the number of edges to be established when adding a new node to the scale free netw...
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
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.
static int search_iterator(void *cls, uint32_t key, void *value)
Iterator for searching over the elements matching a given query.
enum State state
current state of profiling
struct GNUNET_TESTBED_HostHabitableCheckHandle * h
Handle for the compability check.
int GNUNET_CONTAINER_multihashmap32_remove(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, const void *value)
Remove the given key-value pair from the map.
#define LOG(kind,...)
Generic loggins shorthand.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
static char * value
Value of the record to add/remove.
char * topo_file
The file containing topology data.
struct CompatibilityCheckContext * hclist
Array of compatibility check contexts.
struct GNUNET_TESTBED_Operation * topology_operation
The topology generation operation.
static void create_peers(struct GNUNET_TESTBED_RunHandle *rc)
Function to create peers.
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.
void GNUNET_TESTBED_host_resolve_(struct GNUNET_TESTBED_Host *host)
Resolves the hostname of the host to an ip address.
The handle for whether a host is habitable or not.
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.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
A requested testbed operation has been completed.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
unsigned int GNUNET_CONTAINER_multihashmap32_size(const struct GNUNET_CONTAINER_MultiHashMap32 *map)
Get the number of key-value pairs in the map.
uint16_t status
See PRISM_STATUS_*-constants.
struct GNUNET_CONTAINER_MultiHashMap32 * opc_map
The map of active operation contexts.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
struct GNUNET_TESTBED_RunHandle * rc
The run context.
unsigned int reg_hosts
Number of registered hosts.
static void call_master(struct GNUNET_TESTBED_RunHandle *rc)
call test master callback
Internal representation of the hash map.
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...
#define DEBUG(...)
Debug logging shortcut.
void GNUNET_TESTBED_run(const char *host_filename, const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int num_peers, uint64_t event_mask, GNUNET_TESTBED_ControllerCallback cc, void *cc_cls, GNUNET_TESTBED_TestMaster test_master, void *test_master_cls)
Convenience method for running a testbed with a single call.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
The options should always end with this.
struct GNUNET_TESTBED_Controller * GNUNET_TESTBED_run_get_controller_handle(struct GNUNET_TESTBED_RunHandle *h)
Obtain handle to the master controller from a testbed run.
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
static void peer_create_cb(void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
Functions of this signature are called when a peer has been successfully created. ...
uint64_t event_mask
Global event mask for all testbed events.
struct GNUNET_TESTBED_Host * GNUNET_TESTBED_host_create(const char *hostname, const char *username, const struct GNUNET_CONFIGURATION_Handle *cfg, uint16_t port)
Create a host to run peers and controllers on.
Controllers on given hosts started and linked.
void GNUNET_TESTBED_host_destroy(struct GNUNET_TESTBED_Host *host)
Destroy a host handle.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_HashCode key
The key used in the DHT.
static unsigned int size
Size of the "table".
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_have_value(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Test if we have a value for a particular option.
struct RunContextOperation * result
The Run context operation which has the operation being queried.
static void topology_completion_callback(void *cls, unsigned int nsuccess, unsigned int nfailures)
Callbacks of this type are called when topology configuration is completed.
static int netint_proc(void *cls, const char *name, int isDefault, const struct sockaddr *addr, const struct sockaddr *broadcast_addr, const struct sockaddr *netmask, socklen_t addrlen)
Callback function invoked for each interface found.
Small-world network (2d torus plus random links).
static struct GNUNET_FS_SearchContext * sc
struct GNUNET_TESTBED_Controller * GNUNET_TESTBED_controller_connect(struct GNUNET_TESTBED_Host *host, uint64_t event_mask, GNUNET_TESTBED_ControllerCallback cc, void *cc_cls)
Connect to a controller process.
State
Available states during profiling.
A connection between two peers was established.
static unsigned int num_peers
struct GNUNET_TESTBED_Operation * query
The operation pointer to look for.
static void host_registration_completion(void *cls, const char *emsg)
Callback which will be called to after a host registration succeeded or failed.
static void cancel_interrupt_task(struct GNUNET_TESTBED_RunHandle *rc)
Cancels the scheduled interrupt task.
static char * host_filename
Data file with the hosts for the testbed.
internal API to access the 'peers' subsystem
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
Interface for functions internally exported from testbed_api.c.
Allow multiple values with the same key.
void * opcq_empty_cls
Closure for the above task.
void * test_master_cls
The closure for the TestMaster callback.
unsigned int peer_count
Current peer count for an operation; Set this to 0 and increment for each successful operation on a p...
const char * GNUNET_TESTBED_host_get_hostname(const struct GNUNET_TESTBED_Host *host)
Obtain the host's hostname.
Context information to be used while searching for operation contexts.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_shutdown_peers(struct GNUNET_TESTBED_Controller *c, void *op_cls, GNUNET_TESTBED_OperationCompletionCallback cb, void *cb_cls)
Stops and destroys all peers.
GNUNET_TESTBED_ControllerCallback cc
The callback to use as controller callback.
static void rc_cleanup_operations(struct GNUNET_TESTBED_RunHandle *rc)
Cancels operations and tasks which are assigned to the given run context.
unsigned int random_links
Number of random links to established.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
enum GNUNET_TESTBED_TopologyOption topology
The topology which has to be achieved with the peers started in this context.
static void remove_rcop(struct GNUNET_TESTBED_RunHandle *rc, struct RunContextOperation *rcop)
Remove a RunContextOperation from the rcop_map of the given RunContext.
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...
unsigned int GNUNET_TESTBED_hosts_load_from_loadleveler(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTBED_Host ***hosts)
Loads the set of host allocated by the LoadLeveler Job Scheduler.
static void cleanup(struct GNUNET_TESTBED_RunHandle *rc)
Assuming all peers have been destroyed cleanup run handle.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
unsigned int num_hosts
Number of hosts in the given host file.
int shutdown
Have we already shutdown.
struct GNUNET_TESTBED_Peer ** peers
Array of peers which we create.
handle for host registration
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration of the controller.
struct GNUNET_TESTBED_Host ** hosts
An array of hosts loaded from the hostkeys file.
Time for absolute times used by GNUnet, in microseconds.
internal API to access the 'hosts' subsystem
struct GNUNET_SCHEDULER_Task * register_hosts_task
Host registration task.
A peer controlled by the testing framework.
static void controller_status_cb(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, int status)
Callback to signal successfull startup of the controller process.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_peer_create(struct GNUNET_TESTBED_Controller *controller, struct GNUNET_TESTBED_Host *host, const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_TESTBED_PeerCreateCallback cb, void *cls)
Create the given peer at the specified host using the given controller.
static int rcop_cleanup_iterator(void *cls, uint32_t key, void *value)
Iterator for cleaning up elements from rcop_map.
struct GNUNET_TESTBED_HostRegistrationHandle * GNUNET_TESTBED_register_host(struct GNUNET_TESTBED_Controller *controller, struct GNUNET_TESTBED_Host *host, GNUNET_TESTBED_HostRegistrationCompletion cc, void *cc_cls)
Register a host with the controller.
static const char * prof_time(struct GNUNET_TESTBED_RunHandle *rc)
Function to return the string representation of the duration between current time and `pstart_time' i...
header for intra library exported functions
static void register_hosts(void *cls)
Task to register all hosts available in the global host list.
struct GNUNET_TESTBED_ControllerProc * GNUNET_TESTBED_controller_start(const char *trusted_ip, struct GNUNET_TESTBED_Host *host, GNUNET_TESTBED_ControllerStatusCallback cb, void *cls)
Starts a controller process at the given host.
#define GNUNET_malloc(size)
Wrapper around malloc.
unsigned int GNUNET_TESTBED_hosts_load_from_file(const char *filename, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTBED_Host ***hosts)
Load a set of hosts from a configuration file.
static void host_habitable_cb(void *cls, const struct GNUNET_TESTBED_Host *host, int status)
Callbacks of this type are called by GNUNET_TESTBED_is_host_habitable to inform whether the given hos...
#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.
uint64_t event_mask
The event mask for the controller.
Time for relative time used by GNUnet, in microseconds.
GNUNET_TESTBED_TestMaster test_master
TestMaster callback to call when testbed initialization is done.
All peers shutdown (stopped and destroyed)
Small-world network (ring plus random links).
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
#define SCALE_FREE_CAP
Option string for the maximum number of edges a peer is permitted to have while generating scale free...