• Position Allocator

    Decide the nodes initial position

    There are a lot of position allocator, maybe you can look up the official documentation. Though there are no clear specification and show you how to use, but maybe you can work just like me. That is GUESS.

    • Position Allocator Official Doc

    • ListPositionAllocator

      List position allocator source

      I use a loop to generate 30 position and take the allocator as argument for mobility helper.

      Ptr<ListPositionAllocator> nodes_pos = CreateObject<ListPositionAllocator> ();        
      for (double y = 0; y < (nodes.GetN ())/1.0; ++y)
      {
        nodes_pos->Add (Vector (0.0, y * 3.0, 0.0));        
      }
      MobilityHelper mob;
      mob.SetPositionAllocator (nodes_position);
      

    • RandomDiscPositionAllocator

      Random Disk Position source

      This example use string as argument for mobility helper. The "X" and "Y" is the center and "Rho" is the radius for position distribution. For here, I use a uniform random variable as argument.

      MobilityHelper mob;
      mob.SetPositionAllocator ("ns3::RandomDiscPositionAllocator",
                                 "X", StringValue ("100.0"),
                                 "Y", StringValue ("100.0"),
                                 "Rho", StringValue ("ns3::UniformRandomVariable[Min=0|Max=30]"));
      

results matching ""

    No results matching ""