📄 wlan_wsn_mac_interface_31jan06.pr.c
字号:
/* Process model C form file: wlan_wsn_mac_interface_31Jan06.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_wsn_mac_interface_31Jan06_pr_c [] = "MIL_3_Tfile_Hdr_ 140A 30A modeler 7 476CE12B 476CE12B 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. *****/
/* Address assignment definitions. */
#include "oms_auto_addr_support.h"
/* Topology analysis-related definitions. */
#include "oms_tan.h"
/* Process registry-related definitions. */
#include "oms_pr.h"
/***** Transition Macros ******/
#define MAC_LAYER_PKT_ARVL (intrpt_type == OPC_INTRPT_STRM && intrpt_strm == instrm_from_mac)
#define APPL_LAYER_PKT_ARVL (intrpt_type == OPC_INTRPT_STRM && intrpt_strm != instrm_from_mac)
#define MAC_BROADCAST -1
/***** Functional declaration ******/
static void wlan_mac_higher_layer_intf_sv_init ();
static void wlan_mac_higher_layer_register_as_arp ();
/**** Global Variable * accessed as external in teh lower process****/
int my_global;
/* End of Header Block */
#if !defined (VOSD_NO_FIN)
#undef BIN
#undef BOUT
#define BIN FIN_LOCAL_FIELD(_op_last_line_passed) = __LINE__ - _op_block_origin;
#define BOUT BIN
#define BINIT FIN_LOCAL_FIELD(_op_last_line_passed) = 0; _op_block_origin = __LINE__;
#else
#define BINIT
#endif /* #if !defined (VOSD_NO_FIN) */
/* State variable definitions */
typedef struct
{
/* Internal state tracking for FSM */
FSM_SYS_STATE
/* State Variables */
Objid my_objid ; /* Object identifier of the surrounding module. */
Objid my_node_objid ; /* Object identifier of the surrounding node. */
int instrm_from_mac ; /* Stream index of the packet stream coming from MAC. */
int outstrm_to_mac ; /* Stream index of the packet stream going to MAC. */
int destination_address ; /* Destination MAC address to which data should be sent. */
/* When set to "Random", the packet can be sent to any */
/* destination except the surrounding node. */
OmsT_Aa_Address_Handle oms_aa_handle ; /* Auto-address assignment handle. Used while */
/* auto-address and destination address selection. */
int mac_address ; /* Element address of the associated MAC. */
Ici* wlan_mac_req_iciptr ; /* Interface control information needed to indicate */
/* to the MAC of the destination to which packet */
/* needs to be sent. */
} wlan_wsn_mac_interface_31Jan06_state;
#define my_objid op_sv_ptr->my_objid
#define my_node_objid op_sv_ptr->my_node_objid
#define instrm_from_mac op_sv_ptr->instrm_from_mac
#define outstrm_to_mac op_sv_ptr->outstrm_to_mac
#define destination_address op_sv_ptr->destination_address
#define oms_aa_handle op_sv_ptr->oms_aa_handle
#define mac_address op_sv_ptr->mac_address
#define wlan_mac_req_iciptr op_sv_ptr->wlan_mac_req_iciptr
/* These macro definitions will define a local variable called */
/* "op_sv_ptr" in each function containing a FIN statement. */
/* This variable points to the state variable data structure, */
/* and can be used from a C debugger to display their values. */
#undef FIN_PREAMBLE_DEC
#undef FIN_PREAMBLE_CODE
#define FIN_PREAMBLE_DEC wlan_wsn_mac_interface_31Jan06_state *op_sv_ptr;
#define FIN_PREAMBLE_CODE \
op_sv_ptr = ((wlan_wsn_mac_interface_31Jan06_state *)(OP_SIM_CONTEXT_PTR->_op_mod_state_ptr));
/* Function Block */
#if !defined (VOSD_NO_FIN)
enum { _op_block_origin = __LINE__ + 2};
#endif
static void
wlan_mac_higher_layer_intf_sv_init ()
{
int type_of_service;
/** Initializes all state variables used in this **/
/** process model. **/
FIN (wlan_mac_higher_layer_intf_sv_init ());
/* Object identifier for the surrounding module and node. */
my_objid = op_id_self ();
my_node_objid = op_topo_parent (my_objid);
/* Stream indices to and from the WLAN MAC process. */
/* these will be set in the "exit execs" of "init". */
outstrm_to_mac = OPC_INT_UNDEF;
instrm_from_mac = OPC_INT_UNDEF;
/* Determine the destination to which packet should */
/* be sent,and the prioritization to be provided to */
/* the transmitted packet. */
op_ima_obj_attr_get (my_objid, "Destination Address", &destination_address);
op_ima_obj_attr_get (my_objid, "Type of Service", &type_of_service);
/* Some interface control information is needed to */
/* indicate to the MAC of the destination to which */
/* a given packet needs to be sent. Create it. */
wlan_mac_req_iciptr = op_ici_create ("wlan_mac_request");
op_ici_attr_set (wlan_mac_req_iciptr, "type_of_service", type_of_service);
op_ici_attr_set (wlan_mac_req_iciptr, "protocol_type", 0x800);
FOUT;
}
static void
wlan_mac_higher_layer_register_as_arp ()
{
char proc_model_name [128];
OmsT_Pr_Handle own_process_record_handle;
Prohandle own_prohandle;
/** Register this process in the model-wide process registry. **/
FIN (wlan_mac_higher_layer_register_as_arp ());
/* Obtain the process model name and process handle. */
op_ima_obj_attr_get (my_objid, "process model", proc_model_name);
own_prohandle = op_pro_self ();
/* Register this process in the model-wide process registry */
own_process_record_handle = (OmsT_Pr_Handle) oms_pr_process_register (
my_node_objid, my_objid, own_prohandle, proc_model_name);
/* Register this protocol attribute and the element address */
/* of this process into the model-wide registry. */
oms_pr_attr_set (own_process_record_handle,
"protocol", OMSC_PR_STRING, "arp",
OPC_NIL);
FOUT;
}
/* End of Function Block */
/* Undefine optional tracing in FIN/FOUT/FRET */
/* The FSM has its own tracing code and the other */
/* functions should not have any tracing. */
#undef FIN_TRACING
#define FIN_TRACING
#undef FOUTRET_TRACING
#define FOUTRET_TRACING
#if defined (__cplusplus)
extern "C" {
#endif
void wlan_wsn_mac_interface_31Jan06 (OP_SIM_CONTEXT_ARG_OPT);
VosT_Obtype _op_wlan_wsn_mac_interface_31Jan06_init (int * init_block_ptr);
void _op_wlan_wsn_mac_interface_31Jan06_diag (OP_SIM_CONTEXT_ARG_OPT);
void _op_wlan_wsn_mac_interface_31Jan06_terminate (OP_SIM_CONTEXT_ARG_OPT);
VosT_Address _op_wlan_wsn_mac_interface_31Jan06_alloc (VosT_Obtype, int);
void _op_wlan_wsn_mac_interface_31Jan06_svar (void *, const char *, void **);
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif
/* Process model interrupt handling procedure */
void
wlan_wsn_mac_interface_31Jan06 (OP_SIM_CONTEXT_ARG_OPT)
{
#if !defined (VOSD_NO_FIN)
int _op_block_origin = 0;
#endif
FIN_MT (wlan_wsn_mac_interface_31Jan06 ());
{
/* Temporary Variables */
List* proc_record_handle_list_ptr;
int record_handle_list_size;
OmsT_Pr_Handle process_record_handle;
Objid mac_module_objid;
Boolean dest_addr_okay = OPC_FALSE;
double ne_address = OPC_DBL_UNDEF;
int curr_dest_addr = OMSC_AA_AUTO_ASSIGN;
Packet* pkptr;
int intrpt_type = OPC_INT_UNDEF;
int intrpt_strm = OPC_INT_UNDEF;
int i;
OmsT_Aa_Address_Info * ith_address_info_ptr;
/* End of Temporary Variables */
FSM_ENTER ("wlan_wsn_mac_interface_31Jan06")
FSM_BLOCK_SWITCH
{
/*---------------------------------------------------------*/
/** state (init) enter executives **/
FSM_STATE_ENTER_UNFORCED_NOLABEL (0, "init", "wlan_wsn_mac_interface_31Jan06 [init enter execs]")
FSM_PROFILE_SECTION_IN ("wlan_wsn_mac_interface_31Jan06 [init enter execs]", state0_enter_exec)
{
/* Initialize the state variables used by this model. */
wlan_mac_higher_layer_intf_sv_init ();
/* Register this process as "arp" so that lower layer */
/* MAC process can connect to it. */
wlan_mac_higher_layer_register_as_arp ();
/* Schedule a self interrupt to wait for lower layer */
/* wlan MAC process to initialize and register itself in */
/* the model-wide process registry. */
op_intrpt_schedule_self (op_sim_time (), 0);
}
FSM_PROFILE_SECTION_OUT (state0_enter_exec)
/** blocking after enter executives of unforced state. **/
FSM_EXIT (1,"wlan_wsn_mac_interface_31Jan06")
/** state (init) exit executives **/
FSM_STATE_EXIT_UNFORCED (0, "init", "wlan_wsn_mac_interface_31Jan06 [init exit execs]")
FSM_PROFILE_SECTION_IN ("wlan_wsn_mac_interface_31Jan06 [init exit execs]", state0_exit_exec)
{
/* Schedule a self interrupt to wait for lower layer */
/* wlan MAC process to initialize and register itself in*/
/* the model-wide process registry. */
op_intrpt_schedule_self (op_sim_time (), 0);
}
FSM_PROFILE_SECTION_OUT (state0_exit_exec)
/** state (init) transition processing **/
FSM_TRANSIT_FORCE (5, state5_enter_exec, ;, "default", "", "init", "init2", "tr_24", "wlan_wsn_mac_interface_31Jan06 [init -> init2 : default / ]")
/*---------------------------------------------------------*/
/** state (idle) enter executives **/
FSM_STATE_ENTER_UNFORCED (1, "idle", state1_enter_exec, "wlan_wsn_mac_interface_31Jan06 [idle enter execs]")
FSM_PROFILE_SECTION_IN ("wlan_wsn_mac_interface_31Jan06 [idle enter execs]", state1_enter_exec)
{
printf("Interface node %d has my_global = %d/n", mac_address, my_global);
}
FSM_PROFILE_SECTION_OUT (state1_enter_exec)
/** blocking after enter executives of unforced state. **/
FSM_EXIT (3,"wlan_wsn_mac_interface_31Jan06")
/** state (idle) exit executives **/
FSM_STATE_EXIT_UNFORCED (1, "idle", "wlan_wsn_mac_interface_31Jan06 [idle exit execs]")
FSM_PROFILE_SECTION_IN ("wlan_wsn_mac_interface_31Jan06 [idle exit execs]", state1_exit_exec)
{
/* The only interrupt expected in this state is a */
/* stream interrupt. It can be either from the MAC */
/* layer for a packet destined for this node or */
/* from the application layer for a packet destined */
/* for some other node. */
intrpt_type = op_intrpt_type ();
intrpt_strm = op_intrpt_strm ();
pkptr = op_pk_get (intrpt_strm);
}
FSM_PROFILE_SECTION_OUT (state1_exit_exec)
/** state (idle) transition processing **/
FSM_PROFILE_SECTION_IN ("wlan_wsn_mac_interface_31Jan06 [idle trans conditions]", state1_trans_conds)
FSM_INIT_COND (APPL_LAYER_PKT_ARVL)
FSM_TEST_COND (MAC_LAYER_PKT_ARVL)
FSM_TEST_LOGIC ("idle")
FSM_PROFILE_SECTION_OUT (state1_trans_conds)
FSM_TRANSIT_SWITCH
{
FSM_CASE_TRANSIT (0, 2, state2_enter_exec, ;, "APPL_LAYER_PKT_ARVL", "", "idle", "appl layer arrival", "tr_14", "wlan_wsn_mac_interface_31Jan06 [idle -> appl layer arrival : APPL_LAYER_PKT_ARVL / ]")
FSM_CASE_TRANSIT (1, 3, state3_enter_exec, ;, "MAC_LAYER_PKT_ARVL", "", "idle", "mac layer arrival", "tr_17", "wlan_wsn_mac_interface_31Jan06 [idle -> mac layer arrival : MAC_LAYER_PKT_ARVL / ]")
}
/*---------------------------------------------------------*/
/** state (appl layer arrival) enter executives **/
FSM_STATE_ENTER_FORCED (2, "appl layer arrival", state2_enter_exec, "wlan_wsn_mac_interface_31Jan06 [appl layer arrival enter execs]")
FSM_PROFILE_SECTION_IN ("wlan_wsn_mac_interface_31Jan06 [appl layer arrival enter execs]", state2_enter_exec)
{
/* A packet has arrived from the application layer. */
/* If the destination address specified is "Random" */
/* then generate a destination and forward the appl */
/* packet to the MAC layer with that information. */
if (destination_address == OMSC_AA_AUTO_ASSIGN)
{
/* Initialize current destination address to the Auto */
/* Assign value */
curr_dest_addr = destination_address;
/* Call function to generate a random destination */
/* from the pool of available addresses. */
oms_aa_dest_addr_get (oms_aa_handle, &curr_dest_addr);
/* Keep on generating the random addresses until source */
/* address is not same as current address. */
while (curr_dest_addr == mac_address)
{
/* Initialize current destination address to the Auto */
/* Assign value */
curr_dest_addr = destination_address;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -