






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This lab report is for System Engineering course. It was submitted to Katyayani Yatindra at Bengal Engineering and Science University. It includes: Markov, Chain, System, Transitions, Memorylessness, Algorithm, Server, Packets, Random, Variable
Typology: Exercises
1 / 12
This page cannot be seen from the preview
Don't miss anything!







lambda=1; mu=2; s=exprnd(1/lambda,[1 N]); a=exprnd(1/mu,[1 N+1]);
t(1)=0; for i=1:N t(i+1)=t(i)+s(i); end packet=0; block=0; sertime=a(1); inittime=t(1); P(1)=0; for i=1:N if inittime+sertime > t(i+1) block=block+1; if i==N totaltime=inittime+sertime; end end if inittime+sertime < t(i+1) P(1)=P(1)+sertime; sertime=a(i+1); inittime=t(i+1); if i==N totaltime=t(i+1)+a(i+1); end end end P(1)=P(1)/(totaltime); P(2)=1-P(1) block
else itime(k)=t(i); stime(k)=a(i); serocc(k)=2; end end end for k=1:totalservers if serocc(k)==1 || serocc(k)== if itime(k)+stime(k) < t(i+1) time(k)=itime(k)+stime(k); itime(k)=0; stime(k)=0; serocc(k)=0; ts=[ts;time(k)]; else tg=tg+1; serocc(k)=1; end end end pmin=-min(ts(1:length(ts))); q=0; tpr=t(i); if length(ts) > 0 for k=1:length(ts) P(length(ts)+tg-q)=P(length(ts)+tg-q)+nmin-pmin-tpr; tpr=0; if ts(k) > min(ts(k:length(ts))) temp=ts(k); for qa=k:length(ts) if ts(qa)==min(ts(k:length(ts))) break; end end ts(k)=ts(qa); ts(qa)=temp; end nmin=min(ts(k+1:length(ts))); q=q+1; pmin=min(ts(k:length(ts))); end end if length(ts)==0 && tg > 0 P(length(ts)+tg-q)=P(length(ts)+tg-q)+t(i+1)-t(i); elseif length(ts)==q && tg> P(length(ts)+tg-q)=P(length(ts)+tg-q)+t(i+1)-max(ts); end end P=P/(t(N+1)); sum=0; for i=totalservers+1:-1: P(i)=P(i-1) ; sum=sum+P(i); end P(1)=1-sum; P
Algorithm:
Note:
Results:
a(i)=aB(iB); iB=iB+1; packet(i)=2; end end if iA == N+ if iB < N+ t(i)=tB(iB); iB=iB+1; end elseif iB == N+ if iA < N+ t(i)=tA(iA); iA=iA+1; end end end block=0; terminate=0; for i=1:(2*(N+1)) if packet(i) == 1 busy=0; for k=1:totalservers if ptype(k) == 0 ptype(k)=1; itime(k)=t(i); stime(k)=a(i); busy=1; break; end end if busy == 0 block=block+1; end elseif packet(i) == 2 busy=0; for k=1:totalservers if ptype(k) == 0 ptype(k)=2; itime(k)=t(i); stime(k)=a(i); busy=1; break; end end if busy == 0 for k=1:totalservers if ptype(k) == 1 ptype(k)=2; itime(k)=t(i); stime(k)=a(i); busy=2; break; end end end
if busy == 0 block=block+1; elseif busy == 2 terminate=terminate+1; end end for k=1:totalservers if i < (2(N+1)) if itime(k)+stime(k) < t(i+1) ptype(k)=0; end else ptype(k)=0; end end end perception=terminate/(2(N+1)) actual=terminate/((2*(N+1))-block) block terminate
totalservers=3; itime=zeros(1,totalservers); stime=zeros(1,totalservers); ptype=zeros(1,totalservers); lambdaA=1; muA=1; lambdaB=1; muB=1; N=9999; sA=exprnd(1/lambdaA,[1 N]); sB=exprnd(1/lambdaB,[1 N]); aA=exprnd(1/muA,[1 N+1]); aB=exprnd(1/muB,[1 N+1]); tA(1)=0; tB(1)=.1; for i=1:N tA(i+1)=tA(i)+sA(i);
for k=1:totalservers if ptype(k) == 0 ptype(k)=2; itime(k)=t(i); stime(k)=a(i); busy=1; break; end end if busy == 0 for k=1:totalservers if ptype(k) == 1 ptype(k)=2; itime(k)=t(i); stime(k)=a(i); busy=2; break; end end end if busy == 0 block=block+1; elseif busy == 2 terminate=terminate+1; end end for k=1:totalservers if i < (2(N+1)) if itime(k)+stime(k) < t(i+1) if ptype(k) == 1 timeA=[timeA;stime(k)]; end ptype(k)=0; end else ptype(k)=0; end end end perception=terminate/(2(N+1)); actual=terminate/((2(N+1))-block); A_packets_blocked=block-terminate A_packets_terminated=terminate A_packets_serviced=sum(timeA)/(t(-1+2(N+1))) Average_packet_length_A=sum(timeA)/(N-terminate+1) hist(sA,100) title('actual distribution of A') figure hist(timeA,100) title('distribution of packet A which were served')
prob = (N+1-terminate-block)/(N+1-block) Results: