diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-07-11 16:33:55 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-07-11 16:33:55 +0000 |
commit | f6882edc3a6a5528897dc92ed8eca0aa1da4ab6a (patch) | |
tree | 5cd4bc337986bdbed077a65b4c26f8d9c8ed3f74 /src/fragmentation | |
parent | 9b47032b08f64aec95566e0bbaffd39dc225fc51 (diff) | |
download | gnunet-f6882edc3a6a5528897dc92ed8eca0aa1da4ab6a.tar.gz gnunet-f6882edc3a6a5528897dc92ed8eca0aa1da4ab6a.zip |
adding test -- currently failing
Diffstat (limited to 'src/fragmentation')
-rw-r--r-- | src/fragmentation/Makefile.am | 22 | ||||
-rw-r--r-- | src/fragmentation/fragmentation_new.c | 23 | ||||
-rw-r--r-- | src/fragmentation/test_fragmentation.c | 475 | ||||
-rw-r--r-- | src/fragmentation/test_fragmentation_data.conf | 0 |
4 files changed, 125 insertions, 395 deletions
diff --git a/src/fragmentation/Makefile.am b/src/fragmentation/Makefile.am index 15e356fcc..e20d3efb5 100644 --- a/src/fragmentation/Makefile.am +++ b/src/fragmentation/Makefile.am | |||
@@ -14,18 +14,20 @@ libgnunetfragmentation_la_SOURCES = \ | |||
14 | fragmentation_new.c \ | 14 | fragmentation_new.c \ |
15 | defragmentation_new.c | 15 | defragmentation_new.c |
16 | libgnunetfragmentation_la_LIBADD = \ | 16 | libgnunetfragmentation_la_LIBADD = \ |
17 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
17 | $(top_builddir)/src/util/libgnunetutil.la | 18 | $(top_builddir)/src/util/libgnunetutil.la |
18 | 19 | ||
19 | #check_PROGRAMS = \ | 20 | check_PROGRAMS = \ |
20 | # test_fragmentation | 21 | test_fragmentation |
21 | 22 | ||
22 | #if ENABLE_TEST_RUN | 23 | if ENABLE_TEST_RUN |
23 | #TESTS = $(check_PROGRAMS) | 24 | TESTS = $(check_PROGRAMS) |
24 | #endif | 25 | endif |
25 | 26 | ||
26 | #test_fragmentation_SOURCES = \ | 27 | test_fragmentation_SOURCES = \ |
27 | # test_frag_ji.c | 28 | test_fragmentation.c |
28 | #test_fragmentation_LDADD = \ | 29 | test_fragmentation_LDADD = \ |
29 | # $(top_builddir)/src/fragmentation/libgnunetfragmentation.la \ | 30 | $(top_builddir)/src/fragmentation/libgnunetfragmentation.la \ |
30 | # $(top_builddir)/src/util/libgnunetutil.la | 31 | $(top_builddir)/src/util/libgnunetutil.la |
31 | 32 | ||
33 | EXTRA_DIST = test_fragmentation_data.conf \ No newline at end of file | ||
diff --git a/src/fragmentation/fragmentation_new.c b/src/fragmentation/fragmentation_new.c index 6a2747e4d..17b4bb0ab 100644 --- a/src/fragmentation/fragmentation_new.c +++ b/src/fragmentation/fragmentation_new.c | |||
@@ -138,12 +138,14 @@ transmit_next (void *cls, | |||
138 | fsize = size % (fc->mtu - sizeof (struct FragmentHeader)) + sizeof (struct FragmentHeader); | 138 | fsize = size % (fc->mtu - sizeof (struct FragmentHeader)) + sizeof (struct FragmentHeader); |
139 | else | 139 | else |
140 | fsize = fc->mtu; | 140 | fsize = fc->mtu; |
141 | delay = GNUNET_BANDWIDTH_tracker_get_delay (fc->tracker, | 141 | if (fc->tracker != NULL) |
142 | fsize); | 142 | delay = GNUNET_BANDWIDTH_tracker_get_delay (fc->tracker, |
143 | fsize); | ||
144 | else | ||
145 | delay = GNUNET_TIME_UNIT_ZERO; | ||
143 | if (delay.rel_value > 0) | 146 | if (delay.rel_value > 0) |
144 | { | 147 | { |
145 | fc->task = GNUNET_SCHEDULER_add_delayed (GNUNET_BANDWIDTH_tracker_get_delay (fc->tracker, | 148 | fc->task = GNUNET_SCHEDULER_add_delayed (delay, |
146 | fc->mtu), | ||
147 | &transmit_next, | 149 | &transmit_next, |
148 | fc); | 150 | fc); |
149 | return; | 151 | return; |
@@ -163,7 +165,8 @@ transmit_next (void *cls, | |||
163 | &mbuf[bit * (fc->mtu - sizeof (struct FragmentHeader))], | 165 | &mbuf[bit * (fc->mtu - sizeof (struct FragmentHeader))], |
164 | fsize - sizeof (struct FragmentHeader)); | 166 | fsize - sizeof (struct FragmentHeader)); |
165 | fc->proc (fc->proc_cls, &fh->header); | 167 | fc->proc (fc->proc_cls, &fh->header); |
166 | GNUNET_BANDWIDTH_tracker_consume (fc->tracker, fsize); | 168 | if (NULL != fc->tracker) |
169 | GNUNET_BANDWIDTH_tracker_consume (fc->tracker, fsize); | ||
167 | GNUNET_STATISTICS_update (fc->stats, | 170 | GNUNET_STATISTICS_update (fc->stats, |
168 | _("Fragments transmitted"), | 171 | _("Fragments transmitted"), |
169 | 1, GNUNET_NO); | 172 | 1, GNUNET_NO); |
@@ -179,8 +182,11 @@ transmit_next (void *cls, | |||
179 | fsize = size % (fc->mtu - sizeof (struct FragmentHeader)); | 182 | fsize = size % (fc->mtu - sizeof (struct FragmentHeader)); |
180 | else | 183 | else |
181 | fsize = fc->mtu; | 184 | fsize = fc->mtu; |
182 | delay = GNUNET_BANDWIDTH_tracker_get_delay (fc->tracker, | 185 | if (NULL != fc->tracker) |
183 | fsize); | 186 | delay = GNUNET_BANDWIDTH_tracker_get_delay (fc->tracker, |
187 | fsize); | ||
188 | else | ||
189 | delay = GNUNET_TIME_UNIT_ZERO; | ||
184 | if (wrap) | 190 | if (wrap) |
185 | { | 191 | { |
186 | /* full round transmitted wait 2x delay for ACK before going again */ | 192 | /* full round transmitted wait 2x delay for ACK before going again */ |
@@ -189,8 +195,7 @@ transmit_next (void *cls, | |||
189 | fc->last_round = GNUNET_TIME_absolute_get (); | 195 | fc->last_round = GNUNET_TIME_absolute_get (); |
190 | fc->wack = GNUNET_YES; | 196 | fc->wack = GNUNET_YES; |
191 | } | 197 | } |
192 | fc->task = GNUNET_SCHEDULER_add_delayed (GNUNET_BANDWIDTH_tracker_get_delay (fc->tracker, | 198 | fc->task = GNUNET_SCHEDULER_add_delayed (delay, |
193 | fc->mtu), | ||
194 | &transmit_next, | 199 | &transmit_next, |
195 | fc); | 200 | fc); |
196 | } | 201 | } |
diff --git a/src/fragmentation/test_fragmentation.c b/src/fragmentation/test_fragmentation.c index 1aec7bf36..639c0ef17 100644 --- a/src/fragmentation/test_fragmentation.c +++ b/src/fragmentation/test_fragmentation.c | |||
@@ -22,418 +22,141 @@ | |||
22 | * @brief test for fragmentation.c | 22 | * @brief test for fragmentation.c |
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | */ | 24 | */ |
25 | |||
26 | /** | ||
27 | * Testcase for defragmentation code. | ||
28 | * We have testcases for: | ||
29 | * - 2 fragments, aligned, [0,16),[16,32) | ||
30 | * - n (50) fragments, [i*16,(i+1)*16) | ||
31 | * - n (50) fragments, [0,i*16) + [50*16,51*16) | ||
32 | * - n (100) fragments, inserted in interleaved order (holes in sequence) | ||
33 | * - holes in sequence | ||
34 | * - other overlaps | ||
35 | * - timeouts | ||
36 | * - multiple entries in GNUNET_hash-list | ||
37 | * - id collisions in GNUNET_hash-list | ||
38 | */ | ||
39 | |||
40 | #include "platform.h" | 25 | #include "platform.h" |
41 | #include "gnunet_fragmentation_lib.h" | 26 | #include "gnunet_fragmentation_lib.h" |
42 | 27 | ||
43 | #if 0 | 28 | #define NUM_MSGS 1 |
44 | |||
45 | /* -- to speed up the testcases -- */ | ||
46 | #define DEFRAGMENTATION_TIMEOUT (1 * GNUNET_CRON_SECONDS) | ||
47 | |||
48 | |||
49 | static GNUNET_PeerIdentity mySender; | ||
50 | static char *myMsg; | ||
51 | static unsigned short myMsgLen; | ||
52 | |||
53 | /* static buffers to avoid lots of malloc/free */ | ||
54 | static char masterBuffer[65536]; | ||
55 | static char resultBuffer[65536]; | ||
56 | |||
57 | static void | ||
58 | handleHelper (const GNUNET_PeerIdentity * sender, | ||
59 | const char *msg, | ||
60 | const unsigned int len, int wasEncrypted, GNUNET_TSession * ts) | ||
61 | { | ||
62 | GNUNET_GE_ASSERT (NULL, | ||
63 | 0 == memcmp (sender, &mySender, | ||
64 | sizeof (GNUNET_PeerIdentity))); | ||
65 | myMsg = resultBuffer; | ||
66 | memcpy (resultBuffer, msg, len); | ||
67 | myMsgLen = len; | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * Wait long enough to force all fragments to timeout. | ||
72 | */ | ||
73 | static void | ||
74 | makeTimeout () | ||
75 | { | ||
76 | GNUNET_thread_sleep (DEFRAGMENTATION_TIMEOUT * 2); | ||
77 | defragmentationPurgeCron (NULL); | ||
78 | } | ||
79 | |||
80 | /** | ||
81 | * Create a fragment. The data-portion will be filled | ||
82 | * with a sequence of numbers from start+id to start+len-1+id. | ||
83 | * | ||
84 | * @param pep pointer to the ethernet frame/buffer | ||
85 | * @param ip pointer to the ip-header | ||
86 | * @param start starting-offset | ||
87 | * @param length of the data portion | ||
88 | * @param id the identity of the fragment | ||
89 | */ | ||
90 | static GNUNET_MessageHeader * | ||
91 | makeFragment (unsigned short start, | ||
92 | unsigned short size, unsigned short tot, int id) | ||
93 | { | ||
94 | P2P_fragmentation_MESSAGE *frag; | ||
95 | int i; | ||
96 | |||
97 | frag = (P2P_fragmentation_MESSAGE *) masterBuffer; | ||
98 | frag->id = htonl (id); | ||
99 | frag->off = htons (start); | ||
100 | frag->len = htons (tot); | ||
101 | frag->header.size = htons (sizeof (P2P_fragmentation_MESSAGE) + size); | ||
102 | |||
103 | for (i = 0; i < size; i++) | ||
104 | ((char *) &frag[1])[i] = (char) i + id + start; | ||
105 | return &frag->header; | ||
106 | } | ||
107 | |||
108 | /** | ||
109 | * Check that the packet received is what we expected to | ||
110 | * get. | ||
111 | * @param id the expected id | ||
112 | * @param len the expected length | ||
113 | */ | ||
114 | static void | ||
115 | checkPacket (int id, unsigned int len) | ||
116 | { | ||
117 | int i; | ||
118 | |||
119 | GNUNET_GE_ASSERT (NULL, myMsg != NULL); | ||
120 | GNUNET_GE_ASSERT (NULL, myMsgLen == len); | ||
121 | for (i = 0; i < len; i++) | ||
122 | GNUNET_GE_ASSERT (NULL, myMsg[i] == (char) (i + id)); | ||
123 | myMsgLen = 0; | ||
124 | myMsg = NULL; | ||
125 | } | ||
126 | |||
127 | 29 | ||
128 | /* **************** actual testcases ***************** */ | 30 | #define MTU 1111 |
129 | 31 | ||
130 | static void | 32 | static int ret = 1; |
131 | testSimpleFragment () | ||
132 | { | ||
133 | GNUNET_MessageHeader *pep; | ||
134 | 33 | ||
135 | pep = makeFragment (0, 16, 32, 42); | 34 | static struct GNUNET_DEFRAGMENT_Context *defrag; |
136 | processFragment (&mySender, pep); | ||
137 | GNUNET_GE_ASSERT (NULL, myMsg == NULL); | ||
138 | pep = makeFragment (16, 16, 32, 42); | ||
139 | processFragment (&mySender, pep); | ||
140 | checkPacket (42, 32); | ||
141 | } | ||
142 | 35 | ||
143 | static void | 36 | static struct GNUNET_FRAGMENT_Context *frags[NUM_MSGS]; |
144 | testSimpleFragmentTimeout () | ||
145 | { | ||
146 | GNUNET_MessageHeader *pep; | ||
147 | |||
148 | pep = makeFragment (0, 16, 32, 42); | ||
149 | processFragment (&mySender, pep); | ||
150 | GNUNET_GE_ASSERT (NULL, myMsg == NULL); | ||
151 | makeTimeout (); | ||
152 | pep = makeFragment (16, 16, 32, 42); | ||
153 | processFragment (&mySender, pep); | ||
154 | GNUNET_GE_ASSERT (NULL, myMsg == NULL); | ||
155 | pep = makeFragment (0, 16, 32, 42); | ||
156 | processFragment (&mySender, pep); | ||
157 | checkPacket (42, 32); | ||
158 | } | ||
159 | 37 | ||
160 | static void | 38 | static void |
161 | testSimpleFragmentReverse () | 39 | proc_msgs (void *cls, |
40 | const struct GNUNET_MessageHeader *hdr) | ||
162 | { | 41 | { |
163 | GNUNET_MessageHeader *pep; | 42 | static unsigned int total; |
164 | |||
165 | pep = makeFragment (16, 16, 32, 42); | ||
166 | processFragment (&mySender, pep); | ||
167 | GNUNET_GE_ASSERT (NULL, myMsg == NULL); | ||
168 | pep = makeFragment (0, 16, 32, 42); | ||
169 | processFragment (&mySender, pep); | ||
170 | checkPacket (42, 32); | ||
171 | } | ||
172 | 43 | ||
173 | static void | 44 | fprintf (stderr, "!"); |
174 | testManyFragments () | 45 | total++; |
175 | { | 46 | if (total == NUM_MSGS) |
176 | GNUNET_MessageHeader *pep; | ||
177 | int i; | ||
178 | |||
179 | for (i = 0; i < 50; i++) | ||
180 | { | 47 | { |
181 | pep = makeFragment (i * 16, 16, 51 * 16, 42); | 48 | ret = 0; |
182 | processFragment (&mySender, pep); | 49 | GNUNET_DEFRAGMENT_context_destroy (defrag); |
183 | GNUNET_GE_ASSERT (NULL, myMsg == NULL); | 50 | defrag = NULL; |
184 | } | 51 | } |
185 | pep = makeFragment (50 * 16, 16, 51 * 16, 42); | ||
186 | processFragment (&mySender, pep); | ||
187 | checkPacket (42, 51 * 16); | ||
188 | } | 52 | } |
189 | 53 | ||
54 | /** | ||
55 | * Process ACK (by passing to fragmenter) | ||
56 | */ | ||
190 | static void | 57 | static void |
191 | testManyFragmentsMegaLarge () | 58 | proc_acks (void *cls, |
192 | { | 59 | const struct GNUNET_MessageHeader *hdr) |
193 | GNUNET_MessageHeader *pep; | ||
194 | int i; | ||
195 | |||
196 | for (i = 0; i < 4000; i++) | ||
197 | { | ||
198 | pep = makeFragment (i * 16, 16, 4001 * 16, 42); | ||
199 | processFragment (&mySender, pep); | ||
200 | GNUNET_GE_ASSERT (NULL, myMsg == NULL); | ||
201 | } | ||
202 | pep = makeFragment (4000 * 16, 16, 4001 * 16, 42); | ||
203 | processFragment (&mySender, pep); | ||
204 | checkPacket (42, 4001 * 16); | ||
205 | } | ||
206 | |||
207 | static void | ||
208 | testLastFragmentEarly () | ||
209 | { | ||
210 | GNUNET_MessageHeader *pep; | ||
211 | int i; | ||
212 | |||
213 | for (i = 0; i < 5; i++) | ||
214 | { | ||
215 | pep = makeFragment (i * 16, 8, 6 * 16 + 8, 42); | ||
216 | processFragment (&mySender, pep); | ||
217 | GNUNET_GE_ASSERT (NULL, myMsg == NULL); | ||
218 | } | ||
219 | pep = makeFragment (5 * 16, 24, 6 * 16 + 8, 42); | ||
220 | processFragment (&mySender, pep); | ||
221 | for (i = 0; i < 5; i++) | ||
222 | { | ||
223 | pep = makeFragment (i * 16 + 8, 8, 6 * 16 + 8, 42); | ||
224 | processFragment (&mySender, pep); | ||
225 | } | ||
226 | checkPacket (42, 6 * 16 + 8); | ||
227 | } | ||
228 | |||
229 | static void | ||
230 | testManyInterleavedFragments () | ||
231 | { | ||
232 | GNUNET_MessageHeader *pep; | ||
233 | int i; | ||
234 | |||
235 | for (i = 0; i < 50; i++) | ||
236 | { | ||
237 | pep = makeFragment (i * 16, 8, 51 * 16 + 8, 42); | ||
238 | processFragment (&mySender, pep); | ||
239 | GNUNET_GE_ASSERT (NULL, myMsg == NULL); | ||
240 | } | ||
241 | for (i = 0; i < 50; i++) | ||
242 | { | ||
243 | pep = makeFragment (i * 16 + 8, 8, 51 * 16 + 8, 42); | ||
244 | processFragment (&mySender, pep); | ||
245 | GNUNET_GE_ASSERT (NULL, myMsg == NULL); | ||
246 | } | ||
247 | pep = makeFragment (50 * 16, 24, 51 * 16 + 8, 42); | ||
248 | processFragment (&mySender, pep); | ||
249 | checkPacket (42, 51 * 16 + 8); | ||
250 | } | ||
251 | |||
252 | static void | ||
253 | testManyInterleavedOverlappingFragments () | ||
254 | { | 60 | { |
255 | GNUNET_MessageHeader *pep; | 61 | unsigned int i; |
256 | int i; | 62 | int ret; |
257 | 63 | ||
258 | for (i = 0; i < 50; i++) | 64 | fprintf (stderr, "@"); |
259 | { | 65 | for (i=0;i<NUM_MSGS;i++) |
260 | pep = makeFragment (i * 32, 16, 51 * 32, 42); | ||
261 | processFragment (&mySender, pep); | ||
262 | GNUNET_GE_ASSERT (NULL, myMsg == NULL); | ||
263 | } | ||
264 | for (i = 0; i < 50; i++) | ||
265 | { | 66 | { |
266 | pep = makeFragment (i * 32 + 8, 24, 51 * 32, 42); | 67 | if (frags[i] == NULL) |
267 | processFragment (&mySender, pep); | 68 | return; |
268 | GNUNET_GE_ASSERT (NULL, myMsg == NULL); | 69 | ret = GNUNET_FRAGMENT_process_ack (frags[i], |
70 | hdr); | ||
71 | if (ret == GNUNET_OK) | ||
72 | { | ||
73 | GNUNET_FRAGMENT_context_destroy (frags[i]); | ||
74 | frags[i] = NULL; | ||
75 | return; | ||
76 | } | ||
77 | if (ret == GNUNET_NO) | ||
78 | return; | ||
269 | } | 79 | } |
270 | pep = makeFragment (50 * 32, 32, 51 * 32, 42); | 80 | fprintf (stderr, "Got ACK that nobody feels responsible for...\n"); |
271 | processFragment (&mySender, pep); | ||
272 | checkPacket (42, 51 * 32); | ||
273 | } | 81 | } |
274 | 82 | ||
275 | static void | ||
276 | testManyOverlappingFragments () | ||
277 | { | ||
278 | GNUNET_MessageHeader *pep; | ||
279 | int i; | ||
280 | |||
281 | for (i = 0; i < 50; i++) | ||
282 | { | ||
283 | pep = makeFragment (0, i * 16 + 16, 51 * 16, 42); | ||
284 | processFragment (&mySender, pep); | ||
285 | GNUNET_GE_ASSERT (NULL, myMsg == NULL); | ||
286 | } | ||
287 | pep = makeFragment (50 * 16, 16, 51 * 16, 42); | ||
288 | processFragment (&mySender, pep); | ||
289 | checkPacket (42, 51 * 16); | ||
290 | } | ||
291 | 83 | ||
84 | /** | ||
85 | * Process fragment (by passing to defrag). | ||
86 | */ | ||
292 | static void | 87 | static void |
293 | testManyOverlappingFragmentsTimeout () | 88 | proc_frac (void *cls, |
89 | const struct GNUNET_MessageHeader *hdr) | ||
294 | { | 90 | { |
295 | GNUNET_MessageHeader *pep; | 91 | fprintf (stderr, "."); |
296 | int i; | 92 | if (NULL == defrag) |
297 | 93 | return; | |
298 | for (i = 0; i < 50; i++) | 94 | GNUNET_DEFRAGMENT_process_fragment (defrag, hdr); |
299 | { | ||
300 | pep = makeFragment (0, i * 16 + 16, 51 * 16 + 8, 42); | ||
301 | processFragment (&mySender, pep); | ||
302 | GNUNET_GE_ASSERT (NULL, myMsg == NULL); | ||
303 | } | ||
304 | makeTimeout (); | ||
305 | pep = makeFragment (50 * 16, 24, 51 * 16 + 8, 42); | ||
306 | processFragment (&mySender, pep); | ||
307 | GNUNET_GE_ASSERT (NULL, myMsg == NULL); | ||
308 | for (i = 0; i < 50; i++) | ||
309 | { | ||
310 | pep = makeFragment (0, i * 16 + 16, 51 * 16 + 8, 42); | ||
311 | processFragment (&mySender, pep); | ||
312 | } | ||
313 | checkPacket (42, 51 * 16 + 8); | ||
314 | } | 95 | } |
315 | 96 | ||
316 | static void | ||
317 | testManyFragmentsMultiId () | ||
318 | { | ||
319 | GNUNET_MessageHeader *pep; | ||
320 | int i; | ||
321 | int id; | ||
322 | |||
323 | for (i = 0; i < 50; i++) | ||
324 | { | ||
325 | for (id = 0; id < DEFRAG_BUCKET_COUNT; id++) | ||
326 | { | ||
327 | pep = makeFragment (i * 16, 16, 51 * 16, id + 5); | ||
328 | mySender.hashPubKey.bits[0] = id; | ||
329 | processFragment (&mySender, pep); | ||
330 | GNUNET_GE_ASSERT (NULL, myMsg == NULL); | ||
331 | } | ||
332 | } | ||
333 | for (id = 0; id < DEFRAG_BUCKET_COUNT; id++) | ||
334 | { | ||
335 | pep = makeFragment (50 * 16, 16, 51 * 16, id + 5); | ||
336 | mySender.hashPubKey.bits[0] = id; | ||
337 | processFragment (&mySender, pep); | ||
338 | checkPacket (id + 5, 51 * 16); | ||
339 | } | ||
340 | } | ||
341 | 97 | ||
98 | /** | ||
99 | * Main function run with scheduler. | ||
100 | */ | ||
342 | static void | 101 | static void |
343 | testManyFragmentsMultiIdCollisions () | 102 | run (void *cls, |
344 | { | 103 | char *const *args, |
345 | GNUNET_MessageHeader *pep; | 104 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) |
346 | int i; | 105 | { |
347 | int id; | 106 | unsigned int i; |
348 | 107 | struct GNUNET_MessageHeader *msg; | |
349 | for (i = 0; i < 5; i++) | 108 | char buf[MTU + 32 * 1024]; |
350 | { | 109 | |
351 | for (id = 0; id < DEFRAG_BUCKET_COUNT * 4; id++) | 110 | defrag = GNUNET_DEFRAGMENT_context_create (NULL, |
352 | { | 111 | MTU, |
353 | pep = makeFragment (i * 16, 16, 6 * 16, id + 5); | 112 | NUM_MSGS /* enough space for all */, |
354 | mySender.hashPubKey.bits[0] = id; | 113 | NULL, |
355 | processFragment (&mySender, pep); | 114 | &proc_msgs, |
356 | GNUNET_GE_ASSERT (NULL, myMsg == NULL); | 115 | &proc_acks); |
357 | } | 116 | for (i=0;i<sizeof(buf);i++) |
358 | } | 117 | buf[i] = (char) i; |
359 | for (id = 0; id < DEFRAG_BUCKET_COUNT * 4; id++) | 118 | msg = (struct GNUNET_MessageHeader* ) buf; |
119 | for (i=0;i<NUM_MSGS;i++) | ||
360 | { | 120 | { |
361 | pep = makeFragment (5 * 16, 16, 6 * 16, id + 5); | 121 | msg->type = htons ((uint16_t) i); |
362 | mySender.hashPubKey.bits[0] = id; | 122 | msg->size = htons (MTU + 1 + i % (32 * 1024)); |
363 | processFragment (&mySender, pep); | 123 | frags[i] = GNUNET_FRAGMENT_context_create (NULL /* no stats */, |
364 | checkPacket (id + 5, 6 * 16); | 124 | MTU, |
125 | NULL /* no tracker -- infinite BW */, | ||
126 | GNUNET_TIME_UNIT_MILLISECONDS, | ||
127 | msg, | ||
128 | &proc_frac, | ||
129 | NULL); | ||
365 | } | 130 | } |
366 | } | 131 | } |
367 | 132 | ||
368 | /* ************* driver ****************** */ | ||
369 | |||
370 | static int | ||
371 | p2p_register_handler (const unsigned short type, | ||
372 | GNUNET_P2PRequestHandler callback) | ||
373 | { | ||
374 | return GNUNET_OK; | ||
375 | } | ||
376 | |||
377 | static int | ||
378 | p2p_unregister_handler (const unsigned short type, | ||
379 | GNUNET_P2PRequestHandler callback) | ||
380 | { | ||
381 | return GNUNET_OK; | ||
382 | } | ||
383 | |||
384 | |||
385 | static void * | ||
386 | request_service (const char *name) | ||
387 | { | ||
388 | return NULL; | ||
389 | } | ||
390 | |||
391 | #endif | ||
392 | 133 | ||
393 | int | 134 | int |
394 | main (int argc, char *argv[]) | 135 | main (int argc, char *argv[]) |
395 | { | 136 | { |
396 | fprintf (stderr, "WARNING: testcase not yet ported to new API.\n"); | 137 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
397 | #if 0 | 138 | GNUNET_GETOPT_OPTION_END |
398 | GNUNET_CoreAPIForPlugins capi; | 139 | }; |
399 | 140 | char *const argv_prog[] = { | |
400 | memset (&capi, 0, sizeof (GNUNET_CoreAPIForPlugins)); | 141 | "test-fragmentation", |
401 | capi.cron = GNUNET_cron_create (NULL); | 142 | "-c", |
402 | capi.loopback_send = &handleHelper; | 143 | "test_fragmentation_data.conf", |
403 | capi.service_request = &request_service; | 144 | "-L", |
404 | capi.p2p_ciphertext_handler_register = &p2p_register_handler; | 145 | #if VERBOSE |
405 | capi.p2p_ciphertext_handler_unregister = &p2p_unregister_handler; | 146 | "DEBUG", |
406 | provide_module_fragmentation (&capi); | 147 | #else |
407 | 148 | "WARNING", | |
408 | fprintf (stderr, "."); | 149 | #endif |
409 | testSimpleFragment (); | 150 | NULL |
410 | fprintf (stderr, "."); | 151 | }; |
411 | testSimpleFragmentTimeout (); | 152 | |
412 | fprintf (stderr, "."); | 153 | GNUNET_log_setup ("test-fragmentation", |
413 | testSimpleFragmentReverse (); | 154 | #if VERBOSE |
414 | fprintf (stderr, "."); | 155 | "DEBUG", |
415 | testManyFragments (); | 156 | #else |
416 | fprintf (stderr, "."); | 157 | "WARNING", |
417 | testManyFragmentsMegaLarge (); | ||
418 | fprintf (stderr, "."); | ||
419 | testManyFragmentsMultiId (); | ||
420 | fprintf (stderr, "."); | ||
421 | |||
422 | testManyInterleavedFragments (); | ||
423 | fprintf (stderr, "."); | ||
424 | testManyInterleavedOverlappingFragments (); | ||
425 | fprintf (stderr, "."); | ||
426 | testManyOverlappingFragments (); | ||
427 | fprintf (stderr, "."); | ||
428 | testManyOverlappingFragmentsTimeout (); | ||
429 | fprintf (stderr, "."); | ||
430 | testLastFragmentEarly (); | ||
431 | fprintf (stderr, "."); | ||
432 | testManyFragmentsMultiIdCollisions (); | ||
433 | fprintf (stderr, "."); | ||
434 | release_module_fragmentation (); | ||
435 | fprintf (stderr, "\n"); | ||
436 | GNUNET_cron_destroy (capi.cron); | ||
437 | #endif | 158 | #endif |
438 | return 0; /* testcase passed */ | 159 | NULL); |
160 | GNUNET_PROGRAM_run (5, argv_prog, "test-fragmentation", "nohelp", options, &run, NULL); | ||
161 | return ret; | ||
439 | } | 162 | } |
diff --git a/src/fragmentation/test_fragmentation_data.conf b/src/fragmentation/test_fragmentation_data.conf new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/fragmentation/test_fragmentation_data.conf | |||