我正在构建一个以太网模拟项目,以将UDP软件包发送到外部设备(我们称之为A)。
我应该模拟多个设备,其中一些设备发送了UDP软件包(我们称它们为b),而有些则接收UDP软件包(我们称它们为C),B和C在两个不同的VLAN上,具有两个不同的ID。
我使用了B和C的外部ETH/适配器,该元件都连接到主设备A旁边的开关(可以看到VLAN的两个)。然后,我通过将“ VLAN和优先级”设置为启用并将VLAN ID设置为每个B和C的正确ID来配置Windows上的两个ETH/ADP,最后,我为其中每个设置了每个B和C。
然后,我使用QT来创建仿真项目,接收零件是完美的设备A将UDP软件包传输到多播,我将与VLAN C一起在多播上加入并开始读取这些帧。
问题在于发送,我能够正确发送框架,但是定义优先级,dei和ID的4个字节丢失(这意味着设备A未接收和倾倒这些帧)
,您可以在下面的屏幕截图中看到在右侧,设备A和左侧接受的健康包裹的健康包装,未接受的模拟帧
这是我用来绑定和加入多播的代码
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 ..." ;
,这是发送的函数(interface-&gt; 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;
}
,请有人请指出如何设置这些值,以设置这些值的天气。 QT中VLAN或插座的配置?
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 ?
发布评论
评论(1)
因此,是的,正如 @Zac67所提到的,主要问题是ETH/USB适配器不支持此协议,我可以选择不断寻找正确的适配器,或者像我最终一样,更改HW设置和乘坐适配器,相反,我使用了机器上的本机NIC以太网端口,并使用Hyper-V进行了配置来模拟VLAN
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