This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

About receive buffers

Hello to everybody.

I recently started a project with EVM6472, which connects with a camera through TCP/IP. I modified the hpdspua example, and I'm using  MCSDK 1.00.00.08, CCSV5, BIOS 6.33.04.39, NDK 2.21.01.38.

There is a web-interface in the EVM, through which I control the EVM. So I use this interface to make the EVM send a command to the camera. The camera answers the command with a image in JPG format, that is the image it captures in the moment that it receives the command. I can select the image quality. I use the recv function with a buffer enough to receive any image.

What happens is that, when the image is small (low quality), I receive it. When it is larger, I can't receive everything... I discovered that changing the receive buffer (with setsockopt), I can receive all kinds of images. So I use a receive buffer size enough for all... 

So I have some doubts about the NDK... I thought that when the receive buffer is full, the EVM would send something to the camera telling that it is full. But as I saw, the EVM is receiving only the amount of data defined by the buffer size. I used the same camera with a microcontroller (from other company) with a buffer with 40 bytes, and I was able to handle any size of image.

I looked in the documentation, and I didn't find anything specific about the socket receive buffer... Does anyone knows something about it?

Thanks...

  • I was able today to capture everything with Wireshark. What is happening is this: the EVM is sending to the camera the Window Size until it reaches 0. After a while, the EVM sends an WindowUpdate, which says to my camera that its buffer is ready again to receive... The camera then sends the next data, but the EVM don't answers with ACK anymore... My camera retransmit the first packet until the EVM disconnects...

  • Hi Gustavo,

    what do you have your TCP send and receive buffer sizes configured to?

  • Hi, Tom!

    I left the buffer size as it was... But in this example, the configuration through XGCONF is not disabled?

  • Hi Gustavo Adolpho Souteras Barbosa,

    Are you using the TCP or UDP protocol?

    Gustavo Adolpho Souteras Barbosa said:
    I discovered that changing the receive buffer (with setsockopt)

    Can you try setting the size of the TCP send and receive buffers by adding these calls to the NDK stack thread:

    You need to adjust the BufSize variables...

    Int transmitBufSize = X;
    CfgAddEntry(hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPTXBUF,
            CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&transmitBufSize, 0);


    Int receiveBufSize = X;
    CfgAddEntry(hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPRXBUF,
            CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&receiveBufSize, 0);


    Int receiveBufLimit = X;
    CfgAddEntry(hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPRXLIMIT,
            CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&receiveBufLimit, 0);

    Gustavo Adolpho Souteras Barbosa said:
    What is happening is this: the EVM is sending to the camera the Window Size until it reaches 0

    What is the initial window size that you saw in Wireshark?

    Gustavo Adolpho Souteras Barbosa said:
    After a while, the EVM sends an WindowUpdate, which says to my camera that its buffer is ready again to receive...

    What is the window size that you at this point?

    Gustavo Adolpho Souteras Barbosa said:
    The camera then sends the next data, but the EVM don't answers with ACK anymore...

    Is the stack still running? Can you ping it?

    Can you halt the target at this point can open ROV to verify that there aren't any Task stack overflows?

  • Hi, Tom. Sorry for the delay...

    Tom Kopriva said:
    Are you using the TCP or UDP protocol?

    I'm using TCP protocol...

    Tom Kopriva said:

    Can you try setting the size of the TCP send and receive buffers by adding these calls to the NDK stack thread:

    You need to adjust the BufSize variables...

    Int transmitBufSize = X;
    CfgAddEntry(hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPTXBUF,
            CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&transmitBufSize, 0);


    Int receiveBufSize = X;
    CfgAddEntry(hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPRXBUF,
            CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&receiveBufSize, 0);


    Int receiveBufLimit = X;
    CfgAddEntry(hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPRXLIMIT,
            CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&receiveBufLimit, 0);

    Yes, I did that too... If I change the receive buffer size to a value greater than the file that I want to receive, it works... What I want to know is why it only works this way. I worked with the same camera, but linked with an PIC microcontroler that had much less memory, and I could receive all images without problems...

    So I thought that somebody could understand better how the NDK works, and could explain that... 

    Tom Kopriva said:
    What is the initial window size that you saw in Wireshark?

    It's 8192

    Tom Kopriva said:
    What is the window size that you at this point?

    It's 8193

    Tom Kopriva said:
    Is the stack still running? Can you ping it?

    Yes, it's running... I can ping it.

    Tom Kopriva said:
    Can you halt the target at this point can open ROV to verify that there aren't any Task stack overflows?

    Hmmmm, sorry Tom... I'm rather new to the terminology... What is ROV? (I'm just begining to program DSP's)

  • Hi Gustavo Adolpho Souteras Barbosa,

    I'm curious about this problem.  I don't think the NDK TCP buffer size should need to be bigger than the file it's receiving in order for the transfer to complete successfully.  As you state, the stack should advertise it's window size to the camera as 0 at some point, letting the camera know that it should stop sending data.  Then when it processes the data, the NDK stack should send a window update informing the camera that it can send more data ... and that's what you are seeing in wireshark.  At this point the stack should receive the next batch of data.

    Would you mind sharing your NDK socket code that's receiving the camera's data?

    Gustavo Adolpho Souteras Barbosa said:
    What is ROV? (I'm just begining to program DSP's)

    ROV is the RTOS Object Viewer.  You can open it within CCS under the "Tools -> ROV" menu option.  Note that your program must be halted.

    ROV will give you insight into BIOS and is a great tool for helping debug a system.

    Steve