blob: 126c0396db4222aab2bb14f38d7252edead42c69 [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) 2010 Hajime Tazaki
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: Hajime Tazaki (tazaki@sfc.wide.ad.jp)
19 * Ilya Moiseenko <iliamo@cs.ucla.edu>
20 */
21
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080022#ifndef ROCKETFUEL_TOPOLOGY_WEIGHTS_READER_H
23#define ROCKETFUEL_TOPOLOGY_WEIGHTS_READER_H
Ilya Moiseenko58d26672011-12-08 13:48:06 -080024
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080025#include "annotated-topology-reader.h"
Alexander Afanasyev07827182011-12-13 01:07:32 -080026#include "ns3/net-device-container.h"
Ilya Moiseenko58d26672011-12-08 13:48:06 -080027
28namespace ns3 {
29
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080030// ------------------------------------------------------------
31// --------------------------------------------
32/**
33 * \brief Topology file reader (extension of Rocketfuel-format type).
34 *
35 * http://www.cs.washington.edu/research/networking/rocketfuel/
36 *
37 * Only weights and latencies file is supported
38 */
39class RocketfuelWeightsReader : public AnnotatedTopologyReader
40{
41public:
Alexander Afanasyevda021012012-06-28 14:11:46 -070042 RocketfuelWeightsReader (const std::string &path="", double scale=1.0);
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080043 virtual ~RocketfuelWeightsReader ();
44
45 void
46 SetFileType (uint8_t inputType);
47
48 /**
49 * \brief Main topology reading function.
50 *
51 * This method opens an input stream and reads the Rocketfuel-format file.
52 * Every row represents a topology link (the ids of a couple of nodes),
53 * so the input file is read line by line to figure out how many links
54 * and nodes are in the topology.
55 *
56 * \return the container of the nodes created (or empty container if there was an error)
57 */
Alexander Afanasyev7dbdcaf2011-12-13 21:40:37 -080058 virtual NodeContainer
59 Read (void);
60
61 void
62 Commit ();
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080063
64 enum
Ilya Moiseenko58d26672011-12-08 13:48:06 -080065 {
Alexander Afanasyevda021012012-06-28 14:11:46 -070066 LINKS,
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080067 WEIGHTS,
Alexander Afanasyev5beb35a2011-12-21 16:45:13 -080068 LATENCIES,
69 POSITIONS
Ilya Moiseenko58d26672011-12-08 13:48:06 -080070 };
Alexander Afanasyev455e4412013-05-11 12:51:11 -070071
72 inline void
73 SetDefaultBandwidth (const std::string &bw);
74
75 inline std::string
76 GetDefaultBandwidth () const;
77
78 inline void
79 SetDefaultQueue (const std::string &queue);
80
81 inline std::string
82 GetDefaultQueue () const;
Alexander Afanasyev5beb35a2011-12-21 16:45:13 -080083
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080084private:
85 RocketfuelWeightsReader (const RocketfuelWeightsReader&);
86 RocketfuelWeightsReader& operator= (const RocketfuelWeightsReader&);
87
88private:
89 uint8_t m_inputType;
Alexander Afanasyev455e4412013-05-11 12:51:11 -070090 std::string m_defaultBandwidth; // since the topology files don't provide bandwidth parameter
91 std::string m_queue;
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080092
93}; // end class RocketfuelWeightsReader
94
Alexander Afanasyev455e4412013-05-11 12:51:11 -070095inline void
96RocketfuelWeightsReader::SetDefaultBandwidth (const std::string &bw)
97{
98 m_defaultBandwidth = bw;
99}
100
101inline std::string
102RocketfuelWeightsReader::GetDefaultBandwidth () const
103{
104 return m_defaultBandwidth;
105}
106
107inline void
108RocketfuelWeightsReader::SetDefaultQueue (const std::string &queue)
109{
110 m_queue = queue;
111}
112
113inline std::string
114RocketfuelWeightsReader::GetDefaultQueue () const
115{
116 return m_queue;
117}
118
119
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -0800120}; // end namespace ns3
Ilya Moiseenko58d26672011-12-08 13:48:06 -0800121
122
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -0800123#endif /* ROCKETFUEL_TOPOLOGY_WEIGHTS_READER_H */