X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fats-tests%2Fats-testing.h;h=59a9145d7122d48ed734fe576d5982aec68d161a;hb=49abab4a07a12b81d596ba166d3601055acf2da4;hp=b3301f19db54c7a1a1d4d6edbf76cbd25bb58b69;hpb=fa6b31337f6a83bb14586f7afa0335e559454e9e;p=oweals%2Fgnunet.git diff --git a/src/ats-tests/ats-testing.h b/src/ats-tests/ats-testing.h index b3301f19d..59a9145d7 100644 --- a/src/ats-tests/ats-testing.h +++ b/src/ats-tests/ats-testing.h @@ -31,19 +31,63 @@ #define TEST_ATS_PREFERENCE_DEFAULT 1.0 +/** + * Message type sent for traffic generation + */ #define TEST_MESSAGE_TYPE_PING 12345 + +/** + * Message type sent as response during traffic generation + */ #define TEST_MESSAGE_TYPE_PONG 12346 + +/** + * Size of test messages + */ #define TEST_MESSAGE_SIZE 100 struct BenchmarkPartner; + struct BenchmarkPeer; + struct GNUNET_ATS_TEST_Topology; + struct TrafficGenerator; -typedef void (*GNUNET_ATS_TESTING_TopologySetupDoneCallback) (void *cls, +struct LoggingHandle; + + +/** + * Callback to call when topology setup is completed + * + * @param cls the closure + * @param masters array of master peers + * @param slaves array of master peers + */ +typedef void (*GNUNET_ATS_TEST_TopologySetupDoneCallback) (void *cls, struct BenchmarkPeer *masters, struct BenchmarkPeer *slaves); +/** + * Callback called when logging is required for the data contained + * + * @param cls the closure + * @param address an address + * @param address_active is address active + * @param bandwidth_out bandwidth outbound + * @param bandwidth_in bandwidth inbound + * @param ats ats information + * @param ats_count number of ats inforation + */ +typedef void +(*GNUNET_ATS_TEST_LogRequest) (void *cls, + const struct GNUNET_HELLO_Address *address, + int address_active, + struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, + struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, + const struct GNUNET_ATS_Information *ats, + uint32_t ats_count); + /** * Information we track for a peer in the testbed. */ @@ -309,11 +353,6 @@ struct GNUNET_ATS_TEST_Topology */ int result; - /** - * Test result logging - */ - int logging; - /**Test core (GNUNET_YES) or transport (GNUNET_NO) */ int test_core; @@ -377,15 +416,120 @@ struct GNUNET_ATS_TEST_Topology GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb; - GNUNET_ATS_TESTING_TopologySetupDoneCallback done_cb; + GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb; GNUNET_ATS_AddressInformationCallback ats_perf_cb; void *done_cb_cls; }; +enum OperationType +{ + START_SEND, + STOP_SEND, + SET_RATE, + SET_PREFERENCE +}; + +struct Episode; + +struct Experiment; + +typedef void (*GNUNET_ATS_TESTING_EpisodeDoneCallback) ( + struct Episode *e); + +typedef void (*GNUNET_ATS_TESTING_ExperimentDoneCallback) (struct Experiment *e, + struct GNUNET_TIME_Relative duration,int success); + +struct Operation +{ + struct Operation *next; + struct Operation *prev; + long long unsigned int src_id; + long long unsigned int dest_id; + long long unsigned int value; + enum OperationType type; +}; + +struct Episode +{ + int id; + struct Episode *next; + struct GNUNET_TIME_Relative duration; + + struct Operation *head; + struct Operation *tail; +}; + + +struct Experiment +{ + char *name; + char *cfg_file; + unsigned long long int num_masters; + unsigned long long int num_slaves; + struct GNUNET_TIME_Relative max_duration; + struct GNUNET_TIME_Relative total_duration; + struct GNUNET_TIME_Absolute start_time; + unsigned int num_episodes; + struct Episode *start; + + GNUNET_SCHEDULER_TaskIdentifier experiment_timeout_task; + GNUNET_SCHEDULER_TaskIdentifier episode_timeout_task; + struct Episode *cur; + + GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb; + GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb; +}; + +/* + * Experiment related functions + */ + + +/** + * Execute the specified experiment + * + * @param e the Experiment + * @param ep_done_cb a episode is completed + * @param e_done_cb the experiment is completed + */ +void +GNUNET_ATS_TEST_experimentation_run (struct Experiment *e, + GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb, + GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb); + +/** + * Load an experiment from a file + * + * @param filename the file + * @return the Experiment or NULL on failure + */ +struct Experiment * +GNUNET_ATS_TEST_experimentation_load (char *filename); + + +/** + * Stop an experiment + * + * @param e the experiment + */ +void +GNUNET_ATS_TEST_experimentation_stop (struct Experiment *e); + +/* + * Traffic related functions + */ + +void +GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p); + +void +GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p); + struct TrafficGenerator * GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, - struct BenchmarkPartner *dest, unsigned int rate, + struct BenchmarkPartner *dest, + unsigned int rate, struct GNUNET_TIME_Relative duration); void @@ -397,43 +541,92 @@ GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg); void GNUNET_ATS_TEST_generate_traffic_stop_all (); + +/* + * Logging related functions + */ + /** * Start logging + * + * @param log_frequency the logging frequency + * @param testname the testname + * @param masters the master peers used for benchmarking + * @param num_master the number of master peers + * @return the logging handle or NULL on error */ -void +struct LoggingHandle * GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency, - char * testname, struct BenchmarkPeer *masters, int num_masters); + char * testname, + struct BenchmarkPeer *masters, + int num_masters); /** * Stop logging + * + * @param l the logging handle */ void -GNUNET_ATS_TEST_logging_stop (void); +GNUNET_ATS_TEST_logging_clean_up (struct LoggingHandle *l); /** - * Log all data now + * Stop logging + * + * @param l the logging handle */ void -GNUNET_ATS_TEST_logging_now (void); - +GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l); +/** + * Log all data now + * + * @param llogging handle to use + */ void -GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p); +GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l); + +/** + * Write logging data to file + * + * @param l logging handle to use + * @param test_name name of the current test + * @param plots create gnuplots: GNUNET_YES or GNUNET_NO + */ void -GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p); +GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, + char *test_name, int plots); +/* + * Topology related functions + */ +/** + * Create a topology for ats testing + * + * @param name test name + * @param cfg_file configuration file to use for the peers + * @param num_slaves number of slaves + * @param num_masters number of masters + * @param test_core connect to CORE service (GNUNET_YES) or transport (GNUNET_NO) + * @param done_cb function to call when topology is setup + * @param done_cb_cls cls for callback + * @param recv_cb callback to call when data are received + * @param perf_cb callback to call when performance info are received + */ void GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, unsigned int num_slaves, unsigned int num_masters, int test_core, - GNUNET_ATS_TESTING_TopologySetupDoneCallback done_cb, + GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb, void *done_cb_cls, - GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb, - GNUNET_ATS_AddressInformationCallback ats_perf_cb); + GNUNET_TRANSPORT_ReceiveCallback recv_cb, + GNUNET_ATS_TEST_LogRequest ats_perf_cb); +/** + * Shutdown topology + */ void GNUNET_ATS_TEST_shutdown_topology (void);