function [ R_V2I_final,t_V2I_stay ] = VEC_trans (V_n_location, V_n_speed, V_n_size)
    %global N0
    B_V2I=1 % 1MHz
    P_t= 1.3 % 1.3W
    sigma=2
    h=4 % reference this paper 2018 Dynamic Offloading Scheduling Scheme for MEC-enabled Vehicular Networks
    No= 3*10^-13;
    e=100; % 100m
    r=200;   % 200m
    v_abs_t= 16.6667     % 16.6667m/s which is 60km/h

        
        for i=1:V_n_size
            s=2*sqrt(r^2-e^2)   % distance of vehicle running in the coverage area of RSU
            t_V2I_stay(i)=s/V_n_speed(i); % Time during the vehicele being in the coverage area of RSU
            stay=t_V2I_stay(i);
            R_V2I_initial=1;
            time=1;
            j=1;
            while stay>0
                d_n_rsu(j)=sqrt(e^2+(s/2-V_n_speed(i))^2)    %The distance changes with time of source vehicle.
                R_V2I_initial = R_V2I_initial+ (B_V2I*log2(1+((P_t*d_n_rsu(j)^-sigma*h^2)/No)));    %Uplink data rate is
                s=s-V_n_speed(i)
                V_n_location=V_n_location+V_n_speed;
                j=j+1 
                time=time+1;
                stay=stay-1;
            end
            R_V2I_avg=R_V2I_initial/length(d_n_rsu)    %Taking average of all the distances transmission of each time instance
            R_V2I_final(i)= (R_V2I_avg)/ t_V2I_stay(i);    %The V2I average uplink rate 
        end
end
