39 #define PING_PERIOD 500
44 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
49 #define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
54 #define number_rounds sizeof(rounds) / sizeof(rounds[0])
59 static float rounds[] = { 0.8, 0.6, 0.8, 0.5, 0.3, 0.8, 0.0 };
308 "ROUND %3u PEER %3u: %10.2f / %10.2f, PINGS: %3u, PONGS: %3u\n",
309 i, j,
peer->mean[i], sqrt (
peer->var[i] / (
peer->pongs[i] - 1)),
324 long line = (long) cls;
328 "disconnecting cadet service, called from line %ld\n",
342 "%u: channel %p\n", i,
peers[i].
ch);
348 "%u: warmup channel %p\n",
355 "%u: incoming channel %p\n",
456 " STATS %u - %s [%s]: %llu\n",
458 (
unsigned long long)
value);
473 "Start collecting statistics...\n");
524 for (i = 0; i <
delta; i++)
536 if (NULL !=
peers[r].ping_task)
541 if (NULL !=
peers[r].ping_ntr)
543 GNUNET_CADET_notify_transmit_ready_cancel (
peers[r].ping_ntr);
559 "cadet", NULL, NULL,
run);
619 if ((0 ==
size) || (NULL ==
buf))
629 return sizeof(*ping);
643 peer->ping_task = NULL;
671 GNUNET_CADET_notify_transmit_ready (channel,
GNUNET_NO,
691 peer->ping_ntr = NULL;
693 "tmt_rdy called, filling buffer\n");
698 "size %u, buf %p, data_sent %u, data_received %u\n",
702 peer->data_received);
711 msg->counter = htonl (
peer->data_sent++);
780 r = ntohl (
msg->round_number);
784 (uint32_t) ntohl (
msg->counter),
800 static struct GNUNET_CADET_MessageHandler
handlers[] = {
823 enum GNUNET_CADET_ChannelOption
options)
833 "WARMUP %3u: %u <= %u\n",
879 "Channel %p disconnected at peer %ld\n", channel, n);
880 if (
peer->ch == channel)
1002 long n = (long) cls;
1004 if ((NULL == pinfo) || (NULL != emsg))
1073 "requesting id %ld\n",
1101 "usage: %s ROUND_TIME PEERS PINGS [DO_WARMUP]\n",
1104 "example: %s 30s 16 1 Y\n",
1114 "%s is not a valid time\n",
1123 "%s peers is not valid (> 2)\n",
1134 "not enough peers, total should be > 2 * peers_pinging\n");
1138 do_warmup = (5 > argc || argv[4][0] !=
'N');
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MessageHeader * msg
void GNUNET_CADET_TEST_cleanup(struct GNUNET_CADET_TEST_Context *ctx)
Clean up the testbed.
library for writing CADET tests
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run.
static struct GNUNET_ARM_Operation * op
Current operation.
static char * config_file
Set to the name of the config file used.
static uint16_t port
Port number.
#define number_rounds
Total number of rounds.
static struct GNUNET_TESTBED_Peer ** testbed_handles
Testbed peer handles.
int main(int argc, char *argv[])
Main: start profiler.
static struct GNUNET_TIME_Relative delay_ms_rnd(unsigned int max)
Calculate a random delay.
static unsigned int current_round
Round number.
static float rounds[]
Ratio of peers active.
static unsigned long long peers_total
Total number of peers.
static int do_warmup
Do preconnect? (Each peer creates a tunnel to one other peer).
static void show_end_data(void)
Show the results of the test (banwidth achieved) and log them to GAUGER.
static unsigned int get_index(struct CadetPeer *peer)
Get the index of a peer in the peers array.
static struct GNUNET_TIME_Relative round_time
Duration of each round.
static void disconnect_cadet_peers(void *cls)
Disconnect from cadet services af all peers, call shutdown.
static struct GNUNET_CONTAINER_MultiPeerMap * ids
GNUNET_PeerIdentity -> CadetPeer.
static void start_test(void *cls)
START THE TEST ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES.
static void next_rnd(void *cls)
Move to next round.
int pong_handler(void *cls, struct GNUNET_CADET_Channel *channel, void **channel_ctx, const struct GNUNET_MessageHeader *message)
Function is called whenever a PONG message is received.
static void shutdown_task(void *cls)
Shut down peergroup, clean up.
int ping_handler(void *cls, struct GNUNET_CADET_Channel *channel, void **channel_ctx, const struct GNUNET_MessageHeader *message)
Function is called whenever a PING message is received.
static void * incoming_channel(void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *initiator, const struct GNUNET_HashCode *port, enum GNUNET_CADET_ChannelOption options)
Method called whenever another peer has added us to a channel the other peer initiated.
static void tmain(void *cls, struct GNUNET_CADET_TEST_Context *ctx, unsigned int num_peers, struct GNUNET_TESTBED_Peer **testbed_peers, struct GNUNET_CADET_Handle **cadetes)
test main: start test when all peers are connected
static struct GNUNET_TESTBED_Operation * stats_op
Testbed Operation (to get stats).
static void peer_id_cb(void *cls, struct GNUNET_TESTBED_Operation *op, const struct GNUNET_TESTBED_PeerInformation *pinfo, const char *emsg)
Callback to be called when the requested peer information is available.
static struct CadetPeer * select_random_peer(struct CadetPeer *peer)
Select a random peer that has no incoming channel.
static struct GNUNET_SCHEDULER_Task * round_task
Task running each round of the benchmark.
static struct CadetPeer * peers
Operation to get peer ids.
static void finish_profiler(void *cls)
Finish profiler normally.
static void channel_cleaner(void *cls, const struct GNUNET_CADET_Channel *channel, void *channel_ctx)
Function called whenever an inbound channel is destroyed.
static void abort_test(long line)
Finish test normally: schedule disconnect and shutdown.
static unsigned long long peers_pinging
Number of peers doing pings.
static size_t tmt_rdy_pong(void *cls, size_t size, void *buf)
Transmit pong callback.
#define SHORT_TIME
Time to wait for stuff that should be rather fast.
static unsigned int p_ids
Peer ids counter.
static void pong(struct GNUNET_CADET_Channel *channel, const struct CadetPingMessage *ping)
Reply with a pong to origin.
static struct GNUNET_CADET_TEST_Context * test_ctx
Test context (to shut down).
static int stats_iterator(void *cls, const struct GNUNET_TESTBED_Peer *peer, const char *subsystem, const char *name, uint64_t value, int is_persistent)
Process statistic values.
static struct GNUNET_SCHEDULER_Task * disconnect_task
Task called to disconnect peers, before shutdown.
static void ping(void *cls)
Send a ping to destination.
static struct GNUNET_SCHEDULER_Task * test_task
Task to perform tests.
static void adjust_running_peers(unsigned int target)
Set the total number of running peers.
static void collect_stats(void *cls)
Task check that keepalives were sent and received.
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static unsigned long long peers_running
Number of currently running peers.
static unsigned int peers_warmup
Warmup progress.
static void stats_cont(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
Stats callback.
static void warmup(void)
Do warmup: create some channels to spread information about the topology.
#define PING_PERIOD
Paximum ping period in milliseconds.
static size_t tmt_rdy_ping(void *cls, size_t size, void *buf)
Transmit ping callback.
static int test_finished
Flag to notify callbacks not to generate any new traffic anymore.
static struct GNUNET_CADET_Channel * ch
Channel handle.
static unsigned int num_peers
static char * line
Desired phone line (string to be converted to a hash).
static char * value
Value of the record to add/remove.
static struct GNUNET_TESTBED_Peer ** testbed_peers
Handles to all of the running peers.
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
static struct GNUNET_CADET_Handle * cadet
Handle for cadet.
static char * subsystem
Set to subsystem that we're going to get stats for (or NULL for all).
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
CADET service; establish channels to distant peers.
API to create, modify and access statistics.
struct GNUNET_CADET_Channel * GNUNET_CADET_channel_create(struct GNUNET_CADET_Handle *h, void *channel_cls, const struct GNUNET_PeerIdentity *destination, const struct GNUNET_HashCode *port, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Create a new channel towards a remote peer.
void GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Send an ack on the channel to confirm the processing of a message.
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
const struct GNUNET_HashCode * GC_u2h(uint32_t port)
Transitional function to convert an unsigned int port to a hash value.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#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
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
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.
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,...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
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.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_relative(const char *fancy_time, struct GNUNET_TIME_Relative *rtime)
Convert a given fancy human-readable time to our internal representation.
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...
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_peer_get_information(struct GNUNET_TESTBED_Peer *peer, enum GNUNET_TESTBED_PeerInformationType pit, GNUNET_TESTBED_PeerInfoCallback cb, void *cb_cls)
Request information about a peer.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_peer_manage_service(void *op_cls, struct GNUNET_TESTBED_Peer *peer, const char *service_name, GNUNET_TESTBED_OperationCompletionCallback cb, void *cb_cls, unsigned int start)
Start or stop given service at a peer.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_get_statistics(unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, const char *subsystem, const char *name, GNUNET_TESTBED_StatisticsIterator proc, GNUNET_TESTBED_OperationCompletionCallback cont, void *cls)
Convenience method that iterates over all (running) peers and retrieves all statistics from each peer...
uint32_t GNUNET_TESTBED_get_index(const struct GNUNET_TESTBED_Peer *peer)
Return the index of the peer inside of the total peer array, aka.
@ GNUNET_TESTBED_PIT_IDENTITY
What is the identity of the peer? Returns a 'const struct GNUNET_PeerIdentity *'.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
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...
#define GNUNET_TIME_UNIT_SECONDS
One second.
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
static unsigned int size
Size of the "table".
static struct GNUNET_TIME_Relative delta
struct GNUNET_SCHEDULER_Task * ping_task
Task to do the next ping.
struct GNUNET_CADET_Channel * ch
Channel handle for the root peer.
struct CadetPeer * dest
Destinaton to ping.
unsigned int pings[sizeof(rounds)/sizeof(rounds[0])]
struct CadetPeer * incoming
Incoming channel for pings.
int data_received
Number of payload packets received.
struct GNUNET_CADET_Channel * warmup_ch
Channel handle for a warmup channel.
struct GNUNET_PeerIdentity id
Peer ID.
int data_sent
Number of payload packes sent.
float mean[sizeof(rounds)/sizeof(rounds[0])]
unsigned int pongs[sizeof(rounds)/sizeof(rounds[0])]
struct GNUNET_CADET_TransmitHandle * ping_ntr
NTR operation for the next ping.
struct GNUNET_TESTBED_Operation * op
Testbed Operation (to get peer id, etc).
float var[sizeof(rounds)/sizeof(rounds[0])]
struct GNUNET_CADET_Handle * cadet
Cadet handle for the root peer.
struct GNUNET_CADET_Channel * incoming_ch
Channel handle for the dest peer.
uint32_t counter
Message number.
struct GNUNET_MessageHeader header
Header.
struct GNUNET_TIME_AbsoluteNBO timestamp
Time the message was sent.
uint32_t round_number
Round number.
Opaque handle to a channel.
Opaque handle to the service.
Test context for a CADET Test.
Internal representation of the hash map.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Opaque handle to an abstract operation to be executed by the testing framework.
A peer controlled by the testing framework.
Time for absolute time used by GNUnet, in microseconds and in network byte order.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.