[Qt-interest] QUdpSocket issue

Jason H scorp1us at yahoo.com
Wed Jan 20 20:16:27 CET 2010


Are these packets black & red? That would mean a checksum problem and would be dropped before it gets to your application layer.




----- Original Message ----
From: Davide <davide83 at gmail.com>
To: qt-interest <qt-interest at trolltech.com>
Sent: Wed, January 20, 2010 12:51:55 PM
Subject: [Qt-interest] QUdpSocket issue

Hi all,
I’ve got a strange behavior using QUdpSocket class: my pc receives a
set of UDP packets that I can list with Wireshark but some of them are
not received by the QUdpSocket object in my application.

I’ve an Ethernet camera connected to my pc through an Ethernet cable.
My Qt application can send a command to that camera for example
requesting an image.
In my case I’m using a 640x480 RGB565 (16bit) image.
When the camera receives an image request it starts transmitting the
whole image row by row. So in each UDP packet there is a payload of
640*2=1280 Bytes of image data + 2 Bytes for the packet counter. It’s
clear that I should receive 480 packets for each image.
The program works fine in most situations, but if I try to do
something else with the pc during the execution it happens that the
QUdpSocket loses some packets (in the last experiment for example I
lost 4 packets from 84 to 87). The problem arises more often if I use
an old pc with a slower CPU.
Ok, you could say “Buy a new pc!” but there is another thing.
During my experiments I also sniffed the network traffic with
Wireshark and I found that here there are no packets missing. All the
packets have been received in the correct order without errors.

How is it possible that my pc receives all the packets but for some
reason these packets don’t reach my QUdpSocket?

Thanks in advance
     Davide


P.S.: Below there is the piece of code that wait for the whole image.

while (1) {
        if(waitForReadyRead(1500)) {
            size = pendingDatagramSize();
            datagramData = (char*) malloc(size);
            if(readDatagram(datagramData) != 0) {
                switch(ParseMessage(datagramData, size, sync_Get_Image, pktCount)) {
                    case EnetCmd_ST_IMG:
                    case EnetCmd_N_IMG:
                        pktCount++;
                        break;
                    case EnetCmd_END_IMG:
                        free(datagramData);
                        return pktCount;   // OK received Ack
                }
            }
            free(datagramData);
        } else {
            return 0;
        }
    }

--
Davide Ghezzi

http://www.youtube.com/user/StAstRobotics

_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest



      





More information about the Qt-interest-old mailing list