public String toString() {
return "UDP srcPort=" + srcPort + ", dstPort=" + dstPort + ", dataLength=" + getDataLength();
}
private int calcChecksum(SocketBuffer skbuf, int offset) {
final IPv4Header ipHdr = (IPv4Header) skbuf.getNetworkLayerHeader();
final SocketBuffer phdr = new SocketBuffer(12);
phdr.insert(12);
ipHdr.getSource().writeTo(phdr, 0);
ipHdr.getDestination().writeTo(phdr, 4);
phdr.set(8, 0);
phdr.set(9, ipHdr.getProtocol());
phdr.set16(10, udpLength);
phdr.append(offset, skbuf);
final int csLength = udpLength + 12;
return IPv4Utils.calcChecksum(phdr, 0, csLength);
}