NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
rocketfuel-map-reader.h
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 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  * Hajime Tazaki (tazaki@sfc.wide.ad.jp)
20  * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
21  */
22 
23 #ifndef ROCKETFUEL_MAP_READER_H
24 #define ROCKETFUEL_MAP_READER_H
25 
26 #include "ns3/annotated-topology-reader.h"
27 #include "ns3/net-device-container.h"
28 #include "ns3/random-variable.h"
29 #include <set>
30 #include "ns3/data-rate.h"
31 
32 #include <boost/graph/adjacency_list.hpp>
33 
34 using namespace std;
35 
36 namespace ns3 {
37 
39 {
40  double averageRtt;
41  int clientNodeDegrees;
42 
43  //parameters for links Backbone <->Backbone
44  string minb2bBandwidth;
45  string minb2bDelay;
46 
47  string maxb2bBandwidth;
48  string maxb2bDelay;
49 
50  //parameters for links Backbone<->Gateway and Gateway <-> Gateway
51  string minb2gBandwidth;
52  string minb2gDelay;
53 
54  string maxb2gBandwidth;
55  string maxb2gDelay;
56 
57  //parameters for links Gateway <-> Customer
58  string ming2cBandwidth;
59  string ming2cDelay;
60 
61  string maxg2cBandwidth;
62  string maxg2cDelay;
63 };
64 
81 {
82 public:
83  RocketfuelMapReader (const std::string &path="", double scale=1.0, const string &referenceOspfRate="100Mbps");
84  virtual ~RocketfuelMapReader ();
85 
89  virtual
90  NodeContainer
91  Read ();
92 
107  virtual NodeContainer
108  Read (RocketfuelParams params, bool keepOneComponent=true, bool connectBackbones=true);
109 
110  const NodeContainer&
111  GetBackboneRouters() const;
112 
113  const NodeContainer&
114  GetGatewayRouters() const;
115 
116  const NodeContainer&
117  GetCustomerRouters() const;
118 
119  virtual void
120  SaveTopology (const std::string &file);
121 
122  virtual void
123  SaveGraphviz (const std::string &file);
124 
125 private:
127  RocketfuelMapReader& operator= (const RocketfuelMapReader&);
128 
129  // NodeContainer
130  void
131  GenerateFromMapsFile (int argc, char *argv[]);
132 
133  void
134  CreateLink (string nodeName1, string nodeName2,
135  double averageRtt,
136  const string &minBw, const string &maxBw,
137  const string &minDelay, const string &maxDelay);
138  void
139  KeepOnlyBiggestConnectedComponent ();
140 
141  void AssignClients(uint32_t clientDegree, uint32_t gwDegree);
142 
143  void
144  ConnectBackboneRouters ();
145 
146 private:
147  UniformVariable m_randVar;
148 
149  NodeContainer m_backboneRouters;
150  NodeContainer m_gatewayRouters;
151  NodeContainer m_customerRouters;
152 
153  typedef boost::adjacency_list_traits<boost::setS, boost::setS, boost::undirectedS> Traits;
154 
155  enum node_type_t {UNKNOWN = 0, CLIENT = 1, GATEWAY = 2, BACKBONE = 3};
156 
157  typedef boost::property< boost::vertex_name_t, std::string, boost::property
158  < boost::vertex_index_t, uint32_t, boost::property
159  < boost::vertex_rank_t, node_type_t, boost::property
160  < boost::vertex_color_t, std::string > > > > nodeProperty;
161 
162  typedef boost::no_property edgeProperty;
163 
164  typedef boost::adjacency_list< boost::setS, boost::setS, boost::undirectedS,
165  nodeProperty, edgeProperty > Graph;
166 
167  typedef map<string, Traits::vertex_descriptor> node_map_t;
168  node_map_t m_graphNodes;
169 
170  Graph m_graph;
171  uint32_t m_maxNodeId;
172 
173  const DataRate m_referenceOspfRate; // reference rate of OSPF metric calculation
174 
175 
176 private:
177  void
178  assignGw (Traits::vertex_descriptor vertex, uint32_t degree, node_type_t nodeType);
179 }; // end class RocketfuelMapReader
180 
181 }; // end namespace ns3
182 
183 
184 #endif /* ROCKETFUEL_MAP_READER_H */
Topology file reader and topology estimator (extension of Rocketfuel-format type).
This class reads annotated topology and apply settings to the corresponding nodes and links...