Author Archives: Mark Ciecior

IP Addresses in PHP/MySQL

I’ve been working on a web-based tool that stores, among other network-related things, IP addresses. When I first started I stored each IP address as four TINYINTS (0-255 for each octet):

mysql> DESC ipaddresses;
| FIELD    | TYPE                | NULL | KEY | DEFAULT | Extra          |
| id       | INT(10) UNSIGNED    | NO   | PRI | NULL    | AUTO_INCREMENT | 
| A        | tinyint(3) UNSIGNED | NO   |     | NULL    |                | 
| B        | tinyint(3) UNSIGNED | NO   |     | NULL    |                | 
| C        | tinyint(3) UNSIGNED | NO   |     | NULL    |                | 
| D        | tinyint(3) UNSIGNED | NO   |     | NULL    |                | 
5 ROWS IN SET (0.00 sec)
mysql> SELECT * FROM ipaddresses WHERE id=1
| id | A  | B  | C  | D   |
|  1 | 10 | 20 | 30 | 131 |
1 ROW IN SET (0.02 sec)

As I started manipulating these addresses I found it awkward to do common binary math (like bitwise ANDs). I decided instead to store these 32-bit values as unsigned integers (of length 32). To make my life easier yet, MySQL and PHP both have native functions to convert IP addresses between my old and new formats to make this migration extremely easy.
Continue reading

Open Source Router, Proprietary Cake

Keeping with SAI’s proclivity toward open source software, I present to you Vyatta.  Vyatta is a small company with the goal of taking down Cisco by offering an open source router that can run on standard x86 hardware.  With the prevalence of virtualization, one could realistically open a branch office using just a single x86 server with a T1 card from Vyatta.  The router, firewall, and VPN are covered by Vyatta and the apps could run in a virtualized OS.

Better yet is their current sales promotion.  If Cisco’s gross profit margin is 70%, Vyatta will give you a 30% discount.  As Cisco makes less money, Vyatta gets cheaper.

Lastly, proprietary cake tastes good.  I can prove it, too.

Mark is really excited with the Router Cake at his wedding

Mark is really excited with the Router Cake at his wedding

Internet Routing Tables Reaches 300,000

A few weeks ago the global routing table reached its 300,000th route.  Below is a graph showing the exponential growth over the last 15 years.

BGP Table (Yearly)

BGP Table (Yearly)

Let’s do a little math:

Assuming all 4.3 billion IPv4 addresses are used (which isn’t quite true), each route represents approximately 4,294,967,296 / 300,000 = 14317 addresses.   This is almost equivalent to a /18 (16,384 addresses).  However, there are only 2^18 = 262,144 subnets of this size.

Why are there so many routes in the table?

Because there are BGP Administrators who advertise junk like this.  AT&T WorldNet Services is advertising over 1100 prefixes; most of them are /24s.  Due to their lack of summarization, this one group of routers is responsible for almost .5% of the fluctuation in global routing tables during any given week.  That’s really bad.

Poke around here for some more info on BGP and the global routing table.