blob: 2c58bfe89fccbfa505b5d6eb5288aed4f9d54ed5 [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{
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080041 Packet::EnableChecking();
42 Packet::EnablePrinting();
43 std::string input ("./src/NDNabstraction/examples/sprint.weights");
Ilya Moiseenko58d26672011-12-08 13:48:06 -080044
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080045 // ------------------------------------------------------------
46 // -- Read topology data.
47 // --------------------------------------------
Ilya Moiseenko58d26672011-12-08 13:48:06 -080048
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080049 Ptr<RocketfuelWeightsReader> reader = CreateObject<RocketfuelWeightsReader> ();
50 reader->SetFileName (input);
Ilya Moiseenko58d26672011-12-08 13:48:06 -080051
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080052 NodeContainer nodes;
53 if (reader != 0)
Ilya Moiseenko58d26672011-12-08 13:48:06 -080054 {
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080055 nodes = reader->Read ();
Ilya Moiseenko58d26672011-12-08 13:48:06 -080056 }
57
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080058 if (reader->LinksSize () == 0)
Ilya Moiseenko58d26672011-12-08 13:48:06 -080059 {
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080060 NS_LOG_ERROR ("Problems reading the topology file. Failing.");
61 return -1;
Ilya Moiseenko58d26672011-12-08 13:48:06 -080062 }
63
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080064 NS_LOG_INFO("Nodes = " << nodes.GetN());
65 NS_LOG_INFO("Links = " << reader->LinksSize ());
Ilya Moiseenko58d26672011-12-08 13:48:06 -080066
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080067 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++ )
Ilya Moiseenko58d26672011-12-08 13:48:06 -080074 {
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080075 nc[i] = NodeContainer (iter->GetFromNode (), iter->GetToNode ());
Ilya Moiseenko58d26672011-12-08 13:48:06 -080076 }
77
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080078 NetDeviceContainer* ndc = new NetDeviceContainer[totlinks];
79 reader->ApplySettings(ndc,nc);
Ilya Moiseenko58d26672011-12-08 13:48:06 -080080
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080081 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}