                                 README

1. Introduction 
   ATCP was developed at Portland State University, the details of ATCP setup are given in 
   section 4.0. ATCP sender also has ECN support, the details of enabling ALTQ, RED and ECN 
   are given in section 2 & 3. We also recommend to look at 
   http://www.csl.sony.co.jp/person/kjc/software.html for more details about ALTQ, ECN and RED.
  
   Contact Information :
   Dr. Suresh Singh, Shiv Saxena and Harkirat Singh
              Portland State University
               Computer Science Dept. - Aug 16, 2001
 
 
               email: {singh, saxenas, harkirat}@cs.pdx.edu
               project page: http://www.cs.pdx.edu/~singh/pacman.html
 
2. Making ALTQ-kernel (Enabling RED and ECN in a router)

2.1 Prepare FreeBSD-4.2-RELEASE, download ALTQ tar file

2.2 Applying the patch to the kernel source tree and make a new kernel.
  - The kernel patch only contains modifications to the existing source files.
  - The altq original files are provided in a separate directory.

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

2.2.2 Apply the altq kernel patch to the kernel source
# cd /usr/src/sys-altq
# patch -p < ALTQ_DIST/sys-altq/sys-altq-freebsd-4.2.patch.
Here "ALTQ_DIST" is the altq distribution directory (the top directory of the altq release).

2.2.3 Copy the altq files to "sys-altq/altq" directory.
# mkdir altq
# cp ALTQ_DIST/sys-altq/altq/* altq/

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

You might need to uncomment "options ALTQ_NOPCC" in the configuration file if your machine is
         - 386/486 (non-Pentium) CPUs which don't have TSC, or
         - SMP
(By default, ALTQ uses processor cycle counter, Pentium TSC on i386 and PCC on alpha, 
for measuring time.) See ALTQ_DIST/docs/TIPS.txt for more information about 
configuration options.

For FreeBSD, the default configuration includes no queuing discipline but disciplines can be loaded at run 
time using KLD. Disciplines can also be built-in by specifying them in the kernel configuration file. 
(Uncomment options in the ALTQ kernel configuration file)

2.3 Loading altq queueing desciplines (for FreeBSD)
The altq kernel modules are automatically built and installed as part of the kernel build/install.
To manually make the altq KLD modules:

# cd /usr/src/sys-altq/modules/altq
# make
# make install
The modules are installed in the "/modules" directory. The altq modules have names starting with 
"altq_" (e.g., altq_cbq.ko). altqd tries to load required modules automatically so that you do not 
need to "kldload" modules explicitly.

In case you want to manipulate the modules by hand:
To load a module:
# kldload altq_cbq

To check the loaded modules:
# kldstat -v

To unload a module:
# kldunload altq_cbq
2.4 Enabling altq devices
# cd ALTQ_DIST
# sh MAKEDEV.altq all
# altqd
The altqd gets the queuing discipline/module to load from the altq.conf file. 
See Section 1.5 on how to load the Random Early Detection module.

2.5 RED (Random Early Detection)
To enable a simple RED at a router, specify "red" in altq.conf.
        interface wi0 bandwidth 10M red
RED parameters can be specified as follows:
        interface wi0 bandwidth 10M red thmin 10 thmax 20 invpmax 15 qlimit 80

Note that RED never shapes the traffic by itself.
To test RED, run multiple TCP streams from src to sink.
        # altqstat
It will show the statistics (among other thing, the average queue length).
Experimental ECN (explicit congestion notification) support for IPv4 is added 
since altq-0.4.3. To enable ECN by RED, add "ecn" to the "interface" 
command line.

        interface fxp0 bandwidth 10M red ecn

2.6 ECN (Explicit Congestion Notification)
ECN needs support in routers and end-hosts. ECN support in routers is a straightforward 
modification to RED, setting a "Congestion Experienced" bit in the IP header 
instead of dropping a packet.

3. Adding ECN support in the receiver

ECN support in end-hosts needs modifications to TCP that is enabled by the "ALTQ_ECN" 
configuration option. It can be also disabled by sysctl if the kernel is 
configured with ALTQ_ECN.

        # sysctl -w net.inet.tcp.ecn=0

There is no direct patch available for enabling ECN support for FreeBSD 4.2. 
The following five files were modified for enabling ECN support in end-hosts. 
These files exist in the /usr/src/sys/netinet directory.

1. tcp.h
2. tcp_input.c
3. tcp_output.c
4. tcp_timer.c
5. tcp_var.h

The ecn_support_endhost.zip file has the above set of files. Adding ECN support in the receiver consists of 
the following steps:

3.1 Prepare FreeBSD-4.2-RELEASE and unzip ecn_support_endhost.zip.

3.2 Save the original files
        # cd /usr/src/sys/netinet
        # mkdir original
        # cp tcp.h original/.
        # cp tcp_var.h original/.
        # cp tcp_input.c original/.
        # cp tcp_output.c original/.
        # cp tcp_timer.c original/.

3.3 Copy the modified files
        # cp <UNZIP_LOCATION>/* .

3.3 Enable the ALTQ_ECN option in the kernel configuration file and recompile the kernel.
 
Adding ECN support in the sender is coupled with the modifications made for enabling ATCP as
described in next section.

4. Adding ATCP and ECN support in the sender

The following 6 files were modified for adding ATCP and ECN support in the sender. 
These files exist in the /usr/src/sys/netinet directory.

1. tcp_input.c
2. tcp_output.c
3. tcp_timer.c
4. tcp_subr.c
5. tcp_var.h
6. in_proto.c

A new file was also added: atcp.h

The atcpsrc.tar has the above set of files.
Adding ATCP and ECN support in the sender consists of the following steps:

4.1 Save the original files
        # cd /usr/src/sys/netinet
        # mkdir original
        # cp tcp_var.h original/.
        # cp tcp_input.c original/.
        # cp tcp_output.c original/.
        # cp tcp_timer.c original/.
        # cp tcp_subr.c original/.
        # cp in_proto.c original/.
         
4.2 Copy the modified files & the new file atcp.h
        # cp <atcp-src untar dir >/* .

4.3 Make and install the new kernel.

# cd i386/conf
# config ATCP_KERNEL
# cd ../../compile/ATCP_KERNEL
# make depend
# make clean
# make all
# make install
# sync
# shutdown -r now

4.4 ATCP is enabled by setting ATCP preprocessor directive to 1 in atcp.h.





