import os, sys, socket, struct, select, time
# from /usr/include/linux/icmp.h; your milage may vary.
icmp_echo_request = 8 # seems to be the same on solaris.
i’m not too confident that this is right but testing seems
to suggest that it gives the same answers as in_cksum in ping.c
sum = 0
countto = (len(source_string)/2)*2
count = 0
while count 16) + (sum & 0xffff)
sum = sum + (sum >> 16)
answer = ~sum
answer = answer & 0xffff
# swap bytes. bugger me if i know why.
answer = answer >> 8 | (answer