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

📄 opnetwork_chanmatch_no_doppler.ps.c

📁 基于OPNET的网络仿真程序,为Opnet网络仿真书籍的实例
💻 C
字号:
/* opnetwork_chanmatch_no_doppler.ps.c */                                                       
/* Modified channel match model for radio link Transceiver Pipeline */

/****************************************/
/*		  Copyright (c) 1993			*/
/*			by MIL 3, Inc.				*/
/*		(A Delaware Corporation)		*/
/*	3400 International Drive,  N.W.		*/
/*		Washington, D.C., U.S.A.		*/
/*			All Rights Reserved.		*/
/****************************************/

#include <opnet.h>


void
opnetwork_chanmatch_no_doppler (pkptr)
	Packet*		pkptr;
	{
	double		tx_freq, tx_bw, tx_drate, tx_code;
	double		rx_freq, rx_bw, rx_drate, rx_code;
	Vartype		tx_mod;
	Vartype		rx_mod;

	/** Determine the compatibility between transmitter and receiver channels. **/
	FIN (opnetwork_chanmatch_no_doppler (pkptr));

	/* Obtain transmitting channel attributes. */
	tx_freq		= op_td_get_dbl (pkptr, OPC_TDA_RA_TX_FREQ);
	tx_bw		= op_td_get_dbl (pkptr, OPC_TDA_RA_TX_BW);
	tx_drate	= op_td_get_dbl (pkptr, OPC_TDA_RA_TX_DRATE);
	tx_code		= op_td_get_dbl (pkptr, OPC_TDA_RA_TX_CODE);
	tx_mod		= op_td_get_ptr (pkptr, OPC_TDA_RA_TX_MOD);	

	/* Obtain receiving channel attributes. */
	rx_freq		= op_td_get_dbl (pkptr, OPC_TDA_RA_RX_FREQ);
	rx_bw		= op_td_get_dbl (pkptr, OPC_TDA_RA_RX_BW);
	rx_drate	= op_td_get_dbl (pkptr, OPC_TDA_RA_RX_DRATE);
	rx_code		= op_td_get_dbl (pkptr, OPC_TDA_RA_RX_CODE);
	rx_mod		= op_td_get_ptr (pkptr, OPC_TDA_RA_RX_MOD);

	/****************************************************************/
	/* Compute Doppler shifts.                                      */
	/****************************************************************/
#if 0 /*** DELETE THIS LINE ***/
	doppler_shift (pkptr);
#endif /*** DELETE THIS LINE ***/
	/****************************************************************/

	/* For non-overlapping bands, the packet has no	*/
	/* effect; such packets are ignored entirely.	*/
	if ((tx_freq > rx_freq + rx_bw) || (tx_freq + tx_bw < rx_freq))
		{
		op_td_set_int (pkptr, OPC_TDA_RA_MATCH_STATUS, OPC_TDA_RA_MATCH_IGNORE);
		FOUT;
		}

	/* Otherwise check for channel attribute mismatches which would	*/
	/* cause the in-band packet to be considered as noise.			*/
	if ((tx_freq != rx_freq) || (tx_bw != rx_bw) || 
		(tx_drate != rx_drate) || (tx_code != rx_code) || (tx_mod != rx_mod))
		{
		op_td_set_int (pkptr, OPC_TDA_RA_MATCH_STATUS, OPC_TDA_RA_MATCH_NOISE);
		FOUT;
		}

	/* Otherwise the packet is considered a valid transmission which	*/
	/* could eventually be accepted at the error correction stage.		*/
	op_td_set_int (pkptr, OPC_TDA_RA_MATCH_STATUS, OPC_TDA_RA_MATCH_VALID);

	/****************************************************************/
	/* Record statistics for unshifted and shifted frequencies.     */
	/****************************************************************/
	{
		int			i, proc_count;
		Objid		tx_objid, node_objid, proc_objid;
		char		proc_name [255];
		double		tx_freq_shift;
		Stathandle	*doppler_shift_lshandle, *unshifted_lshandle;

		/* Obtain the transmitter object ID.                        */
		tx_objid = op_td_get_int (pkptr, OPC_TDA_RA_TX_OBJID);

		/* Obtain the object ID of the node.                        */
		node_objid = op_topo_parent (tx_objid);

		/* Obtain the object ID of the stats module.                */
		proc_count = op_topo_child_count (node_objid, OPC_OBJTYPE_PROC);
		for (i = 0; i < proc_count; i++)
		{

			/* Access the ith processor module.                     */
			proc_objid = op_topo_child (node_objid, OPC_OBJTYPE_PROC, i);

			/* Check to make sure that this module has the name     */
			/* "wireless_stats".                                    */
			op_ima_obj_attr_get (proc_objid, "name", &proc_name);
			if (strcmp (proc_name, "wireless_stats") == 0)
			{

				/* Access the state variables that hold the         */
				/* registered statistics.                           */
				doppler_shift_lshandle = (Stathandle*) op_ima_obj_svar_get
					(proc_objid, "doppler_shift_lshandle");
				unshifted_lshandle = (Stathandle*) op_ima_obj_svar_get
					(proc_objid, "unshifted_lshandle");

				/* Check whether shifted TDA has been calculated.   */
				if ((op_td_is_set (pkptr, OPC_TDA_RA_MAX_INDEX + 1) == OPC_TRUE) &&
					(doppler_shift_lshandle != OPC_NIL))
				{

					/* Obtain the shifted frequency.                */
					tx_freq_shift = op_td_get_dbl (pkptr, OPC_TDA_RA_MAX_INDEX + 1);

					/* Record shifted frequency.                    */
					op_stat_write (*doppler_shift_lshandle, tx_freq_shift - tx_freq);
				}

				/* Record unshifted frequency.                      */
				if (unshifted_lshandle != OPC_NIL)
					op_stat_write (*unshifted_lshandle, tx_freq - tx_freq);
			}
		}
	}
	/****************************************************************/

	FOUT;
	}                

⌨️ 快捷键说明

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