« ""
"" »
"Routing tooting and bits"

By the way, I moved my private network at home onto a new subnet, and not had any more

routing problems; although I am still using the Buffalo. It’s a huge pain in the bottom moving a Linux server onto a new subnet, or indeed onto a new IP address. It’s the master DNS for my private network, so all that needed changing, plus of course iptables, web-servers, etc, all depend on heavily on IP addresses (or at least they do on my set up). Still, nothing seems to have broken; I just need to remember to move the PS2 onto the new subnet next time I do an online thingy with it.

I also discovered something very interesting about apache httpd – the directive


HostnameLookups off

is global, in the sense that everything running as apache is affected, which of course includes mod_php. This caused me all sorts of hassles getting a web-based management thing going for LfL, as I was trying to fire an sql query to my webhost’s MySQL server, but having no joy – as the server was unknown. The solution, as discovered by a mighty guru at work (he did a better Google than me!) is to explicitly let PHP do hostname lookups:


HostnameLookups off

<Files ~ "\.(php|cgi)$>

HostnameLookups on

</Files>

You want hostname lookups off in general as it doesn’t ‘alf slow things down to be doing a DNS lookup everytime you log a hit.

Incidently, I accidently made up a possibly useful description of binary and binary counting at my Mum’s. Imagine you own 2 shirts, a red one and a blue one. This means you have two choices of what to wear. Now imagine you also have 2 shorts, a red one and a blue one. You now how 4 choices of what to wear; red shirt and red shorts, red shirt and blue shorts, blue shirt and red shorts, and a blue shirt and blue shorts. Let’s say you use ‘R’ to represent a red item of clothing, and ‘B’ to represent a blue item of clothing, and you say that the first item given is the shirt, and the second is the shorts, these 4 outfits can be written down thus


RR

RB

BR

BB

Right – let’s say we now buy two hats, (you’ve guessed it) a red one and a blue one. Straight away we’ve doubled the number of outfits we’ve got, as we can wear the red hat with the 4 outfits mentioned above, or we can wear our blue hat with them (ignore the possibility of not wearing a hat – or indeed any of the other items of clothing – imagine you’re at ascot or something!)

For each item of clothing we only need to store a ‘bit’ of information – either it’s red or it’s blue, and so instead of using ‘R’ and ‘B’ we could just use ‘0’ and ‘1’, which gives the 8 choices of outfit as (with a red hat, if we call the first bit the ‘hat’ bit:) “000”, “001”, “010”, “011”, (and a blue hat:) “100”, “101”, “110”, “111”.

This hopefully shows how we can encode information just using bits, but also how the total amount of information we can store is dependent on how many bits we’ve got. Each time we add a bit we double the amount of information we can store (or, to phrase it another way, the largest number we can represent) – so if we were to add another bit to represent what is the colour of our socks, we now can represent 16 outfits (red socks with the 8 given above, or blue socks with 8 given above).

The clever part is that bits are very easy to encode as voltage inside a computer. If you have +5V (or + 3.3V, or whatever) on a wire then you say this represents a 1, and if there’s 0V on the wire than this represents a 0. so if give me 4 wires, I can encode up my outfit of shirt, shorts, hat, and socks by either applying a voltage or not to the appropriate wire.

And once you’ve got a voltage on a wire, you can do clever stuff with it using flip-flops, transistors, gates, …, and thus a computer is built; which means in turn I can write this nonsense! 🙂

W Wordpress