Cameron Kerr 胡鑫

Ten years experience in Linux, Networking, and Network Programming. Looking to upgrade my career path.

Backup Chinese Computer Displays Computing ecorc Electronics Embedded Essays Files Flatting Hobbies i18n IPv6 Keyboards Keynote Linux Mac OS X Networking NFS Perl PGP Phone Photos Plastic Printers Programming Python Readings Recipes Recycling Redhat RFID Security SIM Card SNMPrtg SQLite3 SSH SSL Standards Study Teaching Terminals Tools Ubuntu Urban Reconstructionism USB VirtualBox Wedding Wireless X11

2011 Aug 3, Jun 2, Mar 1, Feb 2, Jan 4 2010 Dec 1, Nov 3, Oct 1, Aug 2, Jul 3, Jun 2 2009 May 1, Jan 2 2008 Sep 1, Jul 2, May 2, Mar 1, Feb 3, Jan 6 2007 Dec 3, Nov 12, Jul 28 2005 Dec 3, Oct 2 2004 Jul 1 2003 Aug 1

IPv6 Certification Badge for Cameron Kerr

Valid CSS! Valid XHTML 1.0 Strict

Posts about Computing

Extracting C/C++ Functions from Source Code

Fri Mar 25 12:42:28 NZDT 2011

I’ve often desired a little program that I could use for extracting a function from C source-code, generally so I can then put in into some other file as a point of discussion for my students, similarly with structure definitions etc. Other people have certaining wanted such a thing as well. So now I’ve sat down and worked out a bit of scripting to do this. I call it c-extract-function. After downloading it, remove the “.txt” extension and make it exucutable.

$ c-extract-function
Usage: c-extract-function <tag> [to-file]

$ c-extract-function obc_state
Loading vc-svn...
Starting a new list of tags tables
Mark set
Mark set
enum obc_state
Wrote /dev/stdout

The bits that I have greyed out are messages sent to stderr, which I can’t easily get rid of at the moment. As you can see, it’s not limited to functions, but can be used for enums, structs, unions, and even global variables. Unfortunately, its currently limited to only outputting definitions, not declarations. Sorry, its a limitation of Emac’s find-tag function.


Inputting Keyboard Scancodes for VirtualBox (and others?)

Wed Feb 2 20:13:09 NZDT 2011

VirtualBox has a mostly undocumented feature that allows you to input keyboard scancodes. This can be useful when you only input you can use with the virtual machine at that time (eg. interacting with a boot-loader on an install-CD). Unfortunately, in order to allow for arbitrary specification of keystrokes, you have to input the raw keyboard scancodes in hex, which is terribly inconvenient. I have made a simple program that accepts a mini-language, and outputs the scancodes neccesary.


SNMP Real-Time Graph version 2

Wed Jan 19 14:27:37 NZDT 2011

SNMPrtg v2 is my Perl/Tk script for graphing a counter or gauge SNMP variable over with a much shorter interval than typically available with tools such as MRTG. I have just released an updated version, accummulating all the various additions I had added a while ago.

Here is an example of using SSH port-forwarding to access a Net-SNMP agent on a remote host somewhere on the Internet.

$ ssh -CfN
$ snmprtg --title "Number of forwarded IP packets" \
> --peer localhost --port 10161 --domain tcp --interval 15 \
> --oid ipForwDatagrams.0

VirtualBox spinup script

Tue Jan 18 21:21:22 NZDT 2011

VirtualBox is a nice workstation-class virtualisation solution, largely because of its cost and license (free for personal and academic use). The GUI is compelling, although it does lack a few major features with regard to setting up a laboratory environment topology quickly. Fortunately, it can be scripted very well, so I have developed a script to build, start, stop, pause, resume and destroy a lab of virtual machines based around Ubuntu and Vyatta Live CDs.

Currently, does not support the new VirtualBox 4, which has changed a number of things in major ways.


Typing Chinese and Associated Tasks

Sat Nov 6 08:20:18 NZDT 2010

