blob: 91e6d26bf064cd10d4e72d4188f856a42d7fd3c6 [file] [log] [blame]
Ilya Moiseenko1eff17d2011-08-17 10:55:53 -07001/* -*- 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 Moiseenko1eff17d2011-08-17 10:55:53 -070024#include "ns3/topology-reader.h"
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080025#include "ns3/random-variable.h"
Alexander Afanasyev7dbdcaf2011-12-13 21:40:37 -080026#include "ns3/object-factory.h"
Ilya Moiseenko58d26672011-12-08 13:48:06 -080027
Ilya Moiseenko1eff17d2011-08-17 10:55:53 -070028namespace ns3
29{
Ilya Moiseenko7dd43be2011-08-18 18:57:12 -070030
31/**
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080032 * \brief This class reads annotated topology and apply settings to the corresponding nodes and links
33 *
34 */
Ilya Moiseenko7dd43be2011-08-18 18:57:12 -070035class AnnotatedTopologyReader : public TopologyReader
36{
37public:
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080038 /**
39 * \brief Constructor
40 *
41 * \param path ns3::Names path
Alexander Afanasyev011b8592011-12-21 14:45:27 -080042 * \param scale Scaling factor for coordinates in input file
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080043 *
44 * \see ns3::Names class
45 */
Alexander Afanasyev011b8592011-12-21 14:45:27 -080046 AnnotatedTopologyReader (const std::string &path="", double scale=1.0);
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080047 virtual ~AnnotatedTopologyReader ();
Ilya Moiseenko7dd43be2011-08-18 18:57:12 -070048
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080049 /**
50 * \brief Main annotated topology reading function.
51 *
52 * This method opens an input stream and reads topology file with annotations.
53 *
54 * \return the container of the nodes created (or empty container if there was an error)
55 */
Alexander Afanasyev5beb35a2011-12-21 16:45:13 -080056 virtual NodeContainer
57 Read ();
58
59 /**
60 * \brief Get nodes read by the reader
61 */
62 NodeContainer
63 GetNodes () const;
Ilya Moiseenko7dd43be2011-08-18 18:57:12 -070064
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080065 /**
Ilya Moiseenkoad9e8ab2012-01-11 19:58:34 -080066 * \brief Get links read by the reader
67 */
Alexander Afanasyeve9c9d722012-01-19 16:59:30 -080068 const std::list<Link>&
Ilya Moiseenkoad9e8ab2012-01-11 19:58:34 -080069 GetLinks () const;
70
71 /**
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080072 * \brief Assign IPv4 addresses to all links
73 *
74 * Note, IPv4 stack should be installed on all nodes prior this call
75 *
76 * Every link will receive /24 netmask
77 *
78 * \param base Starting IPv4 address (second link will have base+256)
79 */
80 void
81 AssignIpv4Addresses (Ipv4Address base);
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080082
Alexander Afanasyev8e0d2812012-01-19 22:38:14 -080083 /**
84 * \brief Set bounding box where nodes will be randomly places (if positions are unspecified)
85 * \param ulx Upper left x coordinate
86 * \param uly Upper left y coordinate
87 * \param lrx Lower right x coordinate
88 * \param lry Lower right y coordinate
89 */
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080090 void
91 SetBoundingBox (double ulx, double uly, double lrx, double lry);
92
Alexander Afanasyev8e0d2812012-01-19 22:38:14 -080093 /**
94 * \brief Set mobility model to be used on nodes
95 * \param model class name of the model
96 */
Alexander Afanasyev7dbdcaf2011-12-13 21:40:37 -080097 void
98 SetMobilityModel (const std::string &model);
99
Alexander Afanasyev8e0d2812012-01-19 22:38:14 -0800100 /**
101 * \brief Apply OSPF metric on Ipv4 (if exists) and Ccnx (if exists) stacks
102 */
103 void ApplyOspfMetric ();
104
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -0800105protected:
106 Ptr<Node>
107 CreateNode (const std::string name);
108
109 Ptr<Node>
110 CreateNode (const std::string name, double posX, double posY);
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -0800111
Alexander Afanasyev7dbdcaf2011-12-13 21:40:37 -0800112protected:
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -0800113 /**
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -0800114 * \brief This method applies setting to corresponding nodes and links
115 * NetDeviceContainer must be allocated
116 * NodeContainer from Read method
117 */
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -0800118 void ApplySettings ();
Ilya Moiseenko58d26672011-12-08 13:48:06 -0800119
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -0800120protected:
121 std::string m_path;
Alexander Afanasyev5beb35a2011-12-21 16:45:13 -0800122 NodeContainer m_nodes;
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -0800123
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -0800124private:
Alexander Afanasyeva174aa52011-12-13 01:30:32 -0800125 AnnotatedTopologyReader (const AnnotatedTopologyReader&);
126 AnnotatedTopologyReader& operator= (const AnnotatedTopologyReader&);
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -0800127
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -0800128 UniformVariable m_randX;
129 UniformVariable m_randY;
Alexander Afanasyev7dbdcaf2011-12-13 21:40:37 -0800130
131 ObjectFactory m_mobilityFactory;
Alexander Afanasyev011b8592011-12-21 14:45:27 -0800132 double m_scale;
Ilya Moiseenko7dd43be2011-08-18 18:57:12 -0700133};
Ilya Moiseenko1eff17d2011-08-17 10:55:53 -0700134
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -0800135}
Ilya Moiseenko1eff17d2011-08-17 10:55:53 -0700136
137#endif
138
139