22 #include "ns3/constant-position-mobility-model.h"
23 #include "ns3/internet-stack-helper.h"
24 #include "ns3/ipv6-address-generator.h"
26 #include "ns3/point-to-point-helper.h"
27 #include "ns3/string.h"
28 #include "ns3/vector.h"
49 for (uint32_t y = 0; y < nRows; ++y)
55 for (uint32_t
x = 0;
x < nCols; ++
x)
89 for (uint32_t i = 0; i <
m_nodes.size(); ++i)
92 for (uint32_t j = 0; j < rowNodes.
GetN(); ++j)
110 for (uint32_t j = 0; j < rowContainer.
GetN(); j += 2)
113 rowInterfaces.
Add(rowIp.
Assign(rowContainer.
Get(j + 1)));
127 for (uint32_t j = 0; j < colContainer.
GetN(); j += 2)
130 colInterfaces.
Add(colIp.
Assign(colContainer.
Get(j + 1)));
152 for (uint32_t j = 0; j < rowContainer.
GetN(); j += 2)
155 addrHelper.
SetBase(v6network, prefix);
157 rowInterfaces.
Add(ic);
158 ic = addrHelper.
Assign(rowContainer.
Get(j + 1));
159 rowInterfaces.
Add(ic);
173 for (uint32_t j = 0; j < colContainer.
GetN(); j += 2)
176 addrHelper.
SetBase(v6network, prefix);
178 colInterfaces.
Add(ic);
179 ic = addrHelper.
Assign(colContainer.
Get(j + 1));
180 colInterfaces.
Add(ic);
208 double xAdder = xDist /
m_xSize;
209 double yAdder = yDist /
m_ySize;
210 double yLoc = yDist / 2;
211 for (uint32_t i = 0; i <
m_ySize; ++i)
213 double xLoc = xDist / 2;
214 for (uint32_t j = 0; j <
m_xSize; ++j)
221 loc = CreateObject<ConstantPositionMobilityModel>();
224 Vector locVec(xLoc, yLoc, 0);
225 loc->SetPosition(locVec);
238 NS_FATAL_ERROR(
"Index out of bounds in PointToPointGridHelper::GetNode.");
241 return (
m_nodes.at(row)).Get(col);
249 NS_FATAL_ERROR(
"Index out of bounds in PointToPointGridHelper::GetIpv4Address.");
274 NS_FATAL_ERROR(
"Index out of bounds in PointToPointGridHelper::GetIpv6Address.");
Mobility model for which the current position does not change once it has been set and until it is se...
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ipv4Address NewNetwork()
Increment the network number and reset the IP address counter to the base value provided in the SetBa...
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ipv4 addresses are stored in host order in this class.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
void Add(const Ipv4InterfaceContainer &other)
Concatenate the entries in the other container with ours.
static void Init(const Ipv6Address net, const Ipv6Prefix prefix, const Ipv6Address interfaceId="::1")
Initialise the base network and interfaceId for the generator.
static Ipv6Address GetNetwork(const Ipv6Prefix prefix)
Get the current network of the given Ipv6Prefix.
static Ipv6Address NextNetwork(const Ipv6Prefix prefix)
Get the next network according to the given Ipv6Prefix.
Helper class to auto-assign global IPv6 unicast addresses.
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
Describes an IPv6 address.
Keep track of a set of IPv6 interfaces.
void Add(Ptr< Ipv6 > ipv6, uint32_t interface)
Add a couple IPv6/interface.
Describes an IPv6 prefix.
holds a vector of ns3::NetDevice pointers
uint32_t GetN() const
Get the number of Ptr<NetDevice> stored in this container.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
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)
~PointToPointGridHelper()
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.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Every class exported by the ns3 library is enclosed in the ns3 namespace.