Ilya Moiseenko | 9d25869 | 2011-09-01 11:20:11 -0700 | [diff] [blame] | 1 | /* -*- 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" |
| 22 | #include "ns3/annotated-topology-reader.h" |
| 23 | #include "ns3/ccnx-interest-header.h" |
| 24 | #include "ns3/uinteger.h" |
| 25 | #include "ns3/random-variable.h" |
| 26 | #include <limits> |
| 27 | #include "ns3/ccnx-header-helper.h" |
| 28 | #include "ns3/header.h" |
| 29 | #include "ns3/ccnx-name-components.h" |
| 30 | #include "ns3/nstime.h" |
| 31 | #include "ns3/buffer.h" |
| 32 | #include "ns3/log.h" |
| 33 | |
| 34 | #include <ctime> |
| 35 | #include <sstream> |
| 36 | |
| 37 | #include "ns3/internet-stack-helper.h" |
| 38 | #include "ns3/ipv4-list-routing-helper.h" |
| 39 | #include "ns3/ipv4-static-routing-helper.h" |
| 40 | #include "ns3/point-to-point-helper.h" |
| 41 | #include "ns3/application.h" |
| 42 | #include "ns3/ipv4-static-routing-helper.h" |
| 43 | #include "ns3/ipv4-list-routing-helper.h" |
| 44 | #include "ns3/annotated-topology-reader.h" |
| 45 | #include <list> |
| 46 | |
| 47 | |
| 48 | using namespace ns3; |
| 49 | using namespace std; |
| 50 | |
| 51 | NS_LOG_COMPONENT_DEFINE ("CcnxBasicRegressionTest"); |
| 52 | |
| 53 | class BasicRegressionTest : public TestCase |
| 54 | { |
| 55 | public: |
| 56 | |
| 57 | BasicRegressionTest (); |
| 58 | virtual ~BasicRegressionTest (); |
| 59 | |
| 60 | private: |
| 61 | virtual void DoRun (void); |
| 62 | }; |
| 63 | |
| 64 | BasicRegressionTest::BasicRegressionTest () |
| 65 | : TestCase ("Basic regression test") |
| 66 | { |
| 67 | } |
| 68 | |
| 69 | BasicRegressionTest::~BasicRegressionTest () |
| 70 | { |
| 71 | } |
| 72 | |
| 73 | void |
| 74 | BasicRegressionTest::DoRun(void) |
| 75 | { |
| 76 | //string input ("/Users/iliamo/ns3-abstract-ndn/ns-3.11/src/NDNabstraction/examples/simpletopology.txt"); |
| 77 | |
| 78 | // Set up command line parameters used to control the experiment. |
| 79 | //CommandLine cmd; |
| 80 | //cmd.AddValue ("input", "Name of the input file.", |
| 81 | // input); |
| 82 | //cmd.Parse (argc, argv); |
| 83 | |
| 84 | |
| 85 | // ------------------------------------------------------------ |
| 86 | // -- Read topology data. |
| 87 | // -------------------------------------------- |
| 88 | |
Alexander Afanasyev | e9c9d72 | 2012-01-19 16:59:30 -0800 | [diff] [blame^] | 89 | // string input = NS_TEST_SOURCEDIR; |
| 90 | // input += "/testtopology.txt"; |
Ilya Moiseenko | 9d25869 | 2011-09-01 11:20:11 -0700 | [diff] [blame] | 91 | |
Alexander Afanasyev | e9c9d72 | 2012-01-19 16:59:30 -0800 | [diff] [blame^] | 92 | // Ptr<AnnotatedTopologyReader> reader = CreateObject<AnnotatedTopologyReader> (); |
| 93 | // reader->SetFileName (input); |
Ilya Moiseenko | 9d25869 | 2011-09-01 11:20:11 -0700 | [diff] [blame] | 94 | |
Alexander Afanasyev | e9c9d72 | 2012-01-19 16:59:30 -0800 | [diff] [blame^] | 95 | // NodeContainer nodes; |
| 96 | // if (reader != 0) |
| 97 | // { |
| 98 | // nodes = reader->Read (); |
| 99 | // } |
| 100 | // else |
| 101 | // { |
| 102 | // NS_TEST_ASSERT_MSG_EQ (true, false, "file not found"); |
| 103 | // } |
Ilya Moiseenko | 9d25869 | 2011-09-01 11:20:11 -0700 | [diff] [blame] | 104 | |
Alexander Afanasyev | e9c9d72 | 2012-01-19 16:59:30 -0800 | [diff] [blame^] | 105 | // NS_TEST_ASSERT_MSG_EQ (7, reader->LinksSize (), "link count is wrong"); |
Ilya Moiseenko | 9d25869 | 2011-09-01 11:20:11 -0700 | [diff] [blame] | 106 | |
| 107 | |
Alexander Afanasyev | e9c9d72 | 2012-01-19 16:59:30 -0800 | [diff] [blame^] | 108 | // // ------------------------------------------------------------ |
| 109 | // // -- Create nodes and network stacks |
| 110 | // // -------------------------------------------- |
| 111 | // NS_LOG_INFO ("creating internet stack"); |
| 112 | // InternetStackHelper stack; |
Ilya Moiseenko | 9d25869 | 2011-09-01 11:20:11 -0700 | [diff] [blame] | 113 | |
| 114 | |
Alexander Afanasyev | e9c9d72 | 2012-01-19 16:59:30 -0800 | [diff] [blame^] | 115 | // //routing |
| 116 | // /*Ipv4StaticRoutingHelper staticRouting; |
| 117 | // Ipv4ListRoutingHelper listRH; |
| 118 | // listRH.Add (staticRouting, 0); |
| 119 | // stack.SetRoutingHelper (listRH); // has effect on the next Install () |
| 120 | // stack.Install (nodes); |
Ilya Moiseenko | 9d25869 | 2011-09-01 11:20:11 -0700 | [diff] [blame] | 121 | |
Alexander Afanasyev | e9c9d72 | 2012-01-19 16:59:30 -0800 | [diff] [blame^] | 122 | // NS_LOG_INFO ("creating ip4 addresses"); |
| 123 | // Ipv4AddressHelper address; |
| 124 | // address.SetBase ("10.0.0.0", "255.255.255.252");*/ |
Ilya Moiseenko | 9d25869 | 2011-09-01 11:20:11 -0700 | [diff] [blame] | 125 | |
Alexander Afanasyev | e9c9d72 | 2012-01-19 16:59:30 -0800 | [diff] [blame^] | 126 | // int totlinks = reader->LinksSize (); |
Ilya Moiseenko | 9d25869 | 2011-09-01 11:20:11 -0700 | [diff] [blame] | 127 | |
| 128 | |
Alexander Afanasyev | e9c9d72 | 2012-01-19 16:59:30 -0800 | [diff] [blame^] | 129 | // /// applying settings |
| 130 | // NS_LOG_INFO ("creating node containers"); |
| 131 | // NodeContainer* nc = new NodeContainer[totlinks]; |
| 132 | // TopologyReader::ConstLinksIterator iter; |
| 133 | // int i = 0; |
| 134 | // for ( iter = reader->LinksBegin (); iter != reader->LinksEnd (); iter++, i++ ) |
| 135 | // { |
| 136 | // nc[i] = NodeContainer (iter->GetFromNode (), iter->GetToNode ()); |
| 137 | // } |
Ilya Moiseenko | 9d25869 | 2011-09-01 11:20:11 -0700 | [diff] [blame] | 138 | |
Alexander Afanasyev | e9c9d72 | 2012-01-19 16:59:30 -0800 | [diff] [blame^] | 139 | // NetDeviceContainer* ndc = new NetDeviceContainer[totlinks]; |
| 140 | // reader->ApplySettings(ndc,nc); |
| 141 | // /// settings applied |
Ilya Moiseenko | 9d25869 | 2011-09-01 11:20:11 -0700 | [diff] [blame] | 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | // it creates little subnets, one for each couple of nodes. |
| 147 | /*NS_LOG_INFO ("creating ipv4 interfaces"); |
| 148 | Ipv4InterfaceContainer* ipic = new Ipv4InterfaceContainer[totlinks]; |
| 149 | for (int i = 0; i < totlinks; i++) |
| 150 | { |
| 151 | ipic[i] = address.Assign (ndc[i]); |
| 152 | address.NewNetwork (); |
| 153 | } |
| 154 | |
| 155 | // ------------------------------------------------------------ |
| 156 | // -- Run the simulation |
| 157 | // -------------------------------------------- |
| 158 | NS_LOG_INFO ("Run Simulation."); |
| 159 | Simulator::Stop (Seconds (20)); |
| 160 | Simulator::Run (); |
| 161 | Simulator::Destroy (); |
| 162 | |
| 163 | delete[] ipic; |
| 164 | delete[] ndc; |
| 165 | delete[] nc; |
| 166 | |
| 167 | NS_LOG_INFO ("Done."); |
| 168 | |
| 169 | */ |
| 170 | } |
| 171 | |
| 172 | class BasicRegressionTestSuite : public TestSuite |
| 173 | { |
| 174 | public: |
| 175 | BasicRegressionTestSuite (); |
| 176 | }; |
| 177 | |
| 178 | BasicRegressionTestSuite::BasicRegressionTestSuite () |
| 179 | : TestSuite ("ccnx-basic-regression-test-suite", UNIT) |
| 180 | { |
| 181 | SetDataDir (NS_TEST_SOURCEDIR); |
| 182 | AddTestCase (new BasicRegressionTest); |
| 183 | } |
| 184 | |
| 185 | static BasicRegressionTestSuite suite; |