CBQ

From StarOS Community Wiki
Jump to: navigation, search

QShape[edit]

Assuming you have a working StarOS AP setup with associated clients.

1. Using putty, log-in to your StarOS router. 
2. Click Advanced > Scripts > class based queuing (cbq / bw management)

First you will need to set some variables...

  • "Net" will equal your router's gateway interface.
  • "Client" will equal the interface to which your clients (customers) associate.

These values could be… ether (Ethernet), wpci (mini pci), or wlan (pcmcia) interfaces; this will depend on your specific configuration.

Let's assume “net” is your ether1 and your clients connect to wpci1.

Indicate which interface is net and which interface is client

3. at the top of the script type...

# Variables
net = ether1
client = wpci1
  • Use a # sign to put comments in your script to document what you did.

Now you can start limiting your customer’s bandwidth speeds by adding a simple qshape script.

StarOS simple qshape example:[edit]

First you should understand some of the commands and what they mean.

qshape user 100 bw 128k 56k 192.168.10.1 on $client

qshape = The qshape command

user = The user name you have specified for the customer. This value can be anything you want.

100 = Bandwidth pipe number. In this instructional each customer will get their own unique pipe. bw 128k 56k = Bandwidth equals 128kbps download and 56kbps upload. The speeds can be anything you want, but the syntax has to be as displayed in the example.

192.168.10.1 = The IP address of the customer’s PC/Router that you are wanting to qshape.

on = This is self explanatory.

$client = This is the interface that the client is associated. The "$" symbol indicates that this value has been bound.

More Advanced Usage[edit]

Now you are ready to start limiting your customer’s download and upload speeds.

4. Go to the next available line and type…

qshape asmith 100 bw 1024k 512k 192.168.10.1 on $client
  • this qshape rule indicates that asmith’s pipe (pipe 100) has been limited to 1mbps download / 512kbps upload.
  • His PC/Router’s IP address is 192.168.10.1
  • His CPE is associated to your AP’s wpci1 interface.


Let’s do another customer. This customer has two static IP addresses. We need to limit both addresses to the same pipe so that they do not go over their allocated bandwidth.

5. Go to the next available line and type…

qshape bsmith 101 bw 2048k 1024k 192.168.10.2 on $client
qshape bsmith 101 192.168.10.3 on $client
  • this qshape rule indicates that Bob Smith’s pipe (pipe 101) has been limited to 2mbps download / 1mbps upload.
  • Both of this customer’s IP addresses share pipe 101’s total bandwidth.

When we combine what we have done so far, your cbq script should look like this…

# Variables 
net = ether1
client = wpci1

# QShape Rules
qshape asmith 100 bw 1024k 512k 192.168.10.1 on $client
qshape bsmith 101 bw 2048k 1024k 192.168.10.2 on $client
qshape bsmith 101 192.168.10.3 on $client


Other variables can be set to make life easier, for example:

lite = “bw 512k 128k”
basic = “bw 1024k 512k”
plus = “bw 1024k 1024k”
premium = “bw 2048k 1024k”


With this variables set, your rules would now read…

# QShape Rules
qshape asmith 100 $basic 192.168.10.1 on $client
qshape bsmith 101 $premium 192.168.10.2 on $client
qshape bsmith 101 192.168.10.3 on $client


Or you could qshape an entire subnet to a specific pipe.

qshape csmith 102 $plus 10.128.0.0/24 on $client


Or you could add an entire range of clients to individual pipes:

 qshape 110:150 $basic 192.168.10.10 on $client
  • This would create 40 rules starting at 192.168.10.10 and ending at 192.168.10.50.


Our new script looks like this…

# Variables 
net = ether1
client = wpci1

lite = “bw 512k 128k”
basic = “bw 1024k 512k” 
plus = “bw 1024k 1024k”
premium = “bw 2048k 1024k”

# QShape Rules 
qshape asmith 100 $basic 192.168.10.1 on $client
qshape bsmith 101 $premium 192.168.10.2 on $client
qshape bsmith 101 192.168.10.3 on $client
qshape csmith 102 $plus 10.128.0.0/24 on $client
qshape 110:150 $basic 192.168.10.10 on $client


Hopefully this will make qshaping a little more clear and give you a head-start with more advanced shaping scripts.

Oh, and never ever activate a script until you have checked your syntax. Just click the button that says "syntax check"