Apache2 - Bw Mod v0.6 Stable Author : Ivan Barrera A. (Bruce) HomePage : Http://Ivn.cl/apache Release Date : 28-02-2005 Status : Functional. Tested under medium and heavy load. License : Ivn Project License. [bw_mod-license.txt] It must be included in every package containing this file. If it doesn't, please delete this software. You can get a copy in Http://Ivn.cl As Ivn Project License isnt yet an OSI approved license, You can use and include the Apache 2.0 License. Platform : Linux/x86 (Tested with Fedora Core 3, Suse, etc) FreeBSD/x86 v5.2 (Others versions might work as well) MacOS X/Ppc x86 (Darwin on x86 platform) Solaris 8/sparc (Some notes on compile.) Microsoft Windows (Win XP, Win2003. Others should work) Notes : This is a stable version of bw_mod. It works fine with almost any MPM (tested with WinNT/prefork/Worker MPM). It has almost every known bug fixed. If any bug appear, it will be fixed at the next stable release. From now on, every bugfix, feature request, comment, must be addressed at the webpage. Known Bugs : None in this version. However, there is a limitation of this module due to a lack of documentation on the Apach2 API. As the mod isn't able to detect the real bandwidth a client is using, it keeps sending data, at the determined rate (the bw limit you imposed). If the client is downloading to a lower rate (connection limitation) the mod keeps the rate imposed, until finished. But the client will keep the connection open as long as it takes to finish the download. This have a negative impact on the mod, not being able to know exactly how many *real* clients there are, and the real bandwidth used, so the remaining bw be divided on the others clients. If anyone knows how to get the bandwidth used by a client in realtime, please, contact me. If you want to support the development of this, and other software, you can contribute with the author, either with Money or Hardware donations. If you are making profit from this product, you are encouraged to get a paid license, or make a contribution with the Author To make a donation, contact the Author at Bruce@Ivn.cl ------------------------------------------------------------------------------ Contents : 1 .- Notices 1.1 - ChangeLog 1.2 - ToDo 2 .- Installing 2.1 - Windows 2.2 - Linux 3 .- Getting it to Work, Directives 3.1 - BandWidthModule 3.2 - BandWidthDebug 3.3 - ForceBandWidthModule 3.4 - BandWidth 3.5 - MinBandWidth 3.6 - LargeFileLimit 3.7 - BandWidthPacket 3.8 - BandWidthError 3.9 - MaxConnection 4 .- FAQ 5 .- Third Party Modifications 6 .- Thanks to ... [ Not finished yet ] ------------------------------------------------------------------------------ 1.- Notices 1.1 - ChangeLog : v0.6 Stable (28-02-2005) - Ok.. I made some mistakes the last "stable" release. I think the stress of knowing that i'll have to start working hard, made me collpase. Some FreeBSD (and other) guys, were having segfaults. This primarily cause i changed the filter type from TRANSCODE to NETWORK. I still dont know why. Probably i was thinking on a next release when working on that. - Changed the r->finfo.size to bblen again. Mistakes... mistakes... - I changed 0.5 -> 0.6 cause i've released too much fixes to 0.5. Time to move forward on revision numbers. v0.5 Stable (20-02-2005) - Tested with Worker MPM, and WinNT MPM - Fixed a bug that caused bw_mod don't work if EnableMMAP was disabled. - If there is a total reply size availbale, match that instead of file eize. This is useful when limiting scripts that ouput files and stuff. - Added Windows Support. bw_mod v0.5 WR availbale to download (binary) - Some minor bugs fixed. - The excess function was not working. It is disabled until i discover how to determine the real bandwidth a client is using. - Added BandWidthError directive. Allows to deliver personalized error when reaching maxconnections. - First release of the Ivn Project License. Until it is OSI approved, you can use the Apache 2.0 License. v0.5rc1 (21-01-2005) - I'm doing this release as a candidate release, cause i need some testing besides myself. If it works flawlessly, i'm moving to v0.5. - New bucket-split algorithm. - More configuration changes. Now MaxConnection can be by clients. And File Size limit, can be by extensions. - Some error checking added, some debug info added (commented till next release) - New netmask format support. Thanks goes to Ale Feltes Quenhan who provided a nice patch for v0.1. - Added support to compile under FreeBSD 5.2. Need more testing. - Added support to compile under MaxOS X. Need more testing. - Changed internal name to bw_module... so apxs doesnt complain about. ( i hate that... the name is bw_mod :'( ) v0.4 (not released) - Almost total rewrite of the mod. Some helper functions keep the same. - The mod doesn't use the byterange hack i did before. Now it works as an Output Filter, as it should have been in the beggining. - Counting, and stats, are done in shared memory now. The system allocate enough memory to hold every configuration. Some directives changed. - htaccess is removed from suppor for now. It causes some weird thing with my shared memory implementation. - Partial download, file symlinks, are not a problem anymore, as we dont use it. The filter takes care of all this. v0.3 - Mayor rewrite on counting routines. Using shared memory to count. v0.2 (not released) - Fixed partial download problem - Added some error checking routines v0.1 (2004.10.29) - Ported from mod_bandwidth written by Yann Stettler for Apache 1.3 ------------------------------------------------------------------------------ 1.2 - ToDo : - Count Connections using scoreboard. Although it might add too much overhead - Learn how to get the bw used in realtime. Once learnt, i can fix the connection counting problem, and the excess bw function. - BandWidth/Connection limit based on Agent - BandWidth Available to Lists of hosts (via file or comma separated list) - MaxConnections Per Each IP - Handler to see current status - htaccess support. - Add functions to throttle connections like mod_bwshare o mod_throttle - File Size Limit based on Mime Type (? I'm not sure this is a good idea. If noone ask for it, i'm going to dish this idea ) In the 1.0 revision, the mod will have : - More advanced way to use settings. (config files for the mod, etc). - Web configurable. - Please, post any features request, bugs, ideas, to the Homepage. ------------------------------------------------------------------------------ 2.- How To Install : 2.1 - Windows In Windows, you have to download the binary dll from the site (or compile one yourself) that matches your apache version, and Install it under modules on your apache tree. Then edit httpd.conf, and add the LoadModule sentence. If there is no matching binary dll with your version of apache (the latest) you can ask me to compile it for you. Post a message in the home site as a feature request. Example : Download bw_mod-2.0.53.dll from the home site, to c:\apache2\modules Edit httpd.conf, and add LoadModule bw_module modules/bw_mod-2.0.53.dll Restart Apache. Note : The sources to windows, are the same. I didnt include the MSVC 6 project files, cause i dont have a license to use it. anyways, you should be able to figure out, how to compile, following apache standar modules. 2.2 - Linux Well.. (under *nix) you *have* to compile it.. It might sound scary, but it's easy. There is an easy way, and the hard way. If the easy way doesn't work for you, use the hard way. REQUIREMENTS : You will need apache2 headers in the include path. In redhat/suse or others this mean apache-devel or httpd-devel installed. You also need support for SHM in your OS. Usually you will have this. - Easy Way : For this to work, you MUST have apxs (or apxs2) installed. You might need to use it full path (i.e. /usr/sbin/apxs .....). Well, you have to do this : apxs -i -a -c bw_mod-0.6.c or apxs2 -i -a -c bw_mod-0.6.c This will bring out some stuff... nothing to worry (unless you see error) If it says ok, then you are ready. Restart apache (service apache restart on redhat, mandrake, and others... apachectl restart .. rcapache2 restart or... well, you should know) Note On Solaris Users : If you got problems compiling it on Solaris, remember to check you have libgcc correctly installed, and the ld_library_path set up correctly. I didnt, so i compiled this way : export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib apxs -i -a -c bw_mod-0.6.c -L/usr/local/lib -lgcc_s And then started apache, and everything worked fine. Note On SuSe Users : You NEED to have installed apache2 header files (apache2-devel rpm). Otherwise you'll get lots of include files error. Other thing i noticed, is that apxs (you have to use apxs2) didnt put the config in the file i needed, and the init scripts overwrite the loadmodule.conf file everytime you start apache, so you have to add the LoadModule bw_mod.... sentence, in httpd.conf (/etc/apache2/httpd.conf) Something Like : (First 2 lines, are default in the file) # generated from APACHE_MODULES in /etc/sysconfig/apache2 Include /etc/apache2/sysconfig.d/loadmodule.conf LoadModule bw_module /usr/lib/apache2/bw_mod-0.6.so - Hard Way If usgint the easy way, you turned to have some .o files.. you are almost done... skip to the part of installing the module. Back to the hard way..... you might notice that you dont have apxs, dont know why (maybe the dog ate it). Well. try the following (and please do it on a newly-fresh created directory for this purpose) : (this does not necessarily work on all cases) libtool --silent --mode=compile gcc -g -O2 -pthread -DLINUX=2 \ -D_REENTRANT -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_SVID_SOURCE \ -I/usr/include/httpd \ -I/usr/include/apr-0 -Wall -g\ -prefer-pic -c bw_mod-0.6.c && touch bw_mod-0.6.slo libtool --silent --mode=link gcc -g -O2 -pthread -DLINUX=2 \ -D_REENTRANT -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_SVID_SOURCE \ -D_GNU_SOURCE -DAP_HAVE_DESIGNATED_INITIALIZER \ -I/usr/include/httpd \ -I/usr/include/apr-0 -Wall -g\ -export-dynamic -o bw_mod-0.6.la -rpath /usr/lib/httpd/modules \ -module -avoid-version bw_mod-0.6.lo (this cleans some unneeded files) rm -rf *.