blob: 526858b2d70870a892eecf45a604fd1c8fea1186 [file] [log] [blame]
Ilya Moiseenko58d26672011-12-08 13:48:06 -08001/* -*- 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>
Ilya Moiseenko58d26672011-12-08 13:48:06 -080031#include "ns3/rocketfuel-topology-reader.h"
32
33
34using namespace ns3;
35
36NS_LOG_COMPONENT_DEFINE ("CcnxSprintTopology");
37
38int
39main (int argc, char *argv[])
40{
41 Packet::EnableChecking();
42 Packet::EnablePrinting();
43 std::string input ("./src/NDNabstraction/examples/sprint.weights");
44
45 // ------------------------------------------------------------
46 // -- Read topology data.
47 // --------------------------------------------
48
49 Ptr<RocketfuelWeightsReader> reader = CreateObject<RocketfuelWeightsReader> ();
50 reader->SetFileName (input);
51
52 NodeContainer nodes;
53 if (reader != 0)
54 {
55 nodes = reader->Read ();
56 }
57
58 if (reader->LinksSize () == 0)
59 {
60 NS_LOG_ERROR ("Problems reading the topology file. Failing.");
61 return -1;
62 }
63
64 NS_LOG_INFO("Nodes = " << nodes.GetN());
65 NS_LOG_INFO("Links = " << reader->LinksSize ());
66
67 int totlinks = reader->LinksSize ();
68 ///*** applying settings
69 NS_LOG_INFO ("creating node containers");
70 NodeContainer* nc = new NodeContainer[totlinks];
71 TopologyReader::ConstLinksIterator iter;
72 int i = 0;
73 for ( iter = reader->LinksBegin (); iter != reader->LinksEnd (); iter++, i++ )
74 {
75 nc[i] = NodeContainer (iter->GetFromNode (), iter->GetToNode ());
76 }
77
78 NetDeviceContainer* ndc = new NetDeviceContainer[totlinks];
79 reader->ApplySettings(ndc,nc);
80
81 NS_LOG_INFO ("Run Simulation.");
82 Simulator::Run ();
83 Simulator::Destroy ();
84 NS_LOG_INFO ("Done.");
85 return 0;
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080086}