blob: 16a3592125780cb265a23088c1c72693cef32e4f [file] [log] [blame]
Eric Newberry4c3e6b82015-11-10 16:48:42 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesaventoe4b22382018-06-10 14:37:24 -04002/*
Davide Pesaventoe422f9e2022-06-03 01:30:23 -04003 * Copyright (c) 2014-2022, Regents of the University of California,
Eric Newberry4c3e6b82015-11-10 16:48:42 -07004 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis.
10 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26#include "face/lp-reassembler.hpp"
27
28#include "tests/test-common.hpp"
Davide Pesaventocf7db2f2019-03-24 23:17:28 -040029#include "tests/daemon/global-io-fixture.hpp"
Eric Newberry4c3e6b82015-11-10 16:48:42 -070030
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040031namespace nfd::tests {
Eric Newberry4c3e6b82015-11-10 16:48:42 -070032
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040033using namespace nfd::face;
Eric Newberry4c3e6b82015-11-10 16:48:42 -070034
Davide Pesaventocf7db2f2019-03-24 23:17:28 -040035class LpReassemblerFixture : public GlobalIoTimeFixture
Eric Newberry4c3e6b82015-11-10 16:48:42 -070036{
Davide Pesavento97210d52016-10-14 15:45:48 +020037protected:
Eric Newberry4c3e6b82015-11-10 16:48:42 -070038 LpReassemblerFixture()
39 {
40 reassembler.beforeTimeout.connect(
ashiqopu77d0bfd2019-02-20 20:37:31 +000041 [this] (EndpointId remoteEp, size_t nDroppedFragments) {
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040042 timeoutHistory.emplace_back(remoteEp, nDroppedFragments);
Eric Newberry4c3e6b82015-11-10 16:48:42 -070043 });
44 }
45
Davide Pesavento97210d52016-10-14 15:45:48 +020046protected:
Davide Pesaventoe4b22382018-06-10 14:37:24 -040047 LpReassembler reassembler{{}};
ashiqopu77d0bfd2019-02-20 20:37:31 +000048 std::vector<std::pair<EndpointId, size_t>> timeoutHistory;
Eric Newberry4c3e6b82015-11-10 16:48:42 -070049
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040050 static constexpr uint8_t data[] = {
51 0x06, 0x08, // Data
52 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
53 };
Eric Newberry4c3e6b82015-11-10 16:48:42 -070054};
55
Davide Pesavento97210d52016-10-14 15:45:48 +020056BOOST_AUTO_TEST_SUITE(Face)
Eric Newberry4c3e6b82015-11-10 16:48:42 -070057BOOST_FIXTURE_TEST_SUITE(TestLpReassembler, LpReassemblerFixture)
58
59BOOST_AUTO_TEST_SUITE(SingleFragment)
60
61BOOST_AUTO_TEST_CASE(Normal)
62{
63 ndn::Buffer dataBuffer(data, sizeof(data));
64
65 lp::Packet received;
66 received.add<lp::FragmentField>(std::make_pair(dataBuffer.begin(), dataBuffer.end()));
67 received.add<lp::FragIndexField>(0);
68 received.add<lp::FragCountField>(1);
69 received.add<lp::SequenceField>(1000);
70 received.add<lp::NextHopFaceIdField>(200);
71
72 bool isComplete = false;
73 Block netPacket;
74 lp::Packet packet;
75 std::tie(isComplete, netPacket, packet) = reassembler.receiveFragment(0, received);
76
77 BOOST_REQUIRE(isComplete);
78 BOOST_CHECK(packet.has<lp::NextHopFaceIdField>());
79 BOOST_CHECK_EQUAL_COLLECTIONS(data, data + sizeof(data), netPacket.begin(), netPacket.end());
80 BOOST_CHECK_EQUAL(reassembler.size(), 0);
81}
82
83BOOST_AUTO_TEST_CASE(OmitFragIndex)
84{
85 ndn::Buffer dataBuffer(data, sizeof(data));
86
87 lp::Packet received;
88 received.add<lp::FragmentField>(std::make_pair(dataBuffer.begin(), dataBuffer.end()));
89 received.add<lp::FragCountField>(1);
90 received.add<lp::SequenceField>(1000);
91 received.add<lp::NextHopFaceIdField>(200);
92
93 bool isComplete = false;
94 Block netPacket;
95 lp::Packet packet;
96 std::tie(isComplete, netPacket, packet) = reassembler.receiveFragment(0, received);
97
98 BOOST_REQUIRE(isComplete);
99 BOOST_CHECK(packet.has<lp::NextHopFaceIdField>());
100 BOOST_CHECK_EQUAL_COLLECTIONS(data, data + sizeof(data), netPacket.begin(), netPacket.end());
101}
102
103BOOST_AUTO_TEST_CASE(OmitFragCount)
104{
105 ndn::Buffer dataBuffer(data, sizeof(data));
106
107 lp::Packet received;
108 received.add<lp::FragmentField>(std::make_pair(dataBuffer.begin(), dataBuffer.end()));
109 received.add<lp::FragIndexField>(0);
110 received.add<lp::SequenceField>(1000);
111 received.add<lp::NextHopFaceIdField>(200);
112
113 bool isComplete = false;
114 Block netPacket;
115 lp::Packet packet;
116 std::tie(isComplete, netPacket, packet) = reassembler.receiveFragment(0, received);
117
118 BOOST_REQUIRE(isComplete);
119 BOOST_CHECK(packet.has<lp::NextHopFaceIdField>());
120 BOOST_CHECK_EQUAL_COLLECTIONS(data, data + sizeof(data), netPacket.begin(), netPacket.end());
121}
122
123BOOST_AUTO_TEST_CASE(OmitFragIndexAndFragCount)
124{
125 ndn::Buffer dataBuffer(data, sizeof(data));
126
127 lp::Packet received;
128 received.add<lp::FragmentField>(std::make_pair(dataBuffer.begin(), dataBuffer.end()));
129 received.add<lp::SequenceField>(1000);
130 received.add<lp::NextHopFaceIdField>(200);
131
132 bool isComplete = false;
133 Block netPacket;
134 lp::Packet packet;
135 std::tie(isComplete, netPacket, packet) = reassembler.receiveFragment(0, received);
136
137 BOOST_REQUIRE(isComplete);
138 BOOST_CHECK(packet.has<lp::NextHopFaceIdField>());
139 BOOST_CHECK_EQUAL_COLLECTIONS(data, data + sizeof(data), netPacket.begin(), netPacket.end());
140}
141
142BOOST_AUTO_TEST_SUITE_END() // SingleFragment
143
144BOOST_AUTO_TEST_SUITE(MultiFragment)
145
146BOOST_AUTO_TEST_CASE(Normal)
147{
148 ndn::Buffer data1Buffer(data, 4);
149 ndn::Buffer data2Buffer(data + 4, 4);
150 ndn::Buffer data3Buffer(data + 8, 2);
151
152 lp::Packet received1;
153 received1.add<lp::FragmentField>(std::make_pair(data1Buffer.begin(), data1Buffer.end()));
154 received1.add<lp::FragIndexField>(0);
155 received1.add<lp::FragCountField>(3);
156 received1.add<lp::SequenceField>(1000);
157 received1.add<lp::NextHopFaceIdField>(200);
158
159 lp::Packet received2;
160 received2.add<lp::FragmentField>(std::make_pair(data2Buffer.begin(), data2Buffer.end()));
161 received2.add<lp::FragIndexField>(1);
162 received2.add<lp::FragCountField>(3);
163 received2.add<lp::SequenceField>(1001);
164
165 lp::Packet received3;
166 received3.add<lp::FragmentField>(std::make_pair(data3Buffer.begin(), data3Buffer.end()));
167 received3.add<lp::FragIndexField>(2);
168 received3.add<lp::FragCountField>(3);
169 received3.add<lp::SequenceField>(1002);
170
171 bool isComplete = false;
172 Block netPacket;
173 lp::Packet packet;
174
175 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received1);
176 BOOST_REQUIRE(!isComplete);
177 BOOST_CHECK_EQUAL(reassembler.size(), 1);
178
179 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received2);
180 BOOST_REQUIRE(!isComplete);
181 BOOST_CHECK_EQUAL(reassembler.size(), 1);
182
183 std::tie(isComplete, netPacket, packet) = reassembler.receiveFragment(0, received3);
184 BOOST_REQUIRE(isComplete);
185 BOOST_CHECK(packet.has<lp::NextHopFaceIdField>());
186 BOOST_CHECK_EQUAL_COLLECTIONS(data, data + sizeof(data), netPacket.begin(), netPacket.end());
187 BOOST_CHECK_EQUAL(reassembler.size(), 0);
188}
189
190BOOST_AUTO_TEST_CASE(OmitFragIndex0)
191{
192 ndn::Buffer data1Buffer(data, 4);
193 ndn::Buffer data2Buffer(data + 4, 4);
194 ndn::Buffer data3Buffer(data + 8, 2);
195
196 lp::Packet received1;
197 received1.add<lp::FragmentField>(std::make_pair(data1Buffer.begin(), data1Buffer.end()));
198 received1.add<lp::FragCountField>(3);
199 received1.add<lp::SequenceField>(1000);
200 received1.add<lp::NextHopFaceIdField>(200);
201
202 lp::Packet received2;
203 received2.add<lp::FragmentField>(std::make_pair(data2Buffer.begin(), data2Buffer.end()));
204 received2.add<lp::FragIndexField>(1);
205 received2.add<lp::FragCountField>(3);
206 received2.add<lp::SequenceField>(1001);
207
208 lp::Packet received3;
209 received3.add<lp::FragmentField>(std::make_pair(data3Buffer.begin(), data3Buffer.end()));
210 received3.add<lp::FragIndexField>(2);
211 received3.add<lp::FragCountField>(3);
212 received3.add<lp::SequenceField>(1002);
213
214 bool isComplete = false;
215 Block netPacket;
216 lp::Packet packet;
217
218 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received1);
219 BOOST_REQUIRE(!isComplete);
220
221 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received2);
222 BOOST_REQUIRE(!isComplete);
223
224 std::tie(isComplete, netPacket, packet) = reassembler.receiveFragment(0, received3);
225 BOOST_REQUIRE(isComplete);
226 BOOST_CHECK(packet.has<lp::NextHopFaceIdField>());
227 BOOST_CHECK_EQUAL_COLLECTIONS(data, data + sizeof(data), netPacket.begin(), netPacket.end());
228}
229
230BOOST_AUTO_TEST_CASE(OutOfOrder)
231{
232 ndn::Buffer data0Buffer(data, 4);
233 ndn::Buffer data1Buffer(data + 4, 4);
234 ndn::Buffer data2Buffer(data + 8, 2);
235
236 lp::Packet frag0;
237 frag0.add<lp::FragmentField>(std::make_pair(data0Buffer.begin(), data0Buffer.end()));
238 frag0.add<lp::FragIndexField>(0);
239 frag0.add<lp::FragCountField>(3);
240 frag0.add<lp::SequenceField>(1000);
241 frag0.add<lp::NextHopFaceIdField>(200);
242
243 lp::Packet frag1;
244 frag1.add<lp::FragmentField>(std::make_pair(data1Buffer.begin(), data1Buffer.end()));
245 frag1.add<lp::FragIndexField>(1);
246 frag1.add<lp::FragCountField>(3);
247 frag1.add<lp::SequenceField>(1001);
248
249 lp::Packet frag2;
250 frag2.add<lp::FragmentField>(std::make_pair(data2Buffer.begin(), data2Buffer.end()));
251 frag2.add<lp::FragIndexField>(2);
252 frag2.add<lp::FragCountField>(3);
253 frag2.add<lp::SequenceField>(1002);
254
255 bool isComplete = false;
256
257 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, frag2);
258 BOOST_REQUIRE(!isComplete);
259
260 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, frag0);
261 BOOST_REQUIRE(!isComplete);
262
263 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, frag1);
264 BOOST_REQUIRE(isComplete);
265}
266
267BOOST_AUTO_TEST_CASE(Duplicate)
268{
269 ndn::Buffer data0Buffer(data, 5);
270
271 lp::Packet frag0;
272 frag0.add<lp::FragmentField>(std::make_pair(data0Buffer.begin(), data0Buffer.end()));
273 frag0.add<lp::FragIndexField>(0);
274 frag0.add<lp::FragCountField>(2);
275 frag0.add<lp::SequenceField>(1000);
276
277 bool isComplete = false;
278
279 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, frag0);
280 BOOST_REQUIRE(!isComplete);
281
282 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(1, frag0);
283 BOOST_REQUIRE(!isComplete);
284}
285
286BOOST_AUTO_TEST_CASE(Timeout)
287{
288 ndn::Buffer data1Buffer(data, 5);
289 ndn::Buffer data2Buffer(data + 5, 5);
290
291 lp::Packet received1;
292 received1.add<lp::FragmentField>(std::make_pair(data1Buffer.begin(), data1Buffer.end()));
293 received1.add<lp::FragIndexField>(0);
294 received1.add<lp::FragCountField>(2);
295 received1.add<lp::SequenceField>(1000);
296 received1.add<lp::NextHopFaceIdField>(200);
297
298 lp::Packet received2;
299 received2.add<lp::FragmentField>(std::make_pair(data2Buffer.begin(), data2Buffer.end()));
300 received2.add<lp::FragIndexField>(1);
301 received2.add<lp::FragCountField>(2);
302 received2.add<lp::SequenceField>(1001);
303
ashiqopu77d0bfd2019-02-20 20:37:31 +0000304 const EndpointId REMOTE_EP = 11028;
Eric Newberry4c3e6b82015-11-10 16:48:42 -0700305 bool isComplete = false;
306 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(REMOTE_EP, received1);
307 BOOST_REQUIRE(!isComplete);
308 BOOST_CHECK_EQUAL(reassembler.size(), 1);
309 BOOST_CHECK(timeoutHistory.empty());
310
Davide Pesavento14e71f02019-03-28 17:35:25 -0400311 advanceClocks(1_ms, 600);
Eric Newberry4c3e6b82015-11-10 16:48:42 -0700312 BOOST_CHECK_EQUAL(reassembler.size(), 0);
313 BOOST_REQUIRE_EQUAL(timeoutHistory.size(), 1);
314 BOOST_CHECK_EQUAL(std::get<0>(timeoutHistory.back()), REMOTE_EP);
315 BOOST_CHECK_EQUAL(std::get<1>(timeoutHistory.back()), 1);
316
317 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(REMOTE_EP, received2);
318 BOOST_REQUIRE(!isComplete);
319}
320
321BOOST_AUTO_TEST_CASE(MissingSequence)
322{
323 ndn::Buffer data1Buffer(data, 4);
324 ndn::Buffer data2Buffer(data + 4, 4);
325 ndn::Buffer data3Buffer(data + 8, 2);
326
327 lp::Packet received1;
328 received1.add<lp::FragmentField>(std::make_pair(data1Buffer.begin(), data1Buffer.end()));
329 received1.add<lp::FragIndexField>(0);
330 received1.add<lp::FragCountField>(3);
331 received1.add<lp::SequenceField>(1000);
332 received1.add<lp::NextHopFaceIdField>(200);
333
334 lp::Packet received2;
335 received2.add<lp::FragmentField>(std::make_pair(data2Buffer.begin(), data2Buffer.end()));
336 received2.add<lp::FragIndexField>(1);
337 received2.add<lp::FragCountField>(3);
338
339 lp::Packet received3;
340 received3.add<lp::FragmentField>(std::make_pair(data3Buffer.begin(), data3Buffer.end()));
341 received3.add<lp::FragIndexField>(2);
342 received3.add<lp::FragCountField>(3);
343 received3.add<lp::SequenceField>(1002);
344
345 bool isComplete = false;
346
347 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received1);
348 BOOST_REQUIRE(!isComplete);
349
350 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received2);
351 BOOST_REQUIRE(!isComplete);
352
353 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received3);
354 BOOST_REQUIRE(!isComplete);
355
Davide Pesavento14e71f02019-03-28 17:35:25 -0400356 advanceClocks(1_ms, 600);
Eric Newberry4c3e6b82015-11-10 16:48:42 -0700357
358 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received2);
359 BOOST_REQUIRE(!isComplete);
360}
361
362BOOST_AUTO_TEST_CASE(FragCountOverLimit)
363{
364 ndn::Buffer data1Buffer(data, sizeof(data));
365
366 lp::Packet received1;
367 received1.add<lp::FragmentField>(std::make_pair(data1Buffer.begin(), data1Buffer.end()));
368 received1.add<lp::FragIndexField>(0);
369 received1.add<lp::FragCountField>(256);
370 received1.add<lp::SequenceField>(1000);
371 received1.add<lp::NextHopFaceIdField>(200);
372
373 bool isComplete = false;
374
375 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received1);
376 BOOST_REQUIRE(!isComplete);
377}
378
379BOOST_AUTO_TEST_CASE(MissingFragCount)
380{
381 ndn::Buffer data1Buffer(data, 4);
382 ndn::Buffer data2Buffer(data + 4, 4);
383 ndn::Buffer data3Buffer(data + 8, 2);
384
385 lp::Packet received1;
386 received1.add<lp::FragmentField>(std::make_pair(data1Buffer.begin(), data1Buffer.end()));
387 received1.add<lp::FragIndexField>(0);
388 received1.add<lp::FragCountField>(3);
389 received1.add<lp::SequenceField>(1000);
390 received1.add<lp::NextHopFaceIdField>(200);
391
392 lp::Packet received2;
393 received2.add<lp::FragmentField>(std::make_pair(data2Buffer.begin(), data2Buffer.end()));
394 received2.add<lp::FragIndexField>(1);
395 received2.add<lp::FragCountField>(50);
396 received2.add<lp::SequenceField>(1001);
397
398 lp::Packet received3;
399 received3.add<lp::FragmentField>(std::make_pair(data3Buffer.begin(), data3Buffer.end()));
400 received3.add<lp::FragIndexField>(2);
401 received3.add<lp::FragCountField>(3);
402 received3.add<lp::SequenceField>(1002);
403
404 bool isComplete = false;
405
406 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received1);
407 BOOST_REQUIRE(!isComplete);
408
409 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received2);
410 BOOST_REQUIRE(!isComplete);
411
412 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received3);
413 BOOST_REQUIRE(!isComplete);
414}
415
416BOOST_AUTO_TEST_CASE(OverFragCount)
417{
418 LpReassembler::Options options;
419 options.nMaxFragments = 2;
420 reassembler.setOptions(options);
421
422 ndn::Buffer data1Buffer(data, 4);
423 ndn::Buffer data2Buffer(data + 4, 4);
424 ndn::Buffer data3Buffer(data + 8, 2);
425
426 lp::Packet received1;
427 received1.add<lp::FragmentField>(std::make_pair(data1Buffer.begin(), data1Buffer.end()));
428 received1.add<lp::FragIndexField>(0);
429 received1.add<lp::FragCountField>(3);
430 received1.add<lp::SequenceField>(1000);
431 received1.add<lp::NextHopFaceIdField>(200);
432
433 lp::Packet received2;
434 received2.add<lp::FragmentField>(std::make_pair(data2Buffer.begin(), data2Buffer.end()));
435 received2.add<lp::FragIndexField>(1);
436 received2.add<lp::FragCountField>(3);
437 received2.add<lp::SequenceField>(1001);
438
439 lp::Packet received3;
440 received3.add<lp::FragmentField>(std::make_pair(data3Buffer.begin(), data3Buffer.end()));
441 received3.add<lp::FragIndexField>(2);
442 received3.add<lp::FragCountField>(3);
443 received3.add<lp::SequenceField>(1002);
444
445 bool isComplete = false;
446
447 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received1);
448 BOOST_REQUIRE(!isComplete);
449
450 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received2);
451 BOOST_REQUIRE(!isComplete);
452
453 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(0, received3);
454 BOOST_REQUIRE(!isComplete);
455}
456
457BOOST_AUTO_TEST_SUITE_END() // MultiFragment
458
Davide Pesavento97210d52016-10-14 15:45:48 +0200459BOOST_AUTO_TEST_SUITE(MultipleRemoteEndpoints)
460
461BOOST_AUTO_TEST_CASE(Normal)
Eric Newberry4c3e6b82015-11-10 16:48:42 -0700462{
463 ndn::Buffer data1Buffer(data, 5);
464 ndn::Buffer data2Buffer(data + 5, 5);
465
466 lp::Packet frag1_1;
467 frag1_1.add<lp::FragmentField>(std::make_pair(data1Buffer.begin(), data1Buffer.end()));
468 frag1_1.add<lp::FragIndexField>(0);
469 frag1_1.add<lp::FragCountField>(2);
470 frag1_1.add<lp::SequenceField>(2000);
471 frag1_1.add<lp::NextHopFaceIdField>(200);
472
473 lp::Packet frag1_2;
474 frag1_2.add<lp::FragmentField>(std::make_pair(data2Buffer.begin(), data2Buffer.end()));
475 frag1_2.add<lp::FragIndexField>(1);
476 frag1_2.add<lp::FragCountField>(2);
477 frag1_2.add<lp::SequenceField>(2001);
478
479 lp::Packet frag2_1;
480 frag2_1.add<lp::FragmentField>(std::make_pair(data1Buffer.begin(), data1Buffer.end()));
481 frag2_1.add<lp::FragIndexField>(0);
482 frag2_1.add<lp::FragCountField>(2);
483 frag2_1.add<lp::SequenceField>(2000);
484 frag2_1.add<lp::NextHopFaceIdField>(200);
485
486 lp::Packet frag2_2;
487 frag2_2.add<lp::FragmentField>(std::make_pair(data2Buffer.begin(), data2Buffer.end()));
488 frag2_2.add<lp::FragIndexField>(1);
489 frag2_2.add<lp::FragCountField>(2);
490 frag2_2.add<lp::SequenceField>(2001);
491
492 bool isComplete = false;
493
494 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(1, frag1_1);
495 BOOST_REQUIRE(!isComplete);
496 BOOST_CHECK_EQUAL(reassembler.size(), 1);
497
498 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(2, frag2_2);
499 BOOST_REQUIRE(!isComplete);
500 BOOST_CHECK_EQUAL(reassembler.size(), 2);
501
502 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(1, frag1_2);
503 BOOST_REQUIRE(isComplete);
504 BOOST_CHECK_EQUAL(reassembler.size(), 1);
505
506 std::tie(isComplete, std::ignore, std::ignore) = reassembler.receiveFragment(2, frag2_1);
507 BOOST_REQUIRE(isComplete);
508 BOOST_CHECK_EQUAL(reassembler.size(), 0);
509}
510
Davide Pesavento97210d52016-10-14 15:45:48 +0200511BOOST_AUTO_TEST_SUITE_END() // MultipleRemoteEndpoints
512
Eric Newberry4c3e6b82015-11-10 16:48:42 -0700513BOOST_AUTO_TEST_SUITE_END() // TestLpReassembler
514BOOST_AUTO_TEST_SUITE_END() // Face
515
Davide Pesaventoe422f9e2022-06-03 01:30:23 -0400516} // namespace nfd::tests