Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-85872

QTcpSocket High Bandwidth Reading Loses Packets

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Incomplete
    • Affects Version/s: 5.15.0 RC2
    • Fix Version/s: None
    • Component/s: Network: Sockets
    • Labels:
      None
    • Environment:
      MacOS 10.13, Intel i5
    • Platform/s:
      macOS

      Description

      Reading at a high frequency from a QTcpSocket causes the read information to skip bytes. This omission of bytes in invalid behavior under the TCP protocol. 

      Comparing the incoming data to the QTcpSocket as seen through Wireshark and the data read from the QTcpSocket into a buffer, there is a mismatch. Reading from the socket under high load will output into an incomplete set of bytes (skipped portions).

      According to the TCP protocol guarantees, bytes should be received in full and in order, so I'm not sure what is going on. 

       

       

      The relevant code can be found here and the focus is the `SocketRead()` function: 

      https://github.com/scott-huson/LiveViewOpenSource/blob/c20594229f92932688fce7475f605757c0333c90/src/remotecamera.cpp#L78

      The specific application of this use case requires extremely fast reads from the QTcpSocket, pretty much as fast as I can receive data. Because of issues using the `ReadyRead` signal, I have opted to use the `waitForReadyRead()` since I can poll at a greater rate and get a smoother data flow. 

       

      Data in this case is encoded into frames, or set numbers of bytes that I am receiving. Each time that I read any number of bytes I decrement the number of bytes from the frame left to receive. I can tell I am missing bytes by the fact that when I send a test pattern of a constant frame, I am getting holes in the pattern, where bytes never appeared. I have validated this discovery by looking directly at the memory trace of the read buffer and writing code to check for mismatches in this test pattern. 

      I've included a screenshot of what this test pattern looks like just so you can see. 

       

      I'm happy to provide more details. 

      Thanks

       

      The attached image represents a memory trace of the mismatch in data. The values should count upwards in order. Looking at the image, it is evident that there is a section missing which makes it appear as if there are several sections of bytes missing. 

       

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            tpochep Timur Pocheptsov
            Reporter:
            shuson Scott Huson
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes