#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
int main()
{
int
i,packets[10],content=0,newcontent,time,clk,bucketsize,operate;
for(i=0;i<5;i++)
{
packets[i]=rand()%10;
if(packets[i]==0)
--i;
}
printf("\n enter the output
rate of the bucket:\n");
scanf("%d",&operate);
printf("\n enter the
bucket size\n");
scanf("%d",&
bucketsize);
for(i=0;i<5;i++)
{
if((packets[i]+content)>bucketsize)
{
if(packets[i]>bucketsize)
printf("\n incoming packetsize %d
greater than the size of the bucket\n",packets[i]);
else
printf("\n bucket size exceded\n");
}
else
{
newcontent=packets[i];
content+=newcontent;
printf("\n incoming packets:%d\n",newcontent);
printf("\n transmission left:%d\n",content);
time=rand()%10;
printf("\n next packets will come out %d\n",time);
for(clk=0;clk<time && content>0;++clk)
{
printf("\n left time%d",(time-clk));
if(content)
{
printf("\n transmitted\n");
if(content<operate)
content=0;
else
content=content-operate;
printf("\n bytes
remaining:%d\n",content);
}
else
printf("\n
no packets to send\n");
}
}
}
getch();
}
No comments:
Write comments