src/point-to-point-layout/model/point-to-point-grid.h
author Mitch Watrous <watrous@u.washington.edu>
Wed, 18 May 2011 17:24:04 -0700
changeset 7241 0a7a16b599e8
parent 7132 c7c8d07fb48a
permissions -rw-r--r--
Make some more modules show up on doxygen modules page
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7089
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
     2
/*
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
     3
 * This program is free software; you can redistribute it and/or modify
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
     4
 * it under the terms of the GNU General Public License version 2 as
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
     5
 * published by the Free Software Foundation;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
     6
 *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
     7
 * This program is distributed in the hope that it will be useful,
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
     8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
     9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    10
 * GNU General Public License for more details.
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    11
 *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    12
 * You should have received a copy of the GNU General Public License
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    13
 * along with this program; if not, write to the Free Software
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    15
 *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    16
 * Author: Josh Pelkey <jpelkey@gatech.edu>
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    17
 */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    18
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    19
#ifndef POINT_TO_POINT_GRID_HELPER_H
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    20
#define POINT_TO_POINT_GRID_HELPER_H
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    21
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    22
#include <vector>
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    23
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    24
#include "internet-stack-helper.h"
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    25
#include "point-to-point-helper.h"
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    26
#include "ipv4-address-helper.h"
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    27
#include "ipv4-interface-container.h"
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    28
#include "net-device-container.h"
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    29
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    30
namespace ns3 {
7132
c7c8d07fb48a Point-to-point-layout code-style changes
John Abraham<john.abraham@gatech.edu>
parents: 7089
diff changeset
    31
7089
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    32
/**
7241
0a7a16b599e8 Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents: 7132
diff changeset
    33
 * \ingroup pointtopointlayout
0a7a16b599e8 Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents: 7132
diff changeset
    34
 *
7089
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    35
 * \brief A helper to make it easier to create a grid topology
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    36
 * with p2p links
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    37
 */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    38
class PointToPointGridHelper 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    39
{
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    40
public: 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    41
  /**
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    42
   * Create a PointToPointGridHelper in order to easily create
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    43
   * grid topologies using p2p links
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    44
   *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    45
   * \param nRows total number of rows in the grid
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    46
   *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    47
   * \param nCols total number of colums in the grid
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    48
   *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    49
   * \param pointToPoint the PointToPointHelper which is used 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    50
   *                     to connect all of the nodes together 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    51
   *                     in the grid
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    52
   */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    53
  PointToPointGridHelper (uint32_t nRows, 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    54
                          uint32_t nCols, 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    55
                          PointToPointHelper pointToPoint);
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    56
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    57
  ~PointToPointGridHelper ();
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    58
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    59
  /**
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    60
   * \param row the row address of the node desired
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    61
   *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    62
   * \param col the column address of the node desired
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    63
   *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    64
   * \returns a pointer to the node specified by the 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    65
   *          (row, col) address
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    66
   */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    67
  Ptr<Node> GetNode (uint32_t row, uint32_t col);
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    68
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    69
  /**
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    70
   * This returns an Ipv4 address at the node specified by 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    71
   * the (row, col) address.  Technically, a node will have 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    72
   * multiple interfaces in the grid; therefore, it also has 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    73
   * multiple Ipv4 addresses.  This method only returns one of 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    74
   * the addresses. If you picture the grid, the address returned 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    75
   * is the left row device of all the nodes, except the left-most 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    76
   * grid nodes, which returns the right row device.
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    77
   *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    78
   * \param row the row address of the node desired
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    79
   *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    80
   * \param col the column address of the node desired
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    81
   *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    82
   * \returns Ipv4Address of one of the interfaces of the node 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    83
   *          specified by the (row, col) address
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    84
   */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    85
  Ipv4Address GetIpv4Address (uint32_t row, uint32_t col);
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    86
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    87
  /**
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    88
   * \param stack an InternetStackHelper which is used to install 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    89
   *              on every node in the grid
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    90
   */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    91
  void InstallStack (InternetStackHelper stack);
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    92
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    93
  /**
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    94
   * Assigns Ipv4 addresses to all the row and column interfaces
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    95
   *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    96
   * \param rowIp the Ipv4AddressHelper used to assign Ipv4 addresses 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    97
   *              to all of the row interfaces in the grid
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    98
   *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    99
   * \param colIp the Ipv4AddressHelper used to assign Ipv4 addresses 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   100
   *              to all of the row interfaces in the grid
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   101
   */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   102
  void AssignIpv4Addresses (Ipv4AddressHelper rowIp, Ipv4AddressHelper colIp);
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   103
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   104
  /**
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   105
   * Sets up the node canvas locations for every node in the grid.
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   106
   * This is needed for use with the animation interface
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   107
   *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   108
   * \param ulx upper left x value
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   109
   * \param uly upper left y value
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   110
   * \param lrx lower right x value
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   111
   * \param lry lower right y value
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   112
   */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   113
  void BoundingBox (double ulx, double uly, double lrx, double lry);
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   114
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   115
private:
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   116
  uint32_t m_xSize;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   117
  uint32_t m_ySize;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   118
  std::vector<NetDeviceContainer> m_rowDevices;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   119
  std::vector<NetDeviceContainer> m_colDevices;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   120
  std::vector<Ipv4InterfaceContainer> m_rowInterfaces;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   121
  std::vector<Ipv4InterfaceContainer> m_colInterfaces;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   122
  std::vector<NodeContainer> m_nodes;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   123
};
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   124
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   125
} // namespace ns3
7132
c7c8d07fb48a Point-to-point-layout code-style changes
John Abraham<john.abraham@gatech.edu>
parents: 7089
diff changeset
   126
7089
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   127
#endif /* POINT_TO_POINT_GRID_HELPER_H */