⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sim_size.m

📁 best routing protocol
💻 M
字号:
function sim_size%DEPRECATED DONT USE.%fn='sim_size.mat';%fn='sim_size2.mat';fn='sim_size3.mat';%generate%get_raw_data(fn)process_data(fn)function generatenodes_list = [100, 500, 1000,2000, 3000, 4000, 5000];for n=1:length(nodes_list)  topo=sprintf('topo-size-%d.mat',nodes_list(n));  topology_generator(topo, nodes_list(n), 5.12, 0, 0, 0);endfunction get_raw_data(fn)nodes_list = [100, 500, 1000,2000, 3000, 4000, 5000];repeat = 50;for n=1:length(nodes_list)  topo=sprintf('topo-size-%d.mat',nodes_list(n));  optimal(n) = sim_optimal(topo);  for i=1:repeat    fprintf('****sim_size test %s, repeat=%d\n', topo, i);    res(n,i) = simulation(topo, ceil(sqrt(nodes_list(n))));    save(fn, 'res', 'optimal', 'nodes_list','repeat');  endendfunction process_data(fn)load(fn);msz=12;for n=1:length(nodes_list)  clear stretch_bvr_sf_mean  for i=1:repeat    stretch_bvr_sf_mean(i)=plot_routing_stretch( ...	res(n,i).routing_dist_bvr_sf, optimal(n).optimal_dist, 'k',[-1],0);    if stretch_bvr_sf_mean(i)>100      %[res(n,l,i).routing_dist_bvr_sf optimal(n,l, ...      %					i).optimal_dist]      n, i    end    stretch_bvr_2h_mean=plot_routing_stretch( ...	res(n,i).routing_dist_bvr_2h, optimal(n).optimal_dist, 'k',[-1],0);    stretch_cr_mean=plot_routing_stretch( ...	res(n,i).routing_dist_cr, optimal(n).optimal_dist, 'k',[-1],0);  end  bvr_sf(n) = mean(stretch_bvr_sf_mean);  bvr_2h(n) = mean(stretch_bvr_2h_mean);  cr(n) = mean(stretch_cr_mean);  fprintf('# of nodes:%d, avg stretch %f\t%f\t%f\n', ...	  nodes_list(n),  ...	  mean(stretch_bvr_sf_mean), ...	  mean(stretch_bvr_2h_mean), ...	  mean(stretch_cr_mean));  endfigure(1)set(gca, 'FontSize',20);hold onplot(nodes_list, bvr_sf,'r-*','MarkerSize', msz);%plot(nodes_list, bvr_2h,'k-x','MarkerSize', msz);plot(nodes_list, cr,'b-o','MarkerSize', msz);%legend('BVR 1 hop', 'BVR 2 hop', 'PCR',2);legend('BVR', 'PCR',2);xlabel('number of nodes');ylabel('average transmission stretch');saveas(gcf, 'size_stretch.eps','psc2')%%%%%%%%%%%%%%%for n=1:length(nodes_list)  for i=1:repeat    state_cr(n,i)=mean(routing_state_cr(res(n,i)));    state_bvr(n,i) = mean(routing_state_bvr(res(n,i)));  endendfigure(2)set(gca, 'FontSize',20);hold onplot(nodes_list, mean(state_bvr,2),'r-*','MarkerSize', msz)plot(nodes_list, mean(state_cr,2),'b-o','MarkerSize', msz)legend('BVR', 'PCR',2);xlabel('number of nodes N');ylabel('average routing state per node (Byte)');saveas(gcf, 'size_state.eps','psc2')%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%for n=1:length(nodes_list)  for i=1:repeat    [cr_setup(n,i), bvr_setup(n,1)] = setup_traffic(res(n,i));  endendfigure(3)set(gca, 'FontSize',20);hold ony = mean(cr_setup, 2);l = y - min(cr_setup,[], 2);u = max(cr_setup, [], 2) -y;errorbar(nodes_list, y, l, u,'o-b','MarkerSize', msz);plot(nodes_list, bvr_setup, 'x-r','MarkerSize', msz);legend('PCR', 'BVR',2);xlabel('number of beacons K');ylabel('setup control traffic per node (Byte)');saveas(gcf, 'size_traffic.eps','psc2')

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -