A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
point-to-point-grid.h
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation;
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14 *
15 * Author: Josh Pelkey <jpelkey@gatech.edu>
16 */
17
18// Define an object to create a grid topology.
19
20#ifndef POINT_TO_POINT_GRID_HELPER_H
21#define POINT_TO_POINT_GRID_HELPER_H
22
23#include "ns3/internet-stack-helper.h"
24#include "ns3/ipv4-address-helper.h"
25#include "ns3/ipv4-interface-container.h"
26#include "ns3/ipv6-address-helper.h"
27#include "ns3/ipv6-interface-container.h"
28#include "ns3/net-device-container.h"
29#include "ns3/point-to-point-helper.h"
30
31#include <vector>
32
33namespace ns3
34{
35
36/**
37 * \ingroup point-to-point-layout
38 *
39 * \brief A helper to make it easier to create a grid topology
40 * with p2p links
41 */
43{
44 public:
45 /**
46 * Create a PointToPointGridHelper in order to easily create
47 * grid topologies using p2p links
48 *
49 * \param nRows total number of rows in the grid
50 *
51 * \param nCols total number of columns in the grid
52 *
53 * \param pointToPoint the PointToPointHelper which is used
54 * to connect all of the nodes together
55 * in the grid
56 */
58
60
61 /**
62 * \param row the row address of the node desired
63 *
64 * \param col the column address of the node desired
65 *
66 * \returns a pointer to the node specified by the
67 * (row, col) address
68 */
70
71 /**
72 * This returns an Ipv4 address at the node specified by
73 * the (row, col) address. Technically, a node will have
74 * multiple interfaces in the grid; therefore, it also has
75 * multiple Ipv4 addresses. This method only returns one of
76 * the addresses. If you picture the grid, the address returned
77 * is the left row device of all the nodes, except the left-most
78 * grid nodes, which returns the right row device.
79 *
80 * \param row the row address of the node desired
81 *
82 * \param col the column address of the node desired
83 *
84 * \returns Ipv4Address of one of the interfaces of the node
85 * specified by the (row, col) address
86 */
88
89 /**
90 * This returns an Ipv6 address at the node specified by
91 * the (row, col) address. Technically, a node will have
92 * multiple interfaces in the grid; therefore, it also has
93 * multiple Ipv6 addresses. This method only returns one of
94 * the addresses. If you picture the grid, the address returned
95 * is the left row device of all the nodes, except the left-most
96 * grid nodes, which returns the right row device.
97 *
98 * \param row the row address of the node desired
99 *
100 * \param col the column address of the node desired
101 *
102 * \returns Ipv6Address of one of the interfaces of the node
103 * specified by the (row, col) address
104 */
106
107 /**
108 * \param stack an InternetStackHelper which is used to install
109 * on every node in the grid
110 */
112
113 /**
114 * Assigns Ipv4 addresses to all the row and column interfaces
115 *
116 * \param rowIp the Ipv4AddressHelper used to assign Ipv4 addresses
117 * to all of the row interfaces in the grid
118 *
119 * \param colIp the Ipv4AddressHelper used to assign Ipv4 addresses
120 * to all of the column interfaces in the grid
121 */
123
124 /**
125 * Assigns Ipv6 addresses to all the row and column interfaces
126 *
127 * \param network an IPv6 address representing the network portion
128 * of the IPv6 Address
129 * \param prefix the prefix length
130 */
131 void AssignIpv6Addresses(Ipv6Address network, Ipv6Prefix prefix);
132
133 /**
134 * Sets up the node canvas locations for every node in the grid.
135 * This is needed for use with the animation interface
136 *
137 * \param ulx upper left x value
138 * \param uly upper left y value
139 * \param lrx lower right x value
140 * \param lry lower right y value
141 */
142 void BoundingBox(double ulx, double uly, double lrx, double lry);
143
144 private:
145 uint32_t m_xSize; //!< X size of the grid (number of columns)
146 uint32_t m_ySize; //!< Y size of the grid (number of rows)
147 std::vector<NetDeviceContainer> m_rowDevices; //!< NetDevices in a row
148 std::vector<NetDeviceContainer> m_colDevices; //!< NetDevices in a column
149 std::vector<Ipv4InterfaceContainer> m_rowInterfaces; //!< IPv4 interfaces in a row
150 std::vector<Ipv4InterfaceContainer> m_colInterfaces; //!< IPv4 interfaces in a column
151 std::vector<Ipv6InterfaceContainer> m_rowInterfaces6; //!< IPv6 interfaces in a row
152 std::vector<Ipv6InterfaceContainer> m_colInterfaces6; //!< IPv6 interfaces in a column
153 std::vector<NodeContainer> m_nodes; //!< all the nodes in the grid
154};
155
156} // namespace ns3
157
158#endif /* POINT_TO_POINT_GRID_HELPER_H */
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Describes an IPv6 address.
Definition: ipv6-address.h:49
Describes an IPv6 prefix.
Definition: ipv6-address.h:455
A helper to make it easier to create a grid topology with p2p links.
std::vector< Ipv6InterfaceContainer > m_colInterfaces6
IPv6 interfaces in a column.
void InstallStack(InternetStackHelper stack)
void AssignIpv6Addresses(Ipv6Address network, Ipv6Prefix prefix)
Assigns Ipv6 addresses to all the row and column interfaces.
Ipv4Address GetIpv4Address(uint32_t row, uint32_t col)
This returns an Ipv4 address at the node specified by the (row, col) address.
Ptr< Node > GetNode(uint32_t row, uint32_t col)
uint32_t m_ySize
Y size of the grid (number of rows)
Ipv6Address GetIpv6Address(uint32_t row, uint32_t col)
This returns an Ipv6 address at the node specified by the (row, col) address.
std::vector< NodeContainer > m_nodes
all the nodes in the grid
std::vector< NetDeviceContainer > m_colDevices
NetDevices in a column.
std::vector< NetDeviceContainer > m_rowDevices
NetDevices in a row.
std::vector< Ipv6InterfaceContainer > m_rowInterfaces6
IPv6 interfaces in a row.
void BoundingBox(double ulx, double uly, double lrx, double lry)
Sets up the node canvas locations for every node in the grid.
std::vector< Ipv4InterfaceContainer > m_colInterfaces
IPv4 interfaces in a column.
void AssignIpv4Addresses(Ipv4AddressHelper rowIp, Ipv4AddressHelper colIp)
Assigns Ipv4 addresses to all the row and column interfaces.
uint32_t m_xSize
X size of the grid (number of columns)
std::vector< Ipv4InterfaceContainer > m_rowInterfaces
IPv4 interfaces in a row.
Build a set of PointToPointNetDevice objects.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Every class exported by the ns3 library is enclosed in the ns3 namespace.