Ilya Moiseenko | 1eff17d | 2011-08-17 10:55:53 -0700 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2011 University of California, Los Angeles |
| 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: Ilya Moiseenko <iliamo@cs.ucla.edu> |
| 19 | */ |
| 20 | |
| 21 | #ifndef __ANNOTATED_TOPOLOGY_READER_H__ |
| 22 | #define __ANNOTATED_TOPOLOGY_READER_H__ |
| 23 | |
Ilya Moiseenko | 1eff17d | 2011-08-17 10:55:53 -0700 | [diff] [blame] | 24 | #include "ns3/topology-reader.h" |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 25 | |
Ilya Moiseenko | 1eff17d | 2011-08-17 10:55:53 -0700 | [diff] [blame] | 26 | namespace ns3 |
| 27 | { |
Ilya Moiseenko | 7dd43be | 2011-08-18 18:57:12 -0700 | [diff] [blame] | 28 | |
| 29 | /** |
| 30 | * \brief This class reads annotated topology and apply settings to the corresponding nodes and links |
| 31 | * Input File Format |
| 32 | * 1st line is NumberOfNodes TAB NumberofLinks |
Ilya Moiseenko | 7e14efa | 2011-12-12 17:56:22 -0800 | [diff] [blame] | 33 | * Nth line is NodeID1 TAB NodeID2 TAB DataRateKBPS TAB OSPF TAB DelayMiliseconds TAB QueueSizeInPacketsNode1 TAB QueueSizeInPacketsNode2 TAB X-coordinate-node1 TAB Y-coordinate-node1 TAB X-coordinate-node2 TAB Y-coordinate-node2 |
Ilya Moiseenko | 7dd43be | 2011-08-18 18:57:12 -0700 | [diff] [blame] | 34 | * |
| 35 | */ |
| 36 | class AnnotatedTopologyReader : public TopologyReader |
| 37 | { |
| 38 | public: |
| 39 | typedef std::list< Link >::iterator LinksIterator; |
| 40 | static TypeId GetTypeId (void); |
| 41 | |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 42 | /** |
| 43 | * \brief Constructor |
| 44 | * |
| 45 | * \param path ns3::Names path |
| 46 | * |
| 47 | * \see ns3::Names class |
| 48 | */ |
| 49 | AnnotatedTopologyReader (const std::string &path=""); |
Ilya Moiseenko | 7dd43be | 2011-08-18 18:57:12 -0700 | [diff] [blame] | 50 | virtual ~AnnotatedTopologyReader (); |
| 51 | |
Ilya Moiseenko | 1eff17d | 2011-08-17 10:55:53 -0700 | [diff] [blame] | 52 | /** |
Ilya Moiseenko | 7dd43be | 2011-08-18 18:57:12 -0700 | [diff] [blame] | 53 | * \brief Main annotated topology reading function. |
| 54 | * |
| 55 | * This method opens an input stream and reads topology file with annotations. |
| 56 | * |
| 57 | * \return the container of the nodes created (or empty container if there was an error) |
| 58 | */ |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 59 | virtual |
| 60 | NodeContainer Read (void); |
Ilya Moiseenko | 7dd43be | 2011-08-18 18:57:12 -0700 | [diff] [blame] | 61 | |
Alexander Afanasyev | a174aa5 | 2011-12-13 01:30:32 -0800 | [diff] [blame] | 62 | // /** |
| 63 | // * \brief Set bounding box for the nodes |
| 64 | // */ |
| 65 | // void |
| 66 | // SetBoundingBox (double ulx, double uly, double lrx, double lry); |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 67 | |
| 68 | /** |
| 69 | * \brief Assign IPv4 addresses to all links |
| 70 | * |
| 71 | * Note, IPv4 stack should be installed on all nodes prior this call |
| 72 | * |
| 73 | * Every link will receive /24 netmask |
| 74 | * |
| 75 | * \param base Starting IPv4 address (second link will have base+256) |
| 76 | */ |
| 77 | void |
| 78 | AssignIpv4Addresses (Ipv4Address base); |
| 79 | |
Ilya Moiseenko | 7dd43be | 2011-08-18 18:57:12 -0700 | [diff] [blame] | 80 | private: |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 81 | /** |
Ilya Moiseenko | 1eff17d | 2011-08-17 10:55:53 -0700 | [diff] [blame] | 82 | * \brief This method applies setting to corresponding nodes and links |
| 83 | * NetDeviceContainer must be allocated |
| 84 | * NodeContainer from Read method |
| 85 | */ |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 86 | void ApplySettings (); |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 87 | void ApplyOspfMetric (); |
Ilya Moiseenko | 1eff17d | 2011-08-17 10:55:53 -0700 | [diff] [blame] | 88 | |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 89 | private: |
Alexander Afanasyev | a174aa5 | 2011-12-13 01:30:32 -0800 | [diff] [blame] | 90 | AnnotatedTopologyReader (const AnnotatedTopologyReader&); |
| 91 | AnnotatedTopologyReader& operator= (const AnnotatedTopologyReader&); |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 92 | |
| 93 | std::string m_path; |
Alexander Afanasyev | a174aa5 | 2011-12-13 01:30:32 -0800 | [diff] [blame] | 94 | // double m_ulx; |
| 95 | // double m_uly; |
| 96 | // double m_lrx; |
| 97 | // double m_lry; |
Ilya Moiseenko | 1eff17d | 2011-08-17 10:55:53 -0700 | [diff] [blame] | 98 | }; |
| 99 | } |
| 100 | |
| 101 | |
| 102 | #endif |
| 103 | |
| 104 | |