Professional Documents
Culture Documents
THEORY:-
When a packet violates the contract, network can discard or tag the packet giving it The process
of monitoring and enforcing the traffic flow is called policing. Network monitors traffic flows
continuously to ensure they meet their traffic contract. lower priority Leaky Bucket Algorithm is
the most commonly used policing mechanism If congestion occurs, tagged packets are discarded
first o Bucket has specified leak rate for average contracted rate o Bucket has specified depth to
accommodate variations in arrival rate o Arriving packet is conforming if it does not result in
overflow Leaky Bucket algorithm can be used to police arrival rate of a packet stream.
The above figure shows the leaky bucket algorithm that can be used to police the At the arrival of
the first packet, the content of the bucket is set to zero and the lasttraffic flow. The depth of the
bucket is L+I, where l depends on the traffic burstiness.conforming time (LCT) is set to the arrival
time of the first packet.
At the arrival of the kth packet, the auxiliary variable X’ records the difference between the bucket
content at the arrival of the last conforming packet and the If the auxiliary variable is greater than
L, the packet is considered as nonconforming,interarrival time between the last conforming
packet and the kth packet. otherwise the packet is conforming. The bucket content and the arrival
time of the packet are then updated.
CODE:-
#include<stdio.h>
#include<conio.h>
void main()
int i,j,size,st,num,packet[10];
clrscr();
scanf("%d",&num);
scanf("%d",&size);
for(i=num-1;i>=0;i--)
scanf("%d",&packet[i]);
storage=size;
for(i=num-1;i>=0;i--)
if(packet[i]<=st)
st-=packet[i];
}
else
printf("as packet size is higher %d packet cannot be passed, wait for next clock cycle",packet[i]);
st=size;
st-=packet[i];
printf("\n");
getch();
OUTPUT:-
CONCLUSION:-. The leaky bucket algorithm is a method of temporarily storing a variable
number of requests and organizing them into a set-rate output of packets in an asynchronous
transfer mode (ATM) network. Thus we have implemented the leaky bucket algorithm for
congestion control.