Direct Manipulation of Position Attributes
If a trajectory is specified for a mobile site, the path of that site is predetermined for the entire simulation. However, if no trajectory is specified, the site’s position can be directly updated by any process during simulation. A mobile site’s x position and y position attributes specify its location in its parent subnetwork. A mobile site’s altitude attribute specifies its elevation relative to sea level, the underlying terrain, or the parent subnetwork (depending on the site’s altitude modeling attribute setting). A change to one of these attributes will cause an immediate change in the location of the mobile site.
Typically, one of two techniques is employed to dynamically change the location of a mobile site. In both cases, a user-defined process is responsible for modifying the position attributes of a mobile site. The first technique is a centralized approach, in which one process is responsible for updating the positions of all of the mobile sites in a network model. Often this process resides within a site specially designated as a central control site. The second technique is a decentralized approach, in the sense that each mobile site has a process executing within it that updates only its own position. The following diagrams show code samples from an example process model implementing each technique.
Note: In these examples, the node_position_compute() function is a user-supplied routine that computes the position of the node based on some criteria.
Figure 16: Example Process Model State Implementing Decentralized Management of Parent Mobile Node’s Position Attributes
/* Obtain the parent node’s object ID. */
parent_node_objid = op_topo_parent (op_id_self ());
/* Obtain the new subnet-relative coordinates for the parent node. */
node_position_compute (parent_node_objid, &x_pos, &y_pos, &alt);
/* Set the parent node’s position attributes to the new values. */
op_ima_obj_attr_set_dbl (parent_node_objid, “x position”, x_pos);
op_ima_obj_attr_set_dbl (parent_node_objid, “y position”, y_pos);
op_ima_obj_attr_set_dbl (parent_node_objid, “altitude”, alt);
Figure 17: Example Process Model Fragment Implementing Centralized Management of all Mobile Nodes’ Position Attributes
/* Determine number of mobile nodes in the system. */
num_nodes = op_topo_object_count (OPC_OBJTYPE_NDMOB);
/* For each mobile node, obtain its object ID, system ID */
/* and new location. Set the new values in the position */
/* attributes of the node. */
for (i = 0; i < num_nodes; i++)
{
/* Obtain the i_th mobile node’s object ID. */
node_objid = op_topo_object (OPC_OBJTYPE_NDMOB, i);
/* Obtain the new subnet-relative coordinates for the mobile node. */
node_position_compute (node_objid, &x_pos, &y_pos, &alt);
/* Set the parent node’s position attributes to the new values. */
op_ima_obj_attr_set_dbl (node_objid, “x position”, x_pos);
op_ima_obj_attr_set_dbl (node_objid, “y position”, y_pos);
op_ima_obj_attr_set_dbl (node_objid, “altitude”, alt);
}
In contrast to trajectories, where the Simulation Kernel can model continuous movement, direct manipulation of a mobile site’s position attributes forces discrete position changes. Discrete position changes of a mobile site can cause unexpected behavior with respect to the default radio transceiver pipeline. Specifically, there might be issues involving the default signal locking mechanism, packet interference calculations, and the busy statistic of the radio receiver channel. These mechanisms rely on the fact that when two packets are sent back-to-back from a single radio transmitter channel, the first packet’s reception completion time is the same as the second packet’s arrival start time. This is based on two propagation delay calculations: the first packet’s propagation delay at the end of its transmission and the second packet’s propagation delay at the beginning of its transmission. If these propagation delays are not the same, then two back-to-back packets will incorrectly appear to overlap each other or to have a gap between them.
As two sites move closer together or farther apart during transmission, the propagation delay of the radio signal will correspondingly change. Thus, at the beginning and end of transmission of one packet, the start and end propagation delays for a packet sent from a mobile site can be different. If the difference in propagation delays is not accounted for, then the overlap or gap behavior occurs with back-to-back packets.
The default radio transceiver pipeline does not prevent the overlap or gap behavior in the case of discrete position changes. This is due to the fact that the Simulation Kernel cannot predict the future location of a mobile site without use of a trajectory. In this case, the Simulation Kernel sets the end of transmission propagation distance in a packet’s TDA OPC_TDA_RA_END_DIST to the same value as the start of transmission propagation distance, found in the packet’s TDA OPC_TDA_RA_START_DIST. The default radio pipeline stage that computes the propagation delays, dra_propdel.ps.c, uses these values and therefore returns the same result for both delays.
One solution is to replace the default radio pipeline stage with another that will correctly compute the end of transmission propagation delay. The following code is an example pipeline stage that correctly calculates this delay. It is assumed that the procedure node_distance_calculate() returns the distance in meters between the specified sites at the specified time. If such a procedure is not possible, then some other solution that handles the default signal locking mechanism, packet interference calculations, and the busy statistic of the radio receiver channel issues should be used instead.
Figure 18: Example Propagation Delay Radio Pipeline Stage
/* mobile_propdel.ps.c */
/* Propagation delay model for radio link Transceiver Pipeline */
#include <opnet.h>
/* propagation velocity of radio signal (m/s) */
define PROP_VELOCITY 3.0E+08
#if defined (__cplusplus)
extern “c”
#endif
void
mobile_propdel (Packet *pkptr)
{
double start_prop_delay, end_prop_delay;
double start_prop_distance, end_prop_distance;
Objid source_node_objid, destination_node_objid;
double end_rx_time;
/** Compute the propagation delays separating the **/
/** radio transmitter from the radio receiver. **/
FIN (mobile_propdel (pkptr))
/* Obtain source node’s object ID. */
source_node_objid = op_topo_parent (op_td_get_int (pkptr,OPC_TDA_RA_TX_OBJID));
/* Obtain destination node’s object ID. */
destination_node_objid = op_topo_parent (op_td_get_int (pkptr,
OPC_TDA_RA_RX_OBJID));
/* Obtain the end of reception time. */
end_rx_time = op_td_get_dbl (pkptr, OPC_TDA_RA_END_RX);
/* Get the start distance between transmitter and receiver. */
start_prop_distance = op_td_get_dbl (pkptr, OPC_TDA_RA_START_DIST);
/* Compute the end distance between transmitter and receiver, based */
/* on information that specifies where the nodes will be at the */
/* time when the packet has been completely received. This is */
/* necessary because, the end distance stored in the packet’s TDA */
/* is invalid if either node moves during the transmission. */
end_prop_distance = node_distance_calculate (source_node_objid,
destination_node_objid, end_rx_time);
/* Compute propagation delay to start of reception. */
start_prop_delay = start_prop_distance / PROP_VELOCITY;
/* Compute propagation delay to end of reception. */
end_prop_delay = end_prop_distance / PROP_VELOCITY;
/* Place both propagation delays in packet trans. data attributes. */
op_td_set_dbl (pkptr, OPC_TDA_RA_START_PROPDEL, start_prop_delay);
op_td_set_dbl (pkptr, OPC_TDA_RA_END_PROPDEL, end_prop_delay);
FOUT
}