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

📄 jigb_wlan_mac_jamming.pr.c

📁 利用opnet网络仿真软件,研究802.11的QOS,可以利用此模块研究802.11e
💻 C
📖 第 1 页 / 共 5 页
字号:
#define	PLCP_OVERHEAD_CTRL_DR(size,data_rate)	(phy_type == WlanC_11b_PHY ? plcp_overhead_control : wlan_non_11b_plcp_overhead_compute (size, data_rate))

/* Macro definitions to compute the transmission delay of control and data		*/
/* frames.																		*/
#define	TXTIME_CTRL(size)				(PLCP_OVERHEAD_CTRL (size) + (double) size / control_data_rate + \
										 ((wlan_flags->signal_extension) ? WLANC_11g_SIGNAL_EXTENSION : 0.0))						
#define	TXTIME_DATA(size)				(PLCP_OVERHEAD_DATA (size) + (double) size / operational_speed + \
										 ((wlan_flags->signal_extension) ? WLANC_11g_SIGNAL_EXTENSION : 0.0))
#define	TXTIME_CTRL_DR(size,data_rate)	(PLCP_OVERHEAD_CTRL_DR (size, data_rate) + (double) size / data_rate + \
										 ((wlan_flags->signal_extension) ? WLANC_11g_SIGNAL_EXTENSION : 0.0))

/* The size of the step between two non-overlapping WLAN channels in terms of	*/
/* channel numbers.																*/
#define WLANC_CH_STEP_FOR_NO_OVERLAP	((int) ceil (channel_bandwidth / channel_spacing))	

						
/**	State Transitions **/

/** The data frame send flag is set whenever there is a data to be send by	**/
/** the higher layer or the response frame needs to be sent. However, in 	**/
/** either case the flag will not be set if the receiver is busy			**/
/** Frames cannot be transmitted until medium is idle. Once, the medium 	**/
/** is available then the station is eligible to transmit provided there	**/
/** is a need for backoff. Once the transmission is complete then the		**/
/** station will wait for the response provided the frame transmitted  		**/
/** requires a response (such as RTS and Data frames). If response			**/
/** is not needed then the station will defer to transmit next packet		**/

/* After receiving a stream interrupt, we need to switch states from	*/
/* idle to defer or transmit if there is a frame to transmit and the	*/
/* receiver is not busy													*/ 
/* If a frame is received indicating that the STA should scan, all bets */
/* are off, and the STA moves into the scan state to look for other APs */
#define READY_TO_TRANSMIT		(((intrpt_type == OPC_INTRPT_STRM && wlan_flags->data_frame_to_send == OPC_TRUE && \
								   (pcf_flag == OPC_BOOLINT_DISABLED || (wlan_flags->pcf_active == OPC_FALSE && \
								    (ap_flag == OPC_BOOLINT_ENABLED || cfp_ap_medium_control == OPC_FALSE)))) || \
								  fresp_to_send != WlanC_None || \
								  wlan_flags->polled == OPC_TRUE || \
								  wlan_flags->tx_beacon == OPC_TRUE || \
								  (wlan_flags->pcf_active == OPC_TRUE && ap_flag == OPC_BOOLINT_ENABLED)) && \
								 !roam_state_ptr->scan_mode)

/* When we have a frame to transmit, we move to transmit state if the	*/
/* medium was idle for at least a DIFS time, otherwise we go to defer	*/
/* state.																*/
#define MEDIUM_IS_IDLE			(((current_time - nav_duration + PRECISION_RECOVERY >= difs_time) && \
	             				  wlan_flags->receiver_busy == OPC_FALSE && \
								  (current_time - rcv_idle_time + PRECISION_RECOVERY >= difs_time) && \
								  wlan_flags->pcf_active == OPC_FALSE) || \
								 wlan_flags->forced_bk_end == OPC_TRUE)

/* Change state to Defer from Frm_End, if the input buffers are not empty or a frame needs	*/
/* to be retransmitted or the station has to respond to some frame.							*/		
#define FRAME_TO_TRANSMIT		(wlan_flags->data_frame_to_send == OPC_TRUE || fresp_to_send != WlanC_None || \
								 short_retry_count + long_retry_count > 0 || wlan_flags->tx_beacon == OPC_TRUE || \
								 wlan_flags->cw_required == OPC_TRUE)
	
