public void sendPnDcpDiscoveryRequest() {
        for (Map.Entry<MacAddress, PcapHandle> entry : channel.getOpenHandles().entrySet()) {
            MacAddress localMacAddress = entry.getKey();
            PcapHandle handle = entry.getValue();

            // Construct and send the search request.
            Ethernet_Frame identificationRequest = new Ethernet_Frame(
                PROFINET_BROADCAST_MAC_ADDRESS,
                localMacAddress,
                new Ethernet_FramePayload_VirtualLan(VirtualLanPriority.BEST_EFFORT, false, (short) 0,
                    new Ethernet_FramePayload_PnDcp(
                        new PnDcp_Pdu_IdentifyReq(0xFEFE,
                            1,
                            256,
                            Collections.singletonList(
                                new PnDcp_Block_ALLSelector()
                            )))));

            WriteBufferByteBased buffer = new WriteBufferByteBased(identificationRequest.getLengthInBytes());
            try {
                identificationRequest.serialize(buffer);
            } catch (SerializationException e) {
                throw new RuntimeException(e);
            }
            try {
                Packet packet = EthernetPacket.newPacket(buffer.getBytes(), 0, identificationRequest.getLengthInBytes());
                handle.sendPacket(packet);
            } catch (PcapNativeException e) {
                // This occurs, if for example the Wi-Fi network is disabled.
                if(!e.getMessage().contains("Network is down")) {
                    throw new RuntimeException(e);
                }
            } catch (NotOpenException | IllegalRawDataException e) {
                throw new RuntimeException(e);
            }
        }
    }
This Discoverer makes use of part of the Profinet driver.
As every S7 device we know supports Profinet, we'll use the Profinet auto-discovery mechanism
and filter out the devices for which we know support the S7 comm protocol.
plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/discovery/S7PlcDiscoverer.java