21 #include "ns3/point-to-point-grid.h" 
   22 #include "ns3/internet-stack-helper.h" 
   23 #include "ns3/point-to-point-helper.h" 
   24 #include "ns3/constant-position-mobility-model.h" 
   25 #include "ns3/string.h" 
   26 #include "ns3/vector.h" 
   28 #include "ns3/ipv6-address-generator.h" 
   37   : m_xSize (nCols), m_ySize (nRows)
 
   47   for (uint32_t y = 0; y < nRows; ++y)
 
   53       for (uint32_t 
x = 0; 
x < nCols; ++
x)
 
   60               rowDevices.
Add (pointToPoint.
 
   61                               Install (rowNodes.
Get (
x-1), rowNodes.
Get (
x)));
 
   67               colDevices.
Add (pointToPoint.
 
   87   for (uint32_t i = 0; i < 
m_nodes.size (); ++i)
 
   90       for (uint32_t j = 0; j < rowNodes.
GetN (); ++j)
 
  108       for (uint32_t j = 0; j < rowContainer.
GetN (); j+=2)
 
  110           rowInterfaces.
Add (rowIp.
Assign (rowContainer.
Get (j))); 
 
  111           rowInterfaces.
Add (rowIp.
Assign (rowContainer.
Get (j+1)));
 
  125       for (uint32_t j = 0; j < colContainer.
GetN (); j+=2)
 
  127           colInterfaces.
Add (colIp.
Assign (colContainer.
Get (j))); 
 
  128           colInterfaces.
Add (colIp.
Assign (colContainer.
Get (j+1)));
 
  150       for (uint32_t j = 0; j < rowContainer.
GetN (); j+=2)
 
  153           addrHelper.
SetBase(v6network, prefix);
 
  155           rowInterfaces.
Add (ic);
 
  156           ic = addrHelper.
Assign (rowContainer.
Get (j+1));
 
  157           rowInterfaces.
Add (ic);
 
  171       for (uint32_t j = 0; j < colContainer.
GetN (); j+=2)
 
  174           addrHelper.
SetBase(v6network, prefix);
 
  176           colInterfaces.
Add (ic);
 
  177           ic = addrHelper.
Assign (colContainer.
Get (j+1));
 
  178           colInterfaces.
Add (ic);
 
  187                                      double lrx, 
double lry)
 
  207   double xAdder = xDist / 
m_xSize;
 
  208   double yAdder = yDist / 
m_ySize;
 
  209   double yLoc = yDist / 2;
 
  210   for (uint32_t i = 0; i < 
m_ySize; ++i)
 
  212       double xLoc = xDist / 2;
 
  213       for (uint32_t j = 0; j < 
m_xSize; ++j)
 
  219               loc = CreateObject<ConstantPositionMobilityModel> ();
 
  222           Vector locVec (xLoc, yLoc, 0);
 
  223           loc->SetPosition (locVec);
 
  234   if (row > 
m_nodes.size () - 1 || 
 
  235       col > 
m_nodes.at (row).GetN () - 1) 
 
  237       NS_FATAL_ERROR (
"Index out of bounds in PointToPointGridHelper::GetNode.");
 
  240   return (
m_nodes.at (row)).Get (col);
 
  246   if (row > 
m_nodes.size () - 1 || 
 
  247       col > 
m_nodes.at (row).GetN () - 1) 
 
  249       NS_FATAL_ERROR (
"Index out of bounds in PointToPointGridHelper::GetIpv4Address.");
 
  272   if (row > 
m_nodes.size () - 1 ||
 
  273       col > 
m_nodes.at (row).GetN () - 1)
 
  275       NS_FATAL_ERROR (
"Index out of bounds in PointToPointGridHelper::GetIpv6Address.");
 
Keep track of a set of IPv6 interfaces. 
 
holds a vector of std::pair of Ptr and interface index. 
 
std::vector< NetDeviceContainer > m_colDevices
NetDevices in a column. 
 
void AssignIpv4Addresses(Ipv4AddressHelper rowIp, Ipv4AddressHelper colIp)
Assigns Ipv4 addresses to all the row and column interfaces. 
 
Ptr< T > GetObject(void) const 
Get a pointer to the requested aggregated Object. 
 
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(const Ipv4InterfaceContainer &other)
Concatenate the entries in the other container with ours. 
 
void Add(Ptr< Ipv6 > ipv6, uint32_t interface)
Add a couple IPv6/interface. 
 
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together. 
 
Mobility model for which the current position does not change once it has been set and until it is se...
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
 
uint32_t m_xSize
X size of the grid (number of columns) 
 
aggregate IP/TCP/UDP functionality to existing Nodes. 
 
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID. 
 
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate. 
 
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)
 
std::vector< NodeContainer > m_nodes
all the nodes in the grid 
 
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. 
 
holds a vector of ns3::NetDevice pointers 
 
std::vector< Ipv6InterfaceContainer > m_rowInterfaces6
IPv6 interfaces in a row. 
 
std::vector< Ipv4InterfaceContainer > m_rowInterfaces
IPv4 interfaces in a row. 
 
std::vector< NetDeviceContainer > m_rowDevices
NetDevices in a row. 
 
Ipv4Address GetIpv4Address(uint32_t row, uint32_t col)
This returns an Ipv4 address at the node specified by the (row, col) address. 
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
keep track of a set of node pointers. 
 
std::vector< Ipv6InterfaceContainer > m_colInterfaces6
IPv6 interfaces in a column. 
 
void Install(std::string nodeName) const 
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
 
~PointToPointGridHelper()
 
Helper class to auto-assign global IPv6 unicast addresses. 
 
static Ipv6Address NextNetwork(const Ipv6Prefix prefix)
Get the next network according to the given Ipv6Prefix. 
 
static void Init(const Ipv6Address net, const Ipv6Prefix prefix, const Ipv6Address interfaceId="::1")
Initialise the base network and interfaceId for the generator. 
 
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. 
 
uint32_t m_ySize
Y size of the grid (number of rows) 
 
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer. 
 
std::vector< Ipv4InterfaceContainer > m_colInterfaces
IPv4 interfaces in a column. 
 
void BoundingBox(double ulx, double uly, double lrx, double lry)
Sets up the node canvas locations for every node in the grid. 
 
static Ipv6Address GetNetwork(const Ipv6Prefix prefix)
Get the current network of the given Ipv6Prefix.