blob: 2e751f7a9d32b4ddabb1250c64cf3c10c9a12370 [file] [log] [blame]
Alexander Afanasyevec1e3952012-08-20 13:48:15 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2011,2012 University of California, Los Angeles
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 */
20
21#include "generic-tests.h"
22#include "ns3/core-module.h"
23#include "ns3/ndnSIM-module.h"
24#include "ns3/point-to-point-module.h"
25
26#include "../model/pit/ndn-pit-impl.h"
27#include "../utils/trie/persistent-policy.h"
28#include "../apps/ndn-producer.h"
29
30#include <boost/lexical_cast.hpp>
31
32using namespace std;
33
34NS_LOG_COMPONENT_DEFINE ("ndn.test.Generic");
35
36namespace ns3 {
37namespace ndn {
38
39void
40GenericTests::DoRun ()
41{
42 NodeContainer nodes;
43 nodes.Create (2);
44
45 PointToPointHelper p2p;
46 p2p.Install (nodes);
47
48 StackHelper ndn;
49 ndn.SetDefaultRoutes (true);
50 ndn.Install (nodes);
51
52 Ptr<Node> node = nodes.Get (0);
53
54 Ptr<Pit> pit = node->GetObject<Pit> ();
55
56 Ptr<InterestHeader> header = Create<InterestHeader> ();
57 header->SetName (Create<NameComponents> ("/bla"));
58 header->SetInterestLifetime (Seconds (100));
59
60 Ptr<pit::Entry> e1 = pit->Create (header);
61 NS_ASSERT (e1 != 0);
62
63 header = Create<InterestHeader> ();
64 header->SetName (Create<NameComponents> ("/foo"));
65 header->SetInterestLifetime (Seconds (100));
66
67 Ptr<pit::Entry> e2 = pit->Create (header);
68 NS_ASSERT (e2 != 0);
69
70 list< Ptr< pit::Entry > > l;
71
72 l.push_back (e1);
73 l.push_back (e2);
74
75 BOOST_FOREACH (Ptr<pit::Entry> entry, l)
76 {
77 cout << "* " << entry->GetPrefix () << endl;
78 }
79
80 l.remove (e2);
81
82 BOOST_FOREACH (Ptr<pit::Entry> entry, l)
83 {
84 cout << "* " << entry->GetPrefix () << endl;
85 }
86}
87
88} // namespace ndn
89} // namespace ns3