0% found this document useful (0 votes)
3 views1 page

Week6 CN

The document is a C program that simulates a bucket-based packet storage system. It prompts the user for bucket size, output rate, and the number of packets, then processes each packet to determine if it can be stored or if it gets dropped due to congestion. The program also calculates and displays the number of transmitted packets and remaining packets in the bucket after each input.

Uploaded by

saipriyadevansh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Week6 CN

The document is a C program that simulates a bucket-based packet storage system. It prompts the user for bucket size, output rate, and the number of packets, then processes each packet to determine if it can be stored or if it gets dropped due to congestion. The program also calculates and displays the number of transmitted packets and remaining packets in the bucket after each input.

Uploaded by

saipriyadevansh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#include<stdio.

h>

int main()
{
int bucket_size, output_rate, input_pkt, storage = 0;
int i, n;

printf("Enter bucket size: ");


scanf("%d",&bucket_size);

printf("Enter output rate: ");


scanf("%d",&output_rate);

printf("Enter number of packets: ");


scanf("%d",&n);

for(i=1;i<=n;i++)
{
printf("Enter packet size: ");
scanf("%d",&input_pkt);

if(storage + input_pkt > bucket_size)


{
printf("Packet dropped (Congestion)\n");
}
else
{
storage = storage + input_pkt;
printf("Packet stored in bucket\n");
}

if(storage < output_rate)


{
printf("Transmitted packets = %d\n",storage);
storage = 0;
}
else
{
printf("Transmitted packets = %d\n",output_rate);
storage = storage - output_rate;
}

printf("Packets remaining in bucket = %d\n",storage);


}

return 0;
}

You might also like