Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12589 Discussions

The performance of simple socket server

Altera_Forum
Honored Contributor II
1,269 Views

http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/wink.gif  

 

I need to transfer a lot of data from PC to the 1c20 board . 

 

So, I try to modify the simple socket server project which provided by Nios II IDE . 

 

but , I find that the speed of the transfer is very slow. 

 

The speed is only 1.4 kbytes http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/sad.gif  

 

I am very worry about the problem 

 

How to solve this problem ?  

 

thanks a lot
0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
495 Views

I have done the same. Since you probably do not send packets both ways (mostly TO the board), lwip waits for outgoing packets for some time before it ACKs a packet. You need to change the timeout for this counter, and you should also send an immediate reply for each packet. 

 

Do the following in \altera\kits\nios2\components\altera_lwip\UCOSII\src\downloads\lwip-0.6.3\src\api\tcp.h: 

 

# define TCP_FAST_INTERVAL 100  

 

You should try other values as well.  

 

Also, in tcp.c, change tcp_recved() to: 

 

void 

tcp_recved(struct tcp_pcb *pcb, u16_t len) 

int ackNow=0; 

 

if ((u32_t)pcb->rcv_wnd + len > TCP_WND) { 

pcb->rcv_wnd = TCP_WND; 

} else { 

pcb->rcv_wnd += len; 

ackNow=1; 

if (!(pcb->flags & TF_ACK_DELAY) && 

!(pcb->flags & TF_ACK_NOW)) { 

/* 

* We send an ACK here (if one is not already pending, hence 

* the above tests) as tcp_recved() implies that the application 

* has processed some data, and so we can open the receiver&#39;s 

* window to allow more to be transmitted. This could result in 

* two ACKs being sent for each received packet in some limited cases 

* (where the application is only receiving data, and is slow to 

* process it) but it is necessary to guarantee that the sender can 

* continue to transmit. 

*/ 

tcp_ack(pcb); 

}else if((pcb->flags & TF_ACK_DELAY)&&(ackNow)){ 

//++cg[11/10/2004]: I think this is what Atte Kojo was talking about 

tcp_ack(pcb); 

}
0 Kudos
Altera_Forum
Honored Contributor II
495 Views

thanks martinlie ~  

 

I follow your suggestion and the transfer speed is up to 100 kbytes . 

 

How can I do to reach the transfer speed of 1 M bytes per second ?
0 Kudos
Altera_Forum
Honored Contributor II
495 Views

I don&#39;t know how lwip is built internally, but since it is "processor generic", I believe that the simplicity of porting the code is favoured over performance. 

 

If someone could fill me in here, I would also be glad to know how to push performance.  

 

What system are you running on? (memory, speed, processor level)
0 Kudos
Altera_Forum
Honored Contributor II
495 Views

Your figures sound very wrong. I routinely get close to 1 MBytes/s UDP transfer (using a 1c20 full featured design). You will also see in the MicroC/OS-II forum that someone has got throughput of 4Mbytes/s.  

 

I&#39;m afraid this is not a case of a simplified port over performance. It&#39;s mostly down to the performance of the lan91c111 interface.  

 

Useful things to boost performance are to raise the fMax and increase the size of the data cache. 

 

That said though your figures sound low.
0 Kudos
Altera_Forum
Honored Contributor II
495 Views

 

--- Quote Start ---  

I have done the same. Since you probably do not send packets both ways (mostly TO the board), lwip waits for outgoing packets for some time before it ACKs a packet. You need to change the timeout for this counter, and you should also send an immediate reply for each packet. 

 

Do the following in \altera\kits\nios2\components\altera_lwip\UCOSII\src\downloads\lwip-0.6.3\src\api\tcp.h: 

 

 

# define TCP_FAST_INTERVAL 100  

 

You should try other values as well.  

 

Also, in tcp.c, change tcp_recved() to: 

 

void 

tcp_recved(struct tcp_pcb *pcb, u16_t len) 

int ackNow=0; 

 

if ((u32_t)pcb->rcv_wnd + len > TCP_WND) { 

pcb->rcv_wnd = TCP_WND; 

} else { 

pcb->rcv_wnd += len; 

ackNow=1; 

if (!(pcb->flags & TF_ACK_DELAY) && 

!(pcb->flags & TF_ACK_NOW)) { 

/* 

* We send an ACK here (if one is not already pending, hence 

* the above tests) as tcp_recved() implies that the application 

* has processed some data, and so we can open the receiver&#39;s 

* window to allow more to be transmitted. This could result in 

* two ACKs being sent for each received packet in some limited cases 

* (where the application is only receiving data, and is slow to 

* process it) but it is necessary to guarantee that the sender can 

* continue to transmit. 

*/ 

tcp_ack(pcb); 

}else if((pcb->flags & TF_ACK_DELAY)&&(ackNow)){ 

//++cg[11/10/2004]: I think this is what Atte Kojo was talking about 

tcp_ack(pcb); 

--- Quote End ---  

 

 

Hello, 

 

I am using Quartus II version 10.0sp1. I did not found the# define and the function you mentioned. 

 

Can you advice me how can I achieve better data rates using TCP and simple socket server. 

 

Your prompt response is highly appreciated. 

 

Thanks & Regards
0 Kudos
Altera_Forum
Honored Contributor II
495 Views

Hi yctsai, 

 

Do you mind to share with me your working simple socket server project? 

 

I am using the design example i can get from this forum but it doesnt work so far. Thanks. 

 

Please send it to my email account cafukarfoo@yahoo.com
0 Kudos
Reply