/* After deferring for either collision avoidance or interframe gap		*/
/* the channel will be available for transmission. 						*/
#define DEFERENCE_OFF			(intrpt_type == OPC_INTRPT_SELF                                              && \
								 (intrpt_code == WlanC_Deference_Off ||intrpt_code == WlanC_Tslot_Off ||intrpt_code == WlanC_NAV_Reset_Time) && \
								 wlan_flags->receiver_busy == OPC_FALSE)

/* Issue a transmission complete stat once the packet has successfully 	*/
/* been transmitted from the source station								*/						 
#define TRANSMISSION_COMPLETE	(intrpt_type == OPC_INTRPT_STAT && \
								 op_intrpt_stat () == TRANSMITTER_BUSY_INSTAT)

/* Backoff is performed based on the value of the backoff flag.			*/
#define PERFORM_BACKOFF			(wlan_flags->backoff_flag == OPC_TRUE || wlan_flags->perform_cw == OPC_TRUE)

/* Need to start transmitting frame once the backoff (self intrpt) 		*/
/* completed															*/
#define BACKOFF_COMPLETED		(intrpt_type == OPC_INTRPT_SELF && intrpt_code == WlanC_Backoff_Elapsed && \
								 (wlan_flags->receiver_busy == OPC_FALSE || wlan_flags->forced_bk_end == OPC_TRUE))

/* Contention Window period, which follows a successful packet			*/
/* transmission, is completed.											*/
#define CW_COMPLETED			(intrpt_type == OPC_INTRPT_SELF && intrpt_code == WlanC_CW_Elapsed && \
								 (wlan_flags->receiver_busy == OPC_FALSE || wlan_flags->forced_bk_end == OPC_TRUE))

/* After transmission the station will wait for a frame response for    */
/* Data and Rts frames.												    */
#define WAIT_FOR_FRAME          (expected_frame_type != WlanC_None)

/* Need to retransmit frame if there is a frame timeout and the         */
/* required frame is not (successfully) received						*/
#define FRAME_TIMEOUT           ((intrpt_type == OPC_INTRPT_SELF && intrpt_code == WlanC_Frame_Timeout) || \
								 bad_cts_to_self_rcvd == OPC_TRUE)

/* If the frame is received appropriate response will be transmitted    */
/* provided the medium is considered to be idle						    */
#define FRAME_RCVD			    (intrpt_type == OPC_INTRPT_STRM && bad_packet_rcvd == OPC_FALSE && \
		 						 i_strm == LOW_LAYER_INPUT_STREAM)

/* Skip backoff if no backoff is needed								    */
#define TRANSMIT_FRAME			(!PERFORM_BACKOFF)

/* Expecting frame response	after data or Rts transmission			    */
#define EXPECTING_FRAME			(expected_frame_type != WlanC_None)

/* When the contention window period is over then we go to IDLE state	*/
/* if we don't have another frame to send at that moment. If we have	*/
/* one then we go to TRANSMIT state if we did not sense any activity	*/
/* on our receiver for a period that is greater than or equal to DIFS	*/
/* period; otherwise we go to DEFER state to defer and back-off before	*/
/* transmitting the new frame.											*/
#define	BACK_TO_IDLE			(CW_COMPLETED && wlan_flags->data_frame_to_send == OPC_FALSE && !roam_state_ptr->scan_mode)
	
#define SEND_NEW_FRAME_AFTER_CW	(CW_COMPLETED && wlan_flags->data_frame_to_send == OPC_TRUE && MEDIUM_IS_IDLE && !roam_state_ptr->scan_mode)

#define DEFER_AFTER_CW			(CW_COMPLETED && wlan_flags->data_frame_to_send == OPC_TRUE && !MEDIUM_IS_IDLE && !roam_state_ptr->scan_mode)

