You are viewing a read-only archive of the Blogs.Harvard network. Learn more.
Skip to content

Wishlist: Scapy traceroute object pickling

Some of the projects I am working on require that I gather data about particular addresses on the Internet. One method I’ve been experimenting with is scapy’s traceroute function which allows for neat graphing []. One can also combine two arbitrary traceroutes for graphing as simply as:

traceroute1, unans = traceroute([])
traceroute2, unans = traceroute([])
combined_traceroutes = traceroute1 + traceroute2

So for me the next logical step was to start storing all the traceroutes in a database so I could combine two or more at will and see interesting things. Not only could I see differences in different paths but I could even see changes of a single path over time! I fought with scapy for a while and finally realized that the export_object and save_object functions are wrappers for cPickle. I’m not entirely familiar with Pickle so I’ve had to do some reading on the topic. So far it does not look promising. No one has come up with a solution for this just yet although there are some promising recipes in the O’Reilly “Python Cookbook” which touch on this subject in a more abstract way. [“Using the cPickle Module on classes and Instances”]

I’ll document some of the errors in case someone else decides to try this and wants to save some time:

>>> trace, unans = traceroute([""])

>>> save_object("/tmp/hi", trace)
Traceback (most recent call last):
File "", line 1, in
File "", line 876, in save_object
File "/usr/lib/python2.5/", line 69, in _reduce_ex
raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle function objects

>>> export_object(trace)
Traceback (most recent call last):
File "", line 1, in
File "", line 867, in export_object
print base64.encodestring(gzip.zlib.compress(cPickle.dumps(obj,2),9))
PicklingError: Can't pickle : attribute lookup __builtin__.function failed

Post a Comment

You must be logged in to post a comment.