blob: 3776c8ae228e0ef80fb07675fd2d15efff5deb00 [file] [log] [blame]
Yuanzhi Gaodd516fe2015-04-23 04:18:24 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
4 *
5 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
7 *
8 * ndnSIM is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
19
20#include "model/ndn-header.hpp"
21#include "model/ndn-ns3.hpp"
22#include "helper/ndn-stack-helper.hpp"
23
24#include <ndn-cxx/interest.hpp>
25#include <ndn-cxx/data.hpp>
26
27#include "../tests-common.hpp"
28
29namespace ns3 {
30namespace ndn {
31
32BOOST_FIXTURE_TEST_SUITE(ModelNdnHeader, CleanupFixture)
33
34BOOST_AUTO_TEST_CASE(TypeId)
35{
36 auto interest = make_shared<ndn::Interest>("/prefix");
37 PacketHeader<Interest> interestPktHeader(*interest);
38 BOOST_CHECK_EQUAL(interestPktHeader.GetTypeId().GetName().c_str(), "ns3::ndn::Interest");
39
40 auto data = make_shared<ndn::Data>();
41 data->setFreshnessPeriod(ndn::time::milliseconds(1000));
42 data->setContent(std::make_shared< ::ndn::Buffer>(1024));
43 ndn::StackHelper::getKeyChain().sign(*data);
44 PacketHeader<Data> dataPktHeader(*data);
45
46 BOOST_CHECK_EQUAL(dataPktHeader.GetTypeId().GetName().c_str(), "ns3::ndn::Data");
47 BOOST_CHECK_EQUAL(dataPktHeader.GetSerializedSize(), 1354); // 328 + 1024
48}
49
50BOOST_AUTO_TEST_SUITE_END()
51
52} // namespace ndn
53} // namespace ns3