Allocate positions on a rectangular 2d grid. 即把节点分配在一个矩形网格中。
网址:http://www.nsnam.org/doxygen/classns3_1_1_grid_position_allocator.htm
矩形的长度 = GridWidth * DeltaX
矩形的宽度 = GridWidth * DeltaY
GridWidth: The number of objects layed out on a line. 每一行,每一列上的网格数量。
MinX: The x coordinate where the grid starts. 起点x坐标
MinY: The y coordinate where the grid starts. 起点y坐标
DeltaX: The x space between objects. x增量
DeltaY: The y space between objects. y增量
LayoutType: The type of layout. 布局类型,是先分配行,还是先分配列
LayoutType值类型:ROW_FIRST,COLUMN_FIRST
ROW_FIRST: In row-first mode, positions are allocated on the first row until N positions have been allocated. Then, the second row located a yMin + yDelta is used to allocate positions.
COLUMN_FIRST: In column-first mode, positions are allocated on the first column until N positions have been allocated. Then, the second column located a xMin + xDelta is used to allocate positions.
例:
NodeContainer c;c.Create (25);
MobilityHelper mobility;
mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
"MinX", DoubleValue (0.0),
"MinY", DoubleValue (0.0),
"DeltaX", DoubleValue (500),
"DeltaY", DoubleValue (500),
"GridWidth", UintegerValue (5),
"LayoutType", StringValue ("RowFirst"));
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (c);
结果,节点分配位置:
n20 n21 n22 n23 n24
n15 n16 n17 n18 n19
n10 n11 n12 n13 n14
n5 n6 n7 n8 n9
n0 n1 n2 n3 n4