📄 cdma_ber2.ps.c
字号:
/* cdma_ber.ps.c */
/* CDMA Bit-Error-Rate (BER) model for radio link Transceiver Pipeline */
#include "opnet.h"
#include "math.h"
#if defined (__cplusplus)
extern "C"
#endif
//static const char* PowI_Err_Hdr = "Error in CDMA BER computation pipeline stage (cdma_ber2):";
void
cdma_ber2 (Packet * pkptr)
{
//int msgbuf[512];
double ber,bernew,snr,cdmasnr, proc_gain, eff_snr, cdmaeff_snr, code_rate;
Vartype modulation_table;
//Objid rx_nodeid;
/** Calculate the average bit error rate affecting given packet. **/
FIN (cdma_ber (pkptr));
/* We have to make sure that the initialization is done and the extended
attributes are loaded */
/*
rx_nodeid = op_td_get_int(pkptr, OPC_TDA_RA_RX_OBJID);
if (op_ima_obj_attr_get( rx_nodeid, "Coding_Rate",
&code_rate) ==
OPC_COMPCODE_FAILURE)
{
op_sim_end (PowI_Err_Hdr, "No Coding_Rate attr",
OPC_NIL, OPC_NIL);
}
*/
/* Determine current value of Signal-to-Noise-Ratio (SNR). */
snr = op_td_get_dbl (pkptr, OPC_TDA_RA_SNR);
cdmasnr = op_td_get_dbl (pkptr, OPC_TDA_RA_MAX_INDEX+1);
/* Determine address of modulation table. */
modulation_table = op_td_get_ptr (pkptr, OPC_TDA_RA_RX_MOD);
/* Determine processing gain on channel. */
proc_gain = op_td_get_dbl (pkptr, OPC_TDA_RA_PROC_GAIN);
/* Calculate effective SNR incorporating processing gain. */
eff_snr = snr + proc_gain;
cdmaeff_snr = cdmasnr + proc_gain;
/* Derive expected BER from effective SNR. */
ber = op_tbl_mod_ber (modulation_table,cdmaeff_snr);
/* Place the BER in the packet's transmission data. */
op_td_set_dbl (pkptr, OPC_TDA_RA_BER, ber);
FOUT
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -