Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. UDP throughpout is very weak using Qt

UDP throughpout is very weak using Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • LeoCL Offline
    LeoCL Offline
    LeoC
    wrote on last edited by
    #1

    Hey guys,

    I try to send as much data as possible through my 100Mb ethernet interface. I expected to have a throughput around 90MBit/s.
    My first attmept was to just send messages within a loop "to see what is acutally possible":

    void c_main::sendMessage() {
        baDatagram.append(getRandomString(1400));
        QElapsedTimer elapsedTimer;
        elapsedTimer.start();
        for(int iItr = 0; iItr < 1024; iItr++) {
            sUDPsocket->writeDatagram(baDatagram,QHostAddress("fd53::205"),920);
        }
        int iElapsedTime = elapsedTimer.elapsed();
        qDebug() << "elapsed time:" << iElapsedTime;
        qDebug() << "throughput" << (1024 * baDatagram.size()) / (iElapsedTime / 1000));
    }
    

    The result is always an elapsed time around 34s and a throughput of around 42kB what is pretty far away from what is physically possible.
    However, in my second attempt I tried to use a timer that sends a bundle of 8 messages every millisecond. This is what I should do anyway, since the loop blocks the rest of my programm. But still, the result is the same.

    Next, I used iperf to see if there is a difference.
    Using iperf I get a throughput of almost 90MBit/s and I can transfer 221896 datagrams (maximal size of payload) in 30 seconds.

    So, the question is why iperf can transfer around 216 times more data in the same time than my code does? Any ideas?

    Cheers!

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      Something odd with your system?

      Tested:

      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
          QUdpSocket sUDPsocket;
          QByteArray baDatagram(1400,'a');
          QElapsedTimer elapsedTimer;
          elapsedTimer.start();
          for(int iItr = 0; iItr < 1024; iItr++) {
              sUDPsocket.writeDatagram(baDatagram,QHostAddress("fd53::205"),920);
          }
          const int iElapsedTime = elapsedTimer.elapsed();
          qDebug() << "elapsed time:" << iElapsedTime;
          qDebug() << "throughput" << (1024 * baDatagram.size()*1000) / (iElapsedTime);
          return 0;
      }
      

      got

      • 17ms and 84MBit/s in debug mode
      • 13ms and 110MBit/s in release mode

      Qt 5.8.0 Win7 32bit

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      5
      • LeoCL Offline
        LeoCL Offline
        LeoC
        wrote on last edited by
        #3

        Thanks for testing.

        To be honest, I already thought about this as well but I don't have any clue where to look, especially because iperf obviously works fine. Any ideas where to look?
        On the other hand I am now convinced that it isn't a serious problem in the code.

        Anyway, obviously you are connected via Gigabit-Ethernet. I wonder why you don't get more than 110MBit/s...

        I am working on a banana pi (which doesn't have that much power as you have on your windows machine) with Qt 5.3.2.

        aha_1980A 1 Reply Last reply
        0
        • LeoCL LeoC

          Thanks for testing.

          To be honest, I already thought about this as well but I don't have any clue where to look, especially because iperf obviously works fine. Any ideas where to look?
          On the other hand I am now convinced that it isn't a serious problem in the code.

          Anyway, obviously you are connected via Gigabit-Ethernet. I wonder why you don't get more than 110MBit/s...

          I am working on a banana pi (which doesn't have that much power as you have on your windows machine) with Qt 5.3.2.

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @LeoC said in UDP throughpout is very weak using Qt:

          Anyway, obviously you are connected via Gigabit-Ethernet. I wonder why you don't get more than 110MBit/s...

          I guess @VRonin reaches 110 MByte/s (baDatagram.size() is in Byte), and that is effectively the limit for Gigabit Ethernet.

          Qt has to stay free or it will die.

          1 Reply Last reply
          2
          • W Offline
            W Offline
            wrosecrans
            wrote on last edited by
            #5

            Start with using a profiler and measure what it's spending time with. Also, it looks like you aren't checking the return code of writeDatagram -- it could be returning some error code. Does it behave any different with an ipv4 address rather than ipv6?

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved