blob: cfe5233f99aaff53b676445cd151197243a0b95b [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"
Ilya Moiseenko58d26672011-12-08 13:48:06 -080025
Ilya Moiseenko1eff17d2011-08-17 10:55:53 -070026namespace ns3
27{
Ilya Moiseenko7dd43be2011-08-18 18:57:12 -070028
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 Moiseenko7e14efa2011-12-12 17:56:22 -080033* 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 Moiseenko7dd43be2011-08-18 18:57:12 -070034*
35*/
36class AnnotatedTopologyReader : public TopologyReader
37{
38public:
39 typedef std::list< Link >::iterator LinksIterator;
40 static TypeId GetTypeId (void);
41
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080042 /**
43 * \brief Constructor
44 *
45 * \param path ns3::Names path
46 *
47 * \see ns3::Names class
48 */
49 AnnotatedTopologyReader (const std::string &path="");
Ilya Moiseenko7dd43be2011-08-18 18:57:12 -070050 virtual ~AnnotatedTopologyReader ();
51
Ilya Moiseenko1eff17d2011-08-17 10:55:53 -070052 /**
Ilya Moiseenko7dd43be2011-08-18 18:57:12 -070053 * \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 Afanasyev8633d5d2011-12-12 18:02:31 -080059 virtual
60 NodeContainer Read (void);
Ilya Moiseenko7dd43be2011-08-18 18:57:12 -070061
62 /**
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080063 * \brief Set bounding box for the nodes
64 */
65 void
66 SetBoundingBox (double ulx, double uly, double lrx, double lry);
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 Moiseenko7dd43be2011-08-18 18:57:12 -070080private:
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080081 /**
Ilya Moiseenko1eff17d2011-08-17 10:55:53 -070082 * \brief This method applies setting to corresponding nodes and links
83 * NetDeviceContainer must be allocated
84 * NodeContainer from Read method
85 */
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080086 void ApplySettings ();
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080087 void ApplyOspfMetric ();
Ilya Moiseenko1eff17d2011-08-17 10:55:53 -070088
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080089private:
Ilya Moiseenko1eff17d2011-08-17 10:55:53 -070090 AnnotatedTopologyReader (const AnnotatedTopologyReader&);
91 AnnotatedTopologyReader& operator= (const AnnotatedTopologyReader&);
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080092
93 std::string m_path;
94 double m_ulx;
95 double m_uly;
96 double m_lrx;
97 double m_lry;
Ilya Moiseenko1eff17d2011-08-17 10:55:53 -070098};
99}
100
101
102#endif
103
104