@Test
public void testDecode_AlternatingBits() throws Exception {

    byte[] ethPayload = {
        0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xab,
        (byte) 0xcd, (byte) 0xef, 0x01, 0x23, 0x45, 0x67,
        (byte) 0x81, 0x00,
        (byte) 0xff, (byte) 0xff,
        (byte) 0x86, (byte) 0xdd,
        (byte) 0xf5, // Version = 15,  IHL = 5
        (byte) 0x0f, // DSCP =3, ECN = 3
        0x00, 0x00, // Total Length -- 30
        (byte) 0xff, (byte) 0xff, // Identification -- 65535
        (byte) 0x1f, (byte) 0xff, // Flags = all off & Fragment offset = 8191
        0x00, 0x06, // TTL = 00, Protocol = TCP
        (byte) 0xff, (byte) 0xff, // Checksum = 65535
        (byte) 0x00, (byte) 0x00, 0x00, 0x00, // Src IP Address
        (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
        // Dest IP Address
        0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, // 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(18).build()).build());
    Ipv4PacketReceived notification = new Ipv4Decoder(npServiceMock).decode(
            new EthernetPacketReceivedBuilder().setPacketChain(packetChainList).setPayload(ethPayload).build());
    Ipv4Packet ipv4Packet = (Ipv4Packet) notification.getPacketChain().get(2).getPacket();
    assertEquals(15, ipv4Packet.getVersion().intValue());
    assertEquals(5, ipv4Packet.getIhl().intValue());
    assertEquals(0, ipv4Packet.getIpv4Length().intValue());
    assertEquals(3, ipv4Packet.getDscp().getValue().intValue());
    assertEquals(3, ipv4Packet.getEcn().intValue());
    assertEquals(0, ipv4Packet.getIpv4Length().intValue());
    assertEquals(65535, ipv4Packet.getId().intValue());
    assertFalse(ipv4Packet.isReservedFlag());
    assertFalse(ipv4Packet.isDfFlag());
    assertFalse(ipv4Packet.isMfFlag());
    assertEquals(8191, ipv4Packet.getFragmentOffset().intValue());
    assertEquals(0, ipv4Packet.getTtl().intValue());
    assertEquals(KnownIpProtocols.Tcp, ipv4Packet.getProtocol());
    assertEquals(65535, ipv4Packet.getChecksum().intValue());
    Ipv4Address srcAddress = new Ipv4Address("0.0.0.0");
    Ipv4Address dstAddress = new Ipv4Address("255.255.255.255");
    assertEquals(srcAddress, ipv4Packet.getSourceIpv4());
    assertEquals(dstAddress, ipv4Packet.getDestinationIpv4());
    assertEquals(10, ipv4Packet.getPayloadLength().intValue());
    assertEquals(38, ipv4Packet.getPayloadOffset().intValue());
    assertTrue(Arrays.equals(ethPayload, notification.getPayload()));
}