A little while ago I made a Google Doc for my classmates titled `Typing Chinese and Associated Tasks´, which covers how to type Chinese on Mac OS X, Windows and Linux (in no particular order). It covers other associated tasks that a student (or teacher) of Chinese would likely want to know, including how to do things like enter Pinyin letters with tone marks. It was well received and so I thought I would make it available to a wider audience.


Using InterNetNews (INN2) for local news

Sat Jun 5 07:56:08 NZST 2010

I want to encourage my students to help each other more, and in doing so increase their ability to write a useful diagnostic, finding good sources of information, and giving good help, and in the process learning from other’s experiences and also making it faster to help themselves (because I’m typically kept very busy helping others). I had asked by students to fill in an informal survey, and one of the continual themes was that there needed to be more demonstrators; unfortunately we’re not allowed one.

So this post is about installing INN2 (InterNetNews version 2) on Ubuntu, with private newsgroups.


GnuPG with Mac on Snow Leopard

Fri Jun 4 21:47:31 NZST 2010

I’ve been playing with GnuPG recently; mostly because its something I ought to know, professionally, and encourage my students to know about and use, as well as signing keys. It’s been a useful learning experience, though not withouts some pain getting suitable integration on Mac OS X Snow Leopard with Apple Mail (or Mozilla Thunderbird for that matter). This post is about getting Apple Mail on Snow Leopard to work with GnuPG, as Snow Leopard bought some changes in Apple Mail that broke existing support.


Network Gymnastics with VirtualBox, CoRD and socat

Thu May 14 23:53:17 NZST 2009

I’ve been meaning to write this post for a while, but I only found the right sort of excuse to do it today. At work I was playing with VirtualBox’s RDP (Remote Desktop Protocol: like VNC but much better) and wanted to do some work on it from home on my old Mac laptop, which is a PowerPC G4 and therefore basically useless when it comes to anything regarding virtualisation, so I needed to connect to TCP on my offic machine where VirtualBox (actually, I had started it with VBoxHeadless). But to get there, I first have to SSH into a gateway, and then from the gateway, SSH into my office machine… this calls for some gymastics.


HomePlug Performance

Tue Jan 20 00:03:04 NZDT 2009

I have recently purchased a NetComm NP285 Turbo HomePlug Twin Pack from TradeMe, which are Ethernet over Power bridges. Information regarding standards and so forth can be found at the HomePlug Powerline Alliance. In brief, these particular adaptors work at up to 85Mbps (earlier version was 14Mbps and up and coming version at 200Mbps).

This post is trying to give you some information about the performance I was able to attain in my flat, which is quite old, both with regard to typical round-trip-time and throughput.


Wireless Reliability

Mon Jan 19 00:00:00 NZDT 2009

A simple little script which gives an indication of the distribution of round-trip-times (and thus data-link retransmissions) to a particular destination. Useful for determining the reliability of a connection.


How to use Expect on Mac OS X for Serial Devices

Sun Sep 21 16:56:50 NZST 2008

So I’ve been working on a small piece of software to interrogate an RFID reader over its serial connection, implemented using a SiLabs USB Virtual Com Port. Naturally, I’ve been doing this on my Mac. Because this particular piece of kit doesn’t really have a protocol as such but rather implements something much more like a serial terminal, I chose to use Expect to interrogate it, which works reasonably well. I don’t want something production-grade because this is an evaluation kit, which will interact rather differently from the final version.

Anyway, I was having a large problem trying to get the bothersome thing to open. Here is what you would typically write in Expect (really Tcl, which is a fairly cool scripting language).


Building a Multi-Version Rdiff-Backup Server

Sun Jul 20 00:00:00 NZST 2008

Documentation and supporting files for creating and maintaining a backup-server using multiple versions of rdiff-backup, suitable for supporting different operating systems with different versions of rdiff-backup installed.


A “Split SSH” Configuration for Different Access Policies

Sun May 25 15:12:58 NZST 2008

What with all the hubbub with the OpenSSL faults in the news recently, I deciced I would do something to put down another large problem I have with a closely related product–OpenSSH, although I should immediately point out that this is not necessarily particular to OpenSSH.

You see, OpenSSH has very little support for easily creating rich access policies. The access policy I wanted to create was to allow password authentication to clients inside our campus, but only allow public-key authentication to clients coming from outside the network.

The reason for this, as anyone running an Internet-facing SSH server will be able to immediately appreciate, is that every day many login requests are made from the Internet to SSH servers, trying to brute-force account names and passwords; sometimes they are successful, but most of the time it just creates a lot of noise in the logs and an uneasy what-if feeling in your gut.


Updated Keynote Speakers Notes

Fri Mar 7 11:16:27 NZDT 2008

I have released an updated version of my Keynote Speakers Notes extraction utility. It is now available as an easy-to-use Automator Workflow.


Windows Sharing—No port 445 for you!

Mon Feb 25 12:54:58 NZDT 2008

So I was trying to mount my Mac OS X home directory via CIFS to my Ubuntu 7.10 virtual machine (in VirtualBox). I was getting a very long pause for the mount, and it would eventually succeed. Sometimes, the easiest way to diagnose a problem is not using things like --verbose (an argument to mount.cifs), but rather with a sniffer, namely Wireshark.

Turns out, that CIFS tries to connect to TCP/445. Well, no surprises there. What did surprise me was that it was failing (and repeatedly trying again). On my 10.4 Mac, Windows Sharing was enabled for the firewall. Upon closer inspection though, that only enabled the older SMB stuff (TCP/139 and UDP/137,138), but not TCP/445. So I added a custom entry to allow TCP/445 (I called it “Windows Sharing - CIFS”) and filed a bug report with Apple. I wonder if this is already fixed in 10.5.


Multi-Protocol Layer Switching

Thu Jan 24 08:56:55 NZDT 2008

I'm currently attending NZNOG'08, and the talks yesterday covered IPv6 Deployment. One of the topics raised was MPLS, which I only had the vaguest notion about what it was about, so I looked about for a useful quick tutorial. I found the following at



Fri Jan 18 17:24:40 NZDT 2008

I have need to learn of RS-485 for the RFID project I am working on, as my fellow student/predecessor could not get it work right on Linux (we're using a RS485 to RS232 converter). Should be quite interesting... will have to look into the converter more, but must first learn about RS485. Turns out to be a very common data aquisition and control technique, and quite fast to boot. Lammert Bies has an informative article on RS485, specifications and in-depth tutorial.


Monad Manifesto

Wed Nov 28 12:11:51 NZDT 2007

Further to my last post regarding what I like about Microsoft, where I mentioned PowerShell, readers would find the Monad Manifesto very interesting reading. It serves as a nice requirements analysis and roadmap to what Monad became (PowerShell).


What I like about Microsoft

Tue Nov 27 13:23:47 NZDT 2007

I've been accused of being a Linux fanboy [edit: I prefer the term 'weenie'] at times, and a Mac weenie more recently, but in reality, I sit uncomfortably aware that every OS sucks! Some even blow at the same time.

If I'm a weenie of anything, (these days) it would most likely be (semi?) functional programming—disclaimer: I wouldn't use it for everything. You know, I've never really considered myself a programmer, more a scripter. That's one of the things that made me (quite frankly) rather good in a Unix environment; sh, sed, awk, perl etc. were all great friends; the type of friend that had lots of quirks and warts, wheezed regularly when you took them out for a run, and wouldn't particularly want to leave you back exposed to them for too long. In short, they weren't great, but they did (and still do) work, and they were/are still fun to play with.


Death by Powerpoint (and how to fight it)—Alexei Kapterev

Fri Nov 23 03:06:36 NZDT 2007

I saw this on LifeHacker and thought it was worth sharing, both to point out the utility of the content, and the utility of the delivery mechanism, SlideShare


Wildcard DNS

Sat Jul 21 00:03:18 NZST 2007

Pop quiz: where does the following URI take you?|snc9d8ynusktl2wpq↩

Answer: not Barclays Bank in the UK!


Why we teach C

Sat Jul 21 00:03:18 NZST 2007

As my role as a Teaching Fellow in Telecommunications, I always, at least once a year, during TELE 402 (which is partly network programming), get asked why I teach them C, rather than Java (which is what they learn as their first language in Computer Science). Until recently, I've only had about one answer, but now I've found the answer that I've been searching for.

Previously, my answers have been on the following lines.


Vertical Bar

Sat Jul 21 00:03:18 NZST 2007

Ever wondered why there is a ‘|’ symbol on your keyboard? I have, and I finally found out how it got there a few days ago.

(slightly edited)

The SHARE IBM users' group opposed the adoption of ASCII-1967 because the vertical bar, which is the PL/I logical OR operator, appears in a section of the code reserved for "national use" characters, and, moreover, in the lower case section of the code which might not be supported by all devices.

SHARE insisted that there be a vertical bar in the uppercase, international section of the code, so the X3.2 subcommittee made it acceptable to substitute a vertical bar symbol for the exclamation point, and broke the character that was supposed to be a vertical bar in half so it could not be mistaken for a logical OR symbol. The damage was repaired in ASCII-1977, but by this time large numbers of devices were using the broken-bar symbol and the transition back to the real, solid, international, vertical bar is still not complete.


Fun with Unicode

Sat Jul 21 00:03:18 NZST 2007

With the very large array of glyphs available in Unicode, I thought it might be interesting to play with putting some Unicode into my e-mail signature. It's a shame that not all glyphs have been implemented yet. Apparently the most complete typeface comes from Arial Unicode MS. I wonder why there is no glyph for a website; Webdings has both a spider and a web... and a pirate; and Apple Symbols even has a map of the world! Unfortunately these are glyph-variants, which means they could be an entirely different looking character in a different typeface.

• Cameron Kerr  • ✉ • ☧  •
• ✎ • ✆ 021 4117 644 •

Parsing URIs

Sat Jul 21 00:03:18 NZST 2007

In my research into URIs, I came across a useful tool for parsing generic URIs into their five major parts: scheme, authority, path, query and fragment. I've found it useful for increasing my understanding of URIs.

You can find on the (Concluded) IETF URI Working Groups' old website. It's a reference parser written by Roy T. Fielding. You feed it a list of URIs and it breaks them up and spits them out.



Sat Jul 21 00:03:17 NZST 2007

I’ve recently found UnicodeChecker (screenshot), a useful accompaniment to the standard Mac OS X character pallete for finding out more about various Unicode characters. It has a number of useful features. It is particularly useful for giving their various forms. Here is an example of the various ways you can specify CURRENCY SIGN ¤


tcpflow and ssldump

Sat Jul 21 00:03:18 NZST 2007

I’d like to introduce you all to two very useful tools I’ve been using lately while debugging SSL and non-cleartext logins. These two tools are what I shall refer to as “line monitors”, they let you see the protocol interactions as they happen. Unlike a network sniffer/protocol analyser/etc, a line monitor generally concerns the user with the application level interactions. Line monitor is a term I picked up while reading about ASN.1, and I think its a term used mostly with that technology.

The two tools are tcpflow, and ssldump. Both are a simple apt-get away to Debian users. Mac OS X users can get tcpflow via Fink, or both from Darwin Ports.


Progress on Service Advertisement and Discovery Essay

Sat Jul 21 00:03:18 NZST 2007

I'm almost done with the first public draft of my latest essay, which will weigh in at over 40 pages. It's an essay about the various classic and contemporary protocols that have been, are, and shall be used to advertise and discover services.

It covers techniques classical methods such as: Well-known DNS aliases & RR types, DHCP, AppleTalk, NetBIOS, and IPX; and contemporary methods such as: DNS SRV records, DNS-SD & mDNS, SLP, UPnP & SSDP & LLMNR, LDAP, UDDI & WSDL, and JXTA.


Power Over Ethernet

Sat Jul 21 00:03:18 NZST 2007
Photo of my Power-over-Ethernet modules.

I decided I would make myself a pair of power-over ethernet modules to power an access-point for my point-to-point wireless experiment with Zhiyi. Turned out to be pretty easy. The instructions have been written up by New York City Wireless. They're pretty good, so I won't repeat them. You'll want to have a look at a voltage loss calculator to figure out what your input voltage should be.

For those not in the know about Power-over-Ethernet, it's a means of delivering power to a device (commonly an access-point or network-enabled camera) by appropriating the two unused pairs in an ethernet cable (assuming 100Base-Tx or slower, Gigabit Ethernet (1000Base-T) uses all pairs). This is useful when getting power to often awkward locations would be problematic.

As a description of the image above, the unit on the right is the injector. The DC is simply connected to pairs 1 and 4 (each pair is twisted together, thus creating a balanced wire-pair). The cable that gets plugged in between the OUT port on the injector, and the IN port on the splitter module (top left), carries the data and power. When it enters the splitter module, the pairs that carry the power are simply wired to the DC outlet leading in the access point. Similarly with the ethernet.


So just how big is A4?

Sat Jul 21 00:03:18 NZST 2007

The European paper-size A4 (as defined by the ISO standards) we use in New Zealand, is not the same as an American-sized A4 (practically a mis-nomer, as its only ever called ‘letter’ as far as I'm aware. A3 is called ‘ledger’. I guess they use the other An values)

The area of a European A0 sheet (the largest size) is 1m². An+1, n ∈ [0,7] is half the area, with the proportion of 1:√2. So A4 is 1/2⁴ = 1/16 m².

This may clear up some confusion that is probably out there when you see various programs (most commonly with PDF related software, in my experience) that lists A4 as being 8×11 inches, which is not the same as 210×297 mm (the standard European size).


There is no such thing as Plain-Text!

Sat Jul 21 00:03:17 NZST 2007

Reading some more on Joel on Software today, and came across an old article The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) that got me thinking a bit more about what we currently teach (or rather, don't teach) in Computer Science: Unicode.

Since I'm going to be including content about internationalisation in TELE 402 next year, I better brush up on things like wide-characters and the like. I do think that, as a part of some common syllabus, all University Computer Science and Information Science graduates should be expected to have done some course in International Issues. Unfortunately, no such paper seems to exist.


Self-defeating Spammers

Sat Jul 21 00:03:18 NZST 2007

I can't remember why, but for some reason I happened to have a quick glance in my spam folder. I think ever since I've been blogging about Unicode, I've had an enormous amount of foreign spam (strangely enough, the English spam has really dropped off). I've had a lot of foreign spam before (Spanish mainly, since I took a short course in Spanish). But now I'm getting e-mail I can't read at all, because the spammers defeated themselves and didn't include the charset (meaning Mail doesn't know in what charset to display it in).


Fun with Message-of-the-Day (MOTD)

Sat Jul 21 00:03:18 NZST 2007

UNIX admins would know this, and perhaps many Linux admins would also know this, but do you know what the file /etc/motd does? It's output when you login via ssh and similar tools.

Some people like to embellish what is output with various terminal control characters to do things like enable/disable bold, underline and other special characters. One thing I don't recommend though, is to try to use colours, its just too non-portable. Here is an example of what you might see.

Snapshot of terminal login with login banner and message of the day.

mid: and cid: URI schemes for referencing e-mail

Sat Jul 21 00:03:18 NZST 2007

Not very long ago I wrote to you concerning the mailto: URI scheme, which is used for initiating a new e-mail message. Today I shall show you how you can use URIs to reference existing e-mail messages (or content parts of a MIME message), so long as they are in the users e-mail store. This can be useful for cross-referencing e-mail messages in mailing-lists... if it's supported by your software.


Mysteries of ASCII, part Ⅰ

Sat Jul 21 00:03:18 NZST 2007

I'm currently reading an old (1993) book called Software Internationalization and Localization: an Introduction (ISBN: O-442-01498-8) that a collegue leant me so I can learn about the various aspects of internationalisation for protocol design. It's really quite interesting really, and I really think every student educated in any Computer Science or Information Science paper should know about the various issues.


The mailto: URI

Sat Jul 21 00:03:18 NZST 2007

How much do you know about the mailto: URI scheme? I've just had cause to read RFC 2368, and I've learned a few things myself. Using the mailto URI scheme, you can:

  1. send an e-mail to a person using a client-side e-mail program;
  2. send the e-mail to multiple people at one time;
  3. set the subject line of the e-mail;
  4. specify the body of the e-mail;
  5. and specify any header to send in the e-mail.

LCD Screen-burn

Sat Jul 21 00:03:18 NZST 2007

I just noticed that one of my labs Philips 190B 19" LCD monitors are exhibiting a bit of screen-burn where the login screen is normally seen. I thought LCDs weren't supposed to have these problems. Good thing I've set them all to turn off the display after an hour now.


Sound over laser-pointer & solar panel.

Sat Jul 21 00:03:18 NZST 2007
Picture of solar-panel receiver

Since I've been thinking about wireless stuff at present, I thought I would show you all something I cooked up a few years ago, inspired by How Stuff Works. This is a simple experiment to show the principles of carrier waves and modulation. It could be extended to get some data (signalling) over it, perhaps using some HAM software called cocoaModem I downloaded the other day. I've often thought it would be interesting to have a compitition “IP over Anything”, or another competition to see who can achieve the highest baud rate over something like this.


Making a Podcast...sorta

Sat Jul 21 00:03:18 NZST 2007
Directional antenna

I received my copy of iLife 06 the other day, and proceeded to split it into two DVDs, since it's volume licenced, and no-one has a convenient dual-layer DVD burner (the CD image is over 6GB). The process of splitting wasn't too complicated, just a careful search and replace in the installation control files.

But that's not what this blog entry is about. I've recently built an antenna, using a Chinese frying scoop and a USB WiFi adapter (USB 2.0, 802.11g, $58 NZD from Dick Smith), and an old tripod.

And now I'm trying out the new podcast creation features of GarageBand (part of iLife).


Imaging Floppy Discs in Mac OS X Tiger 10.4.4

Sat Jul 21 00:03:17 NZST 2007

I created a couple of DOS boot-discs to install NetWare today, so I plugged in an old USB floppy disc drive from a iMac G3, and fired up Disk Utility. However, the normal image restore procedure failed (Operation not permitted), even though it asked for my credentials. I don't know what releases of Mac OS X this tip will relate to, but its not obvious, so I put it here.



Sat Jul 21 00:03:18 NZST 2007
A retractable ethernet cable

My collegue, Zhiyi, went to LinuxConf 2006 earlier this year, and was given on of these ever-so-useful retracting ethernet cables. He had no use for it, so he gave it to me...which is quite fortunate really, because I'm a very mobile worker (like the proverbial blue-arsed fly).

We (still) don't have a wireless solution at work, so having a cable such as this really makes it useful for moving around quickly. It is also beneficial because I think the ethernet port on my laptop is a bit sensitive to the position of the cable (a common fault on laptops). This cable doesn't have that problem, so I just plug in onto an existing cable using an extension piece.


Saving Paper—Duplex Printing in Mac OS X

Sat Jul 21 00:03:17 NZST 2007

I've just finished an A4 poster [PDF] I intend to distribute around various printers to show people how they can (easily) print on both sides of the paper (duplex printing).

Feel free to distribute it if you like. I may do a Linux version, although documenting anything Linux-based is often a PITA, but fortunately we do have a fairly consistent environment here wrt Linux.


CD Envelopes from Scrap Printer Paper

Sat Jul 21 00:03:18 NZST 2007

I made a guide today showing how you can give your backup CDs etc. some cheap protection, by reusing printer paper.


Wireless by Weather Baloon

Sat Jul 21 00:03:18 NZST 2007

An interesting and cost-effective solution for providing broadband internet speeds via weather-baloons. Some quick points from the Ars Technica article:

  • 12,000m³ weather balloon.
  • Altitude of 24km.
  • Steady data-link of 11Mbps; long term aim of 120Mbps.
  • Supported by 14 partners worldwide; including British Telecom, University of York, and partly funded by European Union.
  • Much cheaper (1/10th), less latency than satellites.
  • Soon to be trialled in Japan

Bowl of Rice?

Sat Jul 21 00:03:18 NZST 2007

What does the image (taken from a site about Japanese table manners) on the left make you think of? If you're Chinese or Japanese, it may very well mean ‘death’.

I point this out because it shows that when translating software, there are cultural nuances to take into account, such as the suitability of clipart and meanings attached to colours and shapes.


Investigating ASN.1

Sat Jul 21 00:03:18 NZST 2007

While reading the RFCs concerting LDAP (I was doing some research for my Service Discovery essay,) I learned that LDAP uses ASN.1.

ASN.1 is a very mature (and still maintained) ITU standard for specifying the protocol syntax for a protocol. What makes it so cool is that you specify your “abstract syntax” (in a manner similar to a grammar), which you can then compile using an ASN.1 compiler, to turn it into program code for coding/decoding the resultant “transfer syntax” to/from its “concrete syntax” (language-specific form, such as a C structure).


About URIs

Sat Jul 21 00:03:18 NZST 2007

I've just received permission (I thought it best to check first, since it was made on company time), to publish my essay About URIs [PDF]. I think you'll find it to be quite informative.

There's questions at the back that you can test yourself on (as well as answers). If you have any questions you can't answer for yourself after thinking it through yourself, feel welcome to ask.