Forum Discussion
Altera_Forum
Honored Contributor
13 years agoyang,
From your original post I see you are sending 2 byte buffers and wait for the answerback data before the next send. This is really inefficient because: - every packet needs to transfer 56bytes for a mere 2 byte data payload, because of Ethernet/IP/TCP protocol headers - the tcp protocol overhead will require a complete tcp/ip transaction (3 ethernet packets) for every cycle which only transfers 2 + 2 data bytes - you are using the socket connection in a synchronous way, waiting an answer for every request. The dead time between send and recv (due to Nios application, tse MAC and line delays) will prevent the system to achieve the maximum allowed speed Note that there's no problem with a 2bytes send itself, since the OS can pack bytes coming from multiple calls. The problem is the next receive which blocks until the answer bytes are received. You can try this modified code; it should be much more fast: while(1){ cnt++; for (i=0; i<100; i++) { send(sockClient,"1",2,0); printf("1 sent OK!\n\n"); } for (i=0; i<100; i++) { recv(sockClient,recvBuf,2,0); printf("%s\nrecieved OK!\ncnt=%d\n\n",recvBuf,cnt); } }