blob: 8d3c6610e111fa0e540cacd72eddc8f8ef19f4c2 [file] [log] [blame]
Ilya Moiseenko9d258692011-09-01 11:20:11 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2011 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: Ilya Moiseenko <iliamo@cs.ucla.edu>
19 */
20
21#include "ns3/test.h"
Ilya Moiseenko9d258692011-09-01 11:20:11 -070022#include "ns3/ccnx-interest-header.h"
23#include "ns3/uinteger.h"
24#include "ns3/random-variable.h"
25#include <limits>
26#include "ns3/ccnx-header-helper.h"
27#include "ns3/header.h"
28#include "ns3/ccnx-name-components.h"
29#include "ns3/nstime.h"
30#include "ns3/buffer.h"
31#include "ns3/log.h"
32
33#include <ctime>
34#include <sstream>
35
36#include "ns3/internet-stack-helper.h"
37#include "ns3/ipv4-list-routing-helper.h"
38#include "ns3/ipv4-static-routing-helper.h"
39#include "ns3/point-to-point-helper.h"
40#include "ns3/application.h"
41#include "ns3/ipv4-static-routing-helper.h"
42#include "ns3/ipv4-list-routing-helper.h"
Alexander Afanasyev864522f2012-05-31 13:33:57 -070043
Ilya Moiseenko9d258692011-09-01 11:20:11 -070044#include <list>
45
46
47using namespace ns3;
48using namespace std;
49
50NS_LOG_COMPONENT_DEFINE ("CcnxBasicRegressionTest");
51
52class BasicRegressionTest : public TestCase
53{
54public:
55
Alexander Afanasyev864522f2012-05-31 13:33:57 -070056 BasicRegressionTest ();
57 virtual ~BasicRegressionTest ();
Ilya Moiseenko9d258692011-09-01 11:20:11 -070058
59private:
Alexander Afanasyev864522f2012-05-31 13:33:57 -070060 virtual void DoRun (void);
Ilya Moiseenko9d258692011-09-01 11:20:11 -070061};
62
63BasicRegressionTest::BasicRegressionTest ()
Alexander Afanasyev864522f2012-05-31 13:33:57 -070064 : TestCase ("Basic regression test")
Ilya Moiseenko9d258692011-09-01 11:20:11 -070065{
66}
67
68BasicRegressionTest::~BasicRegressionTest ()
69{
70}
71
72void
73BasicRegressionTest::DoRun(void)
74{
Alexander Afanasyev864522f2012-05-31 13:33:57 -070075 //string input ("/Users/iliamo/ns3-abstract-ndn/ns-3.11/src/NDNabstraction/examples/simpletopology.txt");
Ilya Moiseenko9d258692011-09-01 11:20:11 -070076
Alexander Afanasyev864522f2012-05-31 13:33:57 -070077 // Set up command line parameters used to control the experiment.
78 //CommandLine cmd;
79 //cmd.AddValue ("input", "Name of the input file.",
80 // input);
81 //cmd.Parse (argc, argv);
Ilya Moiseenko9d258692011-09-01 11:20:11 -070082
83
Alexander Afanasyev864522f2012-05-31 13:33:57 -070084 // ------------------------------------------------------------
85 // -- Read topology data.
86 // --------------------------------------------
Ilya Moiseenko9d258692011-09-01 11:20:11 -070087
Alexander Afanasyev864522f2012-05-31 13:33:57 -070088 // string input = NS_TEST_SOURCEDIR;
89 // input += "/testtopology.txt";
Ilya Moiseenko9d258692011-09-01 11:20:11 -070090
Alexander Afanasyev864522f2012-05-31 13:33:57 -070091 // Ptr<AnnotatedTopologyReader> reader = CreateObject<AnnotatedTopologyReader> ();
92 // reader->SetFileName (input);
Ilya Moiseenko9d258692011-09-01 11:20:11 -070093
Alexander Afanasyev864522f2012-05-31 13:33:57 -070094 // NodeContainer nodes;
95 // if (reader != 0)
96 // {
97 // nodes = reader->Read ();
98 // }
99 // else
100 // {
101 // NS_TEST_ASSERT_MSG_EQ (true, false, "file not found");
102 // }
Ilya Moiseenko9d258692011-09-01 11:20:11 -0700103
Alexander Afanasyev864522f2012-05-31 13:33:57 -0700104 // NS_TEST_ASSERT_MSG_EQ (7, reader->LinksSize (), "link count is wrong");
Ilya Moiseenko9d258692011-09-01 11:20:11 -0700105
106
Alexander Afanasyev864522f2012-05-31 13:33:57 -0700107 // // ------------------------------------------------------------
108 // // -- Create nodes and network stacks
109 // // --------------------------------------------
110 // NS_LOG_INFO ("creating internet stack");
111 // InternetStackHelper stack;
Ilya Moiseenko9d258692011-09-01 11:20:11 -0700112
113
Alexander Afanasyev864522f2012-05-31 13:33:57 -0700114 // //routing
115 // /*Ipv4StaticRoutingHelper staticRouting;
116 // Ipv4ListRoutingHelper listRH;
117 // listRH.Add (staticRouting, 0);
118 // stack.SetRoutingHelper (listRH); // has effect on the next Install ()
119 // stack.Install (nodes);
Ilya Moiseenko9d258692011-09-01 11:20:11 -0700120
Alexander Afanasyev864522f2012-05-31 13:33:57 -0700121 // NS_LOG_INFO ("creating ip4 addresses");
122 // Ipv4AddressHelper address;
123 // address.SetBase ("10.0.0.0", "255.255.255.252");*/
Ilya Moiseenko9d258692011-09-01 11:20:11 -0700124
Alexander Afanasyev864522f2012-05-31 13:33:57 -0700125 // int totlinks = reader->LinksSize ();
Ilya Moiseenko9d258692011-09-01 11:20:11 -0700126
127
Alexander Afanasyev864522f2012-05-31 13:33:57 -0700128 // /// applying settings
129 // NS_LOG_INFO ("creating node containers");
130 // NodeContainer* nc = new NodeContainer[totlinks];
131 // TopologyReader::ConstLinksIterator iter;
132 // int i = 0;
133 // for ( iter = reader->LinksBegin (); iter != reader->LinksEnd (); iter++, i++ )
134 // {
135 // nc[i] = NodeContainer (iter->GetFromNode (), iter->GetToNode ());
136 // }
Ilya Moiseenko9d258692011-09-01 11:20:11 -0700137
Alexander Afanasyev864522f2012-05-31 13:33:57 -0700138 // NetDeviceContainer* ndc = new NetDeviceContainer[totlinks];
139 // reader->ApplySettings(ndc,nc);
140 // /// settings applied
Ilya Moiseenko9d258692011-09-01 11:20:11 -0700141
142
143
144
Alexander Afanasyev864522f2012-05-31 13:33:57 -0700145 // it creates little subnets, one for each couple of nodes.
146 /*NS_LOG_INFO ("creating ipv4 interfaces");
Ilya Moiseenko9d258692011-09-01 11:20:11 -0700147 Ipv4InterfaceContainer* ipic = new Ipv4InterfaceContainer[totlinks];
148 for (int i = 0; i < totlinks; i++)
149 {
Alexander Afanasyev864522f2012-05-31 13:33:57 -0700150 ipic[i] = address.Assign (ndc[i]);
151 address.NewNetwork ();
Ilya Moiseenko9d258692011-09-01 11:20:11 -0700152 }
153
154 // ------------------------------------------------------------
155 // -- Run the simulation
156 // --------------------------------------------
157 NS_LOG_INFO ("Run Simulation.");
158 Simulator::Stop (Seconds (20));
159 Simulator::Run ();
160 Simulator::Destroy ();
161
162 delete[] ipic;
163 delete[] ndc;
164 delete[] nc;
165
166 NS_LOG_INFO ("Done.");
167
Alexander Afanasyev864522f2012-05-31 13:33:57 -0700168 */
Ilya Moiseenko9d258692011-09-01 11:20:11 -0700169}
170
171class BasicRegressionTestSuite : public TestSuite
172{
173public:
Alexander Afanasyev864522f2012-05-31 13:33:57 -0700174 BasicRegressionTestSuite ();
Ilya Moiseenko9d258692011-09-01 11:20:11 -0700175};
176
177BasicRegressionTestSuite::BasicRegressionTestSuite ()
Alexander Afanasyev864522f2012-05-31 13:33:57 -0700178 : TestSuite ("ccnx-basic-regression-test-suite", UNIT)
Ilya Moiseenko9d258692011-09-01 11:20:11 -0700179{
Alexander Afanasyev864522f2012-05-31 13:33:57 -0700180 SetDataDir (NS_TEST_SOURCEDIR);
181 AddTestCase (new BasicRegressionTest);
Ilya Moiseenko9d258692011-09-01 11:20:11 -0700182}
183
184static BasicRegressionTestSuite suite;