blob: bd94360fe2b802f3a262e4c0b469e0cfd2563c82 [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-ns3.hpp"
21#include "helper/ndn-stack-helper.hpp"
22#include "model/ndn-header.hpp"
23#include "utils/ndn-ns3-packet-tag.hpp"
24
25#include <ndn-cxx/encoding/block.hpp>
26#include <ndn-cxx/interest.hpp>
27#include <ndn-cxx/data.hpp>
28#include <ndn-cxx/name.hpp>
29
30#include "../tests-common.hpp"
31
32namespace ns3 {
33namespace ndn {
34
35BOOST_FIXTURE_TEST_SUITE(ModelNdnNs3, CleanupFixture)
36
37BOOST_AUTO_TEST_CASE(ToPacket)
38{
39 auto interest = make_shared<ndn::Interest>("/prefix");
40 Ptr<Packet> interestPacket = Convert::ToPacket(*interest);
41 uint32_t type1;
42 type1 = Convert::getPacketType(interestPacket);
43
44 BOOST_CHECK_EQUAL(type1, ::ndn::tlv::Interest);
45
46 auto data = std::make_shared<ndn::Data>(interest->getName());
47 data->setFreshnessPeriod(ndn::time::milliseconds(1000));
48 data->setContent(std::make_shared< ::ndn::Buffer>(1024));
49 ndn::StackHelper::getKeyChain().sign(*data);
50 Ptr<Packet> DataPacket = Convert::ToPacket(*data);
51 uint32_t type2;
52 type2 = Convert::getPacketType(DataPacket);
53
54 BOOST_CHECK_EQUAL(type2, ::ndn::tlv::Data);
55}
56
57BOOST_AUTO_TEST_SUITE_END()
58
59} // namespace ndn
60} // namespace ns3