blob: 2d8c7d0e9dc9940f439feba85b5d9d60671d97e9 [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 Afanasyevdca091a2015-01-01 20:51:27 -080025#include "ns3/ndnSIM/utils/topology/annotated-topology-reader.hpp"
Alexander Afanasyev07827182011-12-13 01:07:32 -080026#include "ns3/net-device-container.h"
Ilya Moiseenko58d26672011-12-08 13:48:06 -080027
28namespace ns3 {
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080029
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 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080039class RocketfuelWeightsReader : public AnnotatedTopologyReader {
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080040public:
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080041 RocketfuelWeightsReader(const std::string& path = "", double scale = 1.0);
42 virtual ~RocketfuelWeightsReader();
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080043
44 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080045 SetFileType(uint8_t inputType);
46
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080047 /**
48 * \brief Main topology reading function.
49 *
50 * This method opens an input stream and reads the Rocketfuel-format file.
51 * Every row represents a topology link (the ids of a couple of nodes),
52 * so the input file is read line by line to figure out how many links
53 * and nodes are in the topology.
54 *
55 * \return the container of the nodes created (or empty container if there was an error)
56 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080057 virtual NodeContainer
58 Read(void);
Alexander Afanasyev7dbdcaf2011-12-13 21:40:37 -080059
60 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080061 Commit();
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080062
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080063 enum { LINKS, WEIGHTS, LATENCIES, POSITIONS };
Alexander Afanasyev455e4412013-05-11 12:51:11 -070064
65 inline void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080066 SetDefaultBandwidth(const std::string& bw);
Alexander Afanasyev455e4412013-05-11 12:51:11 -070067
68 inline std::string
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080069 GetDefaultBandwidth() const;
Alexander Afanasyev455e4412013-05-11 12:51:11 -070070
71 inline void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080072 SetDefaultQueue(const std::string& queue);
Alexander Afanasyev455e4412013-05-11 12:51:11 -070073
74 inline std::string
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080075 GetDefaultQueue() const;
76
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080077private:
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080078 RocketfuelWeightsReader(const RocketfuelWeightsReader&);
79 RocketfuelWeightsReader&
80 operator=(const RocketfuelWeightsReader&);
81
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080082private:
83 uint8_t m_inputType;
Alexander Afanasyev455e4412013-05-11 12:51:11 -070084 std::string m_defaultBandwidth; // since the topology files don't provide bandwidth parameter
85 std::string m_queue;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080086
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080087}; // end class RocketfuelWeightsReader
88
Alexander Afanasyev455e4412013-05-11 12:51:11 -070089inline void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080090RocketfuelWeightsReader::SetDefaultBandwidth(const std::string& bw)
Alexander Afanasyev455e4412013-05-11 12:51:11 -070091{
92 m_defaultBandwidth = bw;
93}
94
95inline std::string
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080096RocketfuelWeightsReader::GetDefaultBandwidth() const
Alexander Afanasyev455e4412013-05-11 12:51:11 -070097{
98 return m_defaultBandwidth;
99}
100
101inline void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800102RocketfuelWeightsReader::SetDefaultQueue(const std::string& queue)
Alexander Afanasyev455e4412013-05-11 12:51:11 -0700103{
104 m_queue = queue;
105}
106
107inline std::string
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800108RocketfuelWeightsReader::GetDefaultQueue() const
Alexander Afanasyev455e4412013-05-11 12:51:11 -0700109{
110 return m_queue;
111}
112
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -0800113}; // end namespace ns3
Ilya Moiseenko58d26672011-12-08 13:48:06 -0800114
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -0800115#endif /* ROCKETFUEL_TOPOLOGY_WEIGHTS_READER_H */