function y = thr(RTT,b,p,To,L,d,ind)

% Variables:
%
% -For regular TCP formula:
% RTT - roundtrip time
% b - update interval
% p - probability of loss
% To - timeout period
%
% -For misbehaving RCP formula in addition we have:
% L - increase parameter
% d - decrease parameter (d=2 is regular TCP, d=1 -> no backoff)
% ind - indicator  =0 -> the square-root regular TCP formula
%                  =1 -> PFTK-standard TCP formula
%                  =2 -> RCP formula



c1=sqrt(2*b/3);
c2=3*sqrt(3*b/8);

c1r=sqrt((2*b*(d-1))/(L*(d+1)));
c2r=3*sqrt(((1+d)*(d-1)*b)/(2*d*d*L));


if ind == 0
y=1/(c1*RTT*sqrt(p));
end

if ind == 1
 if (c2*sqrt(p)<1)
     y=1/(c1*RTT*sqrt(p)+To*c2*sqrt(p)*(p+32*p*p*p));    
 else
     y=1/(c1*RTT*sqrt(p)+To*(p+32*p*p*p));
 end 
end

if ind == 2  
if (c2r*sqrt(p)<1)
     y=1/(c1r*RTT*sqrt(p)+To*c2r*sqrt(p)*(p+32*p*p*p));    
 else
     y=1/(c1r*RTT*sqrt(p)+To*(p+32*p*p*p));
 end 
end


