Unfortunately, I think it is a bit of work but certainly doable if you follow the pattern of the existing rectangular model.
It may be instructive to enable ns-3 logging of the existing model on a program that uses it, and observe how it works:
NS_LOG="RandomWalk2d" ./ns3 run ..... (program name)
The basic idea is as follows. There is a bounding object (class Rectangle). The mobility model moves by repeatedly drawing a random direction and speed; these constitute a velocity. The mobility model will move at that velocity for either a pre-determined (constant) amount of time, or a pre-determined (constant) distance. Whether distance or time is used is set by the Mode attribute.
When the mobility model reaches its destination, it draws a new velocity. It then looks ahead to see whether its next eventual destination is within the bounds, or outside. If it is inside, it just determines the time that it will reach that (interior) new position, and schedules the next mobility event then, and moves in that direction. If, however, the eventual destination is outside the bounds, the model determines at what point it will hit the boundary. It then schedules a Rebound event for the time that it will hit the boundary, and calculates the angle with which it will rebound from the bounding box, and the remaining motion time left until it draws a new random velocity.
So if you want to follow this approach, you will have to create a new 'Circle' or 'Disc' object similar to 'Rectangle', and define how circular rebound works (e.g., reflect based on the incident angle from the normal of the circle to the rebound point).
Because Rectangle is not a subclass of any common base class that can be used to generalize the existing mobility model, you will have to choose either refactoring the existing model to be more general, or else copy the RandomWalk2dMobilityModel class into some other new class. If we were to merge these extensions to ns-3, we'd probably ask for the former solution, but if you are just writing for your private use, you may find it to be faster to clone and edit the existing.
I will put some more details into an issue in the issue tracker when I get a chance.
- Tom
--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ns-3-users/a20f2093-98cb-4584-ad9b-136c1c9cea9an%40googlegroups.com.