📄 wlan_mac_tmac_nav_rpm_31jan06_ver2.function block
字号:
/* Create an array that will hold the list of object IDs of the */
/* receiver channels that are kept in the receiver group. */
if (new_rxch_count != 0)
{
new_rxch_objid_arr = (Objid *) op_prg_mem_alloc (new_rxch_count * sizeof (Objid));
/* Copy the object IDs from temporary list to the final */
/* list. */
op_prg_mem_copy (temp_rxch_objid_arr, new_rxch_objid_arr, new_rxch_count * sizeof (Objid));
}
/* Set the new list as the receiver group of our transmitter */
/* channel. */
op_radio_txch_rxgroup_set (txch_objid, new_rxch_count, new_rxch_objid_arr);
/* Destroy the object ID arrays used in this function. */
op_prg_mem_free (old_rxch_objid_arr);
op_prg_mem_free (temp_rxch_objid_arr);
op_prg_mem_free (new_rxch_objid_arr);
FOUT;
}
static void
wlan_higher_layer_data_arrival (void)
{
Packet* hld_pkptr;
OpT_Packet_Size data_size, frag_size;
int dest_addr;
Ici* ici_ptr;
Boolean polling;
/** Queue the packet as it arrives from higher layer. **/
/** Also, store the destination address of the packet **/
/** in the queue and the arrival time. **/
FIN (wlan_higher_layer_data_arrival (void));
/* Get packet from the incoming stream from higher layer and */
/* obtain the packet size */
hld_pkptr = op_pk_get (op_intrpt_strm ());
/* If we are in a bridge/switch node, then we don't accept any */
/* higher layer packet unless we are AP enabled. */
if ((wlan_flags->bridge_flag == OPC_TRUE) && (ap_flag == OPC_BOOLINT_DISABLED))
{
op_pk_destroy (hld_pkptr);
FOUT;
}
/* Get the size of the packet arrived from higher layer. */
data_size = op_pk_total_size_get (hld_pkptr);
/* Read ICI parameters at the stream interrupt. */
ici_ptr = op_intrpt_ici ();
/* Retrieve destination address from the ici set by the interface layer. */
if (ici_ptr == OPC_NIL || op_ici_attr_get (ici_ptr, "dest_addr", &dest_addr) == OPC_COMPCODE_FAILURE)
{
/* Generate error message. */
wlan_mac_error ("Destination address is not valid.", OPC_NIL, OPC_NIL);
}
/* The queueing of the packets in the AP is based on the node type */
/* (DCF/PCF) of the destination. If the destination node is a PCF */
/* node, then the packets are queued into the cfpd_list_ptr and */
/* transmitted only during the PCF period. Likewise packets for a */
/* DCF destination node will be inserted into the hld_list_ptr and */
/* transmitted only during DCF. Packets with broadcast address are */
/* transmitted during DCF. */
// mib took out list_member_find function
// mib polling = wlan_poll_list_member_find (dest_addr);
polling = 0; // mib initialized to prevent compile warning
/* If fragmentation is enabled and packet size is greater than the threshold */
/* then MSDU length will not be more than fragmentation threshold, hence */
/* the packet will be fragmented into the size less than or equal to fragmentation */
/* threshold. */
if ((data_size > frag_threshold * 8) && (frag_threshold != -1))
frag_size = frag_threshold * 8;
else
frag_size = data_size;
/* Destroy packet if it is more than max msdu length or its */
/* size zero. Also, if the size of the higher layer queue */
/* will exceed its maximum after the insertion of this packet, */
/* then discard the arrived packet. */
/* The higher layer is responsible for the retransmission of */
/* this packet. */
if ((data_size > WLANC_MAXMSDU_LENGTH && accept_large_packets == OPC_BOOLINT_DISABLED) ||
frag_size > WLANC_MAXMSDU_LENGTH || data_size == 0 || total_hlpk_size + data_size > hld_max_size)
{
/* Drop the higher layer packet. */
wlan_hl_packet_drop (hld_pkptr, data_size);
FOUT;
}
/* Check for an AP bridge that whether the destined stations exist in the BSS or not */
/* if not then no need to broadcast the packet. */
if (wlan_flags->bridge_flag == OPC_TRUE && ap_flag == OPC_BOOLINT_ENABLED)
{
/* If the destination station doesn't exist in the BSS then */
/* no need to broadcast the packet. Use dynamic station */
/* mapping to determine if this station is currently part */
/* of this BSS. */
if (!wlan_sta_info_get (dest_addr, OPC_TRUE) && (dest_addr >= 0))
{
op_pk_destroy (hld_pkptr);
FOUT;
}
}
/* Stamp the packet with the current time. This information will remain */
/* unchanged even if the packet is copied for retransmissions, and */
/* eventually it will be used by the destination MAC to compute the end-to- */
/* end delay. */
op_pk_stamp (hld_pkptr);
/* Maintaining total packet size of the packets in the higher layer */
/* queue(s). */
total_hlpk_size = total_hlpk_size + data_size;
/* Insert the arrived packet in higher layer queue. */
wlan_hlpk_enqueue (hld_pkptr, dest_addr, polling);
FOUT;
}
static void
wlan_hl_packet_drop (Packet* hld_pkptr, OpT_Packet_Size data_size)
{
int large_packet_bit = 0x1;
int full_buffer_bit = 0x2;
/** This function drops the higher layer packets or packets **/
/** received by the AP and need to be forwarded within the **/
/** BSS that can be accepted because of full buffer or **/
/** large size of the packet. It also writes an appropriate **/
/** log message to report the rejection unless the same log **/
/** message is already written before. **/
FIN (wlan_hl_packet_drop (hld_pkptr, data_size));
/* Write an appropriate simulation log message unless the */
/* same message is written before. */
if (drop_pkt_entry_log_flag < full_buffer_bit + large_packet_bit)
{
if (total_hlpk_size + data_size > hld_max_size && !(drop_pkt_entry_log_flag & full_buffer_bit))
{
/* Writing log message for dropped packets. */
op_prg_log_entry_write (drop_pkt_log_handle,
"SYMPTOM(S):\n"
" Wireless LAN MAC layer discarded some packets due to\n "
" insufficient buffer capacity. \n"
"\n"
" This may lead to: \n"
" - application data loss.\n"
" - higher layer packet retransmission.\n"
"\n"
" REMEDIAL ACTION(S): \n"
" 1. Reduce network load. \n"
" 2. Use a higher wireless LAN data rate. \n"
" 3. Increase buffer capacity\n");
drop_pkt_entry_log_flag += full_buffer_bit;
}
else if (total_hlpk_size + data_size <= hld_max_size && data_size > 0 && !(drop_pkt_entry_log_flag & large_packet_bit))
{
/* Writing log message for dropped packets due to */
/* packet size. */
op_prg_log_entry_write (drop_pkt_log_handle,
"SYMPTOM(S):\n"
" Wireless LAN MAC layer discarded some packets due to \n"
" their large sizes. This is an expected protocol \n"
" behavior. \n"
"\n"
" This may lead to: \n"
" - application data loss.\n"
" - higher layer packet retransmission.\n"
"\n"
" SUGGESTION(S): \n"
" 1. Set the higher layer packet size to \n"
" be smaller than max MSDU size (2304 bytes). \n"
" 2. Enable fragmentation threshold and large packet \n"
" processing. \n");
drop_pkt_entry_log_flag += large_packet_bit;
}
}
/* Destroy the dropped packet. */
op_pk_destroy (hld_pkptr);
/* Report stat when data packet is dropped due to overflow */
/* buffer. */
op_stat_write (drop_packet_handle, 1.0);
op_stat_write (drop_packet_handle, 0.0);
/* Report stat when data packet is dropped due to overflow */
/* buffer. */
op_stat_write (drop_packet_handle_inbits, (double) (data_size));
op_stat_write (drop_packet_handle_inbits, 0.0);
op_stat_write (global_dropped_data_handle, (double) (data_size));
op_stat_write (global_dropped_data_handle, 0.0);
FOUT;
}
static void
wlan_hlpk_enqueue (Packet* hld_pkptr, int dest_addr, Boolean polling)
{
char msg_string [120];
char msg_string1 [120];
WlanT_Hld_List_Elem* hld_ptr;
double data_size;
/* Enqueuing data packet for transmission. */
FIN (wlan_hlpk_enqueue (Packet* hld_pkptr, int dest_addr, polling));
/* Allocating pool memory to the higher layer data structure type. */
hld_ptr = (WlanT_Hld_List_Elem *) op_prg_pmo_alloc (hld_pmh);
/* Generate error message and abort simulation if no memory left for data received from higher layer. */
if (hld_ptr == OPC_NIL)
{
wlan_mac_error ("No more memory left to assign for data received from higher layer", OPC_NIL, OPC_NIL);
}
/* Updating higher layer data structure fields. */
hld_ptr->time_rcvd = current_time;
hld_ptr->destination_address = dest_addr;
hld_ptr->pkptr = hld_pkptr;
/* Insert a packet to the list.*/
op_prg_list_insert (hld_list_ptr, hld_ptr, OPC_LISTPOS_TAIL);
/* Enable the flag indicating that there is a data frame to transmit. */
wlan_flags->data_frame_to_send = OPC_TRUE;
/* Report stat when outbound data packet is received. */
op_stat_write (packet_load_handle, 1.0);
/* Report stat in bits when outbound data packet is received. */
data_size = (double) op_pk_total_size_get (hld_pkptr);
op_stat_write (bits_load_handle, data_size);
op_stat_write (bits_load_handle, 0.0);
/* Update the global statistics as well. */
op_stat_write (global_load_handle, data_size);
op_stat_write (global_load_handle, 0.0);
/* Update the queue size statistic. */
if (active_pc)
op_stat_write (hl_packets_rcvd, (double) (op_prg_list_size (hld_list_ptr) + op_prg_list_size (cfpd_list_ptr)));
else
op_stat_write (hl_packets_rcvd, (double) op_prg_list_size (hld_list_ptr));
/* Printing out information to ODB. */
if (wlan_trace_active == OPC_TRUE)
{
sprintf (msg_string, "Just arrived outbound Data packet id " OPC_PACKET_ID_FMT, op_pk_id (hld_ptr->pkptr));
sprintf (msg_string1, "The outbound Data queue size is %d", op_prg_list_size (hld_list_ptr) +
((active_pc) ? op_prg_list_size (cfpd_list_ptr) : 0));
op_prg_odb_print_major (msg_string, msg_string1, OPC_NIL);
}
FOUT;
}
static void
wlan_frame_transmit ()
{
char msg_string [120];
char msg_string1 [120];
WlanT_Hld_List_Elem* hld_ptr;
double pkt_tx_time;
/** Main procedure to invoke function for preparing and **/
/** transmitting the appropriate frames. **/
FIN (wlan_frame_transmit());
/* If not PCF, an Ack needs to be sent for the data */
/* prepare Ack for transmission */
if ((wlan_flags->polled == OPC_FALSE) &&
(fresp_to_send == WlanC_Ack))
{
wlan_prepare_frame_to_send (fresp_to_send);
/* Break the routine once Ack is prepared to transmit */
FOUT;
}
/* Beacon transmission has priority unless we are in the middle of */
/* transmitting fragments of a data packet. */
else if (wlan_flags->tx_beacon == OPC_TRUE &&
(op_sar_buf_size (fragmentation_buffer_ptr) == 0 ||
(wlan_flags->rts_sent == OPC_FALSE && op_sar_buf_size (fragmentation_buffer_ptr) == packet_size_dcf)))
{
/* Reset any pending responses since beacon will terminate sequence anyway */
fresp_to_send = WlanC_None;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -