Search code examples
c++socketsns-3

Need help understanding specific code in NS-3


I am new to ns-3 and I am trying to edit the examples third.cc to make a simple simulation. However I need more than the specified no. of 18 wifiStaNodes . However I don't understand this code snippet to modify the parameters.

mobility.SetPositionAllocator ("ns3::GridPositionAllocator",

                              "MinX", DoubleValue (0.0),
                              "MinY", DoubleValue (0.0),
                              "DeltaX", DoubleValue (5.0),
                              "DeltaY", DoubleValue (10.0),
                              "GridWidth", UintegerValue (3),
                              "LayoutType", StringValue ("RowFirst"));

Can somebody please explain how this arrangement of the grid makes it possible for creating only 18 nodes?


Solution

  • You can find these attributes in src/mobility/model/constant-position-mobility-model.cc where the explanation is as follows:

    MinX= The x coordinate where the grid starts.                              
    MinY = The y coordinate where the grid starts.
    DeltaX= The x space between objects.
    DeltaY= The y space between objects.
    GridWidth= The number of objects laid out on a line.
    LayoutType= The type of layout. (i.e., RowFirst or ColumnFirst)
    

    Based on value of GridWidth the objects in each row/column are laid out, respectively. In your case, it would be 6 rows, each row containing 3 objects (nodes).