- #include<stdio.h>
- #include<stdlib.h>
- #include<unistd.h>
- void bktInput(int a, int b, int size) {
- int time = 0;
- if (a > size)
- printf("\nBucket Overflow.\n");
- else {
- sleep(1);
- time++;
- printf("\n---------------------------\n");
- while (a > b) {
- printf("\nTime %d Sec", time);
- printf("\n%d bytes Outputted\n", b);
- a -= b;
- sleep(1);
- time++;
- }
- printf("\nTime %d Sec", time);
- if (a > 0)
- printf("\nLast %d bytes Sent\n", a);
- printf("\nBucket Output Successful.");
- printf("\n____________________________________________\n");
- }
- }
- int main() {
- int time = 0;
- int OR, PS, i, BS, n, delay;
- printf("____________________________________________");
- printf("\nC Program For Congestion Control Algorithm ");
- printf("\n____________________________________________");
- printf("\nEnter Bucket Size ");
- scanf("%d", &BS);
- printf("\nEnter Output Rate ");
- scanf("%d", &OR);
- printf("\nEnter Number Of Packets ");
- scanf("%d", &n);
- for (i = 0; i < n; i++) {
- delay = (rand() % 10);
- usleep(delay);
- time = time + delay;
- PS = rand() % 1000;
- printf("\n---------------------------");
- printf("\nTime %d Sec", time);
- printf("\nPacket Number %d\nPacket Size %d", i, PS);
- bktInput(PS, OR, BS);
- }
- return 0;
- }
[text] leaku
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: