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

📄 transmit exit execs

📁 opnet无线网络编程
💻
字号:
//printf("\n\n*************************************************\n");
//printf("Entering Transmit EXIT EXEC state for node <%d> \n", my_address);
//printf("*****************************************************\n\n");

// wsn  Call the interrupt processing routine for each interrupt.		*/
wlan_interrupts_process ();


/* Lock the mutex that serializes accessing the roaming		*/
/* related information of this MAC. 						*/


op_prg_mt_mutex_lock (roam_state_ptr->roam_info_mutex, 0);

//Checking op_intrpt_type\n\n");
// mib start - this deference interrupt is NOT supposed to happen
//if ((intrpt_type == OPC_INTRPT_SELF)  && ( (intrpt_code == WlanC_Deference_Off) )) 
//	printf("Interrupt type is self interrupt WlanC_Deference_Off for node <%d>!!!!!\n", my_address);

//if ((intrpt_type == OPC_INTRPT_SELF)  && ( (intrpt_code == WlanC_Sleep_Schedule) )) 
//	printf("Interrupt type is self interrupt WlanC_Sleep_Schedule for node <%d>\n", my_address);

//if ((intrpt_type == OPC_INTRPT_SELF)  && ( (intrpt_code == WlanC_Wake_Schedule) )) 
//	printf("Interrupt type is self interrupt WlanC_Wake_Schedule for node <%d>\n", my_address);

//if ((intrpt_type == OPC_INTRPT_SELF)  && ( (intrpt_code == WlanC_Update_Period) )) 
//	printf("Interrupt type is self interrupt WlanC_Update_Period for node <%d>\n", my_address);

/* Check the interrupt type.								*/
//if (op_intrpt_type () == OPC_INTRPT_STAT)
if (intrpt_type == OPC_INTRPT_STAT)
	{

	/* If the packet is received while the the station is	*/ 
	/* transmitting then mark the received packet as bad.	*/

	//intrpt_code = (WlanT_Mac_Intrpt_Code) op_intrpt_stat ();
	if (intrpt_code < TRANSMITTER_BUSY_INSTAT && op_stat_local_read (intrpt_code) > rx_power_threshold && !wlan_flags->receiver_busy)
		{

		wlan_flags->rcvd_bad_packet = OPC_TRUE;

		/* If we are transmitting a CTS-to-self, then mark	*/
		/* it as bad, too.									*/
		if (last_frametx_type == WlanC_Cts && expected_frame_type == WlanC_Cts)
			wlan_flags->rcvd_bad_cts = OPC_TRUE;
		}
	
	/* If we completed the transmission then reset the		*/
	/* transmitter flag.									*/
	else if (intrpt_code == TRANSMITTER_BUSY_INSTAT)
		{

		wlan_flags->transmitter_busy = OPC_FALSE;
		
		
		
		/* MIB Adaptive Timeout GlobalNotification Mechanism*/
		#ifndef OPD_NO_DEBUG
			printf("Node <%d> finished transmitting a packet at time %e \n", my_address, op_sim_time());
		#endif

		
		/*  The other nodes in network will not normally know the channel is busy until */
		/* after the transmission time expires.  This section provides immediate notification */
	
		op_prg_mt_mutex_lock (wsn_channel_busy_mutex, OPC_MT_MUTEX_LOCK_WRITER);
			wsn_number_TX_nodes_global--;
			#ifndef OPD_NO_DEBUG
			printf("Number transmitting nodes decremented to %d \n", wsn_number_TX_nodes_global);
			#endif
			if (wsn_number_TX_nodes_global == 0) /* only one node transmitting */
				{
				    wsn_channel_busy_global = OPC_FALSE;
					#ifndef OPD_NO_DEBUG
						printf("Turned off channel busy flag\n");
					#endif
				}
			else 
				{
					#ifndef OPD_NO_DEBUG
						printf("Did not turn off channel busy flag\n");
					#endif
				}
						
	
		/* Unlock the mutex that we locked at the beginning.					*/
		op_prg_mt_mutex_unlock (wsn_channel_busy_mutex);
		
				
		
		/* Also update the receiver idle time, since with	*/
		/* the end of our transmission, the medium may		*/
		/* become idle again.								*/
		rcv_idle_time = op_sim_time ();
		}
	}

// else if ((op_intrpt_type () == OPC_INTRPT_STRM) && (op_intrpt_strm () != instrm_from_mac_if))
else if ((intrpt_type == OPC_INTRPT_STRM) && (op_intrpt_strm () != instrm_from_mac_if))
	{
	/* While transmitting, we received a packet from		*/
	/* physical layer. Mark the packet as bad.				*/
	wlan_flags->rcvd_bad_packet = OPC_TRUE;

	/* If we are transmitting a CTS-to-self, then mark it	*/
	/* as bad, too.											*/
	if (last_frametx_type == WlanC_Cts && expected_frame_type == WlanC_Cts)
		wlan_flags->rcvd_bad_cts = OPC_TRUE;
	}


// Updates energy on final transition out of BACKOFF State
if (TRANSMISSION_COMPLETE)
	{
	Update_Energy();
	#ifndef OPD_NO_DEBUG
		if ((op_sim_time() > wsn_test_time) && (my_address == wsn_test_address || my_address == wsn_test_address_2) )
			printf("Node <%d> is exiting TRANSMIT and calculating E before FRM_END\n", my_address);
	#endif
	}

//else printf("Transmission not complete");

⌨️ 快捷键说明

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