Author Topic: LPC2368 - trouble  (Read 13544 times)

Offline db_official

  • Newbie
  • *
  • Posts: 9
    • View Profile
LPC2368 - trouble
« on: December 02, 2009, 01:33:23 PM »
hi
I have trouble with using fnSendBufTCP. When I want to gain transmission about 20KB/s utasker is still running but TCP connection not response. I'am sending buffer about 2 KB four time per second. How can I make it better?

thank's

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: LPC2368 - trouble
« Reply #1 on: December 02, 2009, 03:54:29 PM »
Hi

Do you have a Wireshark recording of the session?
What size have you set the TCP buffer to?

Regards

Mark

Offline db_official

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: LPC2368 - trouble
« Reply #2 on: December 02, 2009, 04:00:35 PM »
I did not save wireshark screen.Buffer was set

#ifdef USE_BUFFERED_TCP                                                    // if using a buffer for TCP to allow interractive data applications (like TELNET)
    #define TCP_BUFFER            2000                                    // size of TCP buffer (with USE_BUFFERED_TCP) - generous with LPC23XX
    #define TCP_BUFFER_FRAME      2000                                   // allow this max. TCP frame size
#endif
« Last Edit: December 02, 2009, 06:19:01 PM by mark »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: LPC2368 - trouble
« Reply #3 on: December 02, 2009, 06:21:06 PM »
Hi

If you are sending 2k blocks of data it is probably best to configure the TCP buffer to this size (it will otherwise discard what doesn't fit).
If problems still exist a Wireshark recording will make it easier to identify the cause.

regards

Mark

Offline db_official

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: LPC2368 - trouble
« Reply #4 on: December 03, 2009, 10:03:03 AM »
Thanks
It's link to wireshark saved printscreen http://a.imagehost.org/download/0712/bad_sending
I am sending 2 buffers one by one in every 0.25 s. I shrinked size of buffers to 1470 bytes because window of application can not use bigger buffer and cut more data. How can I gain 30 KB/s? I want use it to bulk transmission.
thanks


Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: LPC2368 - trouble
« Reply #5 on: December 03, 2009, 01:42:12 PM »
Hi

The recording looks OK. The data transfer is normal.

The TCP operation is not restricting bandwidth in any way and is working in bulk-transfer mode.

To increase throughput you need to send the data faster - not just 4 times a second (giving you about 8kB/s) but about 15 times a second.

Regards

Mark

Offline db_official

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: LPC2368 - trouble
« Reply #6 on: December 03, 2009, 01:56:04 PM »
Yes I know but when I do it, connection is death:
Can You look at this?
http://pastebin.com/m1af46bde
It is server and I connect to this by HyperTerminal and I am sending lot of data to this.
Thanks

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: LPC2368 - trouble
« Reply #7 on: December 03, 2009, 02:25:06 PM »
Hi

The only thing to be careful with is trying to add more data to the TCP buffer than it can accept; once data is in the buffer it will be transmitted automatically (together with your listener).

To achieve maximum throughput for a particular TCP buffer size (where larger size means faster throughput in exchange for greater memory requirements) the following technique is used:


1) Ensure that WAKE_BLOCKED_TCP_BUF is enabled (should be by default)
2) When sending data, fill the buffer as much as possible.

static const UTASK_TASK OurTask = OWN_TASK;

while ((!fnSendBufTCP(Telnet_socket, (unsigned char *)&OurTask, nr_of_bytes, TCP_BUF_CHECK)) != 0) {
    fnSendBufTCP(Test_socket, (unsigned char *)test_message, nr_of_bytes, (TCP_BUF_SEND | TCP_BUF_SEND_REPORT_COPY))
}


This will fill the TCP buffer with as many messages as possible; by adjusting the TCP buffer size to match message length (eg. so that exactly 2 or 3 fit) can also improve efficiency when fixed message lengths are used.

3) When the TCP buffer has space, your task will receive a TX_FREE event. Handle this to immediately add further data - eg.

    while ( fnRead( PortIDInternal, ucInputMessage, HEADER_LENGTH )) {   // check input queue
        switch ( ucInputMessage[ MSG_SOURCE_TASK ] ) {                   // switch depending on message source

        case INTERRUPT_EVENT:
            if (TX_FREE == ucInputMessage[MSG_INTERRUPT_EVENT]) {
                  // call the transmission loop again here
            }
            break;



The result is that the TCP buffer is always filled as soon as it needs more data but never overfilled. This will keep bulk TCP operation flowing and so achieve high bulk data throughput.

Regards

Mark

Offline db_official

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: LPC2368 - trouble
« Reply #8 on: December 03, 2009, 02:26:08 PM »
Thank You;)