19 #include "ns3/point-to-point-grid.h"
20 #include "ns3/internet-stack-helper.h"
21 #include "ns3/point-to-point-helper.h"
22 #include "ns3/constant-position-mobility-model.h"
23 #include "ns3/string.h"
24 #include "ns3/vector.h"
26 #include "ns3/ipv6-address-generator.h"
35 : m_xSize (nCols), m_ySize (nRows)
45 for (uint32_t y = 0; y < nRows; ++y)
51 for (uint32_t
x = 0;
x < nCols; ++
x)
58 rowDevices.
Add (pointToPoint.
59 Install (rowNodes.
Get (
x-1), rowNodes.
Get (
x)));
65 colDevices.
Add (pointToPoint.
85 for (uint32_t i = 0; i <
m_nodes.size (); ++i)
88 for (uint32_t j = 0; j < rowNodes.
GetN (); ++j)
106 for (uint32_t j = 0; j < rowContainer.
GetN (); j+=2)
108 rowInterfaces.
Add (rowIp.
Assign (rowContainer.
Get (j)));
109 rowInterfaces.
Add (rowIp.
Assign (rowContainer.
Get (j+1)));
123 for (uint32_t j = 0; j < colContainer.
GetN (); j+=2)
125 colInterfaces.
Add (colIp.
Assign (colContainer.
Get (j)));
126 colInterfaces.
Add (colIp.
Assign (colContainer.
Get (j+1)));
148 for (uint32_t j = 0; j < rowContainer.
GetN (); j+=2)
151 addrHelper.
SetBase(v6network, prefix);
153 rowInterfaces.
Add (ic);
154 ic = addrHelper.
Assign (rowContainer.
Get (j+1));
155 rowInterfaces.
Add (ic);
169 for (uint32_t j = 0; j < colContainer.
GetN (); j+=2)
172 addrHelper.
SetBase(v6network, prefix);
174 colInterfaces.
Add (ic);
175 ic = addrHelper.
Assign (colContainer.
Get (j+1));
176 colInterfaces.
Add (ic);
185 double lrx,
double lry)
205 double xAdder = xDist /
m_xSize;
206 double yAdder = yDist /
m_ySize;
207 double yLoc = yDist / 2;
208 for (uint32_t i = 0; i <
m_ySize; ++i)
210 double xLoc = xDist / 2;
211 for (uint32_t j = 0; j <
m_xSize; ++j)
217 loc = CreateObject<ConstantPositionMobilityModel> ();
220 Vector locVec (xLoc, yLoc, 0);
221 loc->SetPosition (locVec);
232 if (row >
m_nodes.size () - 1 ||
233 col >
m_nodes.at (row).GetN () - 1)
235 NS_FATAL_ERROR (
"Index out of bounds in PointToPointGridHelper::GetNode.");
238 return (
m_nodes.at (row)).Get (col);
244 if (row >
m_nodes.size () - 1 ||
245 col >
m_nodes.at (row).GetN () - 1)
247 NS_FATAL_ERROR (
"Index out of bounds in PointToPointGridHelper::GetIpv4Address.");
270 if (row >
m_nodes.size () - 1 ||
271 col >
m_nodes.at (row).GetN () - 1)
273 NS_FATAL_ERROR (
"Index out of bounds in PointToPointGridHelper::GetIpv4Address.");
Keep track of a set of IPv6 interfaces.
holds a vector of std::pair of Ptr and interface index.
std::vector< NetDeviceContainer > m_colDevices
void AssignIpv4Addresses(Ipv4AddressHelper rowIp, Ipv4AddressHelper colIp)
Assigns Ipv4 addresses to all the row and column interfaces.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
void AssignIpv6Addresses(Ipv6Address network, Ipv6Prefix prefix)
Assigns Ipv6 addresses to all the row and column interfaces.
void Add(Ptr< Ipv6 > ipv6, uint32_t interface)
Add a couple IPv6/interface.
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.
static Ipv6Address NextNetwork(const Ipv6Prefix prefix)
Get the next network according to the given Ipv6Prefix.
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
Ipv6Address GetIpv6Address(uint32_t row, uint32_t col)
This returns an Ipv6 address at the node specified by the (row, col) address.
Build a set of PointToPointNetDevice objects.
Ptr< Node > GetNode(uint32_t row, uint32_t col)
#define NS_FATAL_ERROR(msg)
fatal error handling
std::vector< NodeContainer > m_nodes
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
PointToPointGridHelper(uint32_t nRows, uint32_t nCols, PointToPointHelper pointToPoint)
Create a PointToPointGridHelper in order to easily create grid topologies using p2p links...
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
static void Init(const Ipv6Address net, const Ipv6Prefix prefix, const Ipv6Address interfaceId="::1")
Initialise the base network and interfaceId for the generator.
holds a vector of ns3::NetDevice pointers
std::vector< Ipv6InterfaceContainer > m_rowInterfaces6
std::vector< Ipv4InterfaceContainer > m_rowInterfaces
std::vector< NetDeviceContainer > m_rowDevices
void AggregateObject(Ptr< Object > other)
Ipv4Address GetIpv4Address(uint32_t row, uint32_t col)
This returns an Ipv4 address at the node specified by the (row, col) address.
keep track of a set of node pointers.
std::vector< Ipv6InterfaceContainer > m_colInterfaces6
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
~PointToPointGridHelper()
NS_LOG_COMPONENT_DEFINE("PointToPointGridHelper")
Helper class to auto-assign global IPv6 unicast addresses.
Describes an IPv6 address.
Ipv4 addresses are stored in host order in this class.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
void InstallStack(InternetStackHelper stack)
Describes an IPv6 prefix.
Ipv4Address NewNetwork(void)
Increment the network number and reset the IP address counter to the base value provided in the SetBa...
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
std::vector< Ipv4InterfaceContainer > m_colInterfaces
void Add(Ipv4InterfaceContainer other)
Concatenate the entries in the other container with ours.
void BoundingBox(double ulx, double uly, double lrx, double lry)
Sets up the node canvas locations for every node in the grid.
Ptr< T > GetObject(void) const
static Ipv6Address GetNetwork(const Ipv6Prefix prefix)
Get the current network of the given Ipv6Prefix.