src/org/jnetpcap/protocol/tcpip/Udp.java
public int calculateChecksum() {

		if (getIndex() == -1) {
			throw new IllegalStateException("Oops index not set");
		}

		final int ipOffset = getPreviousHeaderOffset();

		return Checksum.inChecksumShouldBe(checksum(), Checksum.pseudoUdp(
		    this.packet, ipOffset, getOffset()));
	}
/**
	 * Calculates a checksum using protocol specification for a header. Checksums
	 * for partial headers or fragmented packets (unless the protocol alows it)
	 * are not calculated.
	 * <p>
	 * The method used to compute the checksum is defined in RFC 768:
	 * 
	 * <pre>
	 * Checksum is the 16-bit one's complement of the one's complement sum of 
	 * a pseudo header of information from the IP header, the UDP header, 
	 * and the data, padded with zero octets at the end (if necessary) to make 
	 * a multiple of two octets.
	 * </pre>
	 * 
	 * In other words, all 16-bit words are summed using one's complement
	 * arithmetic. The sum is then one's complemented to yield the value of the
	 * UDP checksum field. If the checksum calculation results in the value zero
	 * (all 16 bits 0) it should be sent as the one's complement (all 1's). The
	 * difference between IPv4 and IPv6 is in the data used to compute the
	 * checksum.
	 * </p>
	 * 
	 * @return header's calculated checksum
	 */
Calculates a checksum using protocol specification for a header. Checksums
for partial headers or fragmented packets (unless the protocol alows it)
are not calculated.

The method used to compute the checksum is defined in RFC 768.


Checksum is the 16-bit one's complement of the one's complement sum of
a pseudo header of information from the IP header, the UDP header,
and the data, padded with zero octets at the end (if necessary) to make
a multiple of two octets.

In other words, all 16-bit words are summed using one's complement
arithmetic. The sum is then one's complemented to yield the value of the
UDP checksum field. If the checksum calculation results in the value zero
(all 16 bits 0) it should be sent as the one's complement (all 1's). The
difference between IPv4 and IPv6 is in the data used to compute the
checksum.

@return header's calculated checksum
Calculates a checksum using protocol specification for a header . Checksums for partial headers or fragmented packets ( unless the protocol alows it ) are not calculated . The method used to compute the checksum is defined in RFC 768 . Checksum is the 16 - bit one ' s complement of the one ' s complement sum of a pseudo header of information from the IP header the UDP header and the data padded with zero octets at the end ( if necessary ) to make a multiple of two octets . In other words all 16 - bit words are summed using one ' s complement arithmetic . The sum is then one ' s complemented to yield the value of the UDP checksum field . If the checksum calculation results in the value zero ( all 16 bits 0 ) it should be sent as the one ' s complement ( all 1 ' s ) . The difference between IPv4 and IPv6 is in the data used to compute the checksum . @return header ' s calculated checksum
public int calculateChecksum() {
		if (getIndex() == -1) {
			throw new IllegalStateException("Oops index not set");
		}
		final int ipOffset = getPreviousHeaderOffset();
		return Checksum.inChecksumShouldBe(checksum(), Checksum.pseudoUdp(
		    this.packet, ipOffset, getOffset()));
	}
public int calculateChecksum ( ) { if ( getIndex ( ) == - 1 ) { throw new IllegalStateException ( "Oops index not set" ) ; } final int ipOffset = getPreviousHeaderOffset ( ) ; return Checksum . inChecksumShouldBe ( checksum ( ) , Checksum . pseudoUdp ( this . packet , ipOffset , getOffset ( ) ) ) ; }
Calculates a checksum using protocol specification for a header.
Calculates a checksum using protocol specification for a header .