I won't explain compilation process in details, just read the README's and various HOWTO's.
Untar every package, first compile iproute2+tc.
Go into the iptables source directory and "make patch-o-matic". You will be prompted with a list of kernel patches, the one we are interested in is the "length match".
Note that since kernel version 2.4.16 you don't need this step, the length match is included in the official kernel.
After patching, configure your kernel, including:
Either builtin or as modules.
Networking options ---> Kernel/User netlink socket Network packet filtering (replaces ipchains) IP: Netfilter Configuration ---> IP tables support (required for filtering/masq/NAT) LENGTH match support MARK target support QoS and/or fair queueing ---> select everything here.
Compile and install as usual.
Next compile iptables and install it too.