Default Error Correction Model (dbu_ecc)
This section describes the functionality and implementation of the default model occupying stage five of the Bus Link Transceiver Pipeline. This model is named dbu_ecc. Source code is provided in the file dbu_ecc.ps.c, which resides in the <reldir>/models/std/links directory.
Invocation Context
The error correction model is the final stage of the bus link transceiver pipeline, and is called immediately after the return of the error model. The simulation time at invocation corresponds to the end of packet reception (i.e., the time at which the last bit of the packet has been received).
The result of the error correction model for each transmitted packet is one Boolean value (i.e., OPC_TRUE or OPC_FALSE) that represents the acceptability of the packet in the destination node. A result of OPC_FALSE will indicate to the Simulation Kernel that the packet should be dropped, while a result of OPC_TRUE will indicate that the packet should be accepted. The Simulation Kernel expects this result to be placed in the packet's OPC_TDA_BU_PK_ACCEPT transmission data attribute.
Acceptability Test
dbu_ecc determines whether a packet can be accepted by the receiver based on the application of two criteria. The first criteria is that the packet must have experienced no collisions. The second criteria compares the proportion of bit errors occurring in the packet and the error correction threshold of the receiver. Because the packet must meet both criteria, the second test is only done if the first condition is met. The source code for this model appears in the following figure.
Figure 9: Source Code for Pipeline Procedure dbu_ecc
/* dbu_ecc.ps.c */
/* Default error correction model for bus link Transceiver Pipeline */
/**********************************/
/* Copyright (c) 2013 */
/* Riverbed Technology, Inc. */
/* All Rights Reserved. */
/**********************************/
#include "opnet.h"
#if defined (__cplusplus)
extern "C"
#endif
void
dbu_ecc (Packet * pkptr)
{
Objid rx_obid;
OpT_Packet_Size pklen;
int num_errs, accept;
double ecc_thresh;
/** Test if packet arriving over point-to-point link is **/
/** acceptable for reception or if it should be discarded. **/
FIN (dbu_ecc (pkptr));
/* A packet will be rejected outright under one of two conditions: */
/* 1. If the packet was affected by any collisions. */
/* 2. If the receiving node was disabled during reception. */
if ((op_td_get_int (pkptr, OPC_TDA_BU_NUM_COLLS) != 0) ||
(op_td_is_set (pkptr, OPC_TDA_BU_ND_FAIL)))
{
accept = OPC_FALSE;
}
else
{
/* Obtain object id of receiver accepting transmission. */
rx_obid = op_td_get_int (pkptr, OPC_TDA_BU_RX_OBJID);
/* Obtain the error correction threshold of the receiver. */
if (op_ima_obj_attr_get (rx_obid, "ecc threshold", &ecc_thresh)
== OPC_COMPCODE_FAILURE)
{
op_sim_end ("Error in bus error correction pipeline stage (dbu_ecc):",
"Unable to get error correction threshold from receiver attribute.",
OPC_NIL, OPC_NIL);
}
/* Obtain length of packet. */
pklen = op_pk_total_size_get (pkptr);
/* Obtain number of errors in packet. */
num_errs = op_td_get_int (pkptr, OPC_TDA_BU_NUM_ERRORS);
/* Test if bit errors exceed threshold. */
if (pklen == 0)
accept = OPC_TRUE;
else
accept = ((((double) num_errs) / pklen) <= ecc_thresh) ? OPC_TRUE :
OPC_FALSE;
}
/* Place flag indicating accept/reject in transmission data block. */
op_td_set_int (pkptr, OPC_TDA_BU_PK_ACCEPT, accept);
FOUT
}