Monday, March 25, 2013

how big is the public cloud?

Fun question came up today about cloud resources and IP adresses. Totally randomly, I also spotted a tweet by my pal Pax, and decided to put two and two together to come up with new values of four!


So I decided to get a little crazy!

jcuff@jcuff-virtualbox:~/netaddr$ wget -qO - https://forums.aws.amazon.com/ann.jspa?annID=1701 | grep -Eoh "[0-9.]+{4}/[0-9]+" | xargs -I % ./size.py % | awk '{print sum=sum+$2}' | tail -1

3,702,664

So enough for over 3.7 million public hosts all thanks to netaddr and a pointer from my pal Pax. Oh, here's the code, remember there are always 2 less hosts per "ip.size" so chopped off two...


jcuff@jcuff-virtualbox:~/netaddr$ cat size.py
#!/usr/bin/python
import sys
from netaddr import *
import pprint
ip = IPNetwork(sys.argv[1])
print sys.argv[1], ip.size-2


And the raw output:

jcuff@jcuff-virtualbox:~/netaddr$ wget -qO - https://forums.aws.amazon.com/ann.jspa?annID=1701 | grep -Eoh "[0-9.]+{4}/[0-9]+" | xargs -I % ./size.py %
72.44.32.0/19 8190
67.202.0.0/18 16382
75.101.128.0/17 32766
174.129.0.0/16 65534
204.236.192.0/18 16382
184.73.0.0/16 65534
184.72.128.0/17 32766
184.72.64.0/18 16382
50.16.0.0/15 131070
50.19.0.0/16 65534
107.20.0.0/14 262142
23.20.0.0/14 262142
54.242.0.0/15 131070
54.234.0.0/15 131070
54.236.0.0/15 131070
54.224.0.0/15 131070
54.226.0.0/15 131070
54.208.0.0/15 131070
54.210.0.0/15 131070
50.112.0.0/16 65534
54.245.0.0/16 65534
54.244.0.0/16 65534
54.214.0.0/16 65534
204.236.128.0/18 16382
184.72.0.0/18 16382
50.18.0.0/16 65534
184.169.128.0/17 32766
54.241.0.0/16 65534
54.215.0.0/16 65534
79.125.0.0/17 32766
46.51.128.0/18 16382
46.51.192.0/20 4094
46.137.0.0/17 32766
46.137.128.0/18 16382
176.34.128.0/17 32766
176.34.64.0/18 16382
54.247.0.0/16 65534
54.246.0.0/16 65534
54.228.0.0/16 65534
54.216.0.0/15 131070
54.229.0.0/16 65534
175.41.128.0/18 16382
122.248.192.0/18 16382
46.137.192.0/18 16382
46.51.216.0/21 2046
54.251.0.0/16 65534
54.254.0.0/16 65534
54.255.0.0/16 65534
54.252.0.0/16 65534
54.253.0.0/16 65534
175.41.192.0/18 16382
46.51.224.0/19 8190
176.32.64.0/19 8190
103.4.8.0/21 2046
176.34.0.0/18 16382
54.248.0.0/15 131070
54.250.0.0/16 65534
177.71.128.0/17 32766
54.232.0.0/16 65534
54.233.0.0/18 16382

I make no apologies for the abuse of xargs and python in the making of this movie!

Update: this has been done before, but never with such epic one liners ref:

http://gigaom.com/2012/04/20/just-how-big-is-the-amazon-cloud-anyway/ :-)


[any opinions here are all mine, and have absolutely nothing to do with my employer]
(c) 2011 James Cuff