blob: 836759f89d1c945e4e22a2f8f2c011914b5ac38f [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>
31#include "ns3/visualizer-module.h"
32#include "ns3/annotated-topology-reader.h"
33
34using namespace ns3;
35using namespace std;
36
37NS_LOG_COMPONENT_DEFINE ("CcnxAbileneTopology");
38
39int
40main (int argc, char *argv[])
41{
42 //GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::VisualSimulatorImpl"));
43 Packet::EnableChecking();
44 Packet::EnablePrinting();
45 string input ("./src/NDNabstraction/examples/abilene-topology.txt");
46
47 CommandLine cmd;
48 cmd.Parse (argc, argv);
49
50 // ------------------------------------------------------------
51 // -- Read topology data.
52 // --------------------------------------------
53
54 Ptr<AnnotatedTopologyReader> reader = CreateObject<AnnotatedTopologyReader> ();
55 reader->SetFileName (input);
56
57 NodeContainer nodes;
58 if (reader != 0)
59 {
60 nodes = reader->Read ();
61 }
62
63 if (reader->LinksSize () == 0)
64 {
65 NS_LOG_ERROR ("Problems reading the topology file. Failing.");
66 return -1;
67 }
68
69 NS_LOG_INFO("Nodes = " << nodes.GetN());
70 NS_LOG_INFO("Links = " << reader->LinksSize ());
71
72 int totlinks = reader->LinksSize ();
73 ///*** applying settings
74 NS_LOG_INFO ("creating node containers");
75 NodeContainer* nc = new NodeContainer[totlinks];
76 TopologyReader::ConstLinksIterator iter;
77 int i = 0;
78 for ( iter = reader->LinksBegin (); iter != reader->LinksEnd (); iter++, i++ )
79 {
80 nc[i] = NodeContainer (iter->GetFromNode (), iter->GetToNode ());
81 }
82
83 NetDeviceContainer* ndc = new NetDeviceContainer[totlinks];
84 reader->ApplySettings(ndc,nc);
85 reader->BoundingBox(nc, 100.0, 100.0, 400.0,400.0);
86
87
88 // Install CCNx stack
89 NS_LOG_INFO ("Installing CCNx stack");
90 CcnxStackHelper ccnxHelper(Ccnx::NDN_FLOODING);
91 ccnxHelper.InstallAll ();
92
93 NS_LOG_INFO ("Installing Applications");
94 CcnxConsumerHelper consumerHelper ("preved");
95 ApplicationContainer consumers = consumerHelper.Install (nc[0]);
96
97 consumers.Start (Seconds (0));
98 consumers.Stop (Seconds (20));
99
100
101 Simulator::Stop (Seconds (20));
102 NS_LOG_INFO ("Run Simulation.");
103 Simulator::Run ();
104 Simulator::Destroy ();
105 NS_LOG_INFO ("Done.");
106 return 0;
107}