blob: 4e55fcc0c668ef66ef07adce3528ad444be294d5 [file] [log] [blame]
Vince Lehman277ecf02016-02-10 16:37:48 -06001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento60f8cc12018-05-10 22:05:21 -04002/*
Davide Pesavento7b9837b2019-02-23 19:07:50 -05003 * Copyright (c) 2014-2019, University of Memphis,
Davide Pesaventof9126532018-08-04 18:31:06 -04004 * University Pierre & Marie Curie, Sorbonne University.
Vince Lehman277ecf02016-02-10 16:37:48 -06005 *
6 * This file is part of ndn-tools (Named Data Networking Essential Tools).
7 * See AUTHORS.md for complete list of ndn-tools authors and contributors.
8 *
9 * ndn-tools is free software: you can redistribute it and/or modify it under the terms
10 * of the GNU General Public License as published by the Free Software Foundation,
11 * either version 3 of the License, or (at your option) any later version.
12 *
13 * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include "tools/dump/ndndump.hpp"
22
Davide Pesavento60f8cc12018-05-10 22:05:21 -040023#include "tests/identity-management-fixture.hpp"
24#include "tests/test-common.hpp"
25
Davide Pesaventof9126532018-08-04 18:31:06 -040026#include <net/ethernet.h>
27#include <netinet/ip.h>
28#include <netinet/ip6.h>
29#include <netinet/tcp.h>
30#include <netinet/udp.h>
31
32#include <boost/endian/conversion.hpp>
33
34#include <ndn-cxx/encoding/encoding-buffer.hpp>
Vince Lehman277ecf02016-02-10 16:37:48 -060035#include <ndn-cxx/lp/packet.hpp>
Junxiao Shic9575a62017-07-01 06:16:02 +000036#include <ndn-cxx/net/ethernet.hpp>
Junxiao Shi20b22972017-05-24 21:04:16 +000037
Vince Lehman277ecf02016-02-10 16:37:48 -060038namespace ndn {
39namespace dump {
40namespace tests {
41
Davide Pesaventof9126532018-08-04 18:31:06 -040042namespace endian = boost::endian;
Vince Lehman277ecf02016-02-10 16:37:48 -060043using namespace ndn::tests;
44
45class StdCoutRedirector
46{
47public:
48 StdCoutRedirector(std::ostream& os)
49 {
50 // Redirect std::cout to the specified output stream
51 originalBuffer = std::cout.rdbuf(os.rdbuf());
52 }
53
54 ~StdCoutRedirector()
55 {
56 // Revert state for std::cout
57 std::cout.rdbuf(originalBuffer);
58 }
59
60private:
61 std::streambuf* originalBuffer;
62};
63
Junxiao Shi20b22972017-05-24 21:04:16 +000064class NdnDumpFixture : public IdentityManagementFixture
Vince Lehman277ecf02016-02-10 16:37:48 -060065{
66protected:
67 NdnDumpFixture()
68 {
69 dump.m_dataLinkType = DLT_EN10MB;
70 }
71
Junxiao Shi20b22972017-05-24 21:04:16 +000072 template<typename Packet>
Vince Lehman277ecf02016-02-10 16:37:48 -060073 void
74 receive(const Packet& packet)
75 {
Junxiao Shi20b22972017-05-24 21:04:16 +000076 EncodingBuffer buffer(packet.wireEncode());
Davide Pesaventof9126532018-08-04 18:31:06 -040077 receiveEthernet(buffer);
Vince Lehman277ecf02016-02-10 16:37:48 -060078 }
79
80 void
Davide Pesaventof9126532018-08-04 18:31:06 -040081 receiveEthernet(EncodingBuffer& buffer, uint16_t ethertype = s_ethertypeNdn)
Vince Lehman277ecf02016-02-10 16:37:48 -060082 {
Junxiao Shic9575a62017-07-01 06:16:02 +000083 ethernet::Address host;
Vince Lehman277ecf02016-02-10 16:37:48 -060084
85 // Ethernet header
Davide Pesaventof9126532018-08-04 18:31:06 -040086 buffer.prependByteArray(reinterpret_cast<const uint8_t*>(&ethertype), ethernet::TYPE_LEN);
Vince Lehman277ecf02016-02-10 16:37:48 -060087 buffer.prependByteArray(host.data(), host.size());
88 buffer.prependByteArray(host.data(), host.size());
89
Davide Pesaventof9126532018-08-04 18:31:06 -040090 // pcap header
Davide Pesaventoecd44802018-07-23 23:48:10 -040091 pcap_pkthdr pkthdr{};
92 pkthdr.caplen = pkthdr.len = buffer.size();
Vince Lehman277ecf02016-02-10 16:37:48 -060093
94 {
95 StdCoutRedirector redirect(output);
Davide Pesaventoecd44802018-07-23 23:48:10 -040096 dump.printPacket(&pkthdr, buffer.buf());
Vince Lehman277ecf02016-02-10 16:37:48 -060097 }
98 }
99
Davide Pesaventof9126532018-08-04 18:31:06 -0400100 void
101 receiveIp4(EncodingBuffer& buffer, const ip* ipHeader)
102 {
103 buffer.prependByteArray(reinterpret_cast<const uint8_t*>(ipHeader), sizeof(ip));
104 receiveEthernet(buffer, s_ethertypeIp4);
105 }
106
107 void
108 receiveIp6(EncodingBuffer& buffer, const ip6_hdr* ip6Header)
109 {
110 buffer.prependByteArray(reinterpret_cast<const uint8_t*>(ip6Header), sizeof(ip6_hdr));
111 receiveEthernet(buffer, s_ethertypeIp6);
112 }
113
114 void
115 receiveTcp4(EncodingBuffer& buffer, const tcphdr* tcpHeader)
116 {
117 buffer.prependByteArray(reinterpret_cast<const uint8_t*>(tcpHeader), sizeof(tcphdr));
118
119 ip ipHeader{};
120 ipHeader.ip_v = 4;
121 ipHeader.ip_hl = 5;
122 ipHeader.ip_len = endian::native_to_big(static_cast<uint16_t>(buffer.size() + sizeof(ipHeader)));
123 ipHeader.ip_ttl = 1;
124 ipHeader.ip_p = IPPROTO_TCP;
125
126 receiveIp4(buffer, &ipHeader);
127 }
128
129 void
130 receiveUdp4(EncodingBuffer& buffer, const udphdr* udpHeader)
131 {
132 buffer.prependByteArray(reinterpret_cast<const uint8_t*>(udpHeader), sizeof(udphdr));
133
134 ip ipHeader{};
135 ipHeader.ip_v = 4;
136 ipHeader.ip_hl = 5;
137 ipHeader.ip_len = endian::native_to_big(static_cast<uint16_t>(buffer.size() + sizeof(ipHeader)));
138 ipHeader.ip_ttl = 1;
139 ipHeader.ip_p = IPPROTO_UDP;
140
141 receiveIp4(buffer, &ipHeader);
142 }
143
144 void
145 readFile(const std::string& filename)
146 {
147 StdCoutRedirector redirect(output);
148 dump.inputFile = filename;
149 dump.run();
150 }
151
Vince Lehman277ecf02016-02-10 16:37:48 -0600152protected:
Davide Pesaventoecd44802018-07-23 23:48:10 -0400153 NdnDump dump;
Vince Lehman277ecf02016-02-10 16:37:48 -0600154 boost::test_tools::output_test_stream output;
Davide Pesaventof9126532018-08-04 18:31:06 -0400155
156 static const uint16_t s_ethertypeNdn;
157 static const uint16_t s_ethertypeIp4;
158 static const uint16_t s_ethertypeIp6;
Vince Lehman277ecf02016-02-10 16:37:48 -0600159};
160
Davide Pesaventof9126532018-08-04 18:31:06 -0400161const uint16_t NdnDumpFixture::s_ethertypeNdn = endian::native_to_big(ethernet::ETHERTYPE_NDN);
162const uint16_t NdnDumpFixture::s_ethertypeIp4 = endian::native_to_big(uint16_t(ETHERTYPE_IP));
163const uint16_t NdnDumpFixture::s_ethertypeIp6 = endian::native_to_big(uint16_t(ETHERTYPE_IPV6));
164
Davide Pesaventoecd44802018-07-23 23:48:10 -0400165BOOST_AUTO_TEST_SUITE(Dump)
166BOOST_FIXTURE_TEST_SUITE(TestNdnDump, NdnDumpFixture)
Vince Lehman277ecf02016-02-10 16:37:48 -0600167
Davide Pesaventof9126532018-08-04 18:31:06 -0400168BOOST_AUTO_TEST_CASE(Interest)
Vince Lehman277ecf02016-02-10 16:37:48 -0600169{
Junxiao Shi20d5a0b2018-08-14 09:26:11 -0600170 this->receive(*makeInterest("/test", true, DEFAULT_INTEREST_LIFETIME, 1));
171 BOOST_CHECK(output.is_equal("0.000000 Ethernet, INTEREST: /test?ndn.Nonce=1\n"));
Vince Lehman277ecf02016-02-10 16:37:48 -0600172}
173
Davide Pesaventof9126532018-08-04 18:31:06 -0400174BOOST_AUTO_TEST_CASE(Data)
Vince Lehman277ecf02016-02-10 16:37:48 -0600175{
Junxiao Shi20d5a0b2018-08-14 09:26:11 -0600176 this->receive(*makeData("/test"));
Davide Pesaventof9126532018-08-04 18:31:06 -0400177 BOOST_CHECK(output.is_equal("0.000000 Ethernet, DATA: /test\n"));
Vince Lehman277ecf02016-02-10 16:37:48 -0600178}
179
Davide Pesaventof9126532018-08-04 18:31:06 -0400180BOOST_AUTO_TEST_CASE(Nack)
Vince Lehman277ecf02016-02-10 16:37:48 -0600181{
Junxiao Shi20d5a0b2018-08-14 09:26:11 -0600182 auto interest = makeInterest("/test", true, DEFAULT_INTEREST_LIFETIME, 1);
183 auto nack = makeNack(*interest, lp::NackReason::DUPLICATE);
184 lp::Packet lpPacket(interest->wireEncode());
Vince Lehman277ecf02016-02-10 16:37:48 -0600185 lpPacket.add<lp::NackField>(nack.getHeader());
186
187 this->receive(lpPacket);
Junxiao Shi20d5a0b2018-08-14 09:26:11 -0600188 BOOST_CHECK(output.is_equal("0.000000 Ethernet, NDNLPv2, NACK (Duplicate): /test?ndn.Nonce=1\n"));
Vince Lehman277ecf02016-02-10 16:37:48 -0600189}
190
Davide Pesaventof9126532018-08-04 18:31:06 -0400191BOOST_AUTO_TEST_CASE(LpFragment)
Vince Lehman277ecf02016-02-10 16:37:48 -0600192{
193 const uint8_t data[10] = {
194 0x06, 0x08, // Data packet
195 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
196 };
197
Junxiao Shi20b22972017-05-24 21:04:16 +0000198 Buffer buffer(data, 4);
Vince Lehman277ecf02016-02-10 16:37:48 -0600199 lp::Packet lpPacket;
200 lpPacket.add<lp::FragmentField>(std::make_pair(buffer.begin(), buffer.end()));
201 lpPacket.add<lp::FragIndexField>(0);
202 lpPacket.add<lp::FragCountField>(2);
203 lpPacket.add<lp::SequenceField>(1000);
204
205 this->receive(lpPacket);
Davide Pesaventof9126532018-08-04 18:31:06 -0400206 BOOST_CHECK(output.is_equal("0.000000 Ethernet, NDNLPv2 fragment\n"));
Vince Lehman277ecf02016-02-10 16:37:48 -0600207}
208
Davide Pesaventof9126532018-08-04 18:31:06 -0400209BOOST_AUTO_TEST_CASE(LpIdle)
Vince Lehman277ecf02016-02-10 16:37:48 -0600210{
211 lp::Packet lpPacket;
Vince Lehman277ecf02016-02-10 16:37:48 -0600212 this->receive(lpPacket);
Davide Pesaventof9126532018-08-04 18:31:06 -0400213 BOOST_CHECK(output.is_equal("0.000000 Ethernet, NDNLPv2 idle\n"));
Vince Lehman277ecf02016-02-10 16:37:48 -0600214}
215
Davide Pesaventof9126532018-08-04 18:31:06 -0400216BOOST_AUTO_TEST_CASE(IncompleteNdnPacket)
Vince Lehman277ecf02016-02-10 16:37:48 -0600217{
218 const uint8_t interest[] = {
219 0x05, 0x0E, // Interest
220 0x07, 0x06, // Name
221 0x08, 0x04, // NameComponent
222 0x74, 0x65, 0x73, 0x74,
223 0x0a, 0x04, // Nonce
224 0x00, 0x00, 0x00, 0x01
225 };
Vince Lehman277ecf02016-02-10 16:37:48 -0600226 EncodingBuffer buffer;
227 buffer.prependByteArray(interest, 4);
228
Davide Pesaventof9126532018-08-04 18:31:06 -0400229 this->receiveEthernet(buffer);
Davide Pesaventof9126532018-08-04 18:31:06 -0400230 BOOST_CHECK(output.is_equal("0.000000 Ethernet, NDN truncated packet, length 4\n"));
Vince Lehman277ecf02016-02-10 16:37:48 -0600231}
232
Davide Pesaventof9126532018-08-04 18:31:06 -0400233BOOST_AUTO_TEST_CASE(UnsupportedNdnPacket)
Vince Lehman277ecf02016-02-10 16:37:48 -0600234{
Junxiao Shi20b22972017-05-24 21:04:16 +0000235 EncodingBuffer buffer(encoding::makeEmptyBlock(tlv::Name));
Davide Pesaventof9126532018-08-04 18:31:06 -0400236 this->receiveEthernet(buffer);
Davide Pesaventof9126532018-08-04 18:31:06 -0400237 BOOST_CHECK(output.is_equal("0.000000 Ethernet, [Unsupported NDN packet type 7]\n"));
238}
239
240BOOST_AUTO_TEST_CASE(UnsupportedEtherType)
241{
242 EncodingBuffer pkt;
243 uint16_t type = ETHERTYPE_ARP;
244 endian::native_to_big_inplace(type);
245
246 this->receiveEthernet(pkt, type);
Davide Pesaventof9126532018-08-04 18:31:06 -0400247 BOOST_CHECK(output.is_equal("0.000000 [Unsupported ethertype 0x806]\n"));
248}
249
250BOOST_AUTO_TEST_CASE(MalformedIpv4Header)
251{
252 dump.wantTimestamp = false;
253
254 uint8_t theAnswer = 42;
255
256 EncodingBuffer pkt1;
257 pkt1.prependByte(theAnswer);
258 this->receiveEthernet(pkt1, s_ethertypeIp4);
259 BOOST_CHECK(output.is_equal("IP truncated header, length 1\n"));
260
261 ip ipHdr2{};
262 ipHdr2.ip_v = 7;
263
264 EncodingBuffer pkt2;
265 this->receiveIp4(pkt2, &ipHdr2);
266 BOOST_CHECK(output.is_equal("IP bad version 7\n"));
267
268 ip ipHdr3{};
269 ipHdr3.ip_v = 4;
270 ipHdr3.ip_hl = 2;
271
272 EncodingBuffer pkt3;
273 this->receiveIp4(pkt3, &ipHdr3);
274 BOOST_CHECK(output.is_equal("IP bad header length 8\n"));
275
276 ip ipHdr4{};
277 ipHdr4.ip_v = 4;
278 ipHdr4.ip_hl = 5;
279 ipHdr4.ip_len = 10;
280 endian::native_to_big_inplace(ipHdr4.ip_len);
281
282 EncodingBuffer pkt4;
283 this->receiveIp4(pkt4, &ipHdr4);
284 BOOST_CHECK(output.is_equal("IP bad length 10\n"));
285
286 ip ipHdr5{};
287 ipHdr5.ip_v = 4;
288 ipHdr5.ip_hl = 5;
289 ipHdr5.ip_len = 1000;
290 endian::native_to_big_inplace(ipHdr5.ip_len);
291
292 EncodingBuffer pkt5;
293 this->receiveIp4(pkt5, &ipHdr5);
294 BOOST_CHECK(output.is_equal("IP truncated packet, 980 bytes missing\n"));
295}
296
Davide Pesavento0ca7e692018-08-05 02:21:06 -0400297BOOST_AUTO_TEST_CASE(MalformedIpv6Header)
298{
299 dump.wantTimestamp = false;
300
301 uint8_t theAnswer = 42;
302
303 EncodingBuffer pkt1;
304 pkt1.prependByte(theAnswer);
305 this->receiveEthernet(pkt1, s_ethertypeIp6);
306 BOOST_CHECK(output.is_equal("IP6 truncated header, length 1\n"));
307
308 ip6_hdr ip6Hdr2{};
309 ip6Hdr2.ip6_vfc = 10 << 4;
310
311 EncodingBuffer pkt2;
312 this->receiveIp6(pkt2, &ip6Hdr2);
313 BOOST_CHECK(output.is_equal("IP6 bad version 10\n"));
314
315 ip6_hdr ip6Hdr3{};
316 ip6Hdr3.ip6_vfc = 6 << 4;
317 ip6Hdr3.ip6_plen = 1400;
318 endian::native_to_big_inplace(ip6Hdr3.ip6_plen);
319
320 EncodingBuffer pkt3;
321 this->receiveIp6(pkt3, &ip6Hdr3);
322 BOOST_CHECK(output.is_equal("IP6 truncated payload, 1400 bytes missing\n"));
323}
324
Davide Pesaventof9126532018-08-04 18:31:06 -0400325BOOST_AUTO_TEST_CASE(UnsupportedIpProto)
326{
327 dump.wantTimestamp = false;
328
329 ip ipHdr{};
330 ipHdr.ip_v = 4;
331 ipHdr.ip_hl = 5;
332 ipHdr.ip_len = sizeof(ipHdr);
333 endian::native_to_big_inplace(ipHdr.ip_len);
334 ipHdr.ip_p = IPPROTO_SCTP;
335
Davide Pesavento0ca7e692018-08-05 02:21:06 -0400336 EncodingBuffer pkt1;
337 this->receiveIp4(pkt1, &ipHdr);
Davide Pesaventof9126532018-08-04 18:31:06 -0400338 BOOST_CHECK(output.is_equal("IP 0.0.0.0 > 0.0.0.0, [Unsupported IP proto 132]\n"));
Davide Pesavento0ca7e692018-08-05 02:21:06 -0400339
340 ip6_hdr ip6Hdr{};
341 ip6Hdr.ip6_vfc = 6 << 4;
342 ip6Hdr.ip6_nxt = IPPROTO_NONE;
343
344 EncodingBuffer pkt2;
345 this->receiveIp6(pkt2, &ip6Hdr);
346 BOOST_CHECK(output.is_equal("IP6 :: > ::, [No next header]\n"));
Davide Pesaventof9126532018-08-04 18:31:06 -0400347}
348
349BOOST_AUTO_TEST_CASE(MalformedTcpHeader)
350{
351 dump.wantTimestamp = false;
352
353 tcphdr tcpHdr1{};
Davide Pesavento7b9837b2019-02-23 19:07:50 -0500354 tcpHdr1.TH_OFF = 0x2;
Davide Pesaventof9126532018-08-04 18:31:06 -0400355
356 EncodingBuffer pkt1;
357 this->receiveTcp4(pkt1, &tcpHdr1);
358 BOOST_CHECK(output.is_equal("IP 0.0.0.0 > 0.0.0.0, TCP bad header length 8\n"));
359
360 tcphdr tcpHdr2{};
Davide Pesavento7b9837b2019-02-23 19:07:50 -0500361 tcpHdr2.TH_OFF = 0xf;
Davide Pesaventof9126532018-08-04 18:31:06 -0400362
363 EncodingBuffer pkt2;
364 this->receiveTcp4(pkt2, &tcpHdr2);
365 BOOST_CHECK(output.is_equal("IP 0.0.0.0 > 0.0.0.0, TCP truncated header, 40 bytes missing\n"));
366}
367
368BOOST_AUTO_TEST_CASE(MalformedUdpHeader)
369{
370 dump.wantTimestamp = false;
371
372 udphdr udpHdr1{};
Davide Pesavento7b9837b2019-02-23 19:07:50 -0500373 udpHdr1.UH_LEN = 3;
374 endian::native_to_big_inplace(udpHdr1.UH_LEN);
Davide Pesaventof9126532018-08-04 18:31:06 -0400375
376 EncodingBuffer pkt1;
377 this->receiveUdp4(pkt1, &udpHdr1);
378 BOOST_CHECK(output.is_equal("IP 0.0.0.0 > 0.0.0.0, UDP bad length 3\n"));
379
380 udphdr udpHdr2{};
Davide Pesavento7b9837b2019-02-23 19:07:50 -0500381 udpHdr2.UH_LEN = 1000;
382 endian::native_to_big_inplace(udpHdr2.UH_LEN);
Davide Pesaventof9126532018-08-04 18:31:06 -0400383
384 EncodingBuffer pkt2;
385 this->receiveUdp4(pkt2, &udpHdr2);
386 BOOST_CHECK(output.is_equal("IP 0.0.0.0 > 0.0.0.0, UDP truncated packet, 992 bytes missing\n"));
387}
388
389BOOST_AUTO_TEST_CASE(InvalidTlvLength)
390{
391 dump.wantTimestamp = false;
392 this->readFile("tests/dump/invalid-tlv-length.pcap");
393
394 const std::string expected =
395 "IP 128.196.203.36 > 128.187.81.12, TCP, length 147, NDNLPv2 invalid packet: "
396 "TLV-LENGTH of sub-element of type 5 exceeds TLV-VALUE boundary of parent block\n";
397 BOOST_CHECK(output.is_equal(expected));
398}
399
400BOOST_AUTO_TEST_CASE(UnrecognizedLpField)
401{
402 dump.wantTimestamp = false;
403 this->readFile("tests/dump/unrecognized-lp-field.pcap");
404
405 const std::string expected = "IP 128.196.203.36 > 128.187.81.12, TCP, length 800, "
406 "NDNLPv2 invalid packet: unrecognized field 4 cannot be ignored\n";
Davide Pesaventoecd44802018-07-23 23:48:10 -0400407 BOOST_CHECK(output.is_equal(expected));
Vince Lehman277ecf02016-02-10 16:37:48 -0600408}
409
Davide Pesaventob5b8f952018-07-26 14:19:16 -0400410BOOST_AUTO_TEST_CASE(NoTimestamp)
411{
412 dump.wantTimestamp = false;
413
414 lp::Packet lpPacket;
415 this->receive(lpPacket);
416
Davide Pesaventof9126532018-08-04 18:31:06 -0400417 BOOST_CHECK(output.is_equal("Ethernet, NDNLPv2 idle\n"));
Davide Pesaventob5b8f952018-07-26 14:19:16 -0400418}
419
Davide Pesaventof9126532018-08-04 18:31:06 -0400420BOOST_AUTO_TEST_CASE(FromFile)
Vince Lehman277ecf02016-02-10 16:37:48 -0600421{
Davide Pesaventoecd44802018-07-23 23:48:10 -0400422 dump.pcapFilter = "";
Davide Pesaventof9126532018-08-04 18:31:06 -0400423 this->readFile("tests/dump/nack.pcap");
Vince Lehman277ecf02016-02-10 16:37:48 -0600424
Davide Pesaventoecd44802018-07-23 23:48:10 -0400425 const std::string expected =
Davide Pesaventof9126532018-08-04 18:31:06 -0400426 "1456768916.467099 IP 1.0.0.1 > 1.0.0.2, UDP, length 42, "
Davide Pesaventod1b1bf62018-07-26 18:05:08 -0400427 "INTEREST: /producer/nack/congestion?ndn.MustBeFresh=1&ndn.Nonce=2581361680\n"
Davide Pesaventof9126532018-08-04 18:31:06 -0400428 "1456768916.567099 IP 1.0.0.1 > 1.0.0.2, UDP, length 41, "
Davide Pesaventod1b1bf62018-07-26 18:05:08 -0400429 "INTEREST: /producer/nack/duplicate?ndn.MustBeFresh=1&ndn.Nonce=4138343109\n"
Davide Pesaventof9126532018-08-04 18:31:06 -0400430 "1456768916.667099 IP 1.0.0.1 > 1.0.0.2, UDP, length 41, "
Davide Pesaventod1b1bf62018-07-26 18:05:08 -0400431 "INTEREST: /producer/nack/no-reason?ndn.MustBeFresh=1&ndn.Nonce=4034910304\n"
Davide Pesaventof9126532018-08-04 18:31:06 -0400432 "1456768916.767099 IP 1.0.0.2 > 1.0.0.1, UDP, length 55, "
433 "NDNLPv2, NACK (Congestion): /producer/nack/congestion?ndn.MustBeFresh=1&ndn.Nonce=2581361680\n"
434 "1456768916.867099 IP 1.0.0.2 > 1.0.0.1, UDP, length 54, "
435 "NDNLPv2, NACK (Duplicate): /producer/nack/duplicate?ndn.MustBeFresh=1&ndn.Nonce=4138343109\n"
436 "1456768916.967099 IP 1.0.0.2 > 1.0.0.1, UDP, length 54, "
437 "NDNLPv2, NACK (None): /producer/nack/no-reason?ndn.MustBeFresh=1&ndn.Nonce=4034910304\n"
438 "1456768917.067099 IP 1.0.0.1 > 1.0.0.2, TCP, length 42, "
Davide Pesaventod1b1bf62018-07-26 18:05:08 -0400439 "INTEREST: /producer/nack/congestion?ndn.MustBeFresh=1&ndn.Nonce=3192497423\n"
Davide Pesaventof9126532018-08-04 18:31:06 -0400440 "1456768917.267099 IP 1.0.0.2 > 1.0.0.1, TCP, length 55, "
441 "NDNLPv2, NACK (Congestion): /producer/nack/congestion?ndn.MustBeFresh=1&ndn.Nonce=3192497423\n"
442 "1456768917.367099 IP 1.0.0.1 > 1.0.0.2, TCP, length 82, "
Davide Pesaventod1b1bf62018-07-26 18:05:08 -0400443 "INTEREST: /producer/nack/duplicate?ndn.MustBeFresh=1&ndn.Nonce=522390724\n"
Davide Pesaventof9126532018-08-04 18:31:06 -0400444 "1456768917.567099 IP 1.0.0.2 > 1.0.0.1, TCP, length 54, "
445 "NDNLPv2, NACK (Duplicate): /producer/nack/duplicate?ndn.MustBeFresh=1&ndn.Nonce=522390724\n"
446 "1456768917.767099 IP 1.0.0.2 > 1.0.0.1, TCP, length 54, "
447 "NDNLPv2, NACK (None): /producer/nack/no-reason?ndn.MustBeFresh=1&ndn.Nonce=2002441365\n"
448 "1456768917.967099 IP 1.0.0.1 > 1.0.0.2, TCP, length 41, "
Davide Pesaventod1b1bf62018-07-26 18:05:08 -0400449 "INTEREST: /producer/nack/no-reason?ndn.MustBeFresh=1&ndn.Nonce=3776824408\n"
Davide Pesaventof9126532018-08-04 18:31:06 -0400450 "1456768918.067099 IP 1.0.0.2 > 1.0.0.1, TCP, length 54, "
451 "NDNLPv2, NACK (None): /producer/nack/no-reason?ndn.MustBeFresh=1&ndn.Nonce=3776824408\n";
Davide Pesaventoecd44802018-07-23 23:48:10 -0400452 BOOST_CHECK(output.is_equal(expected));
Vince Lehman277ecf02016-02-10 16:37:48 -0600453}
454
Davide Pesavento0ca7e692018-08-05 02:21:06 -0400455BOOST_AUTO_TEST_CASE(LinuxSllTcp4)
456{
457 dump.wantTimestamp = false;
458 this->readFile("tests/dump/linux-sll-tcp4.pcap");
459
460 const std::string expected =
461 "IP 162.211.64.84 > 131.179.196.46, TCP, length 57, "
462 "INTEREST: /ndn/edu/ucla/ping/4436024701616433461?ndn.MustBeFresh=1&ndn.Nonce=1827520902\n"
463 "IP 162.211.64.84 > 131.179.196.46, TCP, length 41, "
464 "INTEREST: /ndn/edu/arizona/ping/8202?ndn.Nonce=1059849935\n"
465 "IP 131.179.196.46 > 162.211.64.84, TCP, length 403, "
466 "DATA: /ndn/edu/arizona/ping/8202\n"
467 "IP 131.179.196.46 > 162.211.64.84, TCP, length 57, "
468 "INTEREST: /ndn/edu/ucla/ping/4436024701616433462?ndn.MustBeFresh=1&ndn.Nonce=4082468009\n"
469 "IP 162.211.64.84 > 131.179.196.46, TCP, length 57, "
470 "INTEREST: /ndn/edu/ucla/ping/4436024701616433462?ndn.MustBeFresh=1&ndn.Nonce=4082468009\n";
471 BOOST_CHECK(output.is_equal(expected));
472}
473
474BOOST_AUTO_TEST_CASE(LinuxSllUdp4)
475{
476 dump.wantTimestamp = false;
477 this->readFile("tests/dump/linux-sll-udp4.pcap");
478
479 const std::string expected =
480 "IP 162.211.64.84 > 131.179.196.46, UDP, length 42, "
481 "INTEREST: /ndn/edu/arizona/ping/31044?ndn.Nonce=3171630323\n"
482 "IP 131.179.196.46 > 162.211.64.84, UDP, length 404, "
483 "DATA: /ndn/edu/arizona/ping/31044\n";
484 BOOST_CHECK(output.is_equal(expected));
485}
486
487BOOST_AUTO_TEST_CASE(LinuxSllTcp6)
488{
489 dump.wantTimestamp = false;
490 this->readFile("tests/dump/linux-sll-tcp6.pcap");
491
492 const std::string expected =
493 "IP6 2602:fff6:d:b317::39f8 > 2001:660:3302:282c:160::163, TCP, length 42, "
494 "INTEREST: /ndn/edu/arizona/ping/19573?ndn.Nonce=777756283\n"
495 "IP6 2001:660:3302:282c:160::163 > 2602:fff6:d:b317::39f8, TCP, length 404, "
496 "DATA: /ndn/edu/arizona/ping/19573\n"
497 "IP6 2001:660:3302:282c:160::163 > 2602:fff6:d:b317::39f8, TCP, length 56, "
498 "INTEREST: /ndn/fr/lip6/ping/7847878851635149046?ndn.MustBeFresh=1&ndn.Nonce=1836363210\n";
499 BOOST_CHECK(output.is_equal(expected));
500}
501
502BOOST_AUTO_TEST_CASE(LinuxSllUdp6)
503{
504 dump.wantTimestamp = false;
505 this->readFile("tests/dump/linux-sll-udp6.pcap");
506
507 const std::string expected =
508 "IP6 2602:fff6:d:b317::39f8 > 2001:660:3302:282c:160::163, UDP, length 39, "
509 "INTEREST: /ndn/edu/arizona/ping/18?ndn.Nonce=571618686\n"
510 "IP6 2001:660:3302:282c:160::163 > 2602:fff6:d:b317::39f8, UDP, length 401, "
511 "DATA: /ndn/edu/arizona/ping/18\n"
512 "IP6 2001:660:3302:282c:160::163 > 2602:fff6:d:b317::39f8, UDP, length 56, "
513 "INTEREST: /ndn/fr/lip6/ping/7847878851635149038?ndn.MustBeFresh=1&ndn.Nonce=192371114\n";
514 BOOST_CHECK(output.is_equal(expected));
515}
516
Davide Pesaventoecd44802018-07-23 23:48:10 -0400517BOOST_AUTO_TEST_SUITE_END() // TestNdnDump
518BOOST_AUTO_TEST_SUITE_END() // Dump
Vince Lehman277ecf02016-02-10 16:37:48 -0600519
520} // namespace tests
521} // namespace dump
522} // namespace ndn