Hello,
I have some questions about the Transmitrate over TCP/IP with the AT91SAM7x256 and RTX RL-ARM 412.
I modifyed the Telnet demo and added a Task for an TCP Blaster Test. It's a communication from an Win XP PC to the Developmentkit AT91SAM7X-DK.
The SAM7X sends the Data and the PC is receiving. It shows me a datarate of ~320 bytes/sec
I think thats a little bit slow. Maybe someone can tell me something about good settings for the TCP/IP Task/Handling ... Heap, Tasksize, Taskdelay etc.
This is what I have added in the telnet demo:
opened a socket:
#define SENDLEN 32 /* Number of bytes to send */ socket_tcp = tcp_get_socket (TCP_TYPE_CLIENT, 0, 10, tcp_callback);
create a task:
os_tsk_create (tcp_BlasterTask, 25);
task code:
__task void tcp_BlasterTask (void) { U8 *sendbuf; U8 ucI = 0; U8 tcpState = 0; tcpState = tcpState; while (1) { /* TCP */ if (socket_tcp != 0) { /* Start Connection */ switch (tcpState = tcp_get_state(socket_tcp)) { case TCP_STATE_FREE: case TCP_STATE_CLOSED: tcp_connect (socket_tcp, Rem_IP, PORT_NUM, 0); break; case TCP_STATE_CONNECT: if (tcp_check_send (socket_tcp) == __TRUE) { sendbuf = tcp_get_buf(SENDLEN); for ( ucI = 0; ucI < SENDLEN; ucI++) { sendbuf[ucI] = ucI; } tcp_send (socket_tcp, sendbuf, SENDLEN); } break; } } os_dly_wait(5); } }
Thx for your Help!
that os_dly_wait(5);
is not going to help!
I changed it to 20 and it makes no difference. If I uncomment it the system doesn't run. the TCP_Net function run in the lowest task. I think thats the reason why it couldnt work without a delay.
<prev> os_tsk_create_user (tcp_task, 0, &tcp_stack, sizeof(tcp_stack)); </prev>
<prev> __task void tcp_task (void) { /* Main Thread of the TcpNet. This task should have */ /* the lowest priority because it is always READY. */ // UCHAR ucI = 0; dhcp_tout = DHCP_TOUT;
socket_tcp = tcp_get_socket (TCP_TYPE_CLIENT, 0, 10, tcp_callback);
while (1) { main_TcpNet(); dhcp_check (); os_tsk_pass(); } } </prev>
You can increase the priority of this task to match the priority of other tasks in conjunction with round-robin scheduling. The low priority can explain your poor data transfer rate.
Ok. I set it to the same priority. and changed the delay to: os_tsk_pass();
Now I have a transmitrate of max. 7300 bytes/sec. Looks like it sends the 1460 bytes every 200 ms. I remember there was a limit from Windows with 200 ms...is it true?!
what can i do to send more data now?!
How much memory does the stack have? With multiple outstanding frames, you can get a higher transfer rate if the ack response time is hurting your transfer rate.
Memory Pool Size in Net_Config.c is 8192
The TCP Task has a User Stack: U64 tcp_stack[4096/8]; /* A bigger stack for tcp_task */
Heap Size 0x200
So I have to increase the TCP Task Stack?! and should try to send more tcp telegrams?
You can increase the throughput by using the TCP_TYPE_DELAY_ACK option. See the documentation for tcp_get_socket().
By default, Windows (and most operating systems) use something like a 200 ms delay before sending an ack for a single packet. The assumption is that more packets are coming and it will save network traffic, and increase overall throughput if the multiple packets are ack'd at once.
By using the TCP_TYPE_DELAY_ACK option, the stack will split your packet into two. The second one will only have 4 bytes. That will cause an immediate ACK from the host. So you can then send another packet right away. Otherwise, as you are saying, your throughput is limited to about 7300 bytes/sec.
Everything else works exactly the same, and in my testing only a single ACK will come back even though two packets are actually getting sent. From your application level there is still just one ACK in the callback for each call to tcp_send().
This is not documented well at all in the TCPnet manual...