performs the transmission between users and bs INPUT par general parameters structure bs structure of base-stations mob structure of mobiles msg structure of messages t time index of the simulation OUTPUT mob mobiles structure msg messages structure $Id: transmit_bs.m,v 1.4 2004/07/16 01:58:31 dalai Exp $
0001 % performs the transmission between users and bs 0002 % 0003 % INPUT 0004 % par general parameters structure 0005 % bs structure of base-stations 0006 % mob structure of mobiles 0007 % msg structure of messages 0008 % t time index of the simulation 0009 % 0010 % OUTPUT 0011 % mob mobiles structure 0012 % msg messages structure 0013 % 0014 % 0015 % $Id: transmit_bs.m,v 1.4 2004/07/16 01:58:31 dalai Exp $ 0016 0017 function [mob,msg_mcn,msg_std] = transmit_bs(par,bs,mob,msg_mcn,msg_std,t) 0018 0019 % simplified notations 0020 bs_xy = [bs(:).xy]; 0021 % usr = reshape(struct2array(rmfield(mob,{'msg_mcn' 'msg_std' 'vstate' 'buffer_mcn' 'buffer_std' 'buffer_self'}))',t+1,2,par.mob); 0022 % usr_xy(1:par.mob) = usr(t+1,1,1:par.mob); 0023 usr = reshape([mob(:).xy],t+1,par.mob)'; 0024 usr_xy(1:par.mob) = usr(1:par.mob,t+1); 0025 0026 % deterministic path loss 0027 dist = abs([repmat(usr_xy',1,par.bs) - repmat(bs_xy,par.mob,1)]); 0028 0029 % find the mobiles close enough to bs to transmitt 0030 [mob_near,bs_near] = find(dist<par.cov_bs); 0031 0032 % for each neighboor 0033 for idx=1:length(mob_near) 0034 %%% the multihope case %%% 0035 % find the messages to be transmitted 0036 msg2trsmit_mcn = find(mob(mob_near(idx)).msg_mcn(:)>=0); 0037 % for all messages to be transmitted 0038 for mcn_idx = 1:length(msg2trsmit_mcn) 0039 % transmitt to the bs : 0040 % stop time for message 0041 msg_mcn(msg2trsmit_mcn(mcn_idx)).time_delivered = t; 0042 % the number of hops performed when delivered 0043 msg_mcn(msg2trsmit_mcn(mcn_idx)).nbr_hop = mob(mob_near(idx)).msg_mcn(msg2trsmit_mcn(mcn_idx)); 0044 % erase the message from the whole network 0045 for mob_idx=1:par.mob 0046 mob(mob_idx).msg_mcn(msg2trsmit_mcn(mcn_idx)) = -inf; 0047 end 0048 end 0049 0050 %%% the standard case %%% 0051 % find the messages to be transmitted 0052 msg2trsmit_std = find(mob(mob_near(idx)).msg_std(:)==0); 0053 % for all messages to be transmitted 0054 for std_idx = 1:length(msg2trsmit_std) 0055 % transmitt to the bs : 0056 % stop time for message 0057 msg_std(msg2trsmit_std(std_idx)).time_delivered = t; 0058 % the number of hops performed when delivered 0059 msg_std(msg2trsmit_std(std_idx)).nbr_hop = mob(mob_near(idx)).msg_std(msg2trsmit_std(std_idx)); 0060 % erase the message from the whole network 0061 % we should not need this loop as the message is not spread in the network 0062 % as for the multihop case, but I let it as it is not disturbing and let coherent notations. 0063 for mob_idx=1:par.mob 0064 mob(mob_idx).msg_std(msg2trsmit_std(std_idx)) = -inf; 0065 end 0066 end 0067 0068 end