LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Limit the bandwidth used by an IP Address in Squid3(Ubuntu 10.04) (https://www.linuxquestions.org/questions/linux-newbie-8/limit-the-bandwidth-used-by-an-ip-address-in-squid3-ubuntu-10-04-a-833479/)

vijith.pa@gmail.com 09-21-2010 01:34 AM

Limit the bandwidth used by an IP Address in Squid3(Ubuntu 10.04)
 
hai guys,
i configured Squid3 server in my Ubuntu 10.04.Now the ip based and content based blocking is working fine.Now i want to configured bandwidth allocation of ip address and group ip address..pls give the solution

with regards
Vijtih P A

prayag_pjs 09-21-2010 01:50 AM

For this you have to user Bandwidth Throttling in Squid.

It is done using Delay Pools. Delay pools uses bucketing system.

Quote:

Delay pool --- Defines how many pools we want to use
Delay Class ---- Defines type of the pool you are going to use.
Delay Parameter � allots the restrictions and fill rate/maximum bucket size.
Quote:

Class 1 pool: A single aggregate bucket, shared by all users
Class 2 pool: One aggregate bucket, 256 individual buckets
Class 3 pool: One aggregate bucket, 256 network buckets, 65,536 individual buckets
Quote:

For Class 1 delay pool
delay_parameters 1 32000/32000

For Class 2 delay pool
delay_parameters 1 48000/48000 48000/48000

For Class 3 delay pool
delay_parameters 2 32000/32000 8000/8000 16384/16384
Example Setup:

Quote:

One 512Kbps pipe line. We want to distribute the whole pipe line into 2. One for normal users and other for special users as follows
Normal users --- 128 Kbps
Special Users --- 384 Kbps
Configuration Setup File

Code:

/etc/squid/squid.conf
Before getting into the delay pools setup first create the acl(Access Control List). Through acl you can define rules according to your requirements. Find the Access Control section in the squid.conf file.

Here is an example:

Code:

acl superusers src  192.168.1.1 192.168.1.2 192.168.1.3
acl mynetwork src  192.168.1.0/255.255.255.0

Here in the above example only three users are special users who need 256Kbps bandwidth which are listed in the specialusers label and the whole network including he special users are labeled as mynetwork.

After creating the users you have to allow them to access the internet. Below line specifies for allowing the mentioned labeled users.

Code:

http_access allow superusers
http_access  allow mynetwork

Now comes the funny part Delay Pools. Here We will deal with a basic example for delay pools.

The example is as follows: We are having 512Kbps pipe line connection. We want to divide it into segments one for the special users, web servers and the other for the normal users in the organization. The special users and the web servers are given 384Kbps speed and the remaining 128Kbps for the normal users.

Delay Pools for super users:
Check for the delay pools section in the squid.conf file.
Start the configuration for delay pools as follows
==================================
########## Delay Pools############
==================================

Code:

delay_pools  2
As described above we have to create 2 delay pools, one for each delay class.
====================================================
######### Defining Delay pool 1 in class 2 #########
====================================================

Code:

delay_class  1 2
delay_parameters 1 48000/48000 48000/48000
delay_access 1  allow superusers

The first line specifies Delay Class which defines delay pool 1 for the delay class 2.

Why we are using delay class 2 here?

The first part on the second line ie defines the pool One(1)

The second part on second line defines the aggregate 48000/48000(restore/max). where restore is the number of bytes (not bits - modem and network speeds are usually quoted in bits) per second placed into the bucket, and maximum is the maximum number of bytes which can be in the bucket at any time.

The third part on second line is individual buckets again 48000/48000(restore/max). All the special users and the web servers should obtain the same speed of 384 Kbps.

The third line allows the super users to fall in that bucket.

=====================================================
######### Defining Delay pool 2 in class 3 #########
=====================================================

Delay Pools for normal users:

Code:

delay_class 2 3
delay_parameters 2  32000/32000 8000/8000 16384/16384
delay_access 2 allow !superusers

The first line specifies Delay Class which defines delay pool 2 for the delay class 3.

The first part on the second line defines the pool Two(2) of class three(3)

The second part on second line defines the aggregate 32000/32000(restore/max) as aggregate (ie for whole).

The third part on second line is network bucket. We have defined here 8000/8000 .

The fourth part on second line is for individual.

The third line specifies to throttle all the users except the super users.

How to check:

First set proxy settings in your browser as follows:
Go to any client machine and open an IE(Internet Explorer).

Quote:

Select "Tools" menu then select "Internet Options" then select "Connections" tab. After that select the "LAN Settings" button, you will get a new pop-up window there you select "Use proxy server for your LAN" check box and finally give your squid proxy servers ip address and the port on which the squid proxy server is configured. Now press "OK" and again press "OK". Close the window and now open a new window.
Second Check by downloading any large file.Start to download any lage file not less than 10MB size. Because when ever you download any small file it used to download it quickly. When you start downloading large file at first if you note some starting bytes of the file gets downloaded quickly and later it gets slowed down.

Keep a note on the download pop-up box which shows the speed limits in "kbps". When we start downloading note on the pop-up box the speed limits in kbps shows high value and then slowly gets decreased. This means when you start downloading the bucket gets filled and slowly it decreases and becomes stable to the specified limit in Kbps according to the configuration. Remember again as i told restore value is used to set the download speed, and the max value lets you set the size at which the files are to be slowed down from.

vijith.pa@gmail.com 09-21-2010 04:41 AM

thanks prayag........
i have one doubt remaining...
whether it will effect speed of LAN Copying (System to system)?

prayag_pjs 09-21-2010 04:45 AM

No it should not affect.Squid controls HTTP traffic

vijith.pa@gmail.com 09-21-2010 04:59 AM

hai prayag,

can u explain detail in "delay_parameters 2 32000/32000 8000/8000 16384/16384"

i think 32000/32000 is aggregate speed
16384/16384 is a normal user speed

whatz that 8000/8000?

prayag_pjs 09-21-2010 05:04 AM

The third part on second line is network bucket. We have defined here 8000/8000 . Its used just for example.

leejohnli 09-21-2010 05:46 AM

Hi,
How do you define on squid if i want to delay pool using Class 1 pool: A single aggregate bucket, shared by all users. Tnx

prayag_pjs 09-21-2010 05:51 AM

Hi,

Above example was for reference you have to refer it and try the configurations yourself fist then if you face any problem in installing the services,we are here to help you.

Also do Googling for getting the concepts clear.Learn by doing practically the above configuration.

vijith.pa@gmail.com 09-21-2010 08:14 AM

hai prayag,
here i implement bandwidth allocation in My Company....
Butz not loading even google page

My configuration
ACl Conf
acl superusers src 192.168.1.100 192.168.1.6 192.168.1.3
acl lan src 192.168.1.0/24
http_access allow superusers
http_access allow lan
delay pool conf
delay_pools 2
delay_class 1 2
delay_parameters 1 150000/150000 150000/150000
delay_access 1 allow superusers
delay_class 2 3
delay_parameters 2 110000/110000 8000/8000 100000/100000
delay_access 2 allow !superusers

Net details 2Mbps connection
super user can download limit upto 1.2Mbps normal user 800Kbps
whether my configuration is correct?


All times are GMT -5. The time now is 01:02 PM.