1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| double SimulationMux(double L)
{
int k,T=8620,A,m=20,S,C;
double MD;
//printf("foo 2");
//C stand for buffer occupancy
//S= sum of the queue size
int N=m*T;//simulation for an integer number of periods, i.e., mT time slots
//for timeslot = 1 to infinity,there is 8620 timeslots every 5,875ms(packetization delay)
for(k=0;k<N;k++)
{
if(k==0) { C=0;}
// printf("kboucle1=%d ",k);
//figure out how many of the sources generate an arrival NOW
//this is the number of arriving cells - use the equation of evolution
//to figure out the new buffer occupancy
A=ArrivalFromSources(k,L);
//printf("number of arrival = %d \n",A);
C=BufferOccupancy(A,C);
//printf("buffer occupancy = %d \n",C);
//sum of the queue size :
if(C<0) printf("C est negatif %d\n",C);
S+=C;
//printf(" S=%d\n",S);
}
// if(S<0){S=-S;}
//printf(" S=%d\n",S);
//mean delay
MD=Delay(S,N)+5.875;
//printf("%lf",MD);
return MD;
}
int BufferOccupancy(int A,int C)
{
int Cf;
Cf=C+A-1;
if(Cf<0) Cf=0;
//printf("A=%d\n",A);
return Cf;
} |
Partager