aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-09-18 13:27:45 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-09-18 13:27:45 +0000
commita94bcd89e2a7980dd9de9b17d3395002951240e5 (patch)
treebca3812a1f86261a76f631535b1b5ebb6f389234 /src
parent01d5d427999d38d883defeb4855ce5f8ac7e540f (diff)
downloadgnunet-a94bcd89e2a7980dd9de9b17d3395002951240e5.tar.gz
gnunet-a94bcd89e2a7980dd9de9b17d3395002951240e5.zip
collecting log functionality
mv structs to perf_ats header
Diffstat (limited to 'src')
-rw-r--r--src/ats-tests/perf_ats.c169
-rw-r--r--src/ats-tests/perf_ats.h224
-rw-r--r--src/ats-tests/perf_ats_logging.c65
-rw-r--r--src/ats-tests/perf_ats_logging.h35
4 files changed, 291 insertions, 202 deletions
diff --git a/src/ats-tests/perf_ats.c b/src/ats-tests/perf_ats.c
index 9f4c48f8b..bdd306ec4 100644
--- a/src/ats-tests/perf_ats.c
+++ b/src/ats-tests/perf_ats.c
@@ -28,7 +28,7 @@
28#include "gnunet_testbed_service.h" 28#include "gnunet_testbed_service.h"
29#include "gnunet_ats_service.h" 29#include "gnunet_ats_service.h"
30#include "gnunet_core_service.h" 30#include "gnunet_core_service.h"
31#include "perf_ats_logging.h" 31#include "perf_ats.h"
32 32
33#define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) 33#define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
34#define BENCHMARK_DURATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) 34#define BENCHMARK_DURATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
@@ -46,52 +46,6 @@
46#define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) 46#define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
47 47
48/** 48/**
49 * Information about a benchmarking partner
50 */
51struct BenchmarkPartner
52{
53 /**
54 * The peer itself this partner belongs to
55 */
56 struct BenchmarkPeer *me;
57
58 /**
59 * The partner peer
60 */
61 struct BenchmarkPeer *dest;
62
63 /**
64 * Core transmit handles
65 */
66 struct GNUNET_CORE_TransmitHandle *cth;
67
68 /**
69 * Transport transmit handles
70 */
71 struct GNUNET_TRANSPORT_TransmitHandle *tth;
72
73 /**
74 * Number of messages sent to this partner
75 */
76 unsigned int messages_sent;
77
78 /**
79 * Number of bytes sent to this partner
80 */
81 unsigned int bytes_sent;
82
83 /**
84 * Number of messages received from this partner
85 */
86 unsigned int messages_received;
87
88 /**
89 * Number of bytes received from this partner
90 */
91 unsigned int bytes_received;
92};
93
94/**
95 * Connect peers with testbed 49 * Connect peers with testbed
96 */ 50 */
97struct TestbedConnectOperation 51struct TestbedConnectOperation
@@ -113,123 +67,6 @@ struct TestbedConnectOperation
113}; 67};
114 68
115/** 69/**
116 * Information we track for a peer in the testbed.
117 */
118struct BenchmarkPeer
119{
120 /**
121 * Handle with testbed.
122 */
123 struct GNUNET_TESTBED_Peer *peer;
124
125 /**
126 * Unique identifier
127 */
128 int no;
129
130 /**
131 * Is this peer a measter: GNUNET_YES/GNUNET_NO
132 */
133 int master;
134
135 /**
136 * Peer ID
137 */
138 struct GNUNET_PeerIdentity id;
139
140 /**
141 * Testbed operation to get peer information
142 */
143 struct GNUNET_TESTBED_Operation *peer_id_op;
144
145 /**
146 * Testbed operation to connect to ATS performance service
147 */
148 struct GNUNET_TESTBED_Operation *ats_perf_op;
149
150 /**
151 * Testbed operation to connect to core
152 */
153 struct GNUNET_TESTBED_Operation *comm_op;
154
155 /**
156 * ATS performance handle
157 */
158 struct GNUNET_ATS_PerformanceHandle *ats_perf_handle;
159
160 /**
161 * Masters only:
162 * Testbed connect operations to connect masters to slaves
163 */
164 struct TestbedConnectOperation *core_connect_ops;
165
166 /**
167 * Core handle
168 */
169 struct GNUNET_CORE_Handle *ch;
170
171 /**
172 * Core handle
173 */
174 struct GNUNET_TRANSPORT_Handle *th;
175
176 /**
177 * Masters only:
178 * Peer to set ATS preferences for
179 */
180 struct BenchmarkPeer *pref_partner;
181
182 /**
183 * Masters only
184 * Progress task
185 */
186 GNUNET_SCHEDULER_TaskIdentifier ats_task;
187
188 /**
189 * Masters only
190 * Progress task
191 */
192 double pref_value;
193
194 /**
195 * Array of partners with num_slaves entries (if master) or
196 * num_master entries (if slave)
197 */
198 struct BenchmarkPartner *partners;
199
200 /**
201 * Number of core connections
202 */
203 int core_connections;
204
205 /**
206 * Masters only:
207 * Number of connections to slave peers
208 */
209 int core_slave_connections;
210
211 /**
212 * Total number of messages this peer has sent
213 */
214 unsigned int total_messages_sent;
215
216 /**
217 * Total number of bytes this peer has sent
218 */
219 unsigned int total_bytes_sent;
220
221 /**
222 * Total number of messages this peer has received
223 */
224 unsigned int total_messages_received;
225
226 /**
227 * Total number of bytes this peer has received
228 */
229 unsigned int total_bytes_received;
230};
231
232/**
233 * Overall state of the performance benchmark 70 * Overall state of the performance benchmark
234 */ 71 */
235struct BenchmarkState 72struct BenchmarkState
@@ -614,7 +451,7 @@ do_benchmark ()
614 mps[c_m].ats_task = GNUNET_SCHEDULER_add_now (&ats_pref_task, &mps[c_m]); 451 mps[c_m].ats_task = GNUNET_SCHEDULER_add_now (&ats_pref_task, &mps[c_m]);
615 } 452 }
616 if (GNUNET_YES == logging) 453 if (GNUNET_YES == logging)
617 perf_logging_start(); 454 perf_logging_start (mps, num_masters);
618} 455}
619 456
620static void 457static void
@@ -1209,6 +1046,7 @@ main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers,
1209 mps[c_m].pref_value = TEST_ATS_PREFRENCE_START; 1046 mps[c_m].pref_value = TEST_ATS_PREFRENCE_START;
1210 mps[c_m].partners = 1047 mps[c_m].partners =
1211 GNUNET_malloc (num_slaves * sizeof (struct BenchmarkPeer)); 1048 GNUNET_malloc (num_slaves * sizeof (struct BenchmarkPeer));
1049 mps[c_m].num_partners = num_slaves;
1212 /* Initialize partners */ 1050 /* Initialize partners */
1213 for (c_s = 0; c_s < num_slaves; c_s++) 1051 for (c_s = 0; c_s < num_slaves; c_s++)
1214 { 1052 {
@@ -1228,6 +1066,7 @@ main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers,
1228 sps[c_s].master = GNUNET_NO; 1066 sps[c_s].master = GNUNET_NO;
1229 sps[c_s].partners = 1067 sps[c_s].partners =
1230 GNUNET_malloc (num_masters * sizeof (struct BenchmarkPeer)); 1068 GNUNET_malloc (num_masters * sizeof (struct BenchmarkPeer));
1069 sps[c_s].num_partners = num_masters;
1231 /* Initialize partners */ 1070 /* Initialize partners */
1232 for (c_m = 0; c_m < num_masters; c_m++) 1071 for (c_m = 0; c_m < num_masters; c_m++)
1233 { 1072 {
diff --git a/src/ats-tests/perf_ats.h b/src/ats-tests/perf_ats.h
new file mode 100644
index 000000000..b8e0f1eb7
--- /dev/null
+++ b/src/ats-tests/perf_ats.h
@@ -0,0 +1,224 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010-2013 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 */
20/**
21 * @file ats/perf_ats.c
22 * @brief ats benchmark: start peers and modify preferences, monitor change over time
23 * @author Christian Grothoff
24 * @author Matthias Wachs
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_testbed_service.h"
29#include "gnunet_ats_service.h"
30#include "gnunet_core_service.h"
31
32#define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
33#define BENCHMARK_DURATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
34#define TESTNAME_PREFIX "perf_ats_"
35#define DEFAULT_SLAVES_NUM 3
36#define DEFAULT_MASTERS_NUM 1
37
38#define TEST_ATS_PREFRENCE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
39#define TEST_ATS_PREFRENCE_START 1.0
40#define TEST_ATS_PREFRENCE_DELTA 1.0
41
42#define TEST_MESSAGE_TYPE_PING 12345
43#define TEST_MESSAGE_TYPE_PONG 12346
44#define TEST_MESSAGE_SIZE 1000
45#define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
46
47/**
48 * Information about a benchmarking partner
49 */
50struct BenchmarkPartner
51{
52 /**
53 * The peer itself this partner belongs to
54 */
55 struct BenchmarkPeer *me;
56
57 /**
58 * The partner peer
59 */
60 struct BenchmarkPeer *dest;
61
62 /**
63 * Core transmit handles
64 */
65 struct GNUNET_CORE_TransmitHandle *cth;
66
67 /**
68 * Transport transmit handles
69 */
70 struct GNUNET_TRANSPORT_TransmitHandle *tth;
71
72 /**
73 * Number of messages sent to this partner
74 */
75 unsigned int messages_sent;
76
77 /**
78 * Number of bytes sent to this partner
79 */
80 unsigned int bytes_sent;
81
82 /**
83 * Number of messages received from this partner
84 */
85 unsigned int messages_received;
86
87 /**
88 * Number of bytes received from this partner
89 */
90 unsigned int bytes_received;
91};
92
93
94/**
95 * Information we track for a peer in the testbed.
96 */
97struct BenchmarkPeer
98{
99 /**
100 * Handle with testbed.
101 */
102 struct GNUNET_TESTBED_Peer *peer;
103
104 /**
105 * Unique identifier
106 */
107 int no;
108
109 /**
110 * Is this peer a measter: GNUNET_YES/GNUNET_NO
111 */
112 int master;
113
114 /**
115 * Peer ID
116 */
117 struct GNUNET_PeerIdentity id;
118
119 /**
120 * Testbed operation to get peer information
121 */
122 struct GNUNET_TESTBED_Operation *peer_id_op;
123
124 /**
125 * Testbed operation to connect to ATS performance service
126 */
127 struct GNUNET_TESTBED_Operation *ats_perf_op;
128
129 /**
130 * Testbed operation to connect to core
131 */
132 struct GNUNET_TESTBED_Operation *comm_op;
133
134 /**
135 * ATS performance handle
136 */
137 struct GNUNET_ATS_PerformanceHandle *ats_perf_handle;
138
139 /**
140 * Masters only:
141 * Testbed connect operations to connect masters to slaves
142 */
143 struct TestbedConnectOperation *core_connect_ops;
144
145 /**
146 * Core handle
147 */
148 struct GNUNET_CORE_Handle *ch;
149
150 /**
151 * Core handle
152 */
153 struct GNUNET_TRANSPORT_Handle *th;
154
155 /**
156 * Masters only:
157 * Peer to set ATS preferences for
158 */
159 struct BenchmarkPeer *pref_partner;
160
161 /**
162 * Masters only
163 * Progress task
164 */
165 GNUNET_SCHEDULER_TaskIdentifier ats_task;
166
167 /**
168 * Masters only
169 * Progress task
170 */
171 double pref_value;
172
173 /**
174 * Array of partners with num_slaves entries (if master) or
175 * num_master entries (if slave)
176 */
177 struct BenchmarkPartner *partners;
178
179 /**
180 * Number of partners
181 */
182 int num_partners;
183
184 /**
185 * Number of core connections
186 */
187 int core_connections;
188
189 /**
190 * Masters only:
191 * Number of connections to slave peers
192 */
193 int core_slave_connections;
194
195 /**
196 * Total number of messages this peer has sent
197 */
198 unsigned int total_messages_sent;
199
200 /**
201 * Total number of bytes this peer has sent
202 */
203 unsigned int total_bytes_sent;
204
205 /**
206 * Total number of messages this peer has received
207 */
208 unsigned int total_messages_received;
209
210 /**
211 * Total number of bytes this peer has received
212 */
213 unsigned int total_bytes_received;
214};
215
216
217void
218perf_logging_stop ();
219
220void
221perf_logging_start (struct BenchmarkPeer *masters, int num_masters);
222
223
224/* end of file perf_ats.h */
diff --git a/src/ats-tests/perf_ats_logging.c b/src/ats-tests/perf_ats_logging.c
index 9cdccf54b..1864e0180 100644
--- a/src/ats-tests/perf_ats_logging.c
+++ b/src/ats-tests/perf_ats_logging.c
@@ -25,18 +25,79 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "perf_ats.h"
29
30#define LOGGING_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500)
31
32static GNUNET_SCHEDULER_TaskIdentifier log_task;
33
34static struct BenchmarkPeer *peers;
35static int num_peers;
36
37static void
38write_to_file ()
39{
40
41}
42
43static void
44collect_log_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
45{
46 int c_m;
47 int c_s;
48 log_task = GNUNET_SCHEDULER_NO_TASK;
49
50 struct BenchmarkPeer *m;
51 struct BenchmarkPartner *p;
52
53 for (c_m = 0; c_m < num_peers; c_m++)
54 {
55 m = &peers[c_m];
56 for (c_s = 0; c_s < m->num_partners; c_s++)
57 {
58 p = &peers[c_m].partners[c_s];
59 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
60 "Master [%u]: slave [%u]\n",
61 m->no, p->dest->no);
62 }
63 }
64
65 if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
66 return;
67
68 log_task = GNUNET_SCHEDULER_add_delayed (LOGGING_FREQUENCY,
69 &collect_log_task, NULL);
70}
71
28 72
29void 73void
30perf_logging_stop () 74perf_logging_stop ()
31{ 75{
76 struct GNUNET_SCHEDULER_TaskContext tc;
77
78 if (GNUNET_SCHEDULER_NO_TASK != log_task)
79 GNUNET_SCHEDULER_cancel (log_task);
80 log_task = GNUNET_SCHEDULER_NO_TASK;
81 tc.reason = GNUNET_SCHEDULER_REASON_SHUTDOWN;
82 collect_log_task (NULL, &tc);
83
32 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 84 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
33 _("Start logging\n")); 85 _("Stop logging\n"));
86
87 write_to_file ();
34} 88}
35 89
36void 90void
37perf_logging_start () 91perf_logging_start (struct BenchmarkPeer *masters, int num_masters)
38{ 92{
39 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 93 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
40 _("Start logging\n")); 94 _("Start logging\n"));
95
96 peers = masters;
97 num_peers = num_masters;
98
99 /* Schedule logging task */
100 log_task = GNUNET_SCHEDULER_add_now (&collect_log_task, NULL);
41} 101}
42/* end of file perf_ats_logging.c */ 102/* end of file perf_ats_logging.c */
103
diff --git a/src/ats-tests/perf_ats_logging.h b/src/ats-tests/perf_ats_logging.h
deleted file mode 100644
index 94a9a6590..000000000
--- a/src/ats-tests/perf_ats_logging.h
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010-2013 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 */
20/**
21 * @file ats/perf_ats_logging.c
22 * @brief ats benchmark: logging for performance tests
23 * @author Christian Grothoff
24 * @author Matthias Wachs
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28
29void
30perf_logging_stop ();
31
32void
33perf_logging_start ();
34
35/* end of file perf_ats_logging.c */