User:Roelroscama/trim1/protoyping

From XPUB & Lens-Based wiki
Roel Roscam Abbing, Trimester I, 2012

Traceroute maps

Description

Based on the texts discussed during the RW&R Methodologies class I started to become interested by the physical aspects of the internet. The fact that packets travel from server to server and in this process might travel through different countries and jurisdictions. To research this I wanted to map the different servers one visits before one reaches a certain website. This can be done using the shell command Traceroute, which will output the server routing data in a regular format. Using python and the pygeoip library I then tried to link the ip addresses to countries and convert the data into something that can be visualized using Graphviz's DOT language. I've made a first few rough prototypes and I'm now looking at the different lay-out possibilities.

Media

code

# imports the geoip database and the sys function
import pygeoip, sys, string

# creates a variable called "filename" that equals the first thing that
# has been put after the execution of "routetodot[dot]py"
filename = sys.argv[1]

#creates a variable of the geoip database from the file "GeoIP.dat"
GEOIP = pygeoip.Database('GeoIP.dat')


#create a variable called lastIp



lastNUM = None	 
# create a variable "line" from every line in the "filename"
# split this "line" into a variable called "data"
# check if "data" starts and ends with "(" ")"
# if so create a variable called "ip" that is "data" without "()"
# look up "ip" in the "GEOIP" variable
# checks if "a.country" returns none, it is then printed as "localhost"
# prints the variables "lastIp" and "ip"
# changes "lastIp" into "ip"
lineNUM = 0;
labels = "";
connections = "";
colorsbycountry = dict(US='blue',NL='orange',DE='grey',CN='red',localhost='pink',IE='green',FR='purple',GB='crimson', EU='sienna' )
colors = '"0.8396,0.4862,1.0" "0.8396,0.4862,0.8"  "0.8396,0.4862,0.6" "0.8396,0.4862,0.4" "0.8396,0.4862,0.2" "0.8396,0.4862,0.0"'.split()

nodenamebyip = {}
nodenum=0
lastip = None

colorindex=0;
for line in open(filename):
	parts = line.split()
	NUM = parts[0]
	lineNUM +=1
	for data in parts:	
		#line[1]
		if data.startswith("(") and data.endswith(")"):
			ip= data.strip("()")
			a= GEOIP.lookup(ip)

			if a.country == None:
				a.country = "localhost"
			
			if a.country not in colorsbycountry:
				colorsbycountry[a.country] = colors[colorindex]
				colorindex+=1
				
			labelcolor = colorsbycountry[a.country]
		
			if ip not in nodenamebyip:
				nodenum+=1
				nodenamebyip[ip] = "node"+str(nodenum)
				# first time, print label
				
			nn = nodenamebyip[ip]
			#labels+= nn +' [label="'+ip+' '+a.country+'" fontcolor="'+labelcolor+'" style="filled"]\n'
			#labels+= str(lineNUM)+' [label="'+ip+' '+a.country+'" fontcolor='+labelcolor+' style=filled]\n'
			labels+= str(lineNUM)+' [label="'+ip+' '+a.country+'" fillcolor='+labelcolor+']\n'
			
			
			if lastNUM != None:
				connections+= str(lastNUM)+"->"+str(lineNUM)+'\n'
			#	connections+= nodenamesbyip[lastip]+"->"+nodenamesbyip[ip]+'\n'
				
			lastNUM = lineNUM
			lastip = ip	
			
			graphname = filename;
			if graphname.endswith(".txt"):
				graphname = graphname.strip(".txt")
			
print "digraph iptrace {\n bgcolor = grey; \n node [shape=rect, fontname=Arial, fontcolor=white, style=filled] \n edge [style=dotted] \n"
print 'label=','"'+graphname+'"'
print labels
print connections
print "}"


Photos

The raw output of Traceroute for belbios.nl
The graph output in the DOT language after running the script
The output rendered in Graphviz

Essay

Abstract and bibs/ref + link to PDF (PDF must be uploaded to wiki).
Use Steve's recommendations for abstract length and bibliographic style.

Additional Information

non optional

  • One page itemised budget estimate

optional

  • Project URL (if lives on an external site)
  • extra wiki links (in case you have relevant notes/journals/documentation in your User: page, this is useful particularly if you have been asked to articulate further or refine your project during your assessment)
  • Animated GIFs