80211信道模型学习.docx_第1页
80211信道模型学习.docx_第2页
80211信道模型学习.docx_第3页
80211信道模型学习.docx_第4页
80211信道模型学习.docx_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

图为802.11协议的信道进程模型,通过信道进程模型可以得到全局统计量SINR进程模型有两个非强制状态和三个强制状态头文件中定义了转移条件和中断结构#include WLAN_def.h#include WLAN_data.h#include WLAN_func.h转移条件#define SYS_INIT (op_intrpt_type() = OPC_INTRPT_MCAST) & (op_intrpt_code() = INTRPT_SYS_INIT) 中断方式为多路广播中断中断号是系统初始化#define PHY_TXSTART(op_intrpt_type() = OPC_INTRPT_REMOTE) & (op_intrpt_code() = INTRPT_PHY_TXSTART_REQUEST) 中断方式为远程中断 #define PHY_TXEND(op_intrpt_type() = OPC_INTRPT_SELF) & (op_intrpt_code() = INTRPT_PHY_TXEND) 自中断typedef enum INTRPT_RADIO_CHANNEL_TINTRPT_PHY_TXEND INTRPT_RADIO_CHANNEL_T;函数声明static double get_MPDU_power(int, MPDU_T *); 获得MPDU的功率static void channel_status_refresh(void); 刷新信道(将功率值写入统计量)static void MPDU_sinr_segment_refresh(void); 更新MPDU的SINR字段static void MPDU_sinr_calculate(MPDU_T *); 计算MPDU的SINR函数定义文件static double 获得MPDU的功率get_MPDU_power(int lvi_node_index, MPDU_T *lvp_MPDU)int lvi_frequency_band; 频率范围double lvd_MPDU_power; MPDU功率double lvd_pathloss; 路损FIN(get_MPDU_power();/* this node is an AP */ 接入点if (lvi_node_index frequency_band = lvi_frequency_band)lvd_MPDU_power = lvp_MPDU-power; / linear valuelvd_pathloss = gvo_pathloss_matrixlvp_MPDU-source_node_indexlvi_node_index; / dB valuelvd_pathloss = pow(10.0, lvd_pathloss/10.0);FRET(lvd_MPDU_power / lvd_pathloss);/* otherwise, non-cochannel signal */FRET(0.0); 返回0static void 信道状态更新channel_status_refresh()int lvi_AP_index; 接入点索引int lvi_STA_index; 移动站索引int lvi_node_index; 节点索引int lvi_MPDU_index; MPDU索引int lvi_MPDU_number; MPDU数量MPDU_T *lvp_MPDU; MPDU的指针double lvd_sum_power ;double lvd_sum_power_dBm;FIN(channel_status_refresh();lvi_MPDU_number = op_prg_list_size(gvlist_radio_channel); 获得信道中MPDU的数量遍历所有的接入点for (lvi_AP_index = 0; lvi_AP_index gvi_AP_number; lvi_AP_index+)lvi_node_index = lvi_AP_index;lvd_sum_power = 0.0;遍历信道中所有的MPDUfor (lvi_MPDU_index = 0; lvi_MPDU_index lvi_MPDU_number; lvi_MPDU_index+)lvp_MPDU = (MPDU_T *)op_prg_list_access(gvlist_radio_channel, lvi_MPDU_index); 获取信道中的某位置MPDUlvd_sum_power += get_MPDU_power(lvi_node_index, lvp_MPDU);获取接收MPDU的功率(某个节点的)同一节点发送的MPDUlvd_sum_power += CONST_AP_THERMAL_NOISE; 计算接收到的总功率lvd_sum_power_dBm = 10.0 * log10(lvd_sum_power) + 30.0;op_stat_write(gvo_AP_propertylvi_AP_index.PHY_medium_stathandle, lvd_sum_power_dBm); 写入统计句柄遍历所有的移动站for (lvi_STA_index = 0; lvi_STA_index gvi_STA_number; lvi_STA_index+)lvi_node_index = lvi_STA_index + gvi_AP_number;lvd_sum_power = 0.0;遍历所有的MPDU单元for (lvi_MPDU_index = 0; lvi_MPDU_index lvi_MPDU_number; lvi_MPDU_index+)lvp_MPDU = (MPDU_T *)op_prg_list_access(gvlist_radio_channel, lvi_MPDU_index);获取MPDU的指针 lvd_sum_power += get_MPDU_power(lvi_node_index, lvp_MPDU);获取接收MPDU的功率lvd_sum_power += CONST_STA_THERMAL_NOISE;lvd_sum_power_dBm = 10.0 * log10(lvd_sum_power) + 30.0;op_stat_write(gvo_STA_propertylvi_STA_index.PHY_medium_stathandle, lvd_sum_power_dBm);写入统计句柄FOUT;static void SINR字段更新MPDU_sinr_segment_refresh()int lvi_MPDU_number;int lvi_MPDU_index_1;int lvi_MPDU_index_2;MPDU_T *lvp_MPDU_1;MPDU_T *lvp_MPDU_2;double lvd_signal_power;double lvd_interference_power;double lvd_noise_power;SINR_SEGMENT_T *lvp_sinr_segment;double lvd_sinr;FIN(MPDU_sinr_segment_refresh();lvi_MPDU_number = op_prg_list_size(gvlist_radio_channel);for (lvi_MPDU_index_1 = 0; lvi_MPDU_index_1 destination_node_index gvi_AP_number) lvd_noise_power = CONST_AP_THERMAL_NOISE;else lvd_noise_power = CONST_STA_THERMAL_NOISE;for (lvi_MPDU_index_2 = 0; lvi_MPDU_index_2 source_node_index = lvp_MPDU_1-source_node_index) & (lvp_MPDU_2-destination_node_index = lvp_MPDU_1-destination_node_index) if (lvd_signal_power 0.0)op_sim_end(Error: Duplicate signal MPDU!, Error source module: WLAN_RADIO_CHANNEL, Error source function: MPDU_sinr_segment_refresh(), );elselvd_signal_power = get_MPDU_power(lvp_MPDU_1-destination_node_index, lvp_MPDU_2);/* otherwise, interference */elselvd_interference_power += get_MPDU_power(lvp_MPDU_1-destination_node_index, lvp_MPDU_2);lvd_sinr = lvd_signal_power / (lvd_interference_power + lvd_noise_power); / linear valuelvp_sinr_segment = (SINR_SEGMENT_T *)op_prg_mem_alloc(sizeof(SINR_SEGMENT_T);lvp_sinr_segment-sinr = 10.0 * log10(lvd_sinr); / dB valuelvp_sinr_segment-segment_start_time = op_sim_time();op_prg_list_insert(lvp_MPDU_1-sinr_segment, lvp_sinr_segment, OPC_LISTPOS_TAIL);FOUT;static void 计算SINRMPDU_sinr_calculate(MPDU_T *lvp_MPDU)int lvi_sinr_segment_number;int lvi_sinr_segment_index;SINR_SEGMENT_T *lvp_sinr_segment;double lvd_sinr;double lvd_segment_end_time;FIN(MPDU_sinr_calculate();lvi_sinr_segment_number = op_prg_list_size(lvp_MPDU-sinr_segment);lvd_segment_end_time = lvp_MPDU-end_time;lvd_sinr = 0.0;for (lvi_sinr_segment_index = lvi_sinr_segment_number - 1; lvi_sinr_segment_index = 0; lvi_sinr_segment_index-)lvp_sinr_segment = (SINR_SEGMENT_T *)op_prg_list_access(lvp_MPDU-sinr_segment, lvi_sinr_segment_index);lvd_sinr += lvp_sinr_segment-sinr * (lvd_segment_end_time - lvp_sinr_segment-segment_start_time); / sum of time-weighted dB valuelvd_segment_end_time = lvp_sinr_segment-segment_start_time;lvd_sinr = lvd_sinr/(lvp_MPDU-end_time - lvp_MPDU-start_time);lvp_MPDU-sinr = lvd_sinr; / in dBop_prg_list_free(lvp_MPDU-sinr_segment);/* record MSDU SINR */if (lvp_MPDU-MPDU_type = MPDU_TYPE_MSDU) | (lvp_MPDU-MPDU_type = MPDU_TYPE_AMSDU) | (lvp_MPDU-MPDU_type = MPDU_TYPE_AMPDU)op_stat_write(svgstat_SINR, lvp_MPDU-sinr);if (lvp_MPDU-destination_node_index destination_node_index.PHY_SINR_stathandle, lvp_MPDU-sinr);elseop_stat_write(gvo_STA_propertylvp_MPDU-destination_node_index - gvi_AP_number.PHY_SINR_stathandle, lvp_MPDU-sinr);FOUT;Init状态的入口程序gvoid_radio_channel = op_id_self(); 获取对象周围的处理器或队列gvlist_radio_channel = op_prg_list_create(); 产生一个空的列表声明统计句柄SINRsvgstat_SINR = op_stat_reg(PHY.SINR (dB), OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);tx_end状态的入口程序MPDU_T *lvp_MPDU; MPDU的指针int lvi_MPDU_index; MPDU的索引号int lvi_MPDU_number; MPDU的数量Ici *lvici_MPDU; MPDU的ICI指针/* locate the packet related to the current interrupt */lvi_MPDU_number = op_prg_list_size(gvlist_radio_channel);获取信道中MPDU的数量for (lvi_MPDU_index = 0; lvi_MPDU_index end_time end_time = op_sim_time()如果仿真时间等于指定结束的时间结束,即获得了传输完成的MPDU的索引号 break;if (lvi_MPDU_index = lvi_MPDU_number)如果没有获得相应的MPDUop_sim_end(Error: No matched packet in radio channel is found!, Error source module: WLAN_RADIO_CHANNEL, , );/* remove the packet from list */在列表的指定 位置删除数据包lvp_MPDU = (MPDU_T *)op_prg_list_remove(gvlist_radio_channel, lvi_MPDU_index);lvici_MPDU = op_ici_create(WLAN_MPDU); 创建ICIop_ici_attr_set(lvici_MPDU, MPDU_ptr, lvp_MPDU); 为给定ICI的MPDU属性赋值op_ici_install(lvici_MPDU); 自动与调用进程预设的输出中断相关联/* calculate average SINR for this packet */MPDU_sinr_calculate(lvp_MPDU); 计算接收到的SINR/* issue interrupt for the destination MAC process */op_intrpt_schedule_process(lvp_MPDU-destination_prohandle, op_sim_time(), INTRPT_PHY_RXEND_INDICATION); op_ici_install(OPC_NIL); 自动与调用进程预设的输出中断相关联/* update channel

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论