Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [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 | |
| 22 | #include "ns3/core-module.h" |
| 23 | #include "ns3/network-module.h" |
| 24 | #include "ns3/point-to-point-module.h" |
| 25 | #include "ns3/NDNabstraction-module.h" |
| 26 | #include "ns3/point-to-point-grid.h" |
| 27 | #include "ns3/ipv4-global-routing-helper.h" |
| 28 | |
| 29 | #include <iostream> |
| 30 | #include <sstream> |
| 31 | #include "ns3/visualizer-module.h" |
| 32 | #include "ns3/rocketfuel-topology-reader.h" |
| 33 | |
| 34 | |
| 35 | using namespace ns3; |
| 36 | |
| 37 | NS_LOG_COMPONENT_DEFINE ("CcnxSprintTopology"); |
| 38 | |
| 39 | int |
| 40 | main (int argc, char *argv[]) |
| 41 | { |
| 42 | Packet::EnableChecking(); |
| 43 | Packet::EnablePrinting(); |
| 44 | std::string input ("./src/NDNabstraction/examples/sprint.weights"); |
| 45 | |
| 46 | // ------------------------------------------------------------ |
| 47 | // -- Read topology data. |
| 48 | // -------------------------------------------- |
| 49 | |
| 50 | Ptr<RocketfuelWeightsReader> reader = CreateObject<RocketfuelWeightsReader> (); |
| 51 | reader->SetFileName (input); |
| 52 | |
| 53 | NodeContainer nodes; |
| 54 | if (reader != 0) |
| 55 | { |
| 56 | nodes = reader->Read (); |
| 57 | } |
| 58 | |
| 59 | if (reader->LinksSize () == 0) |
| 60 | { |
| 61 | NS_LOG_ERROR ("Problems reading the topology file. Failing."); |
| 62 | return -1; |
| 63 | } |
| 64 | |
| 65 | NS_LOG_INFO("Nodes = " << nodes.GetN()); |
| 66 | NS_LOG_INFO("Links = " << reader->LinksSize ()); |
| 67 | |
| 68 | int totlinks = reader->LinksSize (); |
| 69 | ///*** applying settings |
| 70 | NS_LOG_INFO ("creating node containers"); |
| 71 | NodeContainer* nc = new NodeContainer[totlinks]; |
| 72 | TopologyReader::ConstLinksIterator iter; |
| 73 | int i = 0; |
| 74 | for ( iter = reader->LinksBegin (); iter != reader->LinksEnd (); iter++, i++ ) |
| 75 | { |
| 76 | nc[i] = NodeContainer (iter->GetFromNode (), iter->GetToNode ()); |
| 77 | } |
| 78 | |
| 79 | NetDeviceContainer* ndc = new NetDeviceContainer[totlinks]; |
| 80 | reader->ApplySettings(ndc,nc); |
| 81 | |
| 82 | NS_LOG_INFO ("Run Simulation."); |
| 83 | Simulator::Run (); |
| 84 | Simulator::Destroy (); |
| 85 | NS_LOG_INFO ("Done."); |
| 86 | return 0; |
| 87 | } |