[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r32256 - in gnunet/src/ats: . experiments
From: |
gnunet |
Subject: |
[GNUnet-SVN] r32256 - in gnunet/src/ats: . experiments |
Date: |
Fri, 7 Feb 2014 19:13:06 +0100 |
Author: wachs
Date: 2014-02-07 19:13:06 +0100 (Fri, 07 Feb 2014)
New Revision: 32256
Modified:
gnunet/src/ats/experiments/example.exp
gnunet/src/ats/gnunet-ats-solver-eval.c
gnunet/src/ats/gnunet-ats-solver-eval.h
Log:
preference generation implemented
Modified: gnunet/src/ats/experiments/example.exp
===================================================================
--- gnunet/src/ats/experiments/example.exp 2014-02-07 17:37:32 UTC (rev
32255)
+++ gnunet/src/ats/experiments/example.exp 2014-02-07 18:13:06 UTC (rev
32256)
@@ -18,15 +18,15 @@
op-0-plugin = udp
op-1-operation = start_set_preference
-op-1-address-id = 0
-op-1-peer-id = 0
+op-1-address-id = 1
+op-1-peer-id = 1
# constant, linear, sinus, random
op-1-gen-type = random
op-1-base-rate= 10000
op-1-max-rate = 10000
-op-1-frequency = 1
+op-1-frequency = 100 ms
# BANDWIDTH, LATENCY
-op-1-pref = LATENCY
+op-1-pref = BANDWIDTH
op-2-operation = start_set_property
op-2-address-id = 0
@@ -35,7 +35,7 @@
op-2-gen-type = random
op-2-base-rate= 10000
op-2-max-rate = 10000
-op-2-frequency = 1
+op-2-frequency = 10
# bandwidth, latency
# "TERMINATOR", "UTILIZATION_UP", "UTILIZATION_DOWN",
"UTILIZATION_PAYLOAD_UP", "UTILIZATION_PAYLOAD_DOWN", "NETWORK_TYPE", "DELAY",
"DISTANCE", "COST_WAN", "COST_LAN", "COST_WLAN"
op-2-property = UTILIZATION_UP
@@ -52,11 +52,11 @@
op-0-plugin = udp
op-1-operation = stop_set_preference
-op-1-address-id = 0
-op-1-peer-id = 0
+op-1-address-id = 1
+op-1-peer-id = 1
op-1-pref = BANDWIDTH
op-2-operation = stop_set_property
op-2-address-id = 0
op-2-peer-id = 0
-#op-2-property = UTILIZATION_UP
\ No newline at end of file
+op-2-property = UTILIZATION_UP
\ No newline at end of file
Modified: gnunet/src/ats/gnunet-ats-solver-eval.c
===================================================================
--- gnunet/src/ats/gnunet-ats-solver-eval.c 2014-02-07 17:37:32 UTC (rev
32255)
+++ gnunet/src/ats/gnunet-ats-solver-eval.c 2014-02-07 18:13:06 UTC (rev
32256)
@@ -61,7 +61,229 @@
static void
end_now ();
+
/**
+ * Preference Generators
+ */
+
+static struct PreferenceGenerator *pg_head;
+static struct PreferenceGenerator *pg_tail;
+
+static double
+get_preference (struct PreferenceGenerator *pg)
+{
+ struct GNUNET_TIME_Relative time_delta;
+ double delta_value;
+ double pref_value;
+
+ /* Calculate the current preference value */
+ switch (pg->type) {
+ case GNUNET_ATS_TEST_TG_CONSTANT:
+ pref_value = pg->base_value;
+ break;
+ case GNUNET_ATS_TEST_TG_LINEAR:
+ time_delta = GNUNET_TIME_absolute_get_duration(pg->time_start);
+ /* Calculate point of time in the current period */
+ time_delta.rel_value_us = time_delta.rel_value_us %
+ pg->duration_period.rel_value_us;
+ delta_value = ((double) time_delta.rel_value_us /
+ pg->duration_period.rel_value_us) * (pg->max_value - pg->base_value);
+ if ((pg->max_value < pg->base_value) &&
+ ((pg->max_value - pg->base_value) > pg->base_value))
+ {
+ /* This will cause an underflow */
+ GNUNET_break (0);
+ }
+ pref_value = pg->base_value + delta_value;
+ break;
+ case GNUNET_ATS_TEST_TG_RANDOM:
+ delta_value = (double) GNUNET_CRYPTO_random_u32
(GNUNET_CRYPTO_QUALITY_WEAK,
+ 10000 * (pg->max_value - pg->base_value)) / 10000;
+ pref_value = pg->base_value + delta_value;
+ break;
+ case GNUNET_ATS_TEST_TG_SINUS:
+ time_delta = GNUNET_TIME_absolute_get_duration(pg->time_start);
+ /* Calculate point of time in the current period */
+ time_delta.rel_value_us = time_delta.rel_value_us %
+ pg->duration_period.rel_value_us;
+ if ((pg->max_value - pg->base_value) > pg->base_value)
+ {
+ /* This will cause an underflow for second half of sinus period,
+ * will be detected in general when experiments are loaded */
+ GNUNET_break (0);
+ }
+ delta_value = (pg->max_value - pg->base_value) *
+ sin ( (2 * M_PI) / ((double) pg->duration_period.rel_value_us) *
+ time_delta.rel_value_us);
+ pref_value = pg->base_value + delta_value;
+ break;
+ default:
+ pref_value = 0.0;
+ break;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Current preference value is %f\n",
+ pref_value);
+ return pref_value;
+}
+
+
+static void
+set_pref_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct PreferenceGenerator *pg = cls;
+ double pref_value;
+ pg->set_task = GNUNET_SCHEDULER_NO_TASK;
+
+ pref_value = get_preference (pg);
+
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ "Setting preference for peer [%u] address [%u] for %s to %f\n",
+ pg->peer, pg->address_id,
+ GNUNET_ATS_print_preference_type (pg->kind), pref_value);
+
+ /* set performance here!
+ GNUNET_ATS_performance_change_preference(p->me->ats_perf_handle,
+ &p->dest->id, p->pg->kind, pref_value, GNUNET_ATS_PREFERENCE_END);
+*/
+
+ switch (pg->kind) {
+ case GNUNET_ATS_PREFERENCE_BANDWIDTH:
+ //p->pref_bandwidth = pref_value;
+ break;
+ case GNUNET_ATS_PREFERENCE_LATENCY:
+ //p->pref_delay = pref_value;
+ break;
+ default:
+ break;
+ }
+
+ pg->set_task = GNUNET_SCHEDULER_add_delayed (pg->frequency,
+ set_pref_task, pg);
+
+}
+
+static struct PreferenceGenerator *
+find_pref_gen (unsigned int peer, unsigned int address,
+ enum GNUNET_ATS_PreferenceKind kind)
+{
+ struct PreferenceGenerator *cur;
+ for (cur = pg_head; NULL != cur; cur = cur->next)
+ if ((cur->peer == peer) && (cur->address_id == address) && (cur->kind ==
kind))
+ return cur;
+ return NULL;
+}
+
+void
+GNUNET_ATS_solver_generate_preferences_stop (struct PreferenceGenerator *pg)
+{
+ GNUNET_CONTAINER_DLL_remove (pg_head, pg_tail, pg);
+
+ if (GNUNET_SCHEDULER_NO_TASK != pg->set_task)
+ {
+ GNUNET_SCHEDULER_cancel (pg->set_task);
+ pg->set_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Removing old up preference generator peer [%u] address [%u] `%s'\n",
+ pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(pg->kind));
+
+ GNUNET_free (pg);
+}
+
+
+/**
+ * Generate between the source master and the partner and set preferences with
a
+ * value depending on the generator.
+ *
+ * @param src source
+ * @param dest partner
+ * @param type type of preferences to generate
+ * @param base_rate traffic base rate to send data with
+ * @param max_rate traffic maximum rate to send data with
+ * @param period duration of a period of traffic generation (~ 1/frequency)
+ * @param duration how long to generate traffic
+ * @return the traffic generator
+ */
+struct PreferenceGenerator *
+GNUNET_ATS_solver_generate_preferences_start (unsigned int peer,
+ unsigned int address_id,
+ enum GeneratorType type,
+ long int base_value,
+ long int value_rate,
+ struct GNUNET_TIME_Relative period,
+ struct GNUNET_TIME_Relative frequency,
+ enum GNUNET_ATS_PreferenceKind kind)
+{
+ struct PreferenceGenerator *pg;
+
+ pg = GNUNET_new (struct PreferenceGenerator);
+ GNUNET_CONTAINER_DLL_insert (pg_head, pg_tail, pg);
+ pg->type = type;
+ pg->peer = peer;
+ pg->address_id = address_id;
+ pg->kind = kind;
+ pg->base_value = base_value;
+ pg->max_value = value_rate;
+ pg->duration_period = period;
+ pg->frequency = frequency;
+ pg->time_start = GNUNET_TIME_absolute_get();
+
+ switch (type) {
+ case GNUNET_ATS_TEST_TG_CONSTANT:
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Setting up constant preference generator peer [%u] address [%u]
`%s' max %u Bips\n",
+ pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind),
+ base_value);
+ break;
+ case GNUNET_ATS_TEST_TG_LINEAR:
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Setting up linear preference generator peer [%u] address [%u] `%s'
min %u Bips max %u Bips\n",
+ pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind),
+ base_value, value_rate);
+ break;
+ case GNUNET_ATS_TEST_TG_SINUS:
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Setting up sinus preference generator peer [%u] address [%u] `%s'
baserate %u Bips, amplitude %u Bps\n",
+ pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind),
+ base_value, value_rate);
+
+ break;
+ case GNUNET_ATS_TEST_TG_RANDOM:
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Setting up random preference generator peer [%u] address [%u] `%s'
min %u Bips max %u Bps\n",
+ pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind),
+ base_value, value_rate);
+ break;
+ default:
+ break;
+ }
+
+ pg->set_task = GNUNET_SCHEDULER_add_now (&set_pref_task, pg);
+ return pg;
+}
+
+
+
+/**
+ * Stop all preferences generators
+ */
+void
+GNUNET_ATS_solver_generate_preferences_stop_all ()
+{
+ struct PreferenceGenerator *cur;
+ struct PreferenceGenerator *next;
+ next = pg_head;
+ for (cur = next; NULL != cur; cur = next)
+ {
+ next = cur->next;
+ GNUNET_ATS_solver_generate_preferences_stop(cur);
+ }
+}
+
+
+
+/**
* Experiments
*/
@@ -87,7 +309,6 @@
return "";
}
-
static struct Experiment *
create_experiment ()
{
@@ -1237,62 +1458,30 @@
static void
enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op)
{
- /*
- struct BenchmarkPeer *peer;
- struct BenchmarkPartner *partner;
-
- peer = GNUNET_ATS_TEST_get_peer (op->src_id);
- if (NULL == peer)
+ struct PreferenceGenerator *pg;
+ if (NULL != (pg = find_pref_gen (op->peer_id, op->address_id,
op->pref_type)))
{
- GNUNET_break (0);
- return;
+ GNUNET_ATS_solver_generate_preferences_stop (pg);
+ GNUNET_free (pg);
}
- partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id);
- if (NULL == partner)
- {
- GNUNET_break (0);
- return;
- }
-
- fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id);
-
- if (NULL != partner->pg)
- {
- fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",
- op->src_id, op->dest_id);
- GNUNET_ATS_TEST_generate_preferences_stop(partner->pg);
- partner->pg = NULL;
- }
-
- partner->pg = GNUNET_ATS_TEST_generate_preferences_start(peer, partner,
- op->tg_type, op->base_rate, op->max_rate, op->period, op->frequency,
- op->pref_type);
- */
+ GNUNET_ATS_solver_generate_preferences_start (op->peer_id,
+ op->address_id,
+ op->type,
+ op->base_rate,
+ op->max_rate,
+ op->period,
+ op->frequency,
+ op->pref_type);
}
static void
enforce_stop_preference (struct GNUNET_ATS_TEST_Operation *op)
{
- /*
- struct BenchmarkPartner *p;
- p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id);
- if (NULL == p)
- {
- GNUNET_break (0);
- return;
- }
-
- fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id);
-
- if (NULL != p->pg)
- {
- fprintf (stderr, "Stopping preference between master %llu slave %llu\n",
- op->src_id, op->dest_id);
- GNUNET_ATS_TEST_generate_preferences_stop (p->pg);
- p->pg = NULL;
- }
- */
+ struct PreferenceGenerator *pg = find_pref_gen(op->peer_id, op->address_id,
+ op->pref_type);
+ if (NULL != pg)
+ GNUNET_ATS_solver_generate_preferences_stop (pg);
}
static void enforce_episode (struct Episode *ep)
@@ -1879,6 +2068,7 @@
done ()
{
/* Clean up experiment */
+ GNUNET_ATS_solver_generate_preferences_stop_all ();
GNUNET_ATS_solvers_experimentation_stop (e);
e = NULL;
@@ -1903,7 +2093,7 @@
// GNUNET_ATS_TEST_generate_traffic_stop_all();
/* Stop all preference generations */
- // GNUNET_ATS_TEST_generate_preferences_stop_all ();
+ GNUNET_ATS_solver_generate_preferences_stop_all ();
/*
evaluate (duration);
Modified: gnunet/src/ats/gnunet-ats-solver-eval.h
===================================================================
--- gnunet/src/ats/gnunet-ats-solver-eval.h 2014-02-07 17:37:32 UTC (rev
32255)
+++ gnunet/src/ats/gnunet-ats-solver-eval.h 2014-02-07 18:13:06 UTC (rev
32256)
@@ -121,246 +121,30 @@
GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb;
};
-
-/**
- * A single logging time step for a partner
- */
-struct PartnerLoggingTimestep
+struct PreferenceGenerator
{
- /**
- * Peer
- */
- struct BenchmarkPeer *slave;
+ struct PreferenceGenerator *prev;
+ struct PreferenceGenerator *next;
- /**
- * Total number of messages this peer has sent
- */
- unsigned int total_messages_sent;
+ enum GeneratorType type;
- /**
- * Total number of bytes this peer has sent
- */
- unsigned int total_bytes_sent;
+ unsigned int peer;
+ unsigned int address_id;
- /**
- * Total number of messages this peer has received
- */
- unsigned int total_messages_received;
+ enum GNUNET_ATS_PreferenceKind kind;
- /**
- * Total number of bytes this peer has received
- */
- unsigned int total_bytes_received;
-
- /**
- * Total outbound throughput for master in Bytes / s
- */
- unsigned int throughput_sent;
-
- /**
- * Total inbound throughput for master in Bytes / s
- */
- unsigned int throughput_recv;
-
- /**
- * Accumulated RTT for all messages
- */
- unsigned int total_app_rtt;
-
- /**
- * Current application level delay
- */
- unsigned int app_rtt;
-
- /* Current ATS properties */
-
- uint32_t ats_distance;
-
- uint32_t ats_delay;
-
- uint32_t bandwidth_in;
-
- uint32_t bandwidth_out;
-
- uint32_t ats_utilization_up;
-
- uint32_t ats_utilization_down;
-
- uint32_t ats_network_type;
-
- uint32_t ats_cost_wan;
-
- uint32_t ats_cost_lan;
-
- uint32_t ats_cost_wlan;
-
- double pref_bandwidth;
- double pref_delay;
-};
-
-
-/**
- * A single logging time step for a peer
- */
-struct PeerLoggingTimestep
-{
- /**
- * Next in DLL
- */
- struct PeerLoggingTimestep *next;
-
- /**
- * Prev in DLL
- */
- struct PeerLoggingTimestep *prev;
-
- /**
- * Logging timestamp
- */
- struct GNUNET_TIME_Absolute timestamp;
-
- /**
- * Total number of messages this peer has sent
- */
- unsigned int total_messages_sent;
-
- /**
- * Total number of bytes this peer has sent
- */
- unsigned int total_bytes_sent;
-
- /**
- * Total number of messages this peer has received
- */
- unsigned int total_messages_received;
-
- /**
- * Total number of bytes this peer has received
- */
- unsigned int total_bytes_received;
-
- /**
- * Total outbound throughput for master in Bytes / s
- */
- unsigned int total_throughput_send;
-
- /**
- * Total inbound throughput for master in Bytes / s
- */
- unsigned int total_throughput_recv;
-
- /**
- * Logs for slaves
- */
- struct PartnerLoggingTimestep *slaves_log;
-};
-
-/**
- * Entry for a benchmark peer
- */
-struct LoggingPeer
-{
- /**
- * Peer
- */
- struct BenchmarkPeer *peer;
-
- /**
- * Start time
- */
- struct GNUNET_TIME_Absolute start;
-
- /**
- * DLL for logging entries: head
- */
- struct PeerLoggingTimestep *head;
-
- /**
- * DLL for logging entries: tail
- */
- struct PeerLoggingTimestep *tail;
-};
-
-
-struct LoggingHandle
-{
- /**
- * Logging task
- */
- GNUNET_SCHEDULER_TaskIdentifier log_task;
-
- /**
- * Reference to perf_ats' masters
- */
- int num_masters;
- int num_slaves;
- int running;
- int verbose;
- char *name;
+ long int base_value;
+ long int max_value;
+ struct GNUNET_TIME_Relative duration_period;
struct GNUNET_TIME_Relative frequency;
- /**
- * Log structure of length num_peers
- */
- struct LoggingPeer *lp;
+ GNUNET_SCHEDULER_TaskIdentifier set_task;
+ struct GNUNET_TIME_Absolute next_ping_transmission;
+ struct GNUNET_TIME_Absolute time_start;
};
-/**
- * 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, int
num_slaves,
- int verbose);
-/**
- * Stop logging
- *
- * @param l the logging handle
- */
-void
-GNUNET_ATS_TEST_logging_clean_up (struct LoggingHandle *l);
-
-/**
- * Stop logging
- *
- * @param l the logging handle
- */
-void
-GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l);
-
-/**
- * Log all data now
- *
- * @param l logging handle to use
- */
-void
-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_logging_write_to_file (struct LoggingHandle *l,
- char *test_name, int plots);
-
-
-
-
-
-
/* LEGACY */
#if 0
@@ -417,7 +201,7 @@
*/
typedef void
(*GNUNET_ATS_TEST_LogRequest) (void *cls,
- const struct GNUNET_HELLO_Address *address,
+ const struct GNUNET_HELLO_Address *address_id,
int address_active,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r32256 - in gnunet/src/ats: . experiments,
gnunet <=