@Test
public void testDecode_WithDiffServAndFlagsAndOffset() throws Exception {

    byte[] ethPayload = {
        0x01, 0x23, 0x66, 0x67, (byte) 0x89, (byte) 0xab, //src mac
        (byte) 0xcd, (byte) 0xef, 0x01, 0x23, 0x45, 0x67, //dst mac
        (byte) 0x81, 0x00,
        0x08, 0x00, // EtherType
        0x45, // Version = 4,  IHL = 5
        (byte) 0xff, // DSCP =63, ECN = 3
        0x00, 0x1E, // Total Length -- 30
        0x01, 0x1E, // Identification -- 286
        (byte) 0xf0, 0x00, // Flags = all on & Fragment offset = 0
        0x12, 0x06, // TTL = 18, Protocol = TCP
        (byte) 0x00, 0x00, // Checksum = 0
        (byte) 0xc0, (byte) 0xa8, 0x00, 0x01, // Src IP Address
        0x01, 0x02, 0x03, 0x04, // Dest IP Address
        0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11,
        0x12, 0x13, // Data
        (byte) 0x98, (byte) 0xfe, (byte) 0xdc, (byte) 0xba // CRC
    };
    NotificationProviderService npServiceMock = Mockito.mock(NotificationProviderService.class);
    ArrayList<PacketChain> packetChainList = new ArrayList<>();
    packetChainList.add(new PacketChainBuilder().setPacket(new RawPacketBuilder().build()).build());
    packetChainList.add(
            new PacketChainBuilder().setPacket(new EthernetPacketBuilder().setPayloadOffset(16).build()).build());
    Ipv4PacketReceived notification = new Ipv4Decoder(npServiceMock).decode(
            new EthernetPacketReceivedBuilder().setPacketChain(packetChainList).setPayload(ethPayload).build());
    Ipv4Packet ipv4Packet = (Ipv4Packet) notification.getPacketChain().get(2).getPacket();
    assertEquals(4, ipv4Packet.getVersion().intValue());
    assertEquals(5, ipv4Packet.getIhl().intValue());
    assertEquals(30, ipv4Packet.getIpv4Length().intValue());
    assertEquals(63, ipv4Packet.getDscp().getValue().intValue());
    assertEquals(3, ipv4Packet.getEcn().intValue());
    assertEquals(30, ipv4Packet.getIpv4Length().intValue());
    assertEquals(286, ipv4Packet.getId().intValue());
    assertTrue(ipv4Packet.isReservedFlag());
    assertTrue(ipv4Packet.isDfFlag());
    assertTrue(ipv4Packet.isMfFlag());
    assertEquals(4096, ipv4Packet.getFragmentOffset().intValue());
    assertEquals(18, ipv4Packet.getTtl().intValue());
    assertEquals(KnownIpProtocols.Tcp, ipv4Packet.getProtocol());
    assertEquals(0, ipv4Packet.getChecksum().intValue());
    Ipv4Address srcAddress = new Ipv4Address("192.168.0.1");
    Ipv4Address dstAddress = new Ipv4Address("1.2.3.4");
    assertEquals(srcAddress, ipv4Packet.getSourceIpv4());
    assertEquals(dstAddress, ipv4Packet.getDestinationIpv4());
    assertEquals(13, ipv4Packet.getPayloadLength().intValue());
    assertEquals(36, ipv4Packet.getPayloadOffset().intValue());
    assertTrue(Arrays.equals(ethPayload, notification.getPayload()));
}