/* Macros that check the change in the busy status of the receiver.	   	*/
#define	RECEIVER_BUSY_HIGH		(intrpt_type == OPC_INTRPT_STAT && intrpt_code < TRANSMITTER_BUSY_INSTAT && \
								 op_stat_local_read (intrpt_code) > rx_power_threshold && !wlan_flags->collision)

#define	RECEIVER_BUSY_LOW		(((intrpt_type == OPC_INTRPT_STAT && intrpt_code < TRANSMITTER_BUSY_INSTAT) || 			\
								  (intrpt_type == OPC_INTRPT_STRM && i_strm != instrm_from_mac_if)			   ) && 	\
	                             !wlan_flags->receiver_busy)

#define	PERFORM_TRANSMIT		((BACKOFF_COMPLETED || SEND_NEW_FRAME_AFTER_CW))

#define	BACK_TO_DEFER			((FRAME_RCVD || DEFER_AFTER_CW || \
								 (wlan_flags->tx_beacon == OPC_TRUE && !wlan_flags->receiver_busy))) 							

/* Macro to evaluate whether the MAC is in a contention free period.	*/
#define	IN_CFP					(pcf_flag == OPC_BOOLINT_ENABLED && \
								 (cfp_ap_medium_control == OPC_TRUE || wlan_flags->pcf_active == OPC_TRUE))

/* After receiving a packet that indicates the end of the current CFP	*/
/* go to back to IDLE state if there is no packet to transmit in the CP.*/
#define	IDLE_AFTER_CFP			(intrpt_type == OPC_INTRPT_STRM && !FRAME_TO_TRANSMIT && !IN_CFP)

/* Macro to cancel the self interrupt for end of deference. It is		*/
/* called at the state transition from DEFER to IDLE.					*/
#define	CANCEL_DEF_EVENT		(op_ev_cancel (deference_evh))

#define FRM_END_TO_IDLE			(!FRAME_TO_TRANSMIT && !EXPECTING_FRAME && !IN_CFP)
	
#define	FRM_END_TO_DEFER		(!EXPECTING_FRAME && (FRAME_TO_TRANSMIT || IN_CFP))

/* Macros associated with the "SCAN" state. If the scan mode flag is	*/
/* set, the STA considers itself disconnected from its AP and starts	*/
/* scanning for a new AP-- only in DCF STAs.							*/
#define AP_DISCONNECTED 		(roam_state_ptr->scan_mode == OPC_TRUE)

#define AP_CONNECTED 			(roam_state_ptr->scan_mode == OPC_FALSE)

#define DATA_FRAME_TO_TX 		(wlan_flags->data_frame_to_send == OPC_TRUE)

#define SCAN_TIMEOUT			(intrpt_type == OPC_INTRPT_SELF && intrpt_code == WlanC_Scan_Timeout)	

#define SCAN_AFTER_CW			(CW_COMPLETED && AP_DISCONNECTED)


/** Function Prototypes **/
static void			wlan_mac_sv_init (void);
static void			wlan_transceiver_channel_init (void);
static void			wlan_rxgroup_reduce (void);
static void			wlan_higher_layer_data_arrival (void);
static void			wlan_hl_packet_drop (Packet* hld_pkptr, OpT_Packet_Size data_size);
static void			wlan_hlpk_enqueue (Packet* hld_pkptr, int dest_addr, Boolean polling);
static void			wlan_frame_transmit (void);
static double		wlan_non_11b_plcp_overhead_compute (OpT_Packet_Size mpdu_length, double data_rate);
static double		wlan_plcp_overhead_ofdm_compute (OpT_Packet_Size mpdu_length, double data_rate);
static Boolean		wlan_dest_is_11g_enabled (int dest_mac_addr);
static void 		wlan_prepare_frame_to_send (WlanT_Mac_Frame_Type frame_type);
static double		wlan_ctrl_response_drate_determine (double rcvd_data_rate);
static void			wlan_slot_time_set (double new_slot_time);
static void			wlan_frame_tx_phy_info_set (Packet* frame_ptr, double tx_data_rate);
static void			wlan_interrupts_process (void);
static void			wlan_physical_layer_data_arrival (void);

⌨️ 快捷键说明

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