📄 wlan_txdel.ps.c
字号:
/* wlan_txdel.ps.c */ /* Modified transmission delay model for IEEE 802.11. *//* It retrieves the transmission data rate from the *//* packet itself instead of the transmitter channel for *//* the computation of the transmission delay. This is *//* needed because the transmissions of all supported *//* WLAN (802.11, 11a, 11b and 11g) data rates use the *//* same tranceiver channel. Hence, the data rate *//* setting of the transmitter channel doesn't always *//* indicate the actual transmission data rate. *//****************************************//* Copyright (c) 1993-2007 *//* by OPNET Technologies, Inc. *//* (A Delaware Corporation) *//* 7255 Woodmont Av., Suite 250 *//* Bethesda, MD 20814, U.S.A. *//* All Rights Reserved. *//****************************************/#include "opnet.h"#include <oms_tan.h>#include <oms_rr.h>#include <oms_pipeline.h> #include <string.h> static OmsT_Bgutil_Channel_State *wlan_txdel_chan_state_create (Objid channel_objid);#if defined (__cplusplus)extern "C"#endifvoidwlan_txdel_mt (OP_SIM_CONTEXT_ARG_OPT_COMMA Packet * pkptr) { OpT_Packet_Size pklen; double tx_drate, tx_delay; Objid channel_objid; Boolean is_congestion_area = OPC_FALSE; char congestion_area_str [3 * OMSC_HNAME_MAX_LEN]; OmsT_Bgutil_Channel_State* chan_state_ptr = OPC_NIL; /** Compute the transmission delay associated with the **/ /** transmission of a packet over a radio link. **/ FIN_MT (wlan_txdel (pkptr)); /* Obtain the transmission rate from the packet. */ op_pk_nfd_get_dbl (pkptr, "Tx Data Rate", &tx_drate); /* Obtain length of packet. */ pklen = op_pk_total_size_get (pkptr); /* Compute time required to complete transmission of */ /* packet. */ tx_delay = pklen / tx_drate; /* Place transmission delay result in packet's */ /* reserved transmission data attribute. */ op_td_set_dbl (pkptr, OPC_TDA_RA_TX_DELAY, tx_delay); /* Also update the transmitter's data rate TDA with the */ /* information retrieved from the packet to be used in */ /* the following pipeline stages. */ op_td_set_dbl (pkptr, OPC_TDA_RA_TX_DRATE, tx_drate); /* Check whether congestion area monitoring is enabled. */ if (CONGESTION_AREAS_ENABLED) { int num_flows = 0; double utilization = 0.0; /* Obtain object id of transmitter channel forwarding transmission. */ channel_objid = op_td_get_int (pkptr, OPC_TDA_RA_TX_CH_OBJID); /* Create a channel state to store the state information. */ if ((chan_state_ptr = (OmsT_Bgutil_Channel_State *) op_ima_obj_state_get (channel_objid)) == OPC_NIL) { chan_state_ptr = wlan_txdel_chan_state_create (channel_objid); } /* If this is a tracer packet update the congestion area info. */ if (op_pk_encap_flag_is_set (pkptr, OMSC_BGUTIL_ENCAP_FLAG_INDEX)) { is_congestion_area = oms_bgutil_state_info_update (pkptr, tx_drate, chan_state_ptr->port_name_ptr, &chan_state_ptr->congestion_area, &num_flows, &utilization, &chan_state_ptr->routed_bgutil_state_ptr); if (is_congestion_area) { /* Add congestion info into the route record string. */ sprintf (congestion_area_str, "%s(CONGESTION <util=%.2f num_flows=%d>),None", chan_state_ptr->node_name_ptr, 100.0 * utilization, num_flows); } } } /* Dump routes for only packets that have requested for */ /* route information by setting the correct flag. */ if (op_pk_encap_flag_is_set (pkptr, OMSC_RR_ENCAP_FLAG_INDEX)) { /* Obtain the channel state if NIL. */ if (chan_state_ptr == OPC_NIL) { /* Obtain object id of transmitter channel forwarding transmission. */ channel_objid = op_td_get_int (pkptr, OPC_TDA_RA_TX_CH_OBJID); /* Get the channel state. */ if ((chan_state_ptr = (OmsT_Bgutil_Channel_State*) op_ima_obj_state_get (channel_objid)) == OPC_NIL) { /* Create a new channel state. */ chan_state_ptr = wlan_txdel_chan_state_create (channel_objid); } } /* Update information about traversed node/links if */ /* this is a bgutil tracer packet. */ if (is_congestion_area) { /* Include the congestion infromation. */ oms_rr_info_update (pkptr, congestion_area_str); } else { oms_rr_info_update (pkptr, chan_state_ptr->node_link_name_ptr); } } FOUT }static OmsT_Bgutil_Channel_State *wlan_txdel_chan_state_create (Objid channel_objid) { Objid port_objid; char tmp_name [OMSC_HNAME_MAX_LEN] = "\0"; char node_link_name [2 * OMSC_HNAME_MAX_LEN] = "\0"; OmsT_Bgutil_Channel_State* chan_state_ptr = OPC_NIL; /* Creates and populates the tx channel state info. */ FIN (wlan_txdel_chan_state_create (Objid channel_objid)); /* Channel state information doesn't exist. Lock */ /* the global mutex before continuing. */ op_prg_mt_global_lock (); /* Check again since another thread may have */ /* already set up the state information. */ if ((chan_state_ptr = (OmsT_Bgutil_Channel_State*) op_ima_obj_state_get (channel_objid)) == OPC_NIL) { /* Obtain a new channel state structure. This */ /* structure will be associated with the channel. */ chan_state_ptr = oms_bgutil_channel_state_create (); /* Determine the port objid. */ port_objid = op_topo_parent (op_topo_parent (channel_objid)); /* Determine the name of the sending port and store */ /* it for future use. */ oms_tan_hname_get (port_objid, tmp_name); /* Allocate memory and store the port name. */ chan_state_ptr->port_name_ptr = (char *) op_prg_mem_alloc (sizeof (char) * (strlen (tmp_name) + 1)); strcpy (chan_state_ptr->port_name_ptr, tmp_name); /* Obtain the node name. */ oms_tan_hname_get (op_topo_parent (port_objid), tmp_name); /* Allocate memory and store the node name. */ chan_state_ptr->node_name_ptr = (char *) op_prg_mem_alloc (sizeof (char) * (strlen (tmp_name) + 1)); strcpy (chan_state_ptr->node_name_ptr, tmp_name); /* Create the node_link_str string. */ strcpy (node_link_name, tmp_name); strcat (node_link_name, ",None"); /* Allocate memory and store the node_link_name_str. */ chan_state_ptr->node_link_name_ptr = (char *) op_prg_mem_alloc (sizeof (char) * (strlen (node_link_name) + 1)); strcpy (chan_state_ptr->node_link_name_ptr, node_link_name); /* Associate the state with the channel; the next call to op_ima_obj_state_get() for */ /* this channel will now return the address of this channel state. */ op_ima_obj_state_set (channel_objid, chan_state_ptr); } /* Unlock the global mutex. */ op_prg_mt_global_unlock (); /* Return the channel state */ FRET (chan_state_ptr); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -