xref: /aosp_15_r20/external/iproute2/examples/README.cbq (revision de1e4e894b0c224df933550f0afdecc354b238c4)
1*de1e4e89SAndroid Build Coastguard Worker# CHANGES
2*de1e4e89SAndroid Build Coastguard Worker# -------
3*de1e4e89SAndroid Build Coastguard Worker# v0.3a2- fixed bug in "if" operator. Thanks [email protected].
4*de1e4e89SAndroid Build Coastguard Worker# v0.3a-  added TIME parameter. Example:
5*de1e4e89SAndroid Build Coastguard Worker#         TIME=00:00-19:00;64Kbit/6Kbit
6*de1e4e89SAndroid Build Coastguard Worker#         So, between 00:00 and 19:00 RATE will be 64Kbit.
7*de1e4e89SAndroid Build Coastguard Worker#         Just start "cbq.init timecheck" periodically from cron (every 10
8*de1e4e89SAndroid Build Coastguard Worker#         minutes for example).
9*de1e4e89SAndroid Build Coastguard Worker#         !!! Anyway you MUST start "cbq.init start" for CBQ initialize.
10*de1e4e89SAndroid Build Coastguard Worker# v0.2 -  Some cosmetique changes. Now it more compatible with
11*de1e4e89SAndroid Build Coastguard Worker#         old bash version. Thanks to Stanislav V. Voronyi
12*de1e4e89SAndroid Build Coastguard Worker#         <[email protected]>.
13*de1e4e89SAndroid Build Coastguard Worker# v0.1 -  First public release
14*de1e4e89SAndroid Build Coastguard Worker#
15*de1e4e89SAndroid Build Coastguard Worker# README
16*de1e4e89SAndroid Build Coastguard Worker# ------
17*de1e4e89SAndroid Build Coastguard Worker#
18*de1e4e89SAndroid Build Coastguard Worker# First of all - this is just a SIMPLE EXAMPLE of CBQ power.
19*de1e4e89SAndroid Build Coastguard Worker# Don't ask me "why" and "how" :)
20*de1e4e89SAndroid Build Coastguard Worker#
21*de1e4e89SAndroid Build Coastguard Worker# This is an example of using CBQ (Class Based Queueing) and policy-based
22*de1e4e89SAndroid Build Coastguard Worker# filter for building smart ethernet shapers. All CBQ parameters are
23*de1e4e89SAndroid Build Coastguard Worker# correct only for ETHERNET (eth0,1,2..) linux interfaces. It works for
24*de1e4e89SAndroid Build Coastguard Worker# ARCNET too (just set bandwidth parameter to 2Mbit). It was tested
25*de1e4e89SAndroid Build Coastguard Worker# on 2.1.125-2.1.129 linux kernels (KSI linux, Nostromo version) and
26*de1e4e89SAndroid Build Coastguard Worker# ip-route utility by A.Kuznetsov (iproute2-ss981101 version).
27*de1e4e89SAndroid Build Coastguard Worker# You can download ip-route from ftp://ftp.inr.ac.ru/ip-routing or
28*de1e4e89SAndroid Build Coastguard Worker# get iproute2*.rpm (compiled with glibc) from ftp.ksi-linux.com.
29*de1e4e89SAndroid Build Coastguard Worker#
30*de1e4e89SAndroid Build Coastguard Worker#
31*de1e4e89SAndroid Build Coastguard Worker# HOW IT WORKS
32*de1e4e89SAndroid Build Coastguard Worker#
33*de1e4e89SAndroid Build Coastguard Worker# Each shaper must be described by config file in $CBQ_PATH
34*de1e4e89SAndroid Build Coastguard Worker# (/etc/sysconfig/cbq/) directory - one config file for each CBQ shaper.
35*de1e4e89SAndroid Build Coastguard Worker#
36*de1e4e89SAndroid Build Coastguard Worker# Some words about config file name:
37*de1e4e89SAndroid Build Coastguard Worker# Each shaper has its personal ID - two byte HEX number. Really ID is
38*de1e4e89SAndroid Build Coastguard Worker# CBQ class.
39*de1e4e89SAndroid Build Coastguard Worker# So, filename looks like:
40*de1e4e89SAndroid Build Coastguard Worker#
41*de1e4e89SAndroid Build Coastguard Worker# cbq-1280.My_first_shaper
42*de1e4e89SAndroid Build Coastguard Worker# ^^^ ^^^  ^^^^^^^^^^^^^
43*de1e4e89SAndroid Build Coastguard Worker#  |  |            |______ Shaper name - any word
44*de1e4e89SAndroid Build Coastguard Worker#  |  |___________________ ID (0000-FFFF), let ID looks like shaper's rate
45*de1e4e89SAndroid Build Coastguard Worker#  |______________________ Filename must begin from "cbq-"
46*de1e4e89SAndroid Build Coastguard Worker#
47*de1e4e89SAndroid Build Coastguard Worker#
48*de1e4e89SAndroid Build Coastguard Worker# Config file describes shaper parameters and source[destination]
49*de1e4e89SAndroid Build Coastguard Worker# address[port].
50*de1e4e89SAndroid Build Coastguard Worker# For example let's prepare /etc/sysconfig/cbq/cbq-1280.My_first_shaper:
51*de1e4e89SAndroid Build Coastguard Worker#
52*de1e4e89SAndroid Build Coastguard Worker# ----------8<---------------------
53*de1e4e89SAndroid Build Coastguard Worker# DEVICE=eth0,10Mbit,1Mbit
54*de1e4e89SAndroid Build Coastguard Worker# RATE=128Kbit
55*de1e4e89SAndroid Build Coastguard Worker# WEIGHT=10Kbit
56*de1e4e89SAndroid Build Coastguard Worker# PRIO=5
57*de1e4e89SAndroid Build Coastguard Worker# RULE=192.168.1.0/24
58*de1e4e89SAndroid Build Coastguard Worker# ----------8<---------------------
59*de1e4e89SAndroid Build Coastguard Worker#
60*de1e4e89SAndroid Build Coastguard Worker# This is minimal configuration, where:
61*de1e4e89SAndroid Build Coastguard Worker# DEVICE:  eth0   - device where we do control our traffic
62*de1e4e89SAndroid Build Coastguard Worker#          10Mbit - REAL ethernet card bandwidth
63*de1e4e89SAndroid Build Coastguard Worker#          1Mbit  - "weight" of :1 class (parent for all shapers for eth0),
64*de1e4e89SAndroid Build Coastguard Worker#                   as a rule of thumb weight=batdwidth/10.
65*de1e4e89SAndroid Build Coastguard Worker#          100Mbit adapter's example: DEVICE=eth0,100Mbit,10Mbit
66*de1e4e89SAndroid Build Coastguard Worker#          *** If you want to build more than one shaper per device it's
67*de1e4e89SAndroid Build Coastguard Worker#              enough to describe bandwidth and weight once  - cbq.init
68*de1e4e89SAndroid Build Coastguard Worker#              is smart :) You can put only 'DEVICE=eth0' into cbq-*
69*de1e4e89SAndroid Build Coastguard Worker#              config file for eth0.
70*de1e4e89SAndroid Build Coastguard Worker#
71*de1e4e89SAndroid Build Coastguard Worker# RATE:    Shaper's speed - Kbit,Mbit or bps (bytes per second)
72*de1e4e89SAndroid Build Coastguard Worker#
73*de1e4e89SAndroid Build Coastguard Worker# WEIGHT:  "weight" of shaper (CBQ class). Like for DEVICE - approx. RATE/10
74*de1e4e89SAndroid Build Coastguard Worker#
75*de1e4e89SAndroid Build Coastguard Worker# PRIO:    shaper's priority from 1 to 8 where 1 is the highest one.
76*de1e4e89SAndroid Build Coastguard Worker#          I do always use "5" for all my shapers.
77*de1e4e89SAndroid Build Coastguard Worker#
78*de1e4e89SAndroid Build Coastguard Worker# RULE:    [source addr][:source port],[dest addr][:dest port]
79*de1e4e89SAndroid Build Coastguard Worker#          Some examples:
80*de1e4e89SAndroid Build Coastguard Worker# RULE=10.1.1.0/24:80         - all traffic for network 10.1.1.0 to port 80
81*de1e4e89SAndroid Build Coastguard Worker#                               will be shaped.
82*de1e4e89SAndroid Build Coastguard Worker# RULE=10.2.2.5               - shaper works only for IP address 10.2.2.5
83*de1e4e89SAndroid Build Coastguard Worker# RULE=:25,10.2.2.128/25:5000 - all traffic from any address and port 25 to
84*de1e4e89SAndroid Build Coastguard Worker#                               address 10.2.2.128 - 10.2.2.255 and port 5000
85*de1e4e89SAndroid Build Coastguard Worker#                               will be shaped.
86*de1e4e89SAndroid Build Coastguard Worker# RULE=10.5.5.5:80,           - shaper active only for traffic from port 80 of
87*de1e4e89SAndroid Build Coastguard Worker#                               address 10.5.5.5
88*de1e4e89SAndroid Build Coastguard Worker# Multiple RULE fields per one config file are allowed. For example:
89*de1e4e89SAndroid Build Coastguard Worker# RULE=10.1.1.2:80
90*de1e4e89SAndroid Build Coastguard Worker# RULE=10.1.1.2:25
91*de1e4e89SAndroid Build Coastguard Worker# RULE=10.1.1.2:110
92*de1e4e89SAndroid Build Coastguard Worker#
93*de1e4e89SAndroid Build Coastguard Worker# *** ATTENTION!!!
94*de1e4e89SAndroid Build Coastguard Worker# All shapers do work only for outgoing traffic!
95*de1e4e89SAndroid Build Coastguard Worker# So, if you want to build bidirectional shaper you must set it up for
96*de1e4e89SAndroid Build Coastguard Worker# both ethernet card. For example let's build shaper for our linux box like:
97*de1e4e89SAndroid Build Coastguard Worker#
98*de1e4e89SAndroid Build Coastguard Worker#                     ---------             192.168.1.1
99*de1e4e89SAndroid Build Coastguard Worker# BACKBONE -----eth0-|  linux  |-eth1------*[our client]
100*de1e4e89SAndroid Build Coastguard Worker#                     ---------
101*de1e4e89SAndroid Build Coastguard Worker#
102*de1e4e89SAndroid Build Coastguard Worker# Let all traffic from backbone to client will be shaped at 28Kbit and
103*de1e4e89SAndroid Build Coastguard Worker# traffic from client to backbone - at 128Kbit. We need two config files:
104*de1e4e89SAndroid Build Coastguard Worker#
105*de1e4e89SAndroid Build Coastguard Worker# ---8<-----/etc/sysconfig/cbq/cbq-28.client-out----
106*de1e4e89SAndroid Build Coastguard Worker# DEVICE=eth1,10Mbit,1Mbit
107*de1e4e89SAndroid Build Coastguard Worker# RATE=28Kbit
108*de1e4e89SAndroid Build Coastguard Worker# WEIGHT=2Kbit
109*de1e4e89SAndroid Build Coastguard Worker# PRIO=5
110*de1e4e89SAndroid Build Coastguard Worker# RULE=192.168.1.1
111*de1e4e89SAndroid Build Coastguard Worker# ---8<---------------------------------------------
112*de1e4e89SAndroid Build Coastguard Worker#
113*de1e4e89SAndroid Build Coastguard Worker# ---8<-----/etc/sysconfig/cbq/cbq-128.client-in----
114*de1e4e89SAndroid Build Coastguard Worker# DEVICE=eth0,10Mbit,1Mbit
115*de1e4e89SAndroid Build Coastguard Worker# RATE=128Kbit
116*de1e4e89SAndroid Build Coastguard Worker# WEIGHT=10Kbit
117*de1e4e89SAndroid Build Coastguard Worker# PRIO=5
118*de1e4e89SAndroid Build Coastguard Worker# RULE=192.168.1.1,
119*de1e4e89SAndroid Build Coastguard Worker# ---8<---------------------------------------------
120*de1e4e89SAndroid Build Coastguard Worker#                 ^pay attention to "," - this is source address!
121*de1e4e89SAndroid Build Coastguard Worker#
122*de1e4e89SAndroid Build Coastguard Worker# Enjoy.
123