dotplan

troubleshooting & performance analysis

Using pcapy and impacket to create a home-made packet decoder in python.

Tags: ,

A real tracer
I cobbled together this example from things I found on the interwebs as well as the demo code. Eventually I want to be able to decode NFS packets. So far, I can get the TCP port numbers – so that’s a start at least.

I used Mac OS X, and compiled both pcapy and impacket from source without any hassle.

from pcapy import open_offline
from impacket.ImpactDecoder import EthDecoder
from impacket.ImpactPacket import IP, TCP, UDP, ICMP

pcap = open_offline("some_packet_trace_file.trc")

decoder = EthDecoder()

def callback(hdr,data):
    print ".",
    packet=decoder.decode(data)
    l2=packet.child()
    if isinstance(l2,IP):
        print "IP",
        l3=l2.child()
        if isinstance(l3,TCP):
           src_ip = l2.get_ip_src()
           dst_ip = l2.get_ip_dst()
           tcp_dst_port = l3.get_th_sport()
           tcp_src_port = l3.get_th_dport()

           print "TCP from %s (%s) to %s(%s) " % (src_ip,tcp_src_port,dst_ip,tcp_dst_port)
        if isinstance(l3,UDP):
            print "UDP"

pcap.loop(0,callback)

print "Done"

The output looks like this

...
. IP TCP from 192.168.10.3 (2049) to 192.168.10.4(947)
. IP TCP from 192.168.10.3 (2049) to 192.168.10.4(947)
Done
  • Author: gary
  • Published: Mar 5th, 2011
  • Category: Apple
  • Comments: None

Uploading to blogger via iPhoto is broken by default.

Tags:

Trying to upload photo’s from your iPhoto application via Mail.app and mail2blogger? It will not work unless you switch to “Plain Text” (Shift+Apple+T) in the Apple Mail application. It seems that when iPhoto creates the email message in Mail.App it inserts additional markup into the mail which confuses blogger.com. The result is a blog page with broken links. If you manually attach a photo into Mail.App then the problem does not occur, which is why I think that iPhoto puts additional formatting into the mail message. In fact you can see that it does by looking at the raw source for the email (View->Message->Raw Source).

© 2009 dotplan. All Rights Reserved.

This blog is powered by Wordpress and Magatheme by Bryan Helmig.