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

📄 wlan_mac_tmac_nav_rpm_31jan06_ver2.pr.c

📁 opnet无线网络编程
💻 C
📖 第 1 页 / 共 5 页
字号:
/* Process model C form file: wlan_mac_TMAC_NAV_RPM_31Jan06_ver2.pr.c */
/* Portions of this file copyright 1992-2007 by OPNET Technologies, Inc. */



/* This variable carries the header into the object file */
const char wlan_mac_TMAC_NAV_RPM_31Jan06_ver2_pr_c [] = "MIL_3_Tfile_Hdr_ 140A 30A modeler 7 476CE539 476CE539 1 pc2-4 Administrator 0 0 none none 0 0 none 0 0 0 0 0 0 0 0 18a9 3                                                                                                                                                                                                                                                                                                                                                                                                      ";
#include <string.h>



/* OPNET system definitions */
#include <opnet.h>



/* Header Block */

/** Include files **/

#include <math.h>
#include <string.h>
#include "oms_pr.h"
#include "oms_tan.h"
#include "oms_bgutil.h"
#include "wsn_support.h" 
#include "oms_auto_addr_support.h"
#include "oms_dist_support.h"
#include "bridge_header.h"	
#include "prg_mapping.h"
#include <prg_geo.h>
#include <oms_rr.h>  

/** Constants **/

/* Incoming statistics and stream wires.							*/
#define 	TRANSMITTER_BUSY_INSTAT		1
#define		LOW_LAYER_INPUT_STREAM		0
#define		LOW_LAYER_OUTPUT_STREAM		0

/* Flags to load different variables based on attribute settings.	*/
#define		WLAN_AP						1
#define		WLAN_STA					0

/* Flags to indicate the medium access mode (PCF/DCF).				*/
#define		PCF_ACTIVE					1
#define		PCF_INACTIVE				0

/* Special value indicating BSS identification is not used.			*/
#define		WLAN_BSSID_NOT_USED			-1

/* Special value indicating radio transceiver frequencies are set	*/
/* based on the BSS identification.									*/
#define 	BSS_BASED_FREQ_USED			-1.0

/* Special value indicating that the bandwidth of the transceiver	*/
/* channels are configured to use the standard value of the			*/
/* specified physical layer technology.								*/
#define		PHY_TECH_BASED_BW_USED		-1.0

/* Special value indicating that the number of back-off slots are	*/
/* not determined yet.												*/
#define		BACKOFF_SLOTS_UNSET			-1.0

/* Special value for nav_reset_time when NAV is not set based on a	*/
/* received RTS.													*/
#define		NAV_RESET_TIME_UNSET		-1.0
	
/* Define a small value (= 1 psec), which will be used to recover	*/
/* from double arithmetic precision losts while doing time related	*/
/* precision sensitive computations.								*/
#define		PRECISION_RECOVERY			0.000000000001

/* Special value indicating BSS identification is currently unset.	*/
#define 	WLANC_BSS_ID_UNKNOWN		-2

/* Speed of light (m/s). 											*/
#define 	C							3.0E+08		

/* 16 times pi-squared. 											*/
#define 	SIXTEEN_PI_SQ				(16.0 * VOSC_NA_PI * VOSC_NA_PI)	

/* A small delay (= 10 nsec) between the transmission and reception	*/
/* of a CTS-to-self message to guarantee that the packet isn't		*/
/* delivered before the transmitter completes the transmission.		*/
#define		CTS_TO_SELF_RX_DELAY		0.00000001

/* In the idle state, number of beacon intervals after which the STA will wake	*/
/* up to check if it is still connected, if scanning is based on beacon			*/
/* reliability. There are no interrupts pending in the idle state, therefore,	*/
/* it is possible that the STA's state may be set to "scan" from a pipeline		*/
/* state without the MAC becoming aware of the state change till a packet		*/
/* arrives from the higher layer. Hence, there is a need to schedule periodic	*/
/* interrupts when in IDLE.    													*/
#define WLANC_CONN_CHK_BEACON_MULT		5.0  

/* Period after which the STA will check for connectivity if scanning is		*/
/* distance based. 																*/
#define WLANC_CONN_CHK_DIST_INTERVAL	10.0

/* When in the SCAN state, the period that an STA will wait before trying a new	*/
/* channel. 																	*/
#define WLANC_NEW_SCAN_BEACON_MULT		2.5


/** Enumerated Types **/

/* Define the three possible values that a global variable takes				*/
/* to check and ensure that all the MAC modules are either BSS ID				*/
/* based or purely subnet based. The variable is initialized to					*/
/* Not_Set and the first wireless MAC process sets it to either					*/
/* Entire_Subnet (if BSS_Identifier is Not Used) or Bssid_Subnet				*/
/* (if the BSS_Identifier is set to some value other than Not					*/
/* Used).																		*/						  
typedef enum WlanT_Bssid_Approach
	{
	WlanC_Not_Set,						/* Type of network not set				*/
	WlanC_Entire_Subnet,				/* The network is a pure subnet			*/
	WlanC_Bss_Divided_Subnet			/* The network is a BSS based subnet	*/
	} WlanT_Bss_Identification_Approach;
 
/* Define interrupt codes for generating handling interrupts					*/
/* indicating changes in deference, frame timeout which infers         			*/
/* that the collision has occurred, random backoff and transmission 			*/
/* completion by the physical layer (self interrupts).							*/
typedef enum WlanT_Mac_Intrpt_Code
	{	
	WlanC_Deference_Off,  	/* Deference before frame transmission 				*/
	WlanC_Frame_Timeout,	/* No frame rcvd in set duration (infer collision)	*/
	WlanC_Backoff_Elapsed,  /* Backoff done before frame transmission			*/
	WlanC_CW_Elapsed,		/* Backoff done after successful frame transmission	*/	
	WlanC_Beacon_Tx_Time,	/* Time to transmit beacon frame                    */
	WlanC_Cfp_End,			/* End of the Contention free period 				*/
	WlanC_Scan_Timeout,		/* End of scan duration for given channel 			*/
	WlanC_AP_Check_Timeout,	/* Time to check the connectivity status with the	*/
							/* current AP.										*/
	WlanC_NAV_Reset_Time,	/* Time to reset NAV that is updated by an RTS.		*/
	
	// wsn
	WlanC_Sleep_Schedule_Cyclic,	// Time for node to go to sleep
	WlanC_Sleep_Schedule_NAV,	// Time for node to go to sleep
	WlanC_Wake_Schedule,		// Time for node to wake up
	WlanC_Update_Period
		
	} WlanT_Mac_Intrpt_Code;


/* Define the individual forced and unforced states to determine energy consumption costs  */
/* upon exiting the state									        			*/
typedef enum WsnT_State
	{	
	
	// Unforced States
	WSN_IDLE,  	
	WSN_DEFER,	
	WSN_BACKOFF,
	WSN_SLEEP_LPM3,	
	WSN_SLEEP_LPM2,		
	WSN_SLEEP_LPM1,		
	WSN_WAIT_FOR_RESPONSE,	
	WSN_SCAN,	
	WSN_TRANSMIT,
	
	// Forced States
	
	WSN_BKOFF_NEEDED,
	WSN_WAKE_TRANSIT,
	WSN_FRM_END
		
	} WsnT_State;


⌨️ 快捷键说明

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