I am writing a Qt (5.6) application that communicates with an FPGA over UDP socket. Packets are being streamed to the PC at 2 KHz (all packets identical size, 1272 bytes). Wireshark shows that packets are being sent, and the UDP header is as expected. The problem is, the Qt UDP Socket that I am using is never receiving these packets. The readyRead signal is never called.
Here is a code snippet:
UdpConnection::UdpConnection(QObject* parent)
{
fpgaConnection = QSharedPointer<QUdpSocket>(new QUdpSocket);
qDebug() << connect(fpgaConnection.data(), &QUdpSocket::readyRead, this, &UdpConnection::readyRead);
if (fpgaConnection->bind(QHostAddress("192.168.10.10"), 1920))
{
qDebug() << "Successfully Bound!";
}
else
{
qDebug() << "BINDING FAILURE";
}
fpgaConnection->connectToHost(QHostAddress("192.168.10.200"), 1919);
sendArpRequest();
}
void UdpConnection::readyRead()
{
while (fpgaConnection->hasPendingDatagrams())
{
QByteArray buffer;
buffer.resize(fpgaConnection->pendingDatagramSize());
QHostAddress sender;
quint16 senderPort;
fpgaConnection->readDatagram(buffer.data(), buffer.size(), &sender, &senderPort);
qDebug() << "Message from:" << sender;
qDebug() << "Message port:" << senderPort;
qDebug() << buffer;
}
}
- UdpConnection is not running on a separate thread from main. Should it be?
- I am binding successfully, and I would assume that "connectToHost" is working because I'm able to send a message to the remote host.
- The application has been added to the Firewall exception list (again, the ARP handshake proves that they are capable of communicating).
- The interface is a direct ethernet connection between the FPGA and a PC.
Why is Wireshark able to see these messages, but my program is not?
UPDATE #1 Wireshark has the 2KHz packets as LLC packets. The Ethernet Header shows a correct Destination (my MAC address), Source Address (hard coded in the FPGA), and Length. The IP header has the Source IP as 192.168.10.200 and the Destination IP as 192.168.10.10, UDP Header has Source Port as 1920 and Destination Port as 1919.
UPDATE #2 Wireshark logs: paste.ee/p/98c1H As you can see, the packet is repeated and sent from the FPGA at 2KHz. The ARP transmission and reply can be found as the 5th, 10th, and 11th packet.
UPDATE #3 The IP packets of the incoming packets have a correct checksum that is NOT being set to 0x0000.
192.168.10.200:1920
to192.168.10.10:1919
? Can you show the actual UDP packet info from Wireshark? Do you receive the packets if you remove the call toconnectToHost()
? – Remy Lebeau