X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fats-tests%2Fats-testing.h;h=59a9145d7122d48ed734fe576d5982aec68d161a;hb=49abab4a07a12b81d596ba166d3601055acf2da4;hp=028789d69af663a3eea7b9836fec69852d20423a;hpb=ee1c5c74a2409a52af706e613bd86a26341abba8;p=oweals%2Fgnunet.git diff --git a/src/ats-tests/ats-testing.h b/src/ats-tests/ats-testing.h index 028789d69..59a9145d7 100644 --- a/src/ats-tests/ats-testing.h +++ b/src/ats-tests/ats-testing.h @@ -31,26 +31,62 @@ #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; + 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, + 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); + const struct GNUNET_ATS_Information *ats, + uint32_t ats_count); /** * Information we track for a peer in the testbed. @@ -385,15 +421,43 @@ struct GNUNET_ATS_TEST_Topology void *done_cb_cls; }; -struct Experiment; +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, int success); +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 @@ -416,28 +480,56 @@ struct Experiment GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb; }; -struct Episode -{ - int id; - struct Episode *next; - struct GNUNET_TIME_Relative duration; -}; +/* + * 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 @@ -449,35 +541,79 @@ 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 */ 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 (struct LoggingHandle *); +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 (struct LoggingHandle *); +GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l); +/** + * Log all data now + * + * @param llogging handle to use + */ void -GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *, char *test); +GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l); -void -GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p); +/** + * 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, @@ -485,9 +621,12 @@ GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, int test_core, GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb, void *done_cb_cls, - GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb, + GNUNET_TRANSPORT_ReceiveCallback recv_cb, GNUNET_ATS_TEST_LogRequest ats_perf_cb); +/** + * Shutdown topology + */ void GNUNET_ATS_TEST_shutdown_topology (void);