Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21611 Discussions

Slow UDP receiving with inichestack

Altera_Forum
Honored Contributor II
2,948 Views

Hi, everyone. 

 

I got a problem here with my udp packet receiving. I use TSE as the MAC driver and inichestack TCP/IP, running on the Altera Cyclone 3 C120, 

I noticed that there is a significant packet loss with my application. After  

very detailed examinination, I found that the inichestack seems to be slow at packet receiving. After a while there will be this log info: 

 

...... 

No free buffers for rx 

No free buffers for rx 

....... 

 

It seems that the inichestack can not catch up with the TSE and the buffer overflows. 

By the way, my udp sending rate is only 500kbps. 

My IDE is quartus 8.0. 

 

Anyone who has the same problem with me or Anyone who can drop me a clue, please do contact me. 

 

Thanks.
0 Kudos
12 Replies
Altera_Forum
Honored Contributor II
1,909 Views

Firstly try to disable UDP checksum calculations. Then compile Your program using -Os optimization and check the results.

0 Kudos
Altera_Forum
Honored Contributor II
1,909 Views

HI Socrates, 

 

Thanks for your help, I appreciate it. 

I have did what you told, but I still got the problem. The inichestack is still slow and can not handle all the packets that sent from the TSE, which result in a overflow of the buffer "bigfreeq".  

I have print the size of the "bigfreeq" queue and it shows that the queue gradually drain. When I stop the udp sender, the queue size bounces back. If the inichestack is fast enough, it would fectch the date sent from TSE and free the packet alloc from the bigfreeq. But it seems the inichestack not fast enough. 

 

...... 

PKTDEMUX pk_alloc bigfreeq len=858, lilfreeq=55, recvdq=5 

PKTDEMUX pk_alloc bigfreeq len=862, lilfreeq=60, recvdq=5 

PKTDEMUX pk_alloc bigfreeq len=857, lilfreeq=55, recvdq=5 

PKTDEMUX pk_alloc bigfreeq len=861, lilfreeq=59, recvdq=5 

..... 

 

Is it related to my socket udp receiving application?  

I have upgrade the udp receiving frequency but I still got the problem. 

 

The udp is so slow and not to say TCP. I think the inichestack cannot handle 200Kbps TCP data. 

 

Could someone help me?
0 Kudos
Altera_Forum
Honored Contributor II
1,909 Views

Hi everyone,I have solved this problem. There are TCP packets on the net but my application doesn't received them, so the TCP packets will remain in the iniche stack buffers and accumulate until the iniche stack timeout to release. That will abosolutely have greate impact on the udp receiving and degrade the rate.Thanks for your help.

0 Kudos
Altera_Forum
Honored Contributor II
1,909 Views

 

--- Quote Start ---  

Hi everyone,I have solved this problem. There are TCP packets on the net but my application doesn't received them, so the TCP packets will remain in the iniche stack buffers and accumulate until the iniche stack timeout to release. That will abosolutely have greate impact on the udp receiving and degrade the rate.Thanks for your help. 

--- Quote End ---  

 

 

Hello Gecko, 

 

I am facing the similar problem..., as you says that Packets remain in iniche stack buffer and accumulate until the iniche stack timeout to release. 

 

my application continuously read this accumulated data without any processing delay, but still same message is there "no free buffer for rx". i am stuck with this error from past several month's but not yet get any solution, could you plz help me out how do i come out from this problem. 

 

My UDP receiver Application written in "simple_socket_server.c

 

kaushal
0 Kudos
Altera_Forum
Honored Contributor II
1,909 Views

Hi, 

I am also stucked in the same issue(No free buffers for Rx) as you said 

that nichestack buffer reading speed is increased to solve this problem. 

 

I want to know How? because once stack is started only application is interacting with stack to take data by using recvfrom() in case of UDP. 

 

Have you increased clk speed of CPU or else? 

 

please help me  

with regards 

Hyanki
0 Kudos
Altera_Forum
Honored Contributor II
1,909 Views

Hi, everyone, 

 

Sorry to reply late because I didn't follow this issue for long time. 

You can take these steps to address this : 

1) change the buffer size in ipport.h 

# define NUMBIGBUFS 600# define NUMLILBUFS 300 

/* some maximum packet buffer numbers */# define MAXBIGPKTS 600# define MAXLILPKTS 300# define MAXPACKETS (MAXLILPKTS+MAXBIGPKTS) 

 

2) reset the receiving buffer size (the default size is only 1 K or so) 

 

int nRecvBuf=32*1024;//设置为32K 

setsockopt(s_UdpSock, SOL_SOCKET, SO_RCVBUF,(const char*)&nRecvBuf,sizeof(int)); 

 

Generally the problem will be addressed if your udp bandwidth is low. 

 

thanks.
0 Kudos
Altera_Forum
Honored Contributor II
1,909 Views

hello Gecko, 

 

Thanx lot, will try this out and get back to you....though i have increase the UDP packet size from 512 to 1472....will sorted out my problem...but i will try this out also. 

 

*i have increase the receiver buffer size big enough as you mantioned but not yet set the socket option... 

 

regards 

 

kaushal
0 Kudos
Altera_Forum
Honored Contributor II
1,909 Views

Hello gecko, 

 

below instruction again generate the same error "no free buffer for rx"...i am using UDP packet size 512 bytes 

 

1) change the buffer size in ipport.h 

# define NUMBIGBUFS 600# define NUMLILBUFS 300 

/* some maximum packet buffer numbers */# define MAXBIGPKTS 600# define MAXLILPKTS 300# define MAXPACKETS (MAXLILPKTS+MAXBIGPKTS) 

 

2) reset the receiving buffer size (the default size is only 1 K or so) 

 

int nRecvBuf=32*1024; 

setsockopt(s_UdpSock, SOL_SOCKET, SO_RCVBUF,(const char*)&nRecvBuf,sizeof(int));
0 Kudos
Altera_Forum
Honored Contributor II
1,909 Views

In pkalloc.c there are redifinitions about NUMBIGBUFS and NUMLILBUFS, get rid of them and make sure that in pk_init the buffer initial size is exact the size that ipport.h defined. 

 

Good luck!
0 Kudos
Altera_Forum
Honored Contributor II
1,909 Views

Hello there, 

Thanking you for your prompt response, 

OK I have found there are redefinitions about NUMBIGBUFS and NUMLILBUFS in pk_alloc.c (Line No. 55 and 57), as you says get rid of them mean I should comment both of them in pk_alloc.c and  

Second one “in pk_init the buffer initial size is exact the size that ipport.h defined”, in ipport.h there is no keyword like pk_init. So little confuse …. 

I have attached my ipport.h and pkalloc.c for your reference please point out where should I edit. 

 

Regards 

 

kaushal
0 Kudos
Altera_Forum
Honored Contributor II
1,909 Views

Hi, kaushal 

 

I have checked the code and the buffer size definition seems to be all right. You can print out in function "pk_init" to make sure size of "bigfreeq" is 600 and size of "litfreeq" is 300. That can be checked by  

"bigfreeq.q_len". 

 

You also need to check that the udp bandwidth is not too high. The tcp/ip stack can only receive udp bandwidth less than 2Mbps (that's a figure evaluated by me, not an authoritative figure) 

 

in the fuction pk_free [pktalloc.c], comment the code: 

//e = pk_validate(pkt); 

 

It will reduce the performance. 

 

Good luck!
0 Kudos
Altera_Forum
Honored Contributor II
1,909 Views

Hi, Kaushal 

 

How is everything going now?
0 Kudos
Reply