默认纠错模型 (dbu_ecc)

本节介绍占用总线链路收发器管道第五阶段的默认模型的功能和实现。该模型名为 dbu_ecc。源代码位于 <reldir>/models/std/links 目录下的文件 dbu_ecc.ps.c 中。

调用上下文

纠错模型是总线链路收发器管道的最后一个阶段,在错误模型返回后立即调用。调用时的模拟时间对应于数据包接收结束的时间(即数据包的最后一个比特被接收的时间)。

对每个传输的数据包,纠错模型的结果是一个布尔值(即 OPC_TRUE 或 OPC_FALSE),表示数据包在目标节点的可接受性。OPC_FALSE 结果将指示仿真内核应丢弃数据包,而 OPC_TRUE 结果将指示应接受数据包。仿真内核期望将此结果放入数据包的 OPC_TDA_BU_PK_ACCEPT 传输数据属性中。

可接受性测试

dbu_ecc 根据两个条件应用来确定数据包是否可被接收器接受。第一个条件是数据包不得经历任何碰撞。第二个条件是将数据包中发生的比特错误比例与接收器的错误纠正阈值进行比较。因为数据包必须满足两个条件,所以仅在满足第一个条件后才进行第二个测试。该模型的源代码如下图所示。

图 9:管道过程 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
	}

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com