
INSTALL

	1. Making ALTQ-kernel.
	2. Installing RSVP daemon
	3. Installing stand-alone CBQ
	4. Using WFQ
	5. Using FIFOQ
	6. Using RED (including ECN)

ALTQ/CBQ can be used for a traffic control kernel for RSVP, for a
stand-alone traffic control kernel, or for both.
ALTQ/RED, ALTQ/CBQ and ALTQ/WFQ can be used for active queue management.
You can enable one of the queueing schemes at one time per interface.

  If you want to modify the existing driver to work with ALTQ,
  please read "How to add ALTQ Support to a Driver".
  It is not difficult for most kernel hackers, but the mileage may vary
  depending on how the driver is structured.

0. Prepare FreeBSD-2.2.6-RELEASE (or 2.2.5 or 2.2.2 or 2.2.1)
	This release only supports FreeBSD-2.2.[1256]-RELEASE.
	2.2.6 is recommeded.
	(It won't be too difficult to port to other FreeBSD release,
	or even to other BSD based UNIX.  But I don't want to spend
	too much time to maintain the portability at this stage.)

1. Making ALTQ-kernel.

1.1 Applying patch to the kernel source tree and make a new kernel.

	Put a fresh kernel source in /usr/src/sys-altq (recommended
	directory name)
	# cd /usr/src
	# mkdir sys-altq
	# cd sys
	# tar cvf - . | (cd ../sys-altq; tar xf -)

	Apply sys-altq.patch to the kernel source
	# cd /usr/src/sys-altq
	# patch -p < ALTQ_DIST/sys-altq.patch

	Here "ALTQ_DIST" is the altq distribution directory.
	this process makes a new kernel with CBQ, WFQ and RED built-in.

	If you are not familiar with how to make a kernel, consult the
	FreeBSD handbook, Configuring the FreeBSD Kernel section.
	(/usr/share/doc/handbook/handbook.html or also available at
	http://www.freebsd.org/handbook/handbook.html) 

	NOTE: when 2.2.5-RELEASE is used, patch will complain that
	the following file is missing.
		pci/if_tx.c
	you can skip these files. by
		File to patch: (return)
		No file found--skip this patch? [n] y (return)

	when 2.2.[12]-RELEASE is used, patch to pci/if_fxp.c
	and pci/if_de.c will fail.
	you should manually apply the patches provided in the
	"other-patches" directory.

	make and install the new kernel.
	
	# cd i386/conf
	# config ALTQ
	# cd ../../compile/ALTQ
	# make depend
	# make
	# make install
	# shutdown -r now

1.2 making altq devices
	
	# cd ALTQ_DIST
	# sh MAKEDEV.altq all

	note that altq (cbq, wfq, red) currently uses the device major
	number 88, defined in sys-altq/net/altq.c.
	you might have to change this if it conflicts with other device.

	Note: device numbers of FreeBSD grows faster than I expected.
	majors.i386 of 2.2.6 says 88 is reserved for DPT RAID Controller
	but apparently it is not used.  So, altq still uses 88 in this
	release.

2. Installing RSVP daemon.
	If you don't use CBQ for RSVP you can skip this section.

2.0 Prepare the RSVP distribution from ISI.
	<http://www.isi.edu/div7/rsvp/rsvp.html>
	at this writing, the latest release is rel4.2a3.
	Note: this release supports ONLY rel4.2a3!

	% cd ALTQ_DIST/cbq-rsvp
	% cp cbq.patch4.2a3 tc_cbq.c tc_cbqinit.c tc_cbqatm.c tc_cbq.h RSVP-ROOT/rsvpd/
	% cd RSVP-ROOT/rsvpd

	here "RSVP-ROOT" is where you put the rsvp distribution.

	    % patch < cbq.patch4.2a3
		cbq.patch modifies the following files:
			Makefile rsvp_global.h rsvp_main.c rsvp_var.h

		if you don't have the altq kernel source in
		"/usr/src/sys-altq", edit Makefile and modify SYSDIR.

	    % make

	before you run rsvpd, you should copy "cbq.conf" to "/etc".

	    # cp ALTQ_DIST/cbq-rsvp/cbq.conf /etc/cbq.conf

	If you use the ALTQ/CBQ kernel with RSVP, you don't have to know
	much about ALTQ or CBQ.
	If you are interested in understanding how it works, please
	read ALTQ_DIST/docs/cbq-howto.txt.

3. Installing stand-alone CBQ
	If you don't use CBQ as a stand-alone setting (means no RSVP),
	you can skip this section.

	For a stand-alone case, a daemon process "cbqd" reads the config
	file (/etc/cbq.conf) and does CBQ setup.

	To make cbqd,

	% cd ALTQ_DIST/cbq-tools
	% make

	Testing CBQ with local loop:
	  A sample config file for local loop is included.
	  It sets interface speed to 300Mbps and gives
		10% of the interface bandwidth to TCP
		10% of the interface bandwidth to UDP
	  thus, both TCP and UDP can get 30Mbps each.

	To run cbqd with this sample config:
		# ./cbqd -d -f cbq.conf.samples/cbq.conf.lo0
		cbq lo0>

	now cbq is enabled!
	(with the "-d" option, cbqd enters the command mode.)

	Run a test with TCP or UDP:
	Prepare a program to measure the throughput.
	    One of the easiest ways is to ftp to localhost, 
	    but I recommend to use netperf
	    <http://www.cup.hp.com/netperf/NetperfPage.html>
	    netperf is also available from FreeBSD ports collection.
	
	you can disable or enable cbq by
		cbq lo0> cbq lo0 disable
		cbq lo0> cbq lo0 enable
	To exit
		cbq lo0> quit
		#

	Terminating cbqd also disables cbq.
	
	Try other interfaces by
	  -replace the interface name 
	  -check the interface speed  (10000000 (10Mbps) for Ethernet)

	see cbqd(8) for how to set the config file.

4. Using WFQ
	If you don't use WFQ, you can skip this section.

	WFQ (weighted fair queueing) is implemented as a sample
	implementation.

	A daemon process "wfqd" sets up wfq.
	To make wfqd,

	% cd wfq-tools
	% make

	To enable WFQ on interface "vx0",

	# ./wfqd vx0

	wfqd enables WFQ on "vx0" and goes into the command mode.

	To disable WFQ,

		> vx0 disable
		or
		> quit

	see wfqd(8) for how to use wfqd.

5. Using FIFOQ
	If you don't use FIFOQ, you can skip this section.

	FIFOQ (first-in first-out queueing) is implemented as a template
	for those who want to write their own queueing schemes on the
	ALTQ framework.
	So, there would be no reason to use FIFOQ unless you want to 
	modify the FIFOQ implementation.

5.0 adding FIFOQ support for your FreeBSD kernel configuration.

	FIFOQ isn't configured in the default ALTQ kernel configuration.
	edit the kernel config file ("/usr/src/sys-altq/i386/conf/ALTQ").
	enable the following line by removing the '#' at the head 
	of the line.

	#options		FIFOQ			#fifo queueing

	config and install the new kernel (see 1.1).

5.1 Using FIFOQ

	A daemon process "fifoqd" sets up fifoq.
	To make fifoqd,

	% cd fifoq-tools
	% make

	To enable FIFOQ on interface "vx0",

	# ./fifoqd -d vx0

	fifoqd enables FIFOQ on "vx0".

	To disable FIFOQ, just kill fifoqd by typing Ctrl-C.

	When you omit the "-d" option to fifoqd, fifoqd goes into the
	daemon mode.

	see fifoqd(8) for how to use fifoqd.

6. Using RED
	If you don't use RED, you can skip this section.

	A daemon process "redd" sets up red.
	To make redd,

	% cd red-tools
	% make

	To enable RED on interface "vx0",

	# ./redd -d vx0

	redd enables RED on "vx0".

	To disable RED, just kill redd by typing Ctrl-C.

	When you omit the "-d" option to redd, redd goes into the
	daemon mode.
	If the interface is not 10baseT, you have to specify the link
	bandwidth by "-b".  (e.g. "-b 100M" for FastEthernet)

	Experimental ECN (explicit congestion notification) support
	for IPv4 is added since altq-0.4.3.
	 - To enable ECN by RED,  pass "-e" option to redd.
	 - if you want to use ECN-capable TCP, you have to add 
	   "options ALTQ_ECN" to your kernel configuration file.
	   (you can disable ECN in TCP by "sysctl -w net.inet.tcp.ecn=0".)
	
	see redd(8) for how to use redd.

