Here you can find the source of checksum_icmpv6(byte pkt[])
public static int checksum_icmpv6(byte pkt[])
//package com.java2s; //License from project: Open Source License public class Main { final static int OFS_IP6_PLEN = 4; final static int OFS_IP6_PLOAD = 40; final static int OFS_ICMP6_CSUM = 40 + 2; public static int checksum_icmpv6(byte pkt[]) { return checksum_icmpv6(pkt, 0); }/*from w ww . ja v a 2s.c om*/ public static int checksum_icmpv6(byte pkt[], int pktofs) { int plen = fetch_net16(pkt, pktofs + OFS_IP6_PLEN); int nxth = ((int) pkt[pktofs + 6]) & 0xff; // Pseudo header is IPv6 src/dst (included with packet) and plen/nxth and zeroes: int csum = plen + nxth; for (int i = 8; i < OFS_IP6_PLOAD + plen; i += 2) { if (i != OFS_ICMP6_CSUM) { // Skip current checksum value csum += fetch_net16(pkt, pktofs + i); } } // No need to treat a trailing single byte: ICMPv6 has no odd packet lengths csum = (csum & 0xffff) + (csum >> 16); csum = (csum & 0xffff) + (csum >> 16); csum = csum ^ 0xffff; // 1's complement limited to 16 bits return csum; } public static int fetch_net16(byte pkt[], int ofs16) { int retval = ((int) pkt[ofs16]) << 8 & 0xff00; retval = retval + (((int) pkt[ofs16 + 1]) & 0xff); return retval; } }