ICMP extends BasePacket { @Override public IPacket deserialize(byte[] data, int offset, int length) { ByteBuffer bb = ByteBuffer.wrap(data, offset, length); this.icmpType = bb.get(); this.icmpCode = bb.get(); this.checksum = bb.getShort(); this.payload = new Data(); this.payload = payload.deserialize(data, bb.position(), bb.limit()-bb.position()); this.payload.setParent(this); return this; }  byte getIcmpType(); ICMP setIcmpType(byte icmpType); byte getIcmpCode(); ICMP setIcmpCode(byte icmpCode); short getChecksum(); ICMP setChecksum(short checksum); byte[] serialize(); @Override int hashCode(); @Override boolean equals(Object obj); @Override IPacket deserialize(byte[] data, int offset, int length);  }
@Test public void testDeserialize() { IPacket packet = new IPv4(); packet.deserialize(pktSerialized, 0, pktSerialized.length); byte[] pktSerialized1 = packet.serialize(); assertTrue(Arrays.equals(pktSerialized, pktSerialized1)); }