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",
330 disconnect_task = NULL;
333 if (NULL != peers[i].
op)
339 if (NULL != peers[i].
ch)
342 "%u: channel %p\n", i, peers[i].ch);
348 "%u: warmup channel %p\n",
349 i, peers[i].warmup_ch);
355 "%u: incoming channel %p\n",
356 i, peers[i].incoming_ch);
375 if (NULL != disconnect_task)
381 if (NULL != round_task)
386 if (NULL != test_task)
402 if (disconnect_task != NULL)
426 if (NULL != disconnect_task)
456 " STATS %u - %s [%s]: %llu\n",
458 (
unsigned long long) value);
473 "Start collecting statistics...\n");
524 for (i = 0; i <
delta; i++)
532 while (peers[r].up == run || NULL != peers[r].incoming);
534 run ?
"arting" :
"opping", r,
GNUNET_i2s (&peers[r].
id));
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);
548 if (NULL != peers[r].
ch)
551 if (NULL != peers[r].dest)
559 "cadet", NULL, NULL, run);
619 if ((0 == size) || (NULL == buf))
629 return sizeof(*ping);
673 GNUNET_CADET_notify_transmit_ready (channel,
GNUNET_NO,
695 "tmt_rdy called, filling buffer\n");
700 "size %u, buf %p, data_sent %u, data_received %u\n",
786 (uint32_t) ntohl (msg->
counter),
802 static struct GNUNET_CADET_MessageHandler
handlers[] = {
825 enum GNUNET_CADET_ChannelOption
options)
835 "WARMUP %3u: %u <= %u\n",
842 if (NULL != test_task)
881 "Channel %p disconnected at peer %ld\n", channel, n);
882 if (peer->
ch == channel)
933 if (NULL == peers[i].
ch)
948 if (NULL != disconnect_task)
1004 long n = (long) cls;
1006 if ((NULL == pinfo) || (NULL != emsg))
1075 "requesting id %ld\n",
1078 peers[i].
cadet = cadetes[i];
1098 config_file =
".profiler.conf";
1103 "usage: %s ROUND_TIME PEERS PINGS [DO_WARMUP]\n",
1106 "example: %s 30s 16 1 Y\n",
1116 "%s is not a valid time\n",
1125 "%s peers is not valid (> 2)\n",
1136 "not enough peers, total should be > 2 * peers_pinging\n");
1140 do_warmup = (5 > argc || argv[4][0] !=
'N');
1149 GNUNET_CADET_TEST_run (
"cadet-profiler", config_file,
peers_total,
static void abort_test(long line)
Finish test normally: schedule disconnect and shutdown.
static struct GNUNET_CADET_Handle * cadet
Handle for cadet.
static struct GNUNET_TESTBED_Operation * stats_op
Testbed Operation (to get stats).
static struct GNUNET_CADET_Channel * ch
Channel handle.
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...
static void ping(void *cls)
Send a ping to destination.
static char * subsystem
Set to subsystem that we're going to get stats for (or NULL for all).
struct GNUNET_MessageHeader * msg
void GNUNET_CADET_TEST_cleanup(struct GNUNET_CADET_TEST_Context *ctx)
Clean up the testbed.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
uint64_t rel_value_us
The actual value.
static struct GNUNET_TIME_Relative delta
static unsigned long long peers_pinging
Number of peers doing pings.
static void adjust_running_peers(unsigned int target)
Set the total number of running peers.
static struct GNUNET_TESTBED_Peer ** testbed_handles
Testbed peer handles.
struct GNUNET_GETOPT_CommandLineOption options[]
Opaque handle to the service.
struct CadetPeer * incoming
Incoming channel for pings.
int main(int argc, char *argv[])
Main: start profiler.
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.
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 unsigned int get_index(struct CadetPeer *peer)
Get the index of a peer in the peers array.
struct CadetPeer * dest
Destinaton to ping.
static void next_rnd(void *cls)
Move to next round.
static unsigned int p_ids
Peer ids counter.
static int do_warmup
Do preconnect? (Each peer creates a tunnel to one other peer).
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int 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.
#define GNUNET_TIME_UNIT_SECONDS
One second.
static int test_finished
Flag to notify callbacks not to generate any new traffic anymore.
static char * config_file
Set to the name of the config file used.
struct GNUNET_SCHEDULER_Task * ping_task
Task to do the next ping.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static void collect_stats(void *cls)
Task check that keepalives were sent and received.
static struct GNUNET_TIME_Relative round_time
Duration of each round.
Opaque handle to a channel.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void finish_profiler(void *cls)
Finish profiler normally.
Test context for a CADET Test.
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_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Time for absolute time used by GNUnet, in microseconds and in network byte order. ...
static size_t tmt_rdy_ping(void *cls, size_t size, void *buf)
Transmit ping callback.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
Opaque handle to an abstract operation to be executed by the testing framework.
const struct GNUNET_HashCode * GC_u2h(uint32_t port)
Transitional function to convert an unsigned int port to a hash value.
static struct GNUNET_SCHEDULER_Task * disconnect_task
Task called to disconnect peers, before shutdown.
static void disconnect_cadet_peers(void *cls)
Disconnect from cadet services af all peers, call shutdown.
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
struct GNUNET_CADET_TransmitHandle * ping_ntr
NTR operation for the next ping.
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 struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_...
static char * line
Desired phone line (string to be converted to a hash).
static size_t tmt_rdy_pong(void *cls, size_t size, void *buf)
Transmit pong callback.
static char * value
Value of the record to add/remove.
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.
unsigned int pings[sizeof(rounds)/sizeof(rounds[0])]
static struct GNUNET_CONTAINER_MultiPeerMap * ids
GNUNET_PeerIdentity -> CadetPeer.
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.
uint32_t round_number
Round number.
struct GNUNET_TIME_AbsoluteNBO timestamp
Time the message was sent.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
float mean[sizeof(rounds)/sizeof(rounds[0])]
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
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 unsigned int peers_warmup
Warmup progress.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
static void show_end_data(void)
Show the results of the test (banwidth acheived) and log them to GAUGER.
static unsigned long long peers_total
Total number of peers.
static unsigned long long peers_running
Number of currently running peers.
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...
int data_sent
Number of payload packes sent.
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.
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
static struct GNUNET_CADET_TEST_Context * test_ctx
Test context (to shut down).
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.
static void stats_cont(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
Stats callback.
struct GNUNET_CADET_Channel * warmup_ch
Channel handle for a warmup channel.
static void pong(struct GNUNET_CADET_Channel *channel, const struct CadetPingMessage *ping)
Reply with a pong to origin.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
static unsigned int size
Size of the "table".
float var[sizeof(rounds)/sizeof(rounds[0])]
static struct GNUNET_TESTBED_Peer ** testbed_peers
Handles to all of the running peers.
uint32_t counter
Message number.
#define PING_PERIOD
Paximum ping period in milliseconds.
struct GNUNET_CADET_Handle * cadet
Cadet handle for the root peer.
static unsigned int num_peers
struct GNUNET_CADET_Channel * incoming_ch
Channel handle for the dest peer.
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.
static unsigned int current_round
Round number.
static struct GNUNET_SCHEDULER_Task * test_task
Task to perform tests.
The identity of the host (wraps the signing key of the peer).
void GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Send an ack on the channel to confirm the processing of a message.
What is the identity of the peer? Returns a 'const struct GNUNET_PeerIdentity *'. ...
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.
static uint16_t port
Port number.
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...
static struct CadetPeer * peers
Operation to get peer ids.
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.
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.
int data_received
Number of payload packets received.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
struct GNUNET_CADET_Channel * ch
Channel handle for the root peer.
struct GNUNET_PeerIdentity id
Peer ID.
struct GNUNET_MessageHeader header
Header.
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_SCHEDULER_Task * round_task
Task running each round of the benchmark.
Time for absolute times used by GNUnet, in microseconds.
static float rounds[]
Ratio of peers active.
static void channel_cleaner(void *cls, const struct GNUNET_CADET_Channel *channel, void *channel_ctx)
Function called whenever an inbound channel is destroyed.
unsigned int pongs[sizeof(rounds)/sizeof(rounds[0])]
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_ARM_Operation * op
Current operation.
static void start_test(void *cls)
START THE TEST ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES.
A peer controlled by the testing framework.
static void shutdown_task(void *cls)
Shut down peergroup, clean up.
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 * op
Testbed Operation (to get peer id, etc).
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
static void warmup(void)
Do warmup: create some channels to spread information about the topology.
#define number_rounds
Total number of rounds.
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
library for writing CADET tests
#define GNUNET_free(ptr)
Wrapper around free.
#define SHORT_TIME
Time to wait for stuff that should be rather fast.
Time for relative time used by GNUnet, in microseconds.
static struct GNUNET_TIME_Relative delay_ms_rnd(unsigned int max)
Calculate a random delay.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.