### Question:
EthernetPacketToolbox { public static IPacket extractPayload(Ethernet packet, List<Integer> vlanStack) { short rootVlan = packet.getVlanID(); if (0 < rootVlan) { vlanStack.add((int) rootVlan); } IPacket payload = packet.getPayload(); while (payload instanceof VlanTag) { short vlanId = ((VlanTag) payload).getVlanId(); vlanStack.add((int) vlanId); payload = payload.getPayload(); } return payload; } private  EthernetPacketToolbox(); static IPacket injectVlan(IPacket payload, int vlanId, EthType type); static IPacket extractPayload(Ethernet packet, List<Integer> vlanStack);  }### Answer:
@Test public void extractEthernetPayloadTest() { short vlan1 = 1234; short vlan2 = 2345; short vlan3 = 4000; byte[] originPayload = new byte[]{0x55, (byte) 0xAA}; Ethernet ethernet = buildEthernet( new byte[]{ 0x01, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x01, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B }, ethTypeToByteArray(EthType.Q_IN_Q), shortToByteArray(vlan1), ethTypeToByteArray(EthType.BRIDGING), shortToByteArray(vlan2), ethTypeToByteArray(EthType.VLAN_FRAME), shortToByteArray(vlan3), ethTypeToByteArray(EthType.IPv4), originPayload); List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(ethernet, vlans); assertEquals(3, vlans.size()); assertEquals(Integer.valueOf(vlan1), vlans.get(0)); assertEquals(Integer.valueOf(vlan2), vlans.get(1)); assertEquals(Integer.valueOf(vlan3), vlans.get(2)); assertArrayEquals(originPayload, payload.serialize()); }