Results 1 to 6 of 6

Thread: QUdpSocket and priority

  1. #1

    Default QUdpSocket and priority

    Hello. I write UDP server. Serever is started in the separate thread and receives packets every 20 mS. Thread has QThread::TimeCriticalPriority. Server reads data after readyRead() signal. When I start web-browser (Google Chrome or Firefox), packets are delayed. And packets received after delay time (delay spike). The delay time, which measured by WireShark is 250 mS. The delay time, which measured in the slot (I use QElapsedTimer), where I read data, is 800-900 mS. I think, delay is genereted in the socket thread (in the network module), which works with native socket for OS. When I start server, i see two new thread. First thread has TimeCriticalPriority (it's my thread). And second has normal priority (I think it's qt network thread, which started with qsocket). Can I increase the priority of this thread?

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QUdpSocket and priority

    Can I increase the priority of this thread?
    Increasing the thread priority will not help, in fact even using a thread will not help because you still rely on readyRead() signal which has nothing to with thread, and not effected by thread priority.

    I am afraid the packet itself is delayed, so your server cannot do much about it, moreover expecting a packet every 20ms over ethernet (or any shared network) is not practical.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3

    Default Re: QUdpSocket and priority

    I probably do not accurately described the situation.

    1 I have server, which receives audiostream. Period between audio (rtp) packets is 20mS. It is ordinary period for rtp packets.
    2 I run WireShark and I see packets and period between arriving. Also I see maximum delay between packets.
    3 I run server (WireShark works too). Maximum delay between packets is the same in the Wireshark and in the server.
    4 I run browser and delay is changed. 250 mS - in WireShark, 800 mS - in the server.

    I made an experiment. Instead QUdpSocket I used native socket API (socket(), select() ...) in the server thread. I was running browser and I got the same delay in the WireShark and in the server. I think, when QUdpSocket is created, in the Qt network module is started thread, which monitors the state of the native socket and sends events. This thread has normal priority. (When I run server with QUdpSocket I see one additional thread.(I use "Process explorer" application for Windows).
    And I want to increase priority of this thread or any way to speed up the network module.

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QUdpSocket and priority

    I think, when QUdpSocket is created, in the Qt network module is started thread, which monitors the state of the native socket and sends events. This thread has normal priority. (When I run server with QUdpSocket I see one additional thread.(I use "Process explorer" application for Windows).
    And I want to increase priority of this thread or any way to speed up the network module.
    I don't think QUdpSocket creates a thread. Please check again you might be looking at some other thread.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  5. #5

    Default Re: QUdpSocket and priority

    You are right. Work with sockets controlled in the events loop Thank you for answers.

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QUdpSocket and priority

    Whether your program is threaded or not you cannot make your CPU deliver network data if it is busy loading a browser and starting the tens of threads typically needed there. Network jitter like this is why streaming media players buffer some input before they start playing, and presumably also manage a buffer in the audio/video hardware which will play while the CPU is busy. All it may take is to buffer a second or two to cover a potential 500 millisecond glitch. The RTP timestamp is there to allow playback at correct intervals and the sequence allows detection/handling of lost packets (how is up to the receiver).

    Qt does use a thread internally to its network code for HTTP (http://peter.hartmann.tk/blog/2012/0...ttp-stack.html) but that should not affect UDP unless Qt5 has done some more in this area.

Similar Threads

  1. How to set thread priority for QtConcurrent::map
    By lni in forum Qt Programming
    Replies: 2
    Last Post: 21st October 2011, 20:32
  2. Qt thread priority
    By SailinShoes in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2010, 01:39
  3. Control the priority of QtConcurrent::run()?
    By PolyVox in forum Qt Programming
    Replies: 4
    Last Post: 16th February 2010, 01:14
  4. Error--High Priority
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 2
    Last Post: 5th February 2009, 16:14
  5. priority of QThread
    By quickNitin in forum Qt Programming
    Replies: 3
    Last Post: 13th May 2006, 12:53

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.