blob: 041bf7edd9c486105575e90b0ba598f859db5da3 [file] [log] [blame]
Ilya Moiseenko58d26672011-12-08 13:48:06 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08002/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
Ilya Moiseenko58d26672011-12-08 13:48:06 -08004 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08005 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
Ilya Moiseenko58d26672011-12-08 13:48:06 -08007 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08008 * ndnSIM is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
Ilya Moiseenko58d26672011-12-08 13:48:06 -080011 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080012 * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
Ilya Moiseenko58d26672011-12-08 13:48:06 -080015 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080016 * You should have received a copy of the GNU General Public License along with
17 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
19
20// Based on the code by Hajime Tazaki <tazaki@sfc.wide.ad.jp>
Ilya Moiseenko58d26672011-12-08 13:48:06 -080021
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
JonnyKong6c53c752019-04-21 00:25:39 -0700113} // 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 */