blob: 06bbe2a9ed95e9b20384126f6b314235f277009e [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"
Ilya Moiseenko58d26672011-12-08 13:48:06 -080026
Ilya Moiseenko1eff17d2011-08-17 10:55:53 -070027namespace ns3
28{
Ilya Moiseenko7dd43be2011-08-18 18:57:12 -070029
30/**
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080031 * \brief This class reads annotated topology and apply settings to the corresponding nodes and links
32 *
33 */
Ilya Moiseenko7dd43be2011-08-18 18:57:12 -070034class AnnotatedTopologyReader : public TopologyReader
35{
36public:
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080037 /**
38 * \brief Constructor
39 *
40 * \param path ns3::Names path
41 *
42 * \see ns3::Names class
43 */
44 AnnotatedTopologyReader (const std::string &path="");
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080045 virtual ~AnnotatedTopologyReader ();
Ilya Moiseenko7dd43be2011-08-18 18:57:12 -070046
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080047 /**
48 * \brief Main annotated topology reading function.
49 *
50 * This method opens an input stream and reads topology file with annotations.
51 *
52 * \return the container of the nodes created (or empty container if there was an error)
53 */
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080054 virtual
55 NodeContainer Read (void);
Ilya Moiseenko7dd43be2011-08-18 18:57:12 -070056
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080057 /**
58 * \brief Assign IPv4 addresses to all links
59 *
60 * Note, IPv4 stack should be installed on all nodes prior this call
61 *
62 * Every link will receive /24 netmask
63 *
64 * \param base Starting IPv4 address (second link will have base+256)
65 */
66 void
67 AssignIpv4Addresses (Ipv4Address base);
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080068
69 void
70 SetBoundingBox (double ulx, double uly, double lrx, double lry);
71
72protected:
73 Ptr<Node>
74 CreateNode (const std::string name);
75
76 Ptr<Node>
77 CreateNode (const std::string name, double posX, double posY);
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080078
Ilya Moiseenko7dd43be2011-08-18 18:57:12 -070079private:
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080080 /**
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080081 * \brief This method applies setting to corresponding nodes and links
82 * NetDeviceContainer must be allocated
83 * NodeContainer from Read method
84 */
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080085 void ApplySettings ();
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080086 void ApplyOspfMetric ();
Ilya Moiseenko1eff17d2011-08-17 10:55:53 -070087
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080088protected:
89 std::string m_path;
90
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080091private:
Alexander Afanasyeva174aa52011-12-13 01:30:32 -080092 AnnotatedTopologyReader (const AnnotatedTopologyReader&);
93 AnnotatedTopologyReader& operator= (const AnnotatedTopologyReader&);
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080094
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080095 UniformVariable m_randX;
96 UniformVariable m_randY;
Ilya Moiseenko1eff17d2011-08-17 10:55:53 -070097};
Ilya Moiseenko1eff17d2011-08-17 10:55:53 -070098
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080099}
Ilya Moiseenko1eff17d2011-08-17 10:55:53 -0700100
101#endif
102
103