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

NIOS II NicheStack:TCP data is not being sent at the required time interval!

Altera_Forum
Honored Contributor II
1,178 Views

I am working on the client side. and do not have control at the server side. 

 

My application is running on altera stratixIII fpga. with LAN 91c111smsc phy/mac IC. My application is based on Nios-II: NicheStack TCP/IP using MicroC-OSII. my sopc builder has configured for Standard NIOS II processor. uses external SRAM for data processing. 

client is connected to the server via a cross cable of approx 2 meters. auto negotiation sets the speed at 100 mbps.  

 

my communication is TCP/IP and my application requires data exchanges at different time intervals.I need to send data with different msg IDs. and for every msg ID, packet size is fixed. for ex: for time update 10 bytes of data has to be sent as per the protocol. 

I have to send Time update to server every second. system clock driver period is 1 ms. i am using ostimeget() function. 

If i send only time update message and disable any other data exchange, i am able to see in ethereal, that time update is going every second(as expected). but when i initiate other data exchanges. time update gets delayed upto 5 sec. i have seen previous posts also. i checked tcp acknowledgment which takes 2 ms to 200 ms to come in my case. so i doubt this myt not be the problem.as it gets delayed for upto 5 sec. in one TCP message entire 10 bytes get sent.  

 

i want to know: 

1. what is causing this delay. Why time update is not being dumped on the physical layer every second when other data processing and exchange is initiated in the simplesocketserver application. 

2. and also In nios II nichestack, does that time update data get lost because of overwriting in the OS tx buffer?? 

3. how does nichestack decides the number of data bytes in one tcp packet?? sometimes i am sending 10 bytes sometimes 5 messages altogether consisting 60 bytes..  

 

if i have not conveyed the query properly plz let me know. i have been struggling with this problem for last 1 week. 

 

any help will be greatly appreciated.
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
341 Views

On a TCP socket the IP stack can decide to wait and regroup data together before sending the packet. Each stack can have different strategies on how to do that and it seems that in your case the Interniche stacks waits a bit too much for you. I can think of two solutions:[list][*]Set the TCP_NODELAY flag on the socket to tell the stack you don't want it to wait and just to send the packet as soon as you call the send() function[*]Use a UDP socket instead of TCP, which could be more adapted to your situation IMHO. TCP is interesting when you have a continuous stream and don't want any data loss. For a time update message you don't really need the loss detection and retransmission system offered by TCP. It would just make the other end receive the message too late. As you are sending one every second it seems it would be better to either receive the packet immediately, or never receive it if it is lost. There will be a new one one second afterwards anyway.[/list]

0 Kudos
Altera_Forum
Honored Contributor II
341 Views

You didn't specify if time update and data messages share the same tcp connection, but I guess they do. 

Then, everything is routed to the same tcp stream and, from my experience, there's no reason for the dealy. 

The data throughput is also very low, so sw/hw performance is not an issue. 

I don't know your code, but I think you have a couple of send() calls in the functions related to data transfer and time update; then, probably you have sort of conflict between them, such as a shared data buffer which gets corrupted. 

Are you using a blocking or non-blocking socket?
0 Kudos
Altera_Forum
Honored Contributor II
341 Views

yes, i have the same TCP connection for time update and data messages, which is in non blocking mode. 

 

in my main code, after entering in while loop 1. timeupdate send call is made every second. 

 

and 2. incoming server queries are handled and depending on the query send call is made.
0 Kudos
Reply