锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
絎竴姝ワ紝鍦╳lan_mac榪涚▼妯″瀷涓紝娣誨姞Simulation Attributes -> Wireless LAN Range (meters) 灞炴э紝綾誨瀷涓篿nteger錛岀己鐪佸間負300銆?br>
絎簩姝ワ紝鏀瑰姩wlan_propdel綆¢亾紼嬪簭銆備互鏌愪竴鐗堟湰鐨勮紼嬪簭涓轟緥錛?br>涔嬪墠鐨勶細
#include <opnet.h>
/**//***** constants *****/
/**//* propagation velocity of radio signal (m/s) */
#define PROP_VELOCITY 3.0E+08
/**//* 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"
#endif
void
Zhou_wlan_propdel (pkptr)
Packet* pkptr;
{
double start_prop_delay, end_prop_delay;
double start_prop_distance, end_prop_distance;
// Compute the propagation delay separating the
// radio transmitter from the radio receiver.
FIN (wlan_propdel (pkptr));
// 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);
// Compute propagation delay to start of reception.
start_prop_delay = start_prop_distance / PROP_VELOCITY;
// Compute propagation delay to end of reception.
end_prop_delay = end_prop_distance / 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 ("wlan_max_distance is %f \n", wlan_max_distance);
}
// 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)
{
// 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);
}
// 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;
}
淇敼涔嬪悗鐨勶紝娉ㄦ剰 "if (wlan_max_distance == OPC_DBL_INFINITY)"閭i儴鍒嗕負娣誨姞璇彞錛?br>
#include <opnet.h>
/**//***** constants *****/
/**//* propagation velocity of radio signal (m/s) */
#define PROP_VELOCITY 3.0E+08
/**//* 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"
#endif
void
wlan_propdel (pkptr)
Packet* pkptr;
{
double start_prop_delay, end_prop_delay;
double start_prop_distance, end_prop_distance;
// Compute the propagation delay separating the
// radio transmitter from the radio receiver.
FIN (wlan_propdel (pkptr));
// 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);
// Compute propagation delay to start of reception.
start_prop_delay = start_prop_distance / PROP_VELOCITY;
// Compute propagation delay to end of reception.
end_prop_delay = end_prop_distance / 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 ("wlan_max_distance is %f \n", wlan_max_distance);
}
// 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)
{
// 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);
}
// 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;
}
絎笁姝ワ紝閫夋嫨file -> Compile錛岀紪璇戣紼嬪簭銆傞渶瑕佹敞鎰忕殑鏄紝濡傛灉灝唚lan_propdel鏀瑰悕涓哄叾浠栧悕瀛楋紝濡?**_wlan_propdel錛岄偅涔堥渶瑕佸皢鍑芥暟鍚嶄篃淇敼涓虹浉搴旂殑***_wlan_propdel銆?br>
]]>
鍦╳lan_mac妯″潡涓殑init鍑芥暟涓坊鍔犲涓嬪懡浠わ細
op_ima_obj_attr_get (my_objid, "Address", &my_address);
//*************************************************************************
if (my_address == AUTO_ASSIGNED)
{
op_ima_obj_attr_get (my_node_objid, "name", my_node_name);
my_address = name_aoti (my_node_name);
op_ima_obj_attr_set (my_node_objid, "Wireless LAN MAC Address", my_address);
}
//*************************************************************************
/* Obtain an address handle for resolving WLAN MAC addresses. */
oms_aa_handle = oms_aa_address_handle_get ("MAC Addresses", "Address");
鍚岀悊錛屽湪鍏朵粬闇瑕佷嬌鐢╩ac灞傚湴鍧鐨勫崗璁眰涓殑鍒濆鍖栭儴鍒嗭紝娣誨姞濡備笅浠g爜錛?br>
{
op_ima_obj_attr_get (op_topo_parent (op_id_self ()), "name", my_node_name);
my_node_addr = name_aoti (my_node_name);
op_ima_obj_attr_set (op_topo_parent (op_id_self ()), "Wireless LAN MAC Address", my_node_addr);
}
娉ㄦ剰錛?br>1.鍦╳lan_mac_intf灞傦紝鍚屾牱闇瑕佷嬌鐢ㄥ埌mac_address錛屼絾鍙湪wait闃舵闇瑕佸璇ュ睘鎬ц繘琛岃鍐欙紝鎵浠ュ茍涓嶄細璇誨埌閿欒鐨勫鹼紝鍙互涓嶇銆?br>2.name_aoti鍑芥暟錛?br>
{
int num = 0;
char *tmp = name;
FIN (name_aoti);
while (*tmp != '\0')
{
num = num * 10 + *tmp - '0';
tmp++;
}
FRET (num);
}
]]>
鍚庢潵鍙戠幇錛屽湪wlan_port_tx.propdel model綆¢亾闃舵鐨?span style="COLOR: red">wlan_propdel紼嬪簭涓湁榪欎箞涓孌典唬鐮侊細
/* 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);
}
}
/* 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)
{
op_td_set_int (pkptr, OPC_TDA_RA_MATCH_STATUS, OPC_TDA_RA_MATCH_IGNORE);
}
璇ユ浠g爜鐨勪綔鐢ㄥ湪浜庯細褰搘lan_max_distance鍙橀噺鏈叿浣撳畾涔夋椂錛屽鏋淲ireless LAN Range (meters)灞炴у湪浠跨湡灞炴т腑瀹氫箟浜嗭紝閭d箞灝嗚灞炴х殑鍊間綔涓烘渶澶х殑鏃犵嚎浼犺緭鍗婂緞錛岃秴榪囪浼犺緭鍗婂緞鐨勬暟鎹寘閫氶氫涪寮冦?br>
]]>
璋冭瘯綰犻敊錛?br>鍒濇璁ゅ畾閿欒鍙戠敓鍦ㄥ湪wlan_mac妯″潡涓紝榪涗竴姝ヨ窡韙皟璇曞彂鐜幫紝涓㈠け鏁版嵁鎶ョ殑鍘熷洜鍦ㄤ簬鎵цwlan_physical_layer_data_arrival鍑芥暟鏃訛紝鍦╥f ((wlan_flags->rcvd_bad_packet == OPC_BOOLINT_ENABLED) || (accept == OPC_FALSE) ||(wlan_flags->collided_packet == OPC_BOOLINT_ENABLED))鍒ゆ柇澶勮繘鍏ュ唴閮ㄤ唬鐮佹騫舵渶緇堟墽琛屼簡op_pk_destroy鍑芥暟錛?span style="COLOR: red">璇存槑璇?/span>鏁版嵁鍖呭洜涓哄湪鐩殑绔笌鍏朵粬鏁版嵁鍖呭啿紿佽屽鑷翠涪澶?/span>銆備粩緇嗗垎鏋愪笂榪板師鍥犲悗錛岀寷鐒跺彂鐜幫紝涔嬫墍浠roadcast妯″紡涓嬪叏閮ㄦ暟鎹寘鍧囦涪澶憋紝鏄洜涓簊ource妯″潡涓殑Packet Interarrival Time璁劇疆涓篶onstant綾誨瀷錛屾墍鏈夎妭鐐瑰潎鍦ㄥ悓涓鏃墮棿鍙戝寘錛屽鑷存墍鏈夋暟鎹寘鍐茬獊錛涜宺andom妯″紡涓嬪啿紿佽緝灝戠殑鍘熷洜鏄洜涓烘暟鎹寘涓嶆槸騫挎挱褰㈠紡鍙戦侊紝鍚屼竴鐩殑绔悓鏃舵帴鍙楀涓暟鎹寘鐨勬鐜囧噺灝忎簡錛屾晠鍙湁涓瀹氬嚑鐜囦笅鎵嶄細鍐茬獊銆?br>
淇鏂規硶錛?br>灝哖acket Interarrival Time璁劇疆涓篹xponenetial綾誨瀷鍗沖彲錛岄敊寮鍚勮妭鐐圭殑鍙戝寘鏃墮棿銆?br>
]]>
2.ODB璋冭瘯鏃剁獥鍙d笉鑷姩鍏抽棴錛?br>preference -> console_exit_pause灞炴ц瀹氫負true錛岃繖鏍烽渶瑕佽緭鍏ヤ袱嬈nter鍚庢墠浼氬叧闂?br>娉ㄦ剰錛氬彇娑坉ebug妯″紡鑰岀洿鎺ヨ繍琛屾椂錛屽鏋滄病鏈夊皢console_exit_pause閰嶇疆閲嶆柊鏀逛負false錛屽彲鑳戒細鍑虹幇榪愯瀹屾瘯鍚巆lose鎸夐挳涓虹伆鑹茬殑鎯呭喌錛屽繀欏繪敞鎰忋?/span>
3.OPNET涓嶸C鑱旇皟錛?br>preference -> bind_shobj_flags鐨勫煎悗闈㈠姞涓?/DEBUG
preference -> comp_flags鍜宑omp_flags_cpp鍚庨潰鍔犱笂/Zi /Od
config simulation(advanced) -> Envirement files -> include涓ら」錛歞ebug鍜宖orce_compile
榪愯ODB錛岀劧鍚庡湪VC涓媋ttach to process錛屾坊鍔爋p_runsim榪涚▼錛屽紑濮嬭仈鍚堣皟璇曘?br>
4.鍒犻櫎鍜屾煡鐪媠ource directory
preference -> mod_dir -> 閫夋嫨鏌愰」鍒犻櫎