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" |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 25 | #include "ns3/random-variable.h" |
Alexander Afanasyev | 7dbdcaf | 2011-12-13 21:40:37 -0800 | [diff] [blame] | 26 | #include "ns3/object-factory.h" |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 27 | |
Ilya Moiseenko | 1eff17d | 2011-08-17 10:55:53 -0700 | [diff] [blame] | 28 | namespace ns3 |
| 29 | { |
Ilya Moiseenko | 7dd43be | 2011-08-18 18:57:12 -0700 | [diff] [blame] | 30 | |
| 31 | /** |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 32 | * \brief This class reads annotated topology and apply settings to the corresponding nodes and links |
| 33 | * |
| 34 | */ |
Ilya Moiseenko | 7dd43be | 2011-08-18 18:57:12 -0700 | [diff] [blame] | 35 | class AnnotatedTopologyReader : public TopologyReader |
| 36 | { |
| 37 | public: |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 38 | /** |
| 39 | * \brief Constructor |
| 40 | * |
| 41 | * \param path ns3::Names path |
| 42 | * |
| 43 | * \see ns3::Names class |
| 44 | */ |
| 45 | AnnotatedTopologyReader (const std::string &path=""); |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 46 | virtual ~AnnotatedTopologyReader (); |
Ilya Moiseenko | 7dd43be | 2011-08-18 18:57:12 -0700 | [diff] [blame] | 47 | |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 48 | /** |
| 49 | * \brief Main annotated topology reading function. |
| 50 | * |
| 51 | * This method opens an input stream and reads topology file with annotations. |
| 52 | * |
| 53 | * \return the container of the nodes created (or empty container if there was an error) |
| 54 | */ |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 55 | virtual |
| 56 | NodeContainer Read (void); |
Ilya Moiseenko | 7dd43be | 2011-08-18 18:57:12 -0700 | [diff] [blame] | 57 | |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 58 | /** |
| 59 | * \brief Assign IPv4 addresses to all links |
| 60 | * |
| 61 | * Note, IPv4 stack should be installed on all nodes prior this call |
| 62 | * |
| 63 | * Every link will receive /24 netmask |
| 64 | * |
| 65 | * \param base Starting IPv4 address (second link will have base+256) |
| 66 | */ |
| 67 | void |
| 68 | AssignIpv4Addresses (Ipv4Address base); |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 69 | |
| 70 | void |
| 71 | SetBoundingBox (double ulx, double uly, double lrx, double lry); |
| 72 | |
Alexander Afanasyev | 7dbdcaf | 2011-12-13 21:40:37 -0800 | [diff] [blame] | 73 | void |
| 74 | SetMobilityModel (const std::string &model); |
| 75 | |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 76 | protected: |
| 77 | Ptr<Node> |
| 78 | CreateNode (const std::string name); |
| 79 | |
| 80 | Ptr<Node> |
| 81 | CreateNode (const std::string name, double posX, double posY); |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 82 | |
Alexander Afanasyev | 7dbdcaf | 2011-12-13 21:40:37 -0800 | [diff] [blame] | 83 | protected: |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 84 | /** |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 85 | * \brief This method applies setting to corresponding nodes and links |
| 86 | * NetDeviceContainer must be allocated |
| 87 | * NodeContainer from Read method |
| 88 | */ |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 89 | void ApplySettings (); |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 90 | void ApplyOspfMetric (); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 91 | |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 92 | protected: |
| 93 | std::string m_path; |
| 94 | |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 95 | private: |
Alexander Afanasyev | a174aa5 | 2011-12-13 01:30:32 -0800 | [diff] [blame] | 96 | AnnotatedTopologyReader (const AnnotatedTopologyReader&); |
| 97 | AnnotatedTopologyReader& operator= (const AnnotatedTopologyReader&); |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 98 | |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 99 | UniformVariable m_randX; |
| 100 | UniformVariable m_randY; |
Alexander Afanasyev | 7dbdcaf | 2011-12-13 21:40:37 -0800 | [diff] [blame] | 101 | |
| 102 | ObjectFactory m_mobilityFactory; |
Ilya Moiseenko | 7dd43be | 2011-08-18 18:57:12 -0700 | [diff] [blame] | 103 | }; |
Ilya Moiseenko | 1eff17d | 2011-08-17 10:55:53 -0700 | [diff] [blame] | 104 | |
Alexander Afanasyev | ae3b7c3 | 2011-12-13 13:20:06 -0800 | [diff] [blame] | 105 | } |
Ilya Moiseenko | 1eff17d | 2011-08-17 10:55:53 -0700 | [diff] [blame] | 106 | |
| 107 | #endif |
| 108 | |
| 109 | |