op_td_get_int()
Abstract
Obtains a 32-bit integer value from the specified transmission data attribute.
Syntax
op_td_get_int (pkptr, tda_index)
| Argument | Type | Description |
|---|---|---|
pkptr |
Packet* |
pointer to the packet-of-interest |
tda_index |
int |
numeric index of the transmission data attribute-of-interest. The TDA must be a 32-bit integer. [This value is an integer code that specifies the transmission data attribute to be accessed. Predefined values for this argument appear in “Transmission Data Attribute“ on page 28. User-defined transmission information can be obtained from any attribute index greater than the largest index occupied by a predefined attribute (assuming the attribute has been previously assigned). The largest predefined attribute indices are OPC_TDA_PT_MAX_INDEX (for the point-to-point pipeline), OPC_TDA_BU_MAX_INDEX (for the bus pipeline), and OPC_TDA_RA_MAX_INDEX (for the radio pipeline).] |
Return Type
int
Value of the specified transmission data attribute.
Example
Excerpt from: example model (models/std/base); pipeline model (dra_inoise).
/* If the previous packet ends just as the new one begins, this is not a collision */
/* (just a near miss, or perhaps back-to-back packets).*/
if (op_td_get_dbl (pkptr_prev, OPC_TDA_RA_END_RX) != op_sim_time())
{
/* Increment the number of collisions in previous packet. */
op_td_increment_int (pkptr_prev, OPC_TDA_RA_NUM_COLLS, 1);
/* Increment the number of collisions in arriving packet. */
op_td_increment_int (pkptr_arriv, OPC_TDA_RA_NUM_COLLS, 1);
/* Determine if previous packet is valid or noise. */
prev_match = op_td_get_int (pkptr_prev, OPC_TDA_RA_MATCH_STATUS);
/* Determine if arriving packet is valid or noise. */
arriv_match = op_td_get_int (pkptr_arriv, OPC_TDA_RA_MATCH_STATUS);
Details
Before invoking this KP, make sure that the TDA in question has already been set. You can use op_td_is_set() to determine if the TDA is set or not.
Transmission data attributes are used to convey link modeling data between the Simulation Kernel and successive Transceiver Pipeline stages. The Td package KPs provide primitive operations (set and get) for operating on transmission data attributes. The basic format of a Pipeline stage model is a C file which contains a single function with the same name (for instance, the base Pipeline stage model dra_power is stored in the file dra_power.ps.c, and is implemented as the C function dra_power()). In most stages, the single argument of the function is a pointer to the packet on which the stage operates. The statements in the C function generally perform the following sequence of activities:
- Extract attributes from the packet’s transmission data (via the KPs op_td_get_dbl(), op_td_get_int(), op_td_get_int64(), and op_td_get_ptr()).
- Perform calculations that characterize the corresponding stage of the link model (typically a combination of numerical and logical processing).
- Assign newly computed attributes to the packet’s transmission data (via the KPs op_td_set_dbl(), op_td_set_int(), op_td_set_int64(), and op_td_set_ptr()).
Purpose
Provides a mechanism to obtain an attribute value from the transmission data that is associated with each packet passing through the stages of the Transceiver Pipeline of a link model. This KP is used to access a single 32-bit integer attribute value from the specified packet’s transmission data block.
Errors
- Recoverable Error:
<type>TDA (<name>) cannot be retrieved using 'op_td_get_int'. - Program Abort: Segmentation violation. (due to an invalid packet pointer or malformed packet)
- Program Abort: Packet pointer is NIL.
- Program Abort: Packet pointer references destroyed packet (
<pk_id>). - Program Abort: Tda index (
<tda_index>) is out-of-range for packet (<pk_id>). - Program Abort: Tda (
<tda_name>) is unassigned in packet (<pk_id>).
Reference
- Use the KP op_td_get_int64() to obtain the value of a 64-bit integer transmission data attribute
- Use the KP op_td_get_dbl() to obtain the value of a double transmission data attribute
- Use the KP op_td_get_ptr() to obtain the value of a pointer transmission data attribute
- Use the KPs op_td_set_int() and op_td_set_int64() to assign the value of an integer transmission data attribute
- Use the KP op_td_set_dbl() to assign the value of a double transmission data attribute
- Use the KP op_td_set_ptr() to assign the value of a pointer transmission data attribute
- Use the KP op_td_is_set() to determine whether a transmission data attribute has been assigned