blob: 6eec5ad94b01b05e23d8092556aa45bb95047059 [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/**
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080030 * \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
33 * Nth line is NodeID1 TAB NodeID2 TAB DataRateKBPS TAB OSPF TAB DelayMiliseconds TAB QueueSizeInPacketsNode1 TAB QueueSizeInPacketsNode2
34 *
35 */
Ilya Moiseenko7dd43be2011-08-18 18:57:12 -070036class AnnotatedTopologyReader : public TopologyReader
37{
38public:
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080039 typedef std::list< Link >::iterator LinksIterator;
40 static TypeId GetTypeId (void);
41
42 /**
43 * \brief Constructor
44 *
45 * \param path ns3::Names path
46 *
47 * \see ns3::Names class
48 */
49 AnnotatedTopologyReader (const std::string &path="");
50 virtual ~AnnotatedTopologyReader ();
51
52 /**
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 */
59 virtual
60 NodeContainer Read (void);
61
62 /**
63 * \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 /**
82 * \brief This method applies setting to corresponding nodes and links
83 * NetDeviceContainer must be allocated
84 * NodeContainer from Read method
85 */
86 void ApplySettings ();
87 void AssignCoordinates ();
88 void ApplyOspfMetric ();
89
90private:
91 AnnotatedTopologyReader (const AnnotatedTopologyReader&);
92 AnnotatedTopologyReader& operator= (const AnnotatedTopologyReader&);
93
94 std::string m_path;
95 double m_ulx;
96 double m_uly;
97 double m_lrx;
98 double m_lry;
Ilya Moiseenko7dd43be2011-08-18 18:57:12 -070099};
Ilya Moiseenko1eff17d2011-08-17 10:55:53 -0700100}
101
102
103#endif
104
105