aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2014-03-21 18:44:30 +0000
committerBart Polot <bart@net.in.tum.de>2014-03-21 18:44:30 +0000
commit21fb197613f700049963715b24a1ffc8aa97e421 (patch)
treec7640faea1f5a0bed99883df737e10bb1454ff1a /src/mesh
parenta046086765eaa8fa0014971ac4b619b82af0103a (diff)
downloadgnunet-21fb197613f700049963715b24a1ffc8aa97e421.tar.gz
gnunet-21fb197613f700049963715b24a1ffc8aa97e421.zip
- add stddev
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-mesh-profiler.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/mesh/gnunet-mesh-profiler.c b/src/mesh/gnunet-mesh-profiler.c
index 14316c5dd..e7be87b91 100644
--- a/src/mesh/gnunet-mesh-profiler.c
+++ b/src/mesh/gnunet-mesh-profiler.c
@@ -45,7 +45,7 @@
45/** 45/**
46 * Duration of each round. 46 * Duration of each round.
47 */ 47 */
48#define ROUND_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) 48#define ROUND_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
49 49
50/** 50/**
51 * Paximum ping period in milliseconds. Real period = rand (0, PING_PERIOD) 51 * Paximum ping period in milliseconds. Real period = rand (0, PING_PERIOD)
@@ -63,14 +63,14 @@
63#define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) 63#define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
64 64
65/** 65/**
66 * Ratio of peers active. First round always is 1.0. 66 * Total number of rounds.
67 */ 67 */
68static float rounds[] = {0.8, 0.7, 0.6, 0.5, 0.0}; 68#define number_rounds sizeof(rounds)/sizeof(rounds[0])
69 69
70/** 70/**
71 * Total number of rounds. 71 * Ratio of peers active. First round always is 1.0.
72 */ 72 */
73static const unsigned int number_rounds = sizeof(rounds)/sizeof(rounds[0]); 73static float rounds[] = {0.8, 0.7, 0.6, 0.5, 0.0};
74 74
75/** 75/**
76 * Message type for pings. 76 * Message type for pings.
@@ -271,8 +271,9 @@ show_end_data (void)
271 for (j = 0; j < PING_PEERS; j++) 271 for (j = 0; j < PING_PEERS; j++)
272 { 272 {
273 peer = &peers[j]; 273 peer = &peers[j];
274 FPRINTF (stdout, "ROUND %u PEER %u: %f, PINGS: %u, PONGS: %u\n", 274 FPRINTF (stdout,
275 i, j, ((float)peer->sum_delay[i])/peer->pongs[i], 275 "ROUND %3u PEER %3u: %10.2f / %10.2f, PINGS: %3u, PONGS: %3u\n",
276 i, j, peer->mean[i], sqrt (peer->var[i] / (peer->pongs[i] - 1)),
276 peer->pings[i], peer->pongs[i]); 277 peer->pings[i], peer->pongs[i]);
277 } 278 }
278 } 279 }
@@ -696,7 +697,8 @@ pong_handler (void *cls, struct GNUNET_MESH_Channel *channel,
696 struct MeshPingMessage *msg; 697 struct MeshPingMessage *msg;
697 struct GNUNET_TIME_Absolute send_time; 698 struct GNUNET_TIME_Absolute send_time;
698 struct GNUNET_TIME_Relative latency; 699 struct GNUNET_TIME_Relative latency;
699 unsigned int ping_round; 700 unsigned int r /* Ping round */;
701 float delta;
700 702
701 GNUNET_MESH_receive_done (channel); 703 GNUNET_MESH_receive_done (channel);
702 peer = &peers[n]; 704 peer = &peers[n];
@@ -705,12 +707,16 @@ pong_handler (void *cls, struct GNUNET_MESH_Channel *channel,
705 707
706 send_time = GNUNET_TIME_absolute_ntoh (msg->timestamp); 708 send_time = GNUNET_TIME_absolute_ntoh (msg->timestamp);
707 latency = GNUNET_TIME_absolute_get_duration (send_time); 709 latency = GNUNET_TIME_absolute_get_duration (send_time);
708 ping_round = ntohl (msg->round_number); 710 r = ntohl (msg->round_number);
709 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u <- %u (%u) latency: %s\n", 711 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u <- %u (%u) latency: %s\n",
710 get_index (peer), get_index (peer->dest), ntohl (msg->counter), 712 get_index (peer), get_index (peer->dest), ntohl (msg->counter),
711 GNUNET_STRINGS_relative_time_to_string (latency, GNUNET_NO)); 713 GNUNET_STRINGS_relative_time_to_string (latency, GNUNET_NO));
712 peer->sum_delay[ping_round] += latency.rel_value_us; 714
713 peer->pongs[ping_round]++; 715 /* Online variance calculation */
716 peer->pongs[r]++;
717 delta = latency.rel_value_us - peer->mean[r];
718 peer->mean[r] = peer->mean[r] + delta/peer->pongs[r];
719 peer->var[r] += delta * (latency.rel_value_us - peer->mean[r]);
714 720
715 return GNUNET_OK; 721 return GNUNET_OK;
716} 722}