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 | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 25 | #include "annotated-topology-reader.h" |
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 { |
| 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 | */ |
| 39 | class RocketfuelWeightsReader : public AnnotatedTopologyReader |
| 40 | { |
| 41 | public: |
Alexander Afanasyev | 7dbdcaf | 2011-12-13 21:40:37 -0800 | [diff] [blame] | 42 | RocketfuelWeightsReader (const std::string &path=""); |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 43 | 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 Afanasyev | 7dbdcaf | 2011-12-13 21:40:37 -0800 | [diff] [blame] | 58 | virtual NodeContainer |
| 59 | Read (void); |
| 60 | |
| 61 | void |
| 62 | Commit (); |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 63 | |
| 64 | enum |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 65 | { |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 66 | WEIGHTS, |
Alexander Afanasyev | 5beb35a | 2011-12-21 16:45:13 -0800 | [diff] [blame] | 67 | LATENCIES, |
| 68 | POSITIONS |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 69 | }; |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 70 | |
Alexander Afanasyev | 5beb35a | 2011-12-21 16:45:13 -0800 | [diff] [blame] | 71 | void |
| 72 | SavePositions (const std::string &file) const; |
| 73 | |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 74 | private: |
| 75 | RocketfuelWeightsReader (const RocketfuelWeightsReader&); |
| 76 | RocketfuelWeightsReader& operator= (const RocketfuelWeightsReader&); |
| 77 | |
| 78 | private: |
| 79 | uint8_t m_inputType; |
| 80 | |
| 81 | }; // end class RocketfuelWeightsReader |
| 82 | |
| 83 | }; // end namespace ns3 |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 84 | |
| 85 | |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 86 | #endif /* ROCKETFUEL_TOPOLOGY_WEIGHTS_READER_H */ |