Search code examples
windowsqtudpethernetvlan

VLAN Priority, DEI and ID are missing in UDP Package


I am building an ethernet simulation project to send and receive UDP packages to an external device (let's call it A).

I am supposed to simulate multiple devices, some of them send UDP packages (let's call them B) and some receive UDP packages (let's call them C), B and C are on two different VLANs with two different IDs.

I used an external ETH/Adapter for B and C, which both are connected to a switch alongside the main device A (which can see both the VLANs). then I configured the two eth/adp on windows by setting the "VLAN and Priority" to Enabled and Set VLAN ID with the correct ID for each B and C, finally, I set static IPs for each one of them.

I then used QT to create the simulation project, The Receiving parts are perfect Device A is transmitting UDP packages to Multicast and I join with VLAN C on the Multicast and start reading these frames.

The problem is with sending, I am able to send the frames correctly however the 4 bytes that define the Priority, DEI, and ID are missing (which means device A is not receiving and dumping these frames)

You can see in the below screenshot, on the right the healthy packages that are accepted by device A and on the left the simulated frames that are not accepted

Comaprison between accepted and unaccepted packages

Here is the Code I use to bind and Join Multicast

    socket_1 = new QUdpSocket(this);
    qDebug() << "Binding UDP Socket ..." ;

    bool bind_res = socket_1->bind(QHostAddress("192.168.11.4"), 51011 , QUdpSocket::ShareAddress);
    if(!bind_res)
    {
        qDebug() << "Faild to bind with Error: " +socket_1->errorString() ;
        QApplication::quit();
    }

    bool join_res = socket_1->joinMulticastGroup(interface->GRP_IP,interface->Qinterface);
    if(!join_res)
    {
        qDebug() << "Failed to join with error: "+ socket_1->errorString() ;
        QApplication::quit();
    }
    connect(socket_1, SIGNAL(readyRead()), this, SLOT(handleReadyRead()));
    qDebug() << "UDP Socket initialized successfully ..." ;

and here is the function to send (interface->GRP_IP is the Multicast IP)

void UDPSocket_VLAN11::sendUDP_1(QByteArray data)
{
    qint64 res =  socket_1->writeDatagram(data, interface->GRP_IP, 50011);
    qDebug() << " --- Sending UDP Packet ---";
    qDebug() << "Sending to: " << interface->GRP_IP;
    qDebug() << "Sending port: " << port;
    qDebug() << "Sending Size: " << data.size();
    qDebug() << "Sending: " << data.toHex().toLower();
    qDebug() << "Sending Result: " << res;
}

Can someone please point how to set these values weather it's in the configuration of the VLAN or the socket in QT ?


Solution

  • So yes, as @Zac67 mentioned, the main issue was that the eth/usb adapters weren't supporting this protocol and I had a choice of either keep looking for the right adapters or, as I finally did, to change the HW setup and get ride of the adapters and instead I used the native NIC ethernet port on the machine and configured it using Hyper-V to simulate the VLAN