clc;
clear;
close all;
warning off;
addpath(genpath(pwd));
number=zeros(1,5);
for i=1:5
global fc_LTE fc_Wimax LTE_BS_coordinate Wimax_BS_coordinate ...
Wimax_BS_coordinate LTE_BS_coordinate large_scale_time_interval...
large_scale_LTE large_scale_wimax large_scale_time_start...
large_scale_time_end N x y
% x = (0:10:1000000)';
% y = gaussmf(x,[1000000,0]);
x = (0:10:100000);
y = gaussmf(x,[10000 0]);
service_type=0; %the subscriber type of service
%0 refers to real time service,on the
% contrary,1 refers to nonreal-time service
large_scale_time_interval=100;
N=20;
large_scale_time_start=0;
large_scale_time_end=large_scale_time_interval;
large_scale_LTE=ShadowGenerate(3,0.5,N);
large_scale_wimax=ShadowGenerate(3,0.5,N);
MS_coordinate=[45000,0];
LTE_BS_coordinate=[0,0]; %the coordinate of LTE BS
Wimax_BS_coordinate=[50000,0]; %the coordinate of wimaxE BS
%MS_speed=100; %the speed of mobile station
%MS_speed=10; %the speed of mobile station
MS_speed=10; %the speed of mobile station
fc_LTE=2000*10^6; %the frequency of the carrier for LTE
fc_Wimax=1760*10^6; %the frequency of the carrier for Wimax
Net_state=0; %0 refers to LTE;1 refers to Wimax
handoff_drop=1; % TTT means
handoff_clock=0;
count_handoff_number=0;
Tc=1; %time of measure interval
record_time=0; %record the number of interval time of system
countinue_run=true;
HOM=0;
%% 1
% service_type=1; % nonreal-time service
% handoff_drop=0;
% HOM=0;
%% 2
% service_type=1; % nonreal-time service
% handoff_drop=1; % this time set is 0.05
% HOM=0.5;
%% 3
service_type=1; % nonreal-time service
handoff_drop=4; % this time set is 0.05
HOM=1;
while countinue_run
%################# measure the receieved signal strength ############
%if the mobile station is in the LTE network
if is_in_LTE_coverage(MS_coordinate)
RSS_LTE=calculate_RSS(MS_coordinate,MS_speed,'LTE',record_time*Tc,Tc);
else
RSS_LTE=-inf;
end
%if the mobile station is in the LTE network
if is_in_Wimax_coverage(MS_coordinate)
RSS_Wimax=calculate_RSS(MS_coordinate,MS_speed,'Wimax',...
record_time*Tc,Tc);
else
RSS_Wimax=-inf;
end
%############### decide whether to handoff according to RSS #########
% if Net_state==0&&RSS_LTE<RSS_Wimax
% if handoff_clock>handoff_drop
% count_handoff_number=count_handoff_number+1;
% Net_state=1;
% handoff_clock=0; %reset the counter
% else
% handoff_clock=handoff_clock+Tc;
% end
% elseif Net_state==1&&RSS_LTE>RSS_Wimax
% if handoff_clock>handoff_drop
% count_handoff_number=count_handoff_number+1;
% Net_state=0;
% handoff_clock=0; %reset the counter
% else
% handoff_clock=handoff_clock+Tc;
% end
% else
% handoff_clock=0;
% end
%% service_type =0 real-time service
if service_type==0
if Net_state==0&&RSS_LTE+HOM<RSS_Wimax % add the
count_handoff_number=count_handoff_number+1;
Net_state=1;
elseif Net_state==1&&(RSS_LTE>RSS_Wimax || norm(MS_coordinate-LTE_BS_coordinate)<980) %add the position information
if handoff_clock>handoff_drop
count_handoff_number=count_handoff_number+1;
Net_state=0;
handoff_clock=0; %reset the counter
else
handoff_clock=handoff_clock+Tc;
end
else
handoff_clock=0;
end
%% service_type=1 nonreal-time service
else
if Net_state==0&&RSS_LTE<RSS_Wimax
if handoff_clock>handoff_drop
count_handoff_number=count_handoff_number+1;
Net_state=1;
handoff_clock=0; %reset the counter
else
handoff_clock=handoff_clock+Tc;
end
elseif Net_state==1&&(RSS_LTE>RSS_Wimax+HOM|| norm(MS_coordinate-LTE_BS_coordinate)<980)
count_handoff_number=count_handoff_number+1;
Net_state=0;
else
handoff_clock=0;
end
end
%%
%##################### decide whether to continue run ################
if MS_speed >= 100
Net_state = 0;
end
if is_in_LTE_coverage(MS_coordinate)||...
is_in_Wimax_coverage(MS_coordinate)
%######################## record the data ########################
record_time=record_time+1;
record_RSS_LTE(record_time)=RSS_LTE;
record_RSS_Wimax(record_time)=RSS_Wimax;
record_Net_state(record_time)=Net_state;
MS_coordinate(1)=MS_coordinate(1)+MS_speed*Tc;
else
countinue_run=false;
end
MS_coordinate
end
count_handoff_number
%######################## plot the simulation results ####################
t=[1:record_time]*Tc;
% plot(t,record_RSS_LTE,'--ro','MarkerEdgeColor','g','MarkerFaceColor','y',...
% 'MarkerSize',2);
% hold on
% plot(t,record_RSS_Wimax,'-.ks','MarkerEdgeColor','b',...
% 'MarkerFaceColor','c','MarkerSize',2);
% hold off
% grid on
% xlabel('time(s)');
% ylabel('RSS(dBm)');
% legend('LTE','Wimax');
% title('the received signal strength about two networks');
%% figure 1--- one
figure
plot(t,record_RSS_LTE,'r->',...
'MarkerEdgeColor','r',...
'MarkerFaceColor','r',...
'MarkerSize',2)
hold on
%plot(t,record_RSS_LTE,'-.ks','MarkerEdgeColor','b',...
% 'MarkerFaceColor','c','MarkerSize',2);
plot(t,record_RSS_Wimax,'-bs',...
'MarkerEdgeColor','b',...
'MarkerFaceColor','b',...
'MarkerSize',2)
hold off
grid on
xlabel('time(s)');
ylabel('RSS(dBm)');
legend('GMR','LTE');
axis([300 700 -120 -75])
title('the received signal strength about two networks');
%%
% figure
% plot(t,record_Net_state,'--ro','MarkerEdgeColor','g','MarkerFaceColor','y',...
% 'MarkerSize',2)
% grid on
% xlabel('time(s)');
% ylabel('mark of network');
% text(0,0,'\leftarrow LTE','FontSize',10)
% text(0,1,'\leftarrow Wimax','FontSize',10)
% title('the state of mobile station in LTE and Wimax network')
%% figure 2--- one
figure
%plot(t,record_Net_state,'--ro','MarkerEdgeColor','k','MarkerFaceColor','g',...
% 'MarkerSize',2)
plot(t,record_Net_state,'k--^',...
'MarkerEdgeColor','k',...
'MarkerFaceColor','k',...
'MarkerSize',3)
grid on
xlabel('time(s)');
ylabel('mark of network');
axis([300 700 0 1])
%
% % speed is over 100
% % axis([0 100 0 1])
% % text(0,0,'\leftarrow GMR','FontSize',10)
% % text(0,1,'\leftarrow LTE','FontSize',10)
%
title('the state of mobile station in GMR and LTE network')
text(300,0,'\leftarrow GMR','FontSize',10)
text(300,1,'\leftarrow LTE','FontSize',10)
number(i)=count_handoff_number;
end
number
mean(number)
%############################END THE PROGRAM ##############################
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
matlab_异构网络中GMR和LTE垂直切换算法matlab仿真_源码.rar (9个子文件)
matlab_异构网络中GMR和LTE垂直切换算法matlab仿真_源码
Runme.m 7KB
func
calculate_fast_fading.m 682B
is_in_Wimax_coverage.m 258B
calculate_slow_fading.m 667B
is_in_LTE_coverage.m 245B
ShadowGenerate.m 303B
calculate_shadow_fading.m 1KB
jakes.m 602B
calculate_RSS.m 667B
共 9 条
- 1
资源评论
- weixin_417087302024-02-13资源很实用,内容详细,值得借鉴的内容很多,感谢分享。
- ihSdcjiascj2024-05-25资源有一定的参考价值,与资源描述一致,很实用,能够借鉴的部分挺多的,值得下载。
- 2301_770572092024-04-23这个资源对我启发很大,受益匪浅,学到了很多,谢谢分享~
mYlEaVeiSmVp
- 粉丝: 1966
- 资源: 19万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功