 Welcome to the another session of Conjection Control. In this session I will explain leaky bucket algorithm which is the most important algorithm provided by provided for conjection control. Learning outcome at the end of the session student will be able to describe conjection prevention policies and the concept of traffic shaping. They will also illustrate the conjection control algorithm that is leaky bucket algorithm. So let us see conjection control policies. Open loop system conjection control are designed to minimize the conjection in the first place rather than letting it happen and reacting after the fact. They try to achieve their goal by using the appropriate policies at various levels. There are different data link, network and transport layer policies that can affect the conjection. So let us see these policies. So I will start it from the bottom layer that is data link layer. So data link layer provides the conjection prevention policies like transmission policy, out of order caching policy, acknowledgement policy, flow control policy. Then the network layer provide the virtual circuit subnet, then packet queuing and service policy, then packet discard policy, routing algorithm and packet lifetime management policy. Now the next layer that is transport layer it provide the policies same as that of the data link layer policies. Only one policy is extra here that is timeout, timeout determination policy. So we have already seen all these policies in detail in my previous video. Now let me explain the very important topic of conjection control that is traffic shaping. So traffic shaping is the mechanism to control the amount and the rate of the traffic sent to the network. Approach of conjection management is called traffic shaping. This shaping helps to reduce the average rate and burstiness of the data transmission and it reduce the conjection. Traffic shaping is also known as packet shaping. It is a conjection mechanism method that regulates the network data transfer by delaying the flow of less important or the less desired packet. It is used to optimize the network performance by prioritizing the certain traffic flow and ensuring the traffic rate which does not exceed the bandwidth limit. When the connection is set up the user and the subnet agree a certain traffic pattern which is called as shape for that circuit. So sometimes this is also called as service level agreement. This agreement are not so important for the file transfer but are a great importance for the real time data such as audio and video connection which have stringent quality of service requirement. Monitoring a traffic flow is called the traffic policing. Now let's see there are two types of traffic shaping algorithm. The first one is leaky bucket algorithm and the another one is token bucket algorithm. The leaky bucket algorithm first proposed by Turner in 1986. It is a single server queuing system with constant service time. Now look at this diagram. In this diagram leaky bucket is shown with the water. Now when the water coming out is in a some fixed rate and if the bucket will full will stop pouring in it. Now just consider in this bucket in this bucket the water is thrown with the in regulated flow right. But from this leaky bucket the water is dripped out of the hole at the constant rate. Now once the bucket is full will stop pouring the water why because if we still pour the water the water is spilled out or we can say that the water is wasted right. So here the input rate can vary but the output rate remains constant. Now look at this diagram similarly or in the networking also the host is allowing to put one packet per clock tick onto the network. This mechanism turns an unseen flow or the uneven flow of packet from host into an even flow of packets onto a network. It smooth the bursty traffic and reduces the chance of conjection. Now look at this diagram. In this diagram the packets or the unregulated flow of packets is coming from the host computer and it is go to the interface which contain the leaky bucket. Now this bucket holds the packets right and it sends the packet one by one with one clock tick or this is what this shows what there is the regulated flow. So before leaky bucket there is a unregulated flow and after leaky bucket there is a regulated flow and this regulated flow is provided to the network. So this is the actual concept of leaky bucket algorithm. Now the size of the packet are same as that of the ATM sales. ATM sales is the virtual circuit and which is having a sale size of fixed sale size right. Then the size of the packet are variable so it is better to allow the fixed number of byte per tick rather than just one packet. So just pause the video and write down your answer. A leaky bucket algorithm shapes bursty traffic into fixed rate traffic by averaging the dash. So the options are data rate, average rate, traffic rate and traffic shaping and the answer is data rate. Now look at the algorithm of leaky bucket. Now the following is an algorithm for variable length packet because what we require? We require the algorithm only for the variable length not for the fixed length packet. So the first step is initialize the counter to n at the tick of the clock. Second step is if n is greater than the size of the packet send the packet and decrement the counter by the packet size. First step is repeat this step until n is smaller than the packet size and the fourth one is reset the counter and go to the step number one. Now let me explain this with the example. Let n is said to as a thousand ok. So we can say that n is a counter and it is said to as a thousand. Now the packets are there are total 6 packets ok, there are total 6 packets having the number of bytes. So 200, 700, 500, 450, 400 and 200 that is the size. Now since n is greater than front of the queue. So what is this front of the queue? Now look at this 200 is a front of the queue ok. So here n equal to thousand. So obviously front of the queue is what less than n. So what is our algorithm we need to minus the front of the queue from your n. So here n minus 200 that is 800. Now the new value of the n is what 800. So the packet size of 200 is sent to the network ok. So this 200 is sent to the network. Now how many packets are remain here? Only 5. Now again n is greater than front of the queue that is 400. So front of the queue is 400 and what is n value that is 800. So n equal to 800 minus 400 that is 400. So now new value of n equal to what 400. So packet size of 400 is sent to the network and how many packets are remain here? Only 4. Now look at the front of the queue that is 450. So since n is less than front of the queue therefore the procedure is stop. Now what is the value of n 400 and what is the value of front of the queue that is 450. So obviously 450 is greater than n. So what we need to stop the procedure here. Then initialize the n equal to thousand on another tick of clock and this procedure is repeated until all the packets are sent to the network. So this is leaky bucket algorithm. Now look at these two diagrams. So in first diagram or in this first graph the input to the leaky bucket and the another graph shows the output from the leaky bucket. Now what is the difference here is in this first graph the bursty data is shown. So here host transmitted the 12 Mbps data for 2 milliseconds sorry for 2 seconds then the host is silent for the 5 second and again it transmit the 2 Mbps data for next 3 seconds. So in this way it transmit the data in 10 seconds. So it is what this is the input to the leaky bucket which is what which is unregulated flow. Look at the another diagram in this diagram the fixed data is transmitted after or which is the output of the leaky bucket. So here here the data 3 Mbps data is transmitted for all 10 seconds. So can we say that this is the regulated flow? Yes this is the regulated flow means after applying the leaky bucket. So this is just now I told you the explanation. So in all the host has sent the 30 Mbps of data in 10 seconds. Now the leaky bucket smooths the traffic by sending out the data at the rate of 3 Mbps during the same 10 seconds. Without leaky bucket the beginning burst may have heard the network by consuming the more bandwidth than it set aside for this host. And the leaky bucket also prevent the conjection. A simple leaky bucket algorithm can be implemented using first in first out queue. A first in first out queue holds the packet. These are the references which I have used for the above material.