System.out.println(packet.toHexdump(128, false, false, true));
System.out.println(packet.getState().toDebugString());
Ip4 ip = new Ip4();
Icmp icmp = new Icmp(); // Need an instance so we can check on sub header
Icmp.DestinationUnreachable unreach = new Icmp.DestinationUnreachable();
assertTrue(packet.hasHeader(Ethernet.ID));
assertTrue(packet.hasHeader(JProtocol.IP4_ID, 0));
assertTrue(packet.hasHeader(icmp));
assertTrue(icmp.hasSubHeader(IcmpType.DESTINATION_UNREACHABLE.getId()));
assertTrue(icmp.hasSubHeader(unreach));
assertTrue(packet.hasHeader(ip, 1));
assertTrue(packet.hasHeader(Udp.ID));
assertTrue(packet.hasHeader(Payload.ID));
// Check specific values
assertEquals(3, icmp.type());
assertEquals(3, icmp.code());
assertEquals(0x2731, icmp.checksum());
assertEquals(0, unreach.reserved());
assertEquals(0x8724, ip.checksum());
assertEquals(440, ip.length());
// Devil's advocate
assertFalse(icmp.hasSubHeader(IcmpType.ECHO_REPLY.getId()));
assertFalse(icmp.hasSubHeader(IcmpType.PARAM_PROBLEM.getId()));
}