📄 bss_init exit execs
字号:
/* Obtain the values assigned to the various attributes */
op_ima_obj_attr_get (my_objid, "Wireless LAN Parameters", &wlan_params_comp_attr_objid);
params_attr_objid = op_topo_child (wlan_params_comp_attr_objid, OPC_OBJTYPE_GENERIC, 0);
/* Determining the final MAC address after address resolution. */
op_ima_obj_attr_get (my_objid, "Address", &my_address);
/* Update our own process registery record with the final address */
/* information. */
oms_pr_attr_set (own_process_record_handle, "address", OMSC_PR_NUMBER, (double) my_address, OPC_NIL);
/* Destroy the global list of BSS IDs that was used while assigning */
/* channels to BSSs. */
wlan_bss_id_list_manage (bss_id, "destroy_list");
/* Since the frequency band of the channels of all radio nodes are */
/* determined, refresh our potential receiver group to exclude the */
/* receiver channels that have non-overlapping bands with ours, */
/* which we can't reach and interfere, to improve simulation */
/* performance. */
wlan_rxgroup_reduce ();
/* Create the pool of station addresses of the same BSS using BSS */
/* ID information. */
my_sta_info_ptr = wlan_sta_addr_register (bss_id, my_address, ap_flag, my_objid, phy_char_flag);
/* Get a handle to the information record of our own BSS, which */
/* also contains the STA list of our BSS. */
my_bss_info_ptr = wlan_bss_info_get (bss_id);
/* If we are operating in a bridge/switch node, indicate that our */
/* address is not a valid destination address, since the station */
/* models may choose their destination addresses randomly from the */
/* address pool. */
if (wlan_flags->bridge_flag)
oms_aa_dest_status_set (oms_aa_handle, my_address, OmsC_Aa_Invalid_Destination);
/* Search for the other WLAN MACs that are in the same LAN with us. */
proc_record_handle_list_ptr = op_prg_list_create ();
/* If the subnet is BSS based then do the process discovery using */
/* BSS ID (domain_id), otherwise do it using subnet ID. */
if (bss_id_type == WlanC_Bss_Divided_Subnet)
{
oms_pr_process_discover (OPC_OBJID_INVALID, proc_record_handle_list_ptr,
"domain_id", OMSC_PR_NUMBER, (double) bss_id,
"mac_type", OMSC_PR_STRING, "wireless_lan",
"protocol", OMSC_PR_STRING, "mac",
OPC_NIL);
}
else
{
oms_pr_process_discover (OPC_OBJID_INVALID, proc_record_handle_list_ptr,
"subnetid", OMSC_PR_OBJID, my_subnet_objid,
"mac_type", OMSC_PR_STRING, "wireless_lan",
"protocol", OMSC_PR_STRING, "mac",
OPC_NIL);
}
/* If the MAC interface process registered itself, */
/* then there must be a valid match */
record_handle_list_size = op_prg_list_size (proc_record_handle_list_ptr);
/* Initialize the address list index to zero. */
addr_index = 0;
/* Variable to counting number of access point in the network. */
ap_count = 0;
/* Initialize the variable which holds the count of PCF users in network */
poll_list_size =0;
/* Keeps track of the number of stations which are PCF enabled */
/* If this value is greater than 0, only then a Beacon frame is */
/* transmitted at the targeted time. */
pcf_enabled_stations = 0;
/* Preserves the PCF status on an AP node */
pcf_enabled_on_AP = OPC_FALSE;
/* Traversing the process record handle list to determine if there is any access point in the subnet. */
for (i_cnt = 0; i_cnt < record_handle_list_size; i_cnt++ )
{
/* Obtain a handle on the process record */
process_record_handle = (OmsT_Pr_Handle) op_prg_list_access (proc_record_handle_list_ptr, i_cnt);
/* Get the Station type. */
oms_pr_attr_get (process_record_handle, "subprotocol", OMSC_PR_NUMBER, &statype);
/* If the station is an Access Point then its station id will be a BSS id for all the station in that subnet. */
if (statype == (double) WLAN_AP)
{
/* If access point found then it means that it is a Infrastructured BSS. */
bss_flag = OPC_TRUE;
/* Obtain the station address of the access point. */
oms_pr_attr_get (process_record_handle, "address", OMSC_PR_NUMBER, &sta_addr);
ap_mac_address = (int) sta_addr;
/* According to IEEE 802.11 there cannot be more than one access point in */
/* the same BSS. */
ap_count = ap_count + 1;
if (ap_count == 2)
{
sprintf(msg1,"More than one Access Point found within the same BSS (BSS ID = %d)" , bss_id);
wlan_mac_error (msg1,"or in the same OPNET subnet.","Check the configuration.");
}
/* Save position information of the connected AP for "virtual" roaming */
if (ap_flag == OPC_BOOLINT_DISABLED)
oms_pr_attr_get (process_record_handle, "position record", OMSC_PR_POINTER, &conn_ap_pos_info_ptr);
}
/* Checking the physical characteristic configuration for the subnet. */
oms_pr_attr_get (process_record_handle, "module objid", OMSC_PR_OBJID, &mac_objid);
/* Obtain the values assigned to the various attributes */
op_ima_obj_attr_get (mac_objid, "Wireless LAN Parameters", &wlan_params_comp_attr_objid);
params_attr_objid = op_topo_child (wlan_params_comp_attr_objid, OPC_OBJTYPE_GENERIC, 0);
/* Load the appropriate physical layer characteristics. */
op_ima_obj_attr_get (params_attr_objid, "Physical Characteristics", &sta_phy_char_flag);
/* Mismatching physical layer technologies within the same BSS are not */
/* allowed. */
if (sta_phy_char_flag != phy_char_flag)
{
/* With one exception: 11g and 11/11b-DSSS STAs can coexist in the same */
/* BSS. */
/* If we are an 11g STA, then set the non_erp_present flag if there are */
/* some non-ERP (11/11b) STAs in our (I)BSS. */
if (phy_char_flag == WlanC_ERP_OFDM_11g && sta_phy_char_flag == WlanC_Direct_Sequence)
wlan_flags->non_erp_present = OPC_TRUE;
/* Terminate the simulation unless it is the exception case. */
else if (phy_char_flag != WlanC_Direct_Sequence || sta_phy_char_flag != WlanC_ERP_OFDM_11g)
{
wlan_mac_error ("Physical Characteristic configuration mismatch in WLAN BSS. All stations in the same BSS (in",
"the same subnet if BSS IDs are auto-assigned) should have the same physical characteristics",
"(exception: Direct Sequence and ERP stations can coexist). Check the configuration.");
}
}
/* Store the physical layer technology used by the AP. */
if (statype == (double) WLAN_AP)
ap_phy_char_flag = sta_phy_char_flag;
/* Check if the PCF mode has been enabled in this station. */
oms_pr_attr_get (process_record_handle, "PCF active", OMSC_PR_NUMBER, &pcf_active);
/* If this station has its PCF functionality enabled, increment the PCF */
/* user count. */
if (pcf_active != 0.0)
{
poll_list_size++;
/* Preserve the PCF status if it is an AP. It is required later, when */
/* we check for PCF functionality enabled on other nodes in the network. */
if (statype == (double) WLAN_AP)
{
pcf_enabled_on_AP = OPC_TRUE;
}
}
}
/* Write a 1 for AP connectivity statistic if we belong to an infrastructure */
/* BSS. */
if (bss_flag == OPC_TRUE)
op_stat_write (ap_conn_handle, 1);
else
op_stat_write (ap_conn_handle, 0);
/* Disable roaming based on the node type and type of BSS -- roaming not */
/* supported in a PCF-based BSS or IBSS. */
if (roam_state_ptr->enable_roaming && (pcf_enabled_on_AP || ap_count == 0 || ap_flag == OPC_BOOLINT_ENABLED))
{
roam_state_ptr->enable_roaming = OPC_FALSE;
/* Write a simulation log message to report this configuration change. */
op_prg_log_entry_write (config_log_handle,
"WARNING:\n"
" Cannot enable roaming functionality at the Wireless LAN MAC\n"
" layer. Roaming cannot be supported by a WLAN MAC if any of\n"
" the conditions below is true:\n"
" a) The MAC belongs to an independent (ad-hoc) WLAN.\n"
" b) Access point functionality is also enabled for that MAC.\n"
" c) PCF functionality is enabled within the initial WLAN of\n"
" the MAC. Currently roaming is not supported with PCF\n"
" functionality.\n"
"\n"
" If you like the MAC layer of this node to execute roaming\n"
" procedures and switch access points when available and\n"
" necessary, then reconfigure the WLAN parameters on this\n"
" node and/or on the other WLAN nodes of its LAN so that\n"
" none of the conditions above is correct.\n");
}
/* Even if enabled, disable the roaming if the surrounding node is fixed, */
/* all the parent subnets are fixed and the beacon efficiency mode is */
/* enabled, which assumes that the APs are not changing the locations. In */
/* other words, there is no need to run roaming functions if the distance */
/* between our node and any AP in the network will not change. */
else if (roam_state_ptr->enable_roaming && op_id_to_type (my_node_objid) == OPC_OBJTYPE_NDFIX &&
beacon_eff_mode == OPC_BOOLINT_ENABLED)
{
/* Make sure all the parent subnets are also fixed. Disable the roaming */
/* and enable it back if one of the parent subnets is not fixed. */
parent_subnet_objid = my_subnet_objid;
roam_state_ptr->enable_roaming = OPC_FALSE;
do
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -