⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 doppler_shift.ex.c

📁 基于OPNET的网络仿真程序,为Opnet网络仿真书籍的实例
💻 C
字号:
#include <opnet.h>
#include <math.h>

/****************************************************************/
/* Compute Doppler shifts.                                      */
/****************************************************************/
void
doppler_shift (Packet *pkptr)
{
	double		start_dist, end_dist;
	double		tx_delay;
	Objid		tx_objid;
	double		prop_velocity, tx_velocity, shift_scalar;
	double		tx_freq, tx_bw;
	double		tx_min_freq_shift, tx_max_freq_shift, tx_bw_shift;

	FIN (doppler_shift (pkptr));

	/* Obtain the transmission frequency and bandwidth.         */
	tx_freq = op_td_get_dbl (pkptr, OPC_TDA_RA_TX_FREQ);
	tx_bw	= op_td_get_dbl (pkptr, OPC_TDA_RA_TX_BW);

	/* Get the start and end distance between transmitter and   */
	/* receiver.                                                */
	start_dist	= op_td_get_dbl (pkptr, OPC_TDA_RA_START_DIST);
	end_dist	= op_td_get_dbl (pkptr, OPC_TDA_RA_END_DIST);

	/* Obtain the propagation velocity from the transmitter     */
	/* object.  It has been declared on the transmitter object  */
	/* as an extended attribute.  This allows for dynamic       */
	/* updating by a process model (if desired).                */
	tx_objid = op_td_get_int (pkptr, OPC_TDA_RA_TX_OBJID);
	op_ima_obj_attr_get (tx_objid, "Propagation Velocity", &prop_velocity);

	/* Obtain the time over which this transmission takes       */
	/* place.  This coincides with the transmission delay.      */
	/* This value will be used to compute the velocity of the   */
	/* transmitting node.                                       */
	tx_delay = op_td_get_dbl (pkptr, OPC_TDA_RA_TX_DELAY);

	/* Compute the doppler shift.                               */
	tx_velocity			= (end_dist - start_dist) / tx_delay; 
	shift_scalar		= (tx_velocity + prop_velocity) / prop_velocity; 
	tx_min_freq_shift	= shift_scalar * tx_freq;
	tx_max_freq_shift	= shift_scalar * (tx_freq + tx_bw);
	tx_bw_shift			= tx_max_freq_shift - tx_min_freq_shift;

	/* Store these values in the user defined TDA locations.    */
	op_td_set_dbl (pkptr, OPC_TDA_RA_MAX_INDEX + 1, tx_min_freq_shift);
	op_td_set_dbl (pkptr, OPC_TDA_RA_MAX_INDEX + 2, tx_bw_shift);
	
	FOUT;
}
/****************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -