1

I am setting up a QUdpSocket broadcaster. when I view the output in wireshark, it says my packets are malformed. Inspecting the packets, it appears they are not emitted with an ethernet trailer. Do I need to emit this myself, or do you see another issue? My code below is slightly condensed. Note that if connected via crossover cable my receiving device (micro-controller) does see and respond to the packet (as seen on wireshark). I want to make sure I don't have malformed frames so I can use this on a switched network which allows UDP traffic.

Thanks

const quint16 s_packetHeader = 0x5A5A;
const quint16 s_sendReadBackRegisters = 0x0203;

m_udpSocketWriter= new QUdpSocket(this);
QByteArray datagram;
QDataStream ds(&datagram, QIODevice::WriteOnly);
ds.setVersion(QDataStream::Qt_4_8);
ds << s_packetHeader << s_sendReadBackRegisters;
m_udpSocketWriter->writeDatagram(datagram.data(), datagram.size(), QHostAddress::Broadcast, 5000);

and the output from wireshark

"1243","886.645245000","172.27.1.117","255.255.255.255","UDP","46","Source port: 58411  Destination port: 5000[Malformed Packet]"

0000   ff ff ff ff ff ff d4 3d 7e 31 e0 27 08 00 45 00  .......=~1.'..E.
0010   00 20 38 6b 00 00 80 11 54 d2 ac 1b 01 75 ff ff  . 8k....T....u..
0020   ff ff e4 2b 13 88 00 0c fe 34 5a 5a 02 03        ...+.....4ZZ..

Note that the last four bytes correspond to the data I sent, 5A 5A 02 03.

According to a google image search, the packet is missing the trailer bits... although I am no network expert that is totally a guess.

Windows 7 x64, VS2010, QT 4.8-latest x64

user2025983
  • 178
  • 10
  • I too have seen something similar (the row in wireshark is colored maroon/pink/black) but unfortunately I was unable to figure out what was wrong since the receiving end-point never had issues. Can you verify that data is being received correctly? Also, I would try to setup wireshark on another node that can receive packets. I hope someone knows how/why this happens. – Son-Huy Pham Aug 05 '13 at 19:43
  • 1
    Note that QUdpSocket works on Layers 4/3, not on Layer 2. Which is the one that adds the trailer. Im pretty sure thats OS work (you could send a packet through you wifi/eth lan, etc... and that implementation is transparent to you.) Although Im not a Win lover... i dont think its making the layer 2 encapsulation bad. So i would focus on the part you can modify, only. Eg. a wrong packet size? Something like that... – trompa Aug 06 '13 at 09:36
  • OSI Layers, ofc. On Internet model it would be TCP(UDP) / IP stack. Either way, the Data Link layer would be the one adding a trailer/fcs/whatever. – trompa Aug 06 '13 at 11:11

0 Answers0