Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 1 | /* -*- 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 Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 22 | #ifndef ROCKETFUEL_TOPOLOGY_WEIGHTS_READER_H |
| 23 | #define ROCKETFUEL_TOPOLOGY_WEIGHTS_READER_H |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 24 | |
Alexander Afanasyev | 0c39537 | 2014-12-20 15:54:02 -0800 | [diff] [blame] | 25 | #include "annotated-topology-reader.hpp" |
Alexander Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 26 | #include "ns3/net-device-container.h" |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 27 | |
| 28 | namespace ns3 { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 29 | |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 30 | // ------------------------------------------------------------ |
| 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 Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 39 | class RocketfuelWeightsReader : public AnnotatedTopologyReader { |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 40 | public: |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 41 | RocketfuelWeightsReader(const std::string& path = "", double scale = 1.0); |
| 42 | virtual ~RocketfuelWeightsReader(); |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 43 | |
| 44 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 45 | SetFileType(uint8_t inputType); |
| 46 | |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 47 | /** |
| 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 Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 57 | virtual NodeContainer |
| 58 | Read(void); |
Alexander Afanasyev | 7dbdcaf | 2011-12-13 21:40:37 -0800 | [diff] [blame] | 59 | |
| 60 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 61 | Commit(); |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 62 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 63 | enum { LINKS, WEIGHTS, LATENCIES, POSITIONS }; |
Alexander Afanasyev | 455e441 | 2013-05-11 12:51:11 -0700 | [diff] [blame] | 64 | |
| 65 | inline void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 66 | SetDefaultBandwidth(const std::string& bw); |
Alexander Afanasyev | 455e441 | 2013-05-11 12:51:11 -0700 | [diff] [blame] | 67 | |
| 68 | inline std::string |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 69 | GetDefaultBandwidth() const; |
Alexander Afanasyev | 455e441 | 2013-05-11 12:51:11 -0700 | [diff] [blame] | 70 | |
| 71 | inline void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 72 | SetDefaultQueue(const std::string& queue); |
Alexander Afanasyev | 455e441 | 2013-05-11 12:51:11 -0700 | [diff] [blame] | 73 | |
| 74 | inline std::string |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 75 | GetDefaultQueue() const; |
| 76 | |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 77 | private: |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 78 | RocketfuelWeightsReader(const RocketfuelWeightsReader&); |
| 79 | RocketfuelWeightsReader& |
| 80 | operator=(const RocketfuelWeightsReader&); |
| 81 | |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 82 | private: |
| 83 | uint8_t m_inputType; |
Alexander Afanasyev | 455e441 | 2013-05-11 12:51:11 -0700 | [diff] [blame] | 84 | std::string m_defaultBandwidth; // since the topology files don't provide bandwidth parameter |
| 85 | std::string m_queue; |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 86 | |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 87 | }; // end class RocketfuelWeightsReader |
| 88 | |
Alexander Afanasyev | 455e441 | 2013-05-11 12:51:11 -0700 | [diff] [blame] | 89 | inline void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 90 | RocketfuelWeightsReader::SetDefaultBandwidth(const std::string& bw) |
Alexander Afanasyev | 455e441 | 2013-05-11 12:51:11 -0700 | [diff] [blame] | 91 | { |
| 92 | m_defaultBandwidth = bw; |
| 93 | } |
| 94 | |
| 95 | inline std::string |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 96 | RocketfuelWeightsReader::GetDefaultBandwidth() const |
Alexander Afanasyev | 455e441 | 2013-05-11 12:51:11 -0700 | [diff] [blame] | 97 | { |
| 98 | return m_defaultBandwidth; |
| 99 | } |
| 100 | |
| 101 | inline void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 102 | RocketfuelWeightsReader::SetDefaultQueue(const std::string& queue) |
Alexander Afanasyev | 455e441 | 2013-05-11 12:51:11 -0700 | [diff] [blame] | 103 | { |
| 104 | m_queue = queue; |
| 105 | } |
| 106 | |
| 107 | inline std::string |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 108 | RocketfuelWeightsReader::GetDefaultQueue() const |
Alexander Afanasyev | 455e441 | 2013-05-11 12:51:11 -0700 | [diff] [blame] | 109 | { |
| 110 | return m_queue; |
| 111 | } |
| 112 | |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 113 | }; // end namespace ns3 |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 114 | |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 115 | #endif /* ROCKETFUEL_TOPOLOGY_WEIGHTS_READER_H */ |