Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
883 Views

Niche "Zero copy" mode trouble: buffer overflow

Hello. 

 

I am trying to launch "Zero copy" mode of the TCP data transmission with Niche stack. 

It seems to be living, but after some amount of packets the transmission buffer overflows (tcp_xout gives error ENP_RESOURCE). 

 

If to debug this, in tcp_xout function so_snd.sb_cc during first several launchs is 0, then it becames 800 (this is the length of the frame payload), after several next launchs it becames 1600 and so on. 

When it becames 8000, it can't place additional packet into buffer (which is 8192 bytes), so tcp_xout gives error ENP_RESOURCE. 

 

The text for the transmission is the next: 

============ 

PACKET pkt; 

 

pkt = tcp_pktalloc(800); 

 

... 

Here I am filling the packet 

... 

pkt->nb_plen = 800; 

 

int e; 

 

e = tcp_xout(conn->fd, pkt); 

 

if (e < 0) 

tcp_pktfree(pkt); 

============ 

 

If I am using "send" function instead of tcp_xout, all is ok. 

 

Please say, what can be a reason for such behaviour? 

 

I have 2 versions, can they be a truth? 

 

1) I don't receiving the packets using "zero copy", because receive bandwidth is not critical. So, I don't register "Callback" function. 

Can this to be the reason of the problem? 

 

2) If I am using "zero copy", should I manually process the acks for the transmitted packets and retransmit the packets w/o ack received? The buffer can be overflowed for example because the packets that was not acked are not retransmitted/acked/dismissed? 

 

Thank you in advance for your answers.
0 Kudos
3 Replies
Altera_Forum
Honored Contributor I
48 Views

I've increased the TX buffer size : tcp_sendspace = 1024*64; 

But now I have another problem: the line pkt = tcp_pktalloc(800); gives me NULL. 

During debug I see that the queue bigfreeq has 0 (zeroes) in nearly all members of the structure. So, the queue is broken and can't give space for the packet. 

 

Does anybody know what can lead to the bigfreeq data corruption?
Altera_Forum
Honored Contributor I
48 Views

I've solved this all and now it works. 

The problem was in lack of time for receiving task, so it could not receive ACK frames. 

I've wrote such code: 

 

do 

e = tcp_xout(conn->fd, pkt); 

 

if (e < 0) 

if (e == ENP_RESOURCE) 

tk_yield(); /* let the system spin once */ 

else 

tcp_pktfree(pkt); 

return; 

while (e == ENP_RESOURCE); 

 

It works... But it works even slower than using send() function. 

So, there is no benefit from using "Zero copy", though I am eliminating one copy process of the data. 

 

Can anybody help to explain such behaviour? What is wrong?
Altera_Forum
Honored Contributor I
48 Views

Recently, i'm working on this, my method to fill data is MEMCPY(pkt->nb_prot, buf, sendlen); can you tell me your method to fill packet data?

Reply