📄 wlan_propdel.ps.c
字号:
/* wlan_propdel.ps.c */ /* Modified for IEEE802.11 *//* Propagation delay model for radio link Transceiver Pipeline *//****************************************//* Copyright (c) 1993 *//* by MIL 3, Inc. *//* (A Delaware Corporation) *//* 3400 International Drive, N.W. *//* Washington, D.C., U.S.A. *//* All Rights Reserved. *//****************************************/#include <opnet.h>/***** constants *****//* propagation velocity of radio signal (m/s) */#define PROP_VELOCITY 3.0E+08#define DEBUG 0/* The variable defining a maximum range across which the station can communicate (meters) */ static double wlan_max_distance = OPC_DBL_INFINITY;/***** pipeline procedure *****/#if defined (__cplusplus)extern "C"#endifvoidwlan_propdel (pkptr) Packet* pkptr; { double start_prop_delay, end_prop_delay; double start_prop_distance, end_prop_distance; Objid rx_node_id, tx_node_id; int rx_addr; double rx_x, rx_y, tx_x, tx_y, dist_rx_tx; /** Compute the propagation delay separating the **/ /** radio transmitter from the radio receiver. **/ FIN (wlan_propdel (pkptr)); rx_node_id = op_topo_parent(op_td_get_int (pkptr, OPC_TDA_RA_RX_OBJID)); op_ima_obj_attr_get(rx_node_id,"x position",&rx_x); rx_x = (double) rx_x; op_ima_obj_attr_get(rx_node_id,"y position",&rx_y); rx_y = (double) rx_y; op_ima_obj_attr_get(rx_node_id,"wlan_mac.station_address",&rx_addr); tx_node_id = op_topo_parent(op_td_get_int (pkptr, OPC_TDA_RA_TX_OBJID)); op_ima_obj_attr_get(tx_node_id,"x position",&tx_x); tx_x = (double) tx_x; op_ima_obj_attr_get(tx_node_id,"y position",&tx_y); tx_y = (double) tx_y; dist_rx_tx= sqrt((tx_x-rx_x)*(tx_x-rx_x) + (rx_y-tx_y)*(rx_y-tx_y)); /* Get the start distance between transmitter and receiver. */ start_prop_distance = op_td_get_dbl (pkptr, OPC_TDA_RA_START_DIST); /* Get the end distance between transmitter and receiver. */ end_prop_distance = op_td_get_dbl (pkptr, OPC_TDA_RA_END_DIST); if(DEBUG) printf("@ node %d :: dist = %f ", rx_addr,start_prop_distance); /* Compute propagation delay to start of reception. */ //start_prop_delay = start_prop_distance / PROP_VELOCITY; start_prop_delay = dist_rx_tx / PROP_VELOCITY; /* Compute propagation delay to end of reception. */ //end_prop_delay = end_prop_distance / PROP_VELOCITY; end_prop_delay = dist_rx_tx / PROP_VELOCITY; /* If the maximum transmission range of the station is not already set then extract */ /* it from the user defined simulation attribute. */ if (wlan_max_distance == OPC_DBL_INFINITY) { if (op_ima_sim_attr_exists ("Wireless LAN Range (meters)") == OPC_TRUE) { op_ima_sim_attr_get (OPC_IMA_DOUBLE, "Wireless LAN Range (meters)", &wlan_max_distance); } } //printf("\n|-------------------------------------------------|\n"); //op_pk_print(pkptr); /* If the starting and ending propagation distance is more than the maximum transmission */ /* range then discard the packet in the pipeline stage. This will model the physical */ /* transmission boundary of a wireless station. */ if (end_prop_distance > wlan_max_distance || start_prop_distance > wlan_max_distance) { if(DEBUG) printf("- IGNORED\n"); /* Discard the packet if the destination is more than the specified range */ op_td_set_int (pkptr, OPC_TDA_RA_MATCH_STATUS, OPC_TDA_RA_MATCH_IGNORE); } else if(DEBUG) printf("- ACCEPTED\n"); /* Place both propagation delays in packet transmission data attributes. */ op_td_set_dbl (pkptr, OPC_TDA_RA_START_PROPDEL, start_prop_delay); op_td_set_dbl (pkptr, OPC_TDA_RA_END_PROPDEL, end_prop_delay); FOUT; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -