📄 update_mobile_structres_before_frame_g_fac_no_fsf.m
字号:
function [st_channelGrid,st_testConfig,st_mobileStations,MobileIdCnt,st_baseStation,st_measurement]= update_mobile_structres_before_frame_g_fac_no_fsf(st_testConfig,st_channelGrid,st_mobileStations,MobileIdCnt,st_baseStation,st_measurement)
%__________________________________________________________________________
% Type: : Function Header
% Function name : ofdma_sfn_Cellular_la_dl_simulator
% input : st_channelGrid,st_testConfig,st_mobileStations,st_baseStations
% output : st_channelGrid,st_testConfig,st_mobileStations,st_baseStations
% :
% calling functions : input_config
% called functions :
% Function Description : % Update mobile structure.
% its acceleraion
% its position, therefore
% its pathloss
% settings of channel object
% its history to zero. No need to store history now
% its rms delay spread as per the distance.
% its doppler as per the new velocity
% ALSO UPDATE REQUIRED PARAMETERS
%__________________________________________________________________________
% Update new velocity and location
% st_testConfig.locMS=nan(st_testConfig.nuMob,1); % This is done so that for
% % each frame, the mobile
% % begins at a new location
% % This has to be changed
% % depending on the
% % simulation condition,
% % probably a switch is a
% % good option
if st_testConfig.nFrmCnt > 1
%Plot current mobiles
figure(1);
hold on;
plot(st_testConfig.locMS,'g.');
% pause(1)
end
% Check each mobile, if the remaining file size to be trasmitted is less
% than zero. If so, then initiate a new mobile in that handle
new_mobile_handles=[];
finished_locs=[];
bad_mobiles_loc=[];
old_mobile_handles=[];
for lp_nmob =1:st_testConfig.nuMob
% IDENTIFY MOBILE WHICH ARE NOT ABLE TO GET THROUGH BUT ARE SIMPLY BLOCKING
% THE NETWORK RESOURCES.
% TAKE THEM AWAY FROM THE NETWORK, i.e. DO NOT SERVE THEM ANY MORE AND MARK
% THEM WITH A YELLOW STAR
% if st_testConfig.nFrmCnt > 4
% if sum(st_mobileStations(lp_nmob).MobNumber([st_testConfig.nFrmCnt - [0:3] ])) == 0
% bad_mobiles_loc=st_testConfig.locMS(lp_nmob);
% st_mobileStations(lp_nmob).RemFileSz(st_testConfig.nFrmCnt-[1 0]) = -999999;
% st_measurement.outageCnt=st_measurement.outageCnt+1;
% end
% end
% MAX_OFDM_SYMBOL_WAIT=4*4; %(4 ofdm symbols x 4 sub frames )
% if st_testConfig.nFrmCnt > MAX_OFDM_SYMBOL_WAIT
% if ( ( st_mobileStations(lp_nmob).RemFileSz(st_testConfig.nFrmCnt) == st_mobileStations(lp_nmob).RemFileSz(st_testConfig.nFrmCnt-MAX_OFDM_SYMBOL_WAIT+1)) & (sum(st_mobileStations(lp_nmob).MobNumber([st_testConfig.nFrmCnt - [0:MAX_OFDM_SYMBOL_WAIT-1] ])) == 0) )
% bad_mobiles_loc=st_testConfig.locMS(lp_nmob);
% st_mobileStations(lp_nmob).RemFileSz(st_testConfig.nFrmCnt-[1 0]) = -999999;
% st_measurement.outageCnt=st_measurement.outageCnt+1;
% end
% end
% IF SINR is extreemly low, then take away the mobile from being served
if st_testConfig.nFrmCnt > 1
if ( mean(st_mobileStations(lp_nmob).sinrFeedBack) < 10^(st_testConfig.SINR_Threshold/10) )
if st_testConfig.nFrmCnt > st_testConfig.MAX_OFDM_SYMBOL_WAIT
if ( ( st_mobileStations(lp_nmob).RemFileSz(st_testConfig.nFrmCntSlot) == st_mobileStations(lp_nmob).RemFileSz(mod((st_testConfig.nFrmCntSlot-st_testConfig.MAX_OFDM_SYMBOL_WAIT+1),st_testConfig.nuFrmPerSlot)+1)) & (sum(st_mobileStations(lp_nmob).MobNumber(mod([st_testConfig.nFrmCntSlot - [0:st_testConfig.MAX_OFDM_SYMBOL_WAIT-1] ],st_testConfig.nuFrmPerSlot)+1)) == 0) )
% mod([st_testConfig.nFrmCntSlot - [0:st_testConfig.MAX_OFDM_SYMBOL_WAIT-1] ],st_testConfig.nuFrmPerSlot)
bad_mobiles_loc=st_testConfig.locMS(lp_nmob);
st_mobileStations(lp_nmob).RemFileSz(mod(st_testConfig.nFrmCntSlot-[1 0],st_testConfig.nuFrmPerSlot)+1) = -999999;
st_measurement.outageCnt=st_measurement.outageCnt+1;
end
end
end
end
if st_mobileStations(lp_nmob).RemFileSz(st_testConfig.nFrmCntSlot)<=0
new_mobile_handles = [new_mobile_handles lp_nmob];% Store the mobile handle number
% to be used in channel creation
MobileIdCnt=MobileIdCnt+1;
st_mobileStations(lp_nmob).MobNumber(st_testConfig.nFrmCntSlot) = MobileIdCnt;
st_mobileStations(lp_nmob).RemFileSz(st_testConfig.nFrmCntSlot)=st_testConfig.MaxFileSz;
st_mobileStations(lp_nmob).ThptAvgPast = 1;% Past average throughput to be used in the PF algorithm
finished_locs(lp_nmob)=st_testConfig.locMS(lp_nmob);
st_testConfig.locMS(lp_nmob)=nan;
st_testConfig.veloMS(lp_nmob)=nan;
else
% Store the handles for the mobile handlers who will continue with
% the same old mobiles
old_mobile_handles=[old_mobile_handles lp_nmob];
end
end
st_baseStation.new_mobile_handles(1:length(new_mobile_handles))=new_mobile_handles;
if st_testConfig.nFrmCnt > 1
% % Plot location of mobiles which finished transmitting
figure(1);
hold on;
plot(finished_locs,'k.');
% % pause(1)
end
% Plot location of mobiles which have been terminated
figure(1);
hold on;
plot(bad_mobiles_loc,'rs');
% % pause(1)
% %title (['Cell Layout, Frm No = ' num2str(st_testConfig.nFrmCnt) ' out no = ' num2str(st_measurement.outageCnt) 'total bits = ' num2str(round(st_measurement.totalBitsSent)) ' Tot Users = ' num2str(MobileIdCnt)])
% title (['Frm No.=' num2str(st_testConfig.nFrmCnt-1) ' out=' num2str(st_measurement.outageCnt) ' bps/Hz=' num2str(round(st_measurement.totalBitsSent)/((st_testConfig.nFrmCnt-1)*st_testConfig.FramePeriod*st_testConfig.bw)) ' Nu Usrs=' num2str(MobileIdCnt) ' T=' num2str((st_testConfig.nFrmCnt-1)*st_testConfig.FramePeriod) 's' ' Mbps=' num2str(round(st_measurement.totalBitsSent)/((st_testConfig.nFrmCnt-1)*st_testConfig.FramePeriod*1024*1024)) ' KB=' num2str(round(st_measurement.totalBitsSent)/(8*1024))])
% xlabel(['Total chunks(blocks) in error=' num2str(st_measurement.totalFramesinError) ', BLER=' num2str(st_measurement.totalFramesinError/(st_testConfig.nFrmCnt*st_baseStation.nuSubChannels)) ])
%sprintf('\n Total Frames in Error = %d \n average FER = %f \n', st_measurement.totalFramesinError,st_measurement.totalFramesinError/(st_testConfig.nFrmCnt*st_baseStation.nuSubChannels))
% ['Frm No.=' num2str(st_testConfig.nFrmCnt-1) ' out=' num2str(st_measurement.outageCnt) ' bps/Hz=' num2str(round(st_measurement.totalBitsSent)/((st_testConfig.nFrmCnt-1)*st_testConfig.FramePeriod*st_testConfig.bw)) ' Nu Usrs=' num2str(MobileIdCnt) ' T=' num2str((st_testConfig.nFrmCnt-1)*st_testConfig.FramePeriod) 's' ' Mbps=' num2str(round(st_measurement.totalBitsSent)/((st_testConfig.nFrmCnt-1)*st_testConfig.FramePeriod*1024*1024)) ' KB=' num2str(round(st_measurement.totalBitsSent)/(8*1024))]
% as of now this function will create a random drop of users this will be
% changed very soon where users who have finished trasmitting will quit the
% system while new users will join: This latter part has been accomplised
% [st_testConfig.locMS,st_testConfig.veloMS]=mobmove(st_testConfig.locMS,st_testConfig.veloMS,st_testConfig.aMean,st_testConfig.vMean,st_testConfig.dT,st_testConfig.rombvec/st_testConfig.coverageReductionFactor);
[st_testConfig.locMS,st_testConfig.veloMS]=mobmoveScale(st_testConfig.locMS,st_testConfig.veloMS,st_testConfig.aMean,st_testConfig.vMean,st_testConfig.dT,st_testConfig.rombvec,st_testConfig.centerBsLoc);
% %The next block of codes checks if the new user added should be allocated
% %to the desired base station! This is done by comparing the signal power of
% %all base stations at the new mobile location. If the highest power is that
% %due to the current base station, then ok, otherwise, the new mobile is not
% %put under the desired base station and a new mobile is generated for this
% %handler
%
%
% % Store the location and velocities of the old mobiles. This is needed,
% % since the mobmove function will be called several times and location of
% % the old mobiles would get updated, which is not desired. Therefore the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -