资源简介
代码 注释全有 方便你阅读,修改 ,对研究无线传感器网络有着很大的帮助
代码片段和文件信息
function [NewEvents] = action(event log_file)
% debug:
% TTL is determined at network layer only
% one way transmission received reverse transmission fails why?
% mainly because randomness in the ‘shadowing‘ model: solved...same distance generates same random number
% friis model works fine
% tworay model is mostly the same as friis because crossover distance = 100 m
% freq should be 2.4G instead of 2.4M white_noise_variance is changed correspondingly
% Duplicated packets due to early time out and retransmission: this is ok just provide a larger timeout
% queue waiting problem: net_queue is actually always empty all NET packets stack at mac_queue
% mac_queue is accompanied by mac_status
% Question 1: how to decide the priority of broadcast unicast transmission and receptioin?
% to add virtual carrier sense: done
% to add RTS-CTS: done
% to add ad hoc routing: done
% to add application layer actions:
% to add figures or animations to show network and traffic change: not critical
global adebug bdebug;
global Gt Gr freq L ht hr pathLossExp std_db d0 rmodel;
global cs_threshold white_noise_variance rv_threshold rv_threshold_delta;
global slot_time CW_min CW_max turnaround_time max_retries SIFS DIFS cca_time basic_rate default_power;
global max_size_mac_body size_mac_header size_rts size_cts size_ack size_plcp;
global n node Event_list;
global packet_id retransmit pending_id mac_queue backoff_attmpt backoff_counter backoff_attempt;
global nav;
global ack_tx_time cts_tx_time rts_tx_time;
global default_rate default_ttl;
global size_rreq size_rrep;
global rreq_timeout net_queue net_pending net_max_retries;
global rrep_table; % id route metric
global bcast_table;
global mac_status;
global adebug bdebug cdebug ddebug;
global rreq_out rreq_in rreq_forward;
global rreq_out_crosslayer rreq_in_crosslayer rreq_forward_crosslayer;
global rrep_out rrep_in rrep_forward;
global rrep_out_crosslayer rrep_in_crosslayer rrep_forward_crosslayer rrep_destination_crosslayer;
NewEvents = [];
switch event.type
case ‘send_phy‘
t = event.instant;
i = event.node;
j = event.pkt.rv;
if adebug disp([‘send_phy at time ‘ num2str(t) ‘ node ‘ num2str(i) ‘ will send a packet to node ‘ num2str(j)]); end
txtime = tx_time(event.pkt);
if node(i 4) == 0 & (nav(i).start > (t+txtime) | nav(i).end < t) % idle and no nav
node(i 3) = event.pkt.power;
node(i 4) = 1; % switch to transmit mode assume turnaround time is zero
% set up the receiver
if j == 0 % broadcast from node i
for k=1:n
% due to broadcast nature in wireless channel every idle node may capture/sense this transmission
if node(k 4)~=0 | k==i continue; end
if overlap(t t+txtime nav(k).start nav(k).end) continue; end
node(k 4) =
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 60361 2006-04-05 13:11 0.5\action.m
文件 467 2006-03-21 21:26 0.5\carrier_sense.m
文件 261 2006-01-23 17:10 0.5\friis.m
文件 1442 2006-01-23 17:49 0.5\inv_erfc.m
文件 126 2006-01-23 17:49 0.5\inv_q.m
文件 1458 2006-03-27 00:32 0.5\inv_recv_power.m
文件 1069 2006-03-26 23:38 0.5\log_normal_shadowing.m
文件 194 2006-02-20 14:16 0.5\new_id.m
文件 243 2006-02-15 16:19 0.5\overlap.m
文件 7279 2006-05-07 15:36 0.5\parameter.m
文件 525 2006-04-10 14:08 0.5\position_init.m
文件 2747 2006-04-10 16:40 0.5\position_update.m
文件 3363 2006-05-07 15:28 0.5\process_sim1.m
文件 643 2006-03-23 18:45 0.5\recv_phy.m
文件 821 2006-04-10 14:47 0.5\recv_power.m
文件 688 2006-04-10 10:50 0.5\run.m
文件 2592 2006-05-07 15:24 0.5\sim1.m
文件 2768 2006-05-07 15:36 0.5\sim2.m
文件 749 2006-03-30 12:44 0.5\topo.m
文件 243 2006-02-17 14:22 0.5\topo_dist.m
文件 635 2006-01-23 17:07 0.5\tworay.m
文件 594 2006-02-15 16:35 0.5\tx_time.m
目录 0 2006-05-07 15:38 0.5\
- 上一篇:数字时钟multisim仿真实验
- 下一篇:视频运动目标检测与跟踪 matlab代码
评论
共有 条评论