Random Mobility
gradysim.protocol.plugin.random_mobility
A common use case of network simulations is to simulate a network of mobile nodes whose mobility is random. This plugin provides a simple way to implement random mobility in your protocol.
RandomMobilityConfig
dataclass
Configuration class for the RandomMobilityPlugin class.
Source code in gradysim/protocol/plugin/random_mobility.py
tolerance: float = 1
class-attribute
instance-attribute
Tolerance in meters for considering a waypoint as reached. When the node is within this distance from the waypoint, it will be considered as reached and a new waypoint will be drawn, if a random trip is ongoing.
x_range: Tuple[float, float] = (-50, 50)
class-attribute
instance-attribute
Random waypoints will be drawn from this range for the x coordinate
y_range: Tuple[float, float] = (-50, 50)
class-attribute
instance-attribute
Random waypoints will be drawn from this range for the y coordinate
z_range: Tuple[float, float] = (0, 50)
class-attribute
instance-attribute
Random waypoints will be drawn from this range for the z coordinate
RandomMobilityPlugin
Plugin for random mobility. This plugin will assist you in implementing random movement behaviour in your protocol.
This plugin should be initialized by your protocol. To use it you should call the initiate_random_trip method to start a random trip. This method will make the node travel to a random waypoint and then draw a new waypoint when the node reaches it. This process will repeat until you call the finish_random_trip method.
If you only want to make the node travel to a random waypoint once, you can use the travel_to_random_waypoint method.
Source code in gradysim/protocol/plugin/random_mobility.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
current_target: Optional[Position]
property
Returns the position the node is currently traveling to, or None if it isn't traveling anywhere.
Returns:
Type | Description |
---|---|
Optional[Position]
|
The position the node is currently traveling to, or None if it isn't traveling anywhere. |
trip_ongoing
property
Returns whether a random trip is ongoing or not Returns: True if a random trip is ongoing, False otherwise
__init__(protocol, config=RandomMobilityConfig())
Initializes the plugin
Parameters:
Name | Type | Description | Default |
---|---|---|---|
protocol |
IProtocol
|
The protocol instance to which this plugin will be attached |
required |
config |
RandomMobilityConfig
|
Configuration for the plugin, if not specified, the default configuration will be used |
RandomMobilityConfig()
|
Source code in gradysim/protocol/plugin/random_mobility.py
finish_random_trip()
Finishes an ongoing random trip. If no trip is ongoing, this method does nothing.
Source code in gradysim/protocol/plugin/random_mobility.py
initiate_random_trip()
Initiates a random trip. This means this node will draw a random waypoint, travel to it and repeat this process until finish_random_trip is called.
Source code in gradysim/protocol/plugin/random_mobility.py
travel_to_random_waypoint()
Issues a mobility command that makes the node travel to a randomly drawn position within the range specified in the configuration of this class.
Returns:
Type | Description |
---|---|
Position
|
Node's new destination |