Esempio n. 1
0
 @Test
 public void testDeserialize() {
   IPacket packet = new IPv4();
   packet.deserialize(pktSerialized, 0, pktSerialized.length);
   byte[] pktSerialized1 = packet.serialize();
   assertTrue(Arrays.equals(pktSerialized, pktSerialized1));
 }
Esempio n. 2
0
 @Test
 public void testSerialize() {
   IPacket packet =
       new IPv4()
           .setIdentification((short) 0)
           .setFlags((byte) 0x02)
           .setTtl((byte) 64)
           .setSourceAddress("192.168.10.231")
           .setDestinationAddress("192.168.10.219")
           .setPayload(
               new ICMP()
                   .setIcmpType((byte) 8)
                   .setIcmpCode((byte) 0)
                   .setPayload(new Data(new byte[] {0x76, (byte) 0xf2, 0x0, 0x2, 0x1, 0x1, 0x1})));
   byte[] actual = packet.serialize();
   assertTrue(Arrays.equals(pktSerialized, actual));
 }