blob: 99da7eb33b40ebaf97ccf679b12fec80d56591a9 [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/annotated-topology-reader.h"
32
33using namespace ns3;
34using namespace std;
35
36NS_LOG_COMPONENT_DEFINE ("CcnxAbileneTopology");
37
38int
39main (int argc, char *argv[])
40{
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080041 // Packet::EnableChecking();
42 // Packet::EnablePrinting();
43 string input ("./src/NDNabstraction/examples/abilene-topology.txt");
Ilya Moiseenko58d26672011-12-08 13:48:06 -080044
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080045 CommandLine cmd;
46 cmd.Parse (argc, argv);
Ilya Moiseenko58d26672011-12-08 13:48:06 -080047
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080048 // ------------------------------------------------------------
49 // -- Read topology data.
50 // --------------------------------------------
Ilya Moiseenko58d26672011-12-08 13:48:06 -080051
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080052 Ptr<AnnotatedTopologyReader> reader = CreateObject<AnnotatedTopologyReader> ();
53 reader->SetFileName (input);
Ilya Moiseenko58d26672011-12-08 13:48:06 -080054
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080055 NodeContainer nodes;
56 if (reader != 0)
Ilya Moiseenko58d26672011-12-08 13:48:06 -080057 {
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080058 nodes = reader->Read ();
Ilya Moiseenko58d26672011-12-08 13:48:06 -080059 }
60
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080061 if (reader->LinksSize () == 0)
Ilya Moiseenko58d26672011-12-08 13:48:06 -080062 {
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080063 NS_LOG_ERROR ("Problems reading the topology file. Failing.");
64 return -1;
Ilya Moiseenko58d26672011-12-08 13:48:06 -080065 }
66
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080067 NS_LOG_INFO("Nodes = " << nodes.GetN());
68 NS_LOG_INFO("Links = " << reader->LinksSize ());
Ilya Moiseenko58d26672011-12-08 13:48:06 -080069
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080070 int totlinks = reader->LinksSize ();
71 ///*** applying settings
72 NS_LOG_INFO ("creating node containers");
73 NodeContainer* nc = new NodeContainer[totlinks];
74 TopologyReader::ConstLinksIterator iter;
75 int i = 0;
76 for ( iter = reader->LinksBegin (); iter != reader->LinksEnd (); iter++, i++ )
Ilya Moiseenko58d26672011-12-08 13:48:06 -080077 {
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080078 nc[i] = NodeContainer (iter->GetFromNode (), iter->GetToNode ());
Ilya Moiseenko58d26672011-12-08 13:48:06 -080079 }
80
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080081 NetDeviceContainer* ndc = new NetDeviceContainer[totlinks];
82 reader->ApplySettings(ndc,nc);
83 reader->BoundingBox(nc, 100.0, 100.0, 400.0,400.0);
Ilya Moiseenko58d26672011-12-08 13:48:06 -080084
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080085 // Install CCNx stack
86 NS_LOG_INFO ("Installing CCNx stack");
87 CcnxStackHelper ccnxHelper;
88 // ccnxHelper.SetForwardingStrategy (strategy);
89 ccnxHelper.EnableLimits (true, Seconds(0.1));
90 ccnxHelper.InstallAll ();
Ilya Moiseenko58d26672011-12-08 13:48:06 -080091
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080092 NS_LOG_INFO ("Installing Applications");
93 CcnxConsumerHelper consumerHelper ("preved");
94 ApplicationContainer consumers = consumerHelper.Install (nc[0]);
Ilya Moiseenko58d26672011-12-08 13:48:06 -080095
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080096 consumers.Start (Seconds (0));
97 consumers.Stop (Seconds (20));
Ilya Moiseenko58d26672011-12-08 13:48:06 -080098
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080099 Simulator::Stop (Seconds (20));
100 NS_LOG_INFO ("Run Simulation.");
101 Simulator::Run ();
102 Simulator::Destroy ();
103 NS_LOG_INFO ("Done.");
104 return 0;
105}