A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
point-to-point-grid.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-2.0-only
3 *
4 * Author: Josh Pelkey <jpelkey@gatech.edu>
5 */
6
7// Define an object to create a grid topology.
8
9#ifndef POINT_TO_POINT_GRID_HELPER_H
10#define POINT_TO_POINT_GRID_HELPER_H
11
12#include "ns3/internet-stack-helper.h"
13#include "ns3/ipv4-address-helper.h"
14#include "ns3/ipv4-interface-container.h"
15#include "ns3/ipv6-address-helper.h"
16#include "ns3/ipv6-interface-container.h"
17#include "ns3/net-device-container.h"
18#include "ns3/point-to-point-helper.h"
19
20#include <vector>
21
22namespace ns3
23{
24
25/**
26 * \ingroup point-to-point-layout
27 *
28 * \brief A helper to make it easier to create a grid topology
29 * with p2p links
30 */
32{
33 public:
34 /**
35 * Create a PointToPointGridHelper in order to easily create
36 * grid topologies using p2p links
37 *
38 * \param nRows total number of rows in the grid
39 *
40 * \param nCols total number of columns in the grid
41 *
42 * \param pointToPoint the PointToPointHelper which is used
43 * to connect all of the nodes together
44 * in the grid
45 */
47
49
50 /**
51 * \param row the row address of the node desired
52 *
53 * \param col the column address of the node desired
54 *
55 * \returns a pointer to the node specified by the
56 * (row, col) address
57 */
59
60 /**
61 * This returns an Ipv4 address at the node specified by
62 * the (row, col) address. Technically, a node will have
63 * multiple interfaces in the grid; therefore, it also has
64 * multiple Ipv4 addresses. This method only returns one of
65 * the addresses. If you picture the grid, the address returned
66 * is the left row device of all the nodes, except the left-most
67 * grid nodes, which returns the right row device.
68 *
69 * \param row the row address of the node desired
70 *
71 * \param col the column address of the node desired
72 *
73 * \returns Ipv4Address of one of the interfaces of the node
74 * specified by the (row, col) address
75 */
77
78 /**
79 * This returns an Ipv6 address at the node specified by
80 * the (row, col) address. Technically, a node will have
81 * multiple interfaces in the grid; therefore, it also has
82 * multiple Ipv6 addresses. This method only returns one of
83 * the addresses. If you picture the grid, the address returned
84 * is the left row device of all the nodes, except the left-most
85 * grid nodes, which returns the right row device.
86 *
87 * \param row the row address of the node desired
88 *
89 * \param col the column address of the node desired
90 *
91 * \returns Ipv6Address of one of the interfaces of the node
92 * specified by the (row, col) address
93 */
95
96 /**
97 * \param stack an InternetStackHelper which is used to install
98 * on every node in the grid
99 */
101
102 /**
103 * Assigns Ipv4 addresses to all the row and column interfaces
104 *
105 * \param rowIp the Ipv4AddressHelper used to assign Ipv4 addresses
106 * to all of the row interfaces in the grid
107 *
108 * \param colIp the Ipv4AddressHelper used to assign Ipv4 addresses
109 * to all of the column interfaces in the grid
110 */
112
113 /**
114 * Assigns Ipv6 addresses to all the row and column interfaces
115 *
116 * \param network an IPv6 address representing the network portion
117 * of the IPv6 Address
118 * \param prefix the prefix length
119 */
120 void AssignIpv6Addresses(Ipv6Address network, Ipv6Prefix prefix);
121
122 /**
123 * Sets up the node canvas locations for every node in the grid.
124 * This is needed for use with the animation interface
125 *
126 * \param ulx upper left x value
127 * \param uly upper left y value
128 * \param lrx lower right x value
129 * \param lry lower right y value
130 */
131 void BoundingBox(double ulx, double uly, double lrx, double lry);
132
133 private:
134 uint32_t m_xSize; //!< X size of the grid (number of columns)
135 uint32_t m_ySize; //!< Y size of the grid (number of rows)
136 std::vector<NetDeviceContainer> m_rowDevices; //!< NetDevices in a row
137 std::vector<NetDeviceContainer> m_colDevices; //!< NetDevices in a column
138 std::vector<Ipv4InterfaceContainer> m_rowInterfaces; //!< IPv4 interfaces in a row
139 std::vector<Ipv4InterfaceContainer> m_colInterfaces; //!< IPv4 interfaces in a column
140 std::vector<Ipv6InterfaceContainer> m_rowInterfaces6; //!< IPv6 interfaces in a row
141 std::vector<Ipv6InterfaceContainer> m_colInterfaces6; //!< IPv6 interfaces in a column
142 std::vector<NodeContainer> m_nodes; //!< all the nodes in the grid
143};
144
145} // namespace ns3
146
147#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.
Describes an IPv6 address.
Describes an IPv6 prefix.
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)
PointToPointGridHelper(uint32_t nRows, uint32_t nCols, PointToPointHelper pointToPoint)
Create a PointToPointGridHelper in order to easily create grid topologies using p2p links.
std::vector< Ipv4InterfaceContainer > m_rowInterfaces
IPv4 interfaces in a row.
Build a set of PointToPointNetDevice objects.
Smart pointer class similar to boost::intrusive_ptr.
Every class exported by the ns3 library is enclosed in the ns3 namespace.