blob: f118b04dac8fea370d13615c5cb7f594a6ee5d62 [file] [log] [blame]
Ilya Moiseenko46bdc7c2012-01-09 14:44:15 -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
23#include "ns3/core-module.h"
24#include "ns3/network-module.h"
25#include "ns3/point-to-point-module.h"
26#include "ns3/NDNabstraction-module.h"
27#include "ns3/point-to-point-grid.h"
28#include "ns3/ipv4-global-routing-helper.h"
29#include "ns3/animation-interface.h"
30// #include "ns3/ccnx-l3-protocol.h"
31
32#include <iostream>
33#include <sstream>
34#include "ns3/annotated-topology-reader.h"
35#include "../utils/spring-mobility-helper.h"
36
37#include "ns3/config-store.h"
38
39using namespace ns3;
40using namespace std;
41
42NS_LOG_COMPONENT_DEFINE ("CcnxLinkFailureAbilene");
43
44
45int
46main (int argc, char *argv[])
47{
48 // Packet::EnableChecking();
49 // Packet::EnablePrinting();
50 string input ("./src/NDNabstraction/examples/abilene-topology.txt");
51
52 Time finishTime = Seconds (20.0);
53 string animationFile;
54 string strategy = "ns3::CcnxFloodingStrategy";
55 CommandLine cmd;
56 cmd.AddValue ("finish", "Finish time", finishTime);
57 cmd.AddValue ("netanim", "NetAnim filename", animationFile);
58 cmd.AddValue ("strategy", "CCNx forwarding strategy", strategy);
59 cmd.Parse (argc, argv);
60
61 ConfigStore config;
62 config.ConfigureDefaults ();
63
64 // ------------------------------------------------------------
65 // -- Read topology data.
66 // --------------------------------------------
67
68 AnnotatedTopologyReader reader ("/abilene");
69 reader.SetMobilityModel ("ns3::SpringMobilityModel");
70 reader.SetFileName (input);
71
72 NodeContainer nodes = reader.Read ();
73
74 if (reader.LinksSize () == 0)
75 {
76 NS_LOG_ERROR ("Problems reading the topology file. Failing.");
77 return -1;
78 }
79
80 SpringMobilityHelper::InstallSprings (reader.LinksBegin (), reader.LinksEnd ());
81
82 // InternetStackHelper stack;
83 Ipv4GlobalRoutingHelper ipv4RoutingHelper ("ns3::Ipv4GlobalRoutingOrderedNexthops");
84 stack.SetRoutingHelper (ipv4RoutingHelper);
85 stack.Install (nodes);
86
87 // reader.AssignIpv4Addresses (Ipv4Address ("10.0.0.0"));
88
89 NS_LOG_INFO("Nodes = " << nodes.GetN());
90 NS_LOG_INFO("Links = " << reader.LinksSize ());
91
92 // Install CCNx stack
93 NS_LOG_INFO ("Installing CCNx stack");
94 CcnxStackHelper ccnxHelper;
95 ccnxHelper.SetForwardingStrategy (strategy);
96 ccnxHelper.EnableLimits (false, Seconds(0.1));
97 ccnxHelper.SetDefaultRoutes (true);
98 ccnxHelper.InstallAll ();
99
100 NS_LOG_INFO ("Installing Applications");
101 CcnxConsumerHelper consumerHelper ("/5");
102 ApplicationContainer consumers = consumerHelper.Install (Names::Find<Node> ("/abilene", "ATLAng"));
103
104 // CcnxProducerHelper producerHelper ("/5",1024);
105 // ApplicationContainer producers = producerHelper.Install (Names::Find<Node> ("/abilene", "IPLSng"));
106
107 // // Populate FIB based on IPv4 global routing controller
108 // ccnxHelper.InstallFakeGlobalRoutes ();
109 // ccnxHelper.InstallRouteTo (Names::Find<Node> ("/abilene", "IPLSng"));
110
111 // Simulator::Schedule (Seconds (1.0), PrintFIBs);
112 // PrintFIBs ();
113
114 // Simulator::Schedule (Seconds (10.0), PrintTime);
115
116 Simulator::Stop (finishTime);
117
118 AnimationInterface *anim = 0;
119 if (animationFile != "")
120 {
121 anim = new AnimationInterface (animationFile);
122 anim->SetMobilityPollInterval (Seconds (1));
123 }
124
125 // NS_LOG_INFO ("Configure Tracing.");
126 /*AggregateTrace trace;
127 Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::CcnxConsumer/TransmittedInterests",
128 MakeCallback (&AggregateTrace::TransmittedInterests, &trace));
129
130 Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::CcnxConsumer/ReceivedNacks",
131 MakeCallback (&AggregateTrace::ReceivedNacks, &trace));
132
133 Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::CcnxProducer/ReceivedInterests",
134 MakeCallback (&AggregateTrace::ReceivedInterests, &trace));
135
136 Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::CcnxProducer/TransmittedContentObjects",
137 MakeCallback (&AggregateTrace::TransmittedData, &trace));
138
139 Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::CcnxConsumer/ReceivedContentObjects",
140 MakeCallback (&AggregateTrace::ReceivedData, &trace));
141 */
142 // Config::Connect("/NodeList/*/ns3::CcnxL3Protocol/TransmittedInterestTrace",
143 // MakeCallback (&OnTransmittedInterest));
144 // Config::Connect ("/NodeList/*/ns3::CcnxL3Protocol/ReceivedInterestTrace",
145 // MakeCallback (&OnReceivedInterest));
146 // Config::Connect ("/NodeList/*/ns3::CcnxL3Protocol/DroppedInterestTrace",
147 // MakeCallback (&OnDroppedInterest));
148
149 // Config::Connect ("/NodeList/*/ns3::CcnxL3Protocol/ReceivedDataTrace",
150 // MakeCallback (&OnReceivedData));
151 // Config::Connect ("/NodeList/*/ns3::CcnxL3Protocol/TransmittedDataTrace",
152 // MakeCallback (&OnTransmittedData));
153 // Config::Connect ("/NodeList/*/ns3::CcnxL3Protocol/DroppedDataTrace",
154 // MakeCallback (&OnDroppedData));
155
156 config.ConfigureAttributes ();
157
158 NS_LOG_INFO ("Run Simulation.");
159 Simulator::Run ();
160 Simulator::Destroy ();
161 NS_LOG_INFO ("Done.");
162
163 // NS_LOG_INFO("Total received interests = " << receivedInterests);
164 // NS_LOG_INFO("Total transmitted interests = " << transmittedInterests);
165 // NS_LOG_INFO("Total dropped interests = " << droppedInterests);
166 // NS_LOG_INFO("Total received data = " << receivedData);
167 // NS_LOG_INFO("Total transmitted data = " << transmittedData);
168 // NS_LOG_INFO("Total dropped data = " << droppedData);
169 NS_LOG_INFO (trace);
170 return 0;
171}