Alan Ford's ECS Homepage

I graduated in Summer 2005 from the MEng Computer Science course at ECS at the University of Southampton, UK.

This page currently contains Perl and Java tips and tricks, documents and presentations I've created, and software and patches I've written.

I can be emailed at (mangled) <ajf AT>, or <ajf101 AT>. Also, I'm 3033272 on ICQ and on MSN.

I take a lot of photographs on various travels - many can be seen as contributions on my Wikipedia User Page.

Perl Useful Bits

This section is some useful but obscure bits of perl I've gathered over time, that I find useful and hopefully so will other people.

Java Useful Bits

These are a few bits of Java that are not obviously documented, but can be handy in programs.

MD5 Checksums in Java

Java provides a class, but this is how to make it actually do a MD5 sum of a String:

    public static String MD5Sum (String s) {
        MessageDigest MD5;
        try { MD5 = MessageDigest.getInstance("MD5"); }
        catch (Exception e) { return null; }
        String ans="", temp;

        byte[] digest = MD5.digest(s.getBytes());
        for (int i=0;i<digest.length;i++) {
            temp = Integer.toHexString(0xFF & digest[i]);
            ans += (temp.length() == 1 ? "0" + temp : temp);
        return ans;

NIS/YP Directory Lookups in Java

Java can integrate with a NIS database via JNDI, it's just not documented. You'll need the special JNDI NIS service provider.

The following example will connect to NIS domain "foo" on the server "", and extract the value attributed to the given key (user) from the "system/passwd" NIS map.

    public static String NISPasswd (String user) throws Exception {
        Hashtable env = new Hashtable();
        env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.nis.NISCtxFactory");
        env.put(Context.PROVIDER_URL, "nis://");
        Context ctx = new InitialContext(env);
        Context passwd = (Context)ctx.lookup("system/passwd");
        String value = passwd.lookup(user).toString();
        return value;

You can also do things like interate over the passwd data, line-by-line, rather than lookup a particular user. More details on this can be found on the JavaDoc for the Context interface (see the listBindings method).


Things to Think About when Renumbering an IPv6 Network

This Internet-Draft came out of work I did during summer 2004, and have continued since, with Tim Chown, Mark Thompson, and Stig Venaas, related to the 6net project. It is a companion document to RFC4192, Procedures for Renumbering an IPv6 Network.

IPv6 Multihoming

This was my fourth year Individual Research Project, summarising the current state and possible future developments in the field of IPv6 multihoming, one of the last major hurdles with IPv6 development.

Introduction to 802.11 and Meshed Networking

This presentation was done for the 4th year computer networks course. I was rather pleased with it as a summary however so thought I'd stck it up here!

Modified Kernel Packet Travelling Diagram

I have an interest in Linux routing and QoS, and my third year project was heavily involved with this topic. Stef Coene's KPTD is a brilliant resource for seeing how the Linux kernel processes packets. This KPTD has become rather crowded, with both kernel 2.2 and 2.4 and IMQ information, which is not directly relevant. So, I drew my own handy cut-out-and-keep (well, full A4 printout) version.

Maths Revision Notes

I originally wrote these notes for my A-Level Maths exams (NEAB non-modular, if memory serves) back in 2001, and have found them surprisingly useful in other maths-related things since then, including parts of the first-year Engineering Maths module.

Random Linux Software Stuff

These are rather minor, yet useful, creations of mine come about over recent times.


Is a machine up? This attempts to make a TCP connection on a port (default 7, can specify something else). If it can connect, or the connection is refused, it infers the machine is up and returns success. Otherwise, it returns an error code. I've found it useful in shell scripts that need to know if a machine is up or not. In addition, it can optionally print out a message saying if the machine is up or not, and if it is not, give the error message. The latest versions (v0.3+) also can be used for connection testing (whether a port is available or not) as well as whether the machine is actually up. Version 0.4 added support for a specified timeout. Version 0.5 added IPv6 support, although due to the removal of several kludges the source code size actually decreased!


This will search through the system passwd file, or NIS passwd file if it exists, for a given username or part of username or name. The results are presented in a way it can easily be used as an external mutt query program.

The latest version of this program is 0.6, and should now be generic enough to work in places other than ECS (although ECS is still the compile-time default domain name, this can be changed on the command line and by changing the DEFINE in the source). It now has several useful command-line options. If NIS is available, it will directly search the NIS passwd file, which is far far quicker than doing getpwent searches - these are only used as a last resort if NIS is unavailable, or if the program is not compiled with NIS support (see comments in source for compile instructions).

There used to be two versions of this program, still retained here for historical reasons. The 0.2 series is the old version that used to be used in CSLib, since it is designed to work fast and efficently, but only for ECS addresses. The 0.5 series was supposed to be a more generic version, not requiring NIS and having flexible domain definitions. Versions from 0.6 onwards, however, handle this much better. Version 0.7 added support for additional addresses to be kept in an external file.


This is a simple command-line SMTP relay program intended to be used as a lightweight replacement for sendmail or other MTA. It simply relays all mail to the defined host (via the -S option), failing if unable to relay the email.

This program was originally written by Michael Elkins, the original author of the mutt e-mail client, to send directly to a SMTP server. Since it was no longer maintained, and in fact had pretty much disappeared off the face of the Internet, yet I still found it useful, I decided to continue maintaining it, with new features where appropriate.

My first modification, version 0.3: uses getaddrinfo, for IPv6 support; supports multiple addresses associated with hostnames; supports iteration over multiple servers until one is available; and adds the -l command-line option for allowing more flexibility over the HELO value.


This will look for all your X background pictures, by default in ~/backgrounds, and pick a random one to use. It requires xv to work. It should pick the resolution of one monitor and use that as the scaled size for the background image.


This will take a list of items on standard input, and calculate the frequency with which each one occurs. Command line arguments - -s to sort the list by frequency (default is alphabetically), -h to print the list as a histogram.


This will process a unix mbox mailbox, counting how many mails you received each day, and producing a histogram thingy.

Perl/Tk NS Lookup (ptknslookup)

I wrote this many years ago to learn how to use Perl/Tk. It's still quite a nice GUI interface to DNS lookups, and is a fair example of simple Perl/Tk programming.

Various Patches

OpenSSL Tricks

These are just a couple of handy incantations to make OpenSSL do useful stuff.