assertNotNull(errbuf.toString(), pcap);
pcap.loop(Pcap.LOOP_INFINATE, new PcapPacketHandler<String>() {
Ip4 ip = new Ip4();
Tcp tcp = new Tcp();
// public void nextPacket(PcapHeader header, JBuffer buffer, String user)
// {
public void nextPacket(PcapPacket packet, String user) {
if (packet.hasHeader(tcp) == false) {
return;
}
// PcapPacket packet = new PcapPacket(header, buffer);
long f = packet.getFrameNumber();
assertTrue("#" + f, packet.hasHeader(ip));
final int crc =
Checksum.pseudoTcp(packet, ip.getOffset(), tcp.getOffset());
if (crc != 0 && tcp.checksum() != crc) {
System.out.println(tcp);
System.out.printf("#%d: tcp.crc=%x computed=%x\n", f, tcp.checksum(),
crc);
// System.out.println(ip.toHexdump());
// System.out.println(tcp.toHexdump());
System.exit(0);
}