简体   繁体   English

UDP Package 中缺少 VLAN 优先级、DEI 和 ID

[英]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).我正在构建一个以太网模拟项目,以将 UDP 包发送和接收到外部设备(我们称之为 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.我应该模拟多个设备,其中一些发送 UDP 包(我们称它们为 B)和一些接收 UDP 包(我们称它们为 C),B 和 Z0D61F8370CAD1D412F80B84D143E1 上有两个不同的 VLAN。

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).我为 B 和 C 使用了外部 ETH/适配器,它们都连接到主设备 A 旁边的交换机(可以看到两个 VLAN)。 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.然后我在 windows 上配置了两个 eth/adp,方法是将“VLAN 和优先级”设置为已启用,并为每个 B 和 C 设置正确的 ID 的 VLAN ID,最后,我为每个 B 设置 ZA81259CEF8E959C624DFD1D4 中的一个。

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.然后我使用 QT 创建模拟项目,接收部分是完美的 设备 A 正在将 UDP 包传输到多播,我加入 VLAN C 并开始阅读这些多播帧。

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)问题在于发送,我能够正确发送帧,但是缺少定义优先级、DEI 和 ID 的 4 个字节(这意味着设备 A 没有接收和转储这些帧)

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您可以在下面的屏幕截图中看到,右侧是设备 A 接受的健康包,左侧是不接受的模拟帧

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)这是要发送的 function (interface->GRP_IP 是多播 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?有人可以指出如何在 VLAN 配置或 QT 中的套接字中设置这些值吗?

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所以是的,正如@Zac67 提到的,主要问题是 eth/usb 适配器不支持此协议,我可以选择继续寻找正确的适配器,或者像我最终所做的那样,更改硬件设置和使用适配器,而是使用机器上的本机 NIC 以太网端口并使用 Hyper-V 对其进行配置以模拟 VLAN

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM