/* Process model C form file: aodv_wlan_mac.pr.c */
/* Portions of this file copyright 1992-2003 by OPNET Technologies, Inc. */
/* This variable carries the header into the object file */
const char aodv_wlan_mac_pr_c [] = "MIL_3_Tfile_Hdr_ 100A 30A modeler 7 43C4D6AE 43C4D6AE 1 wind Administrator 0 0 none none 0 0 none 0 0 0 0 0 0 0 0 8f3 1 ";
#include <string.h>
/* OPNET system definitions */
#include <opnet.h>
/* Header Block */
#include <math.h>
#include "oms_pr.h"
#include "oms_tan.h"
#include "oms_bgutil.h"
/* Definitions to all protocol specific parameters*/
#include "wlan_support.h"
/* Station address assignment definitions. */
#include "oms_auto_addr_support.h"
#include "oms_dist_support.h"
//$$$$$$$$$$$$$$$$$$ DSR $$$$$$$$$$$$$$$$$$$$$$$$
// define packet Types
#define DATA_PACKET_TYPE 5
#define REQUEST_PACKET_TYPE 7
#define REPLY_PACKET_TYPE 11
#define ERROR_PACKET_TYPE 13
// remote intrpt or self intrpt codes definition
#define ACK_CODE 10000
#define ERROR_CODE 20000
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#define WLANC_MSDU_HEADER_SIZE 272
#define WLAN_AIR_PROPAGATION_TIME 512
/* incoming statistics and stream wires */
#define TRANSMITTER_INSTAT 2
#define RECEIVER_BUSY_INSTAT 1
#define RECEIVER_COLL_INSTAT 0
#define LOW_LAYER_INPUT_STREAM_CH4 3
#define LOW_LAYER_OUT_STREAM_CH1 0
#define LOW_LAYER_OUT_STREAM_CH2 1
#define LOW_LAYER_OUT_STREAM_CH3 2
#define LOW_LAYER_OUT_STREAM_CH4 3
/* Flags to load different variables based on attribute settings. */
#define WLAN_AP 1
#define WLAN_STA 0
//$$$$$$$$$$$$$$$$$$ DSR $$$$$$$$$$$$$$$$$$$$$$$$
Stathandle stat_mac_failed_data;
int mac_failed_data;
Stathandle stat_mac_failed_reply;
int mac_failed_reply;
Stathandle stat_mac_failed_error;
int mac_failed_error=0;
Stathandle stat_mac_total_failed;
int mac_total_failed=0;
Stathandle stat_mac_retry_rts;
int mac_retry_rts;
Stathandle stat_mac_retry_data;
int mac_retry_data;
Stathandle stat_mac_retry_reply;
int mac_retry_reply;
Stathandle stat_mac_retry_error;
int mac_retry_error;
Stathandle stat_mac_total_retry;
int mac_total_retry;
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
/* 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 /* Bakcoff done after successful frame transmission */
} WlanT_Mac_Intrpt_Code;
/* Define codes for data and managment frames use in DCF */
/* The code defined is consistent with IEEE 802.11 format */
/* There are 6 bits used to define the code and in the following */
/* enumeration the first 6 bits are used in the type field of the frame.*/
//typedef enum WlanT_Mac_Frame_Type
//{
//WlanC_Rts = 0x6C, /* Rts code set into the Rts control frame */
//WlanC_Cts = 0x70, /* Cts code set into the Cts control frame */
//WlanC_Ack = 0x74, /* Ack code set into the Ack control frame */
//WlanC_Data = 0x80, /* Data code set into the Data frame */
//WlanC_None = 0x00 /* None type */
//} WlanT_Mac_Frame_Type;
/* Defining codes for the physical layer characteristics type */
typedef enum WlanT_Phy_Char_Code
{
WlanC_Frequency_Hopping,
WlanC_Direct_Sequence,
WlanC_Infra_Red
} WlanT_Phy_Char_Code;
/* Define a structure to maintain data fragments received by each */
/* station for the purpose of reassembly (or defragmentation) */
typedef struct WlanT_Mac_Defragmentation_Buffer_Entry
{
int tx_station_address ;/* Store the station address of transmitting station */
double time_rcvd ;/* Store time the last fragment for this frame was received */
Sbhandle reassembly_buffer_ptr ;/* Store data fragments for a particular packet */
} WlanT_Mac_Defragmentation_Buffer_Entry;
/* Define a structure to maintain a copy of each unique data frame */
/* received by the station. This is done so that the station can */
/* discard any additional copies of the frame received by it. */
typedef struct WlanT_Mac_Duplicate_Buffer_Entry
{
int tx_station_address; /* store the station address of transmitting station */
int sequence_id ; /* rcvd packet sequence id */
int fragment_number ; /* rcvd packet fragment number */
} WlanT_Mac_Duplicate_Buffer_Entry;
/* This structure contains all the flags used in this process model to determine */
/* various conditions as mentioned in the comments for each flag */
typedef struct WlanT_Mac_Flags
{
Boolean data_frame_to_send; /* Flag to check when station needs to transmit. */
Boolean backoff_flag; /* Backoff flag is set when either the collision is */
/* inferred or the channel switched from busy to idle */
Boolean rts_sent; /* Flag to indicate that wether the Rts for this */
/* particular data frame is sent */
Boolean rcvd_bad_packet; /* Flag to indicate that the received packet is bad */
Boolean receiver_busy; /* Set this flag if receiver busy stat is enabled */
Boolean transmitter_busy; /* Set this flag if we are transmitting something. */
Boolean wait_eifs_dur; /* Set this flag if the station needs to wait for eifs */
/* duration. */
Boolean gateway_flag; /* Set this flag if the station is a gateway. */
Boolean bridge_flag; /* Set this flag if the station is a bridge */
Boolean immediate_xmt; /* Set this flag if the new frame can be transmitted */
/* without deferring. */
Boolean cw_required; /* Indicates the arrival of an ACK making the */
/* transmission successful, which requires a CW period. */
Boolean nav_updated; /* Indicates a new NAV value since the last time when */
/* self interrupt is scheduled for the end of deference.*/
} WlanT_Mac_Flags;
/* This structure contains the destination address to which the received */
/* data packet needs to be sent and the contents of the recieved packet */
/* from the higher layer. */
typedef struct WlanT_Hld_List_Elem
{
double time_rcvd; /* Time packet is received by the higher layer */
int destination_address; /* Station to which this packet needs to be sent*/
Packet* pkptr; /* store packet contents */
} WlanT_Hld_List_Elem;
/** Macros Definition **/
/** 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 respons