On Tue, 2006-08-22 at 08:15 +0200, Hampus Thorell wrote: > Hello! > > I have some questions about the tcp_tmr(). I know this function calls > two other timer functions but why are they needed? > > In the documentation it says that it must be called every > TCP_TMR_INTERVAL milliseconds. Does this imply that it must be called > exactly every TCP_TMR_INTERVAL milliseconds or is it okay to call it > more often than that? What happens if it isn't called exactly every > TCP_TMR_INTERVAL milliseconds?
I think (and it's been a while since I looked at this code in detail, so could be wrong) that the reasoning behind this is that to make lwIP more portable it does not assume there are any particular facilities available to it from the operating system, and timers are one of these. As a result, it is left as an exercise to the porter to find some mechanism to ensure that the timers are executed in a timely manner, and the API for this is the tcp_tmr() function. Because the lwIP code can't access anything to do with measuring time (without becoming less portable) it wouldn't know if you called it more or less often than TCP_TMR_INTERVAL milliseconds. It just counts how often the function has been called, and uses that count to decide when to do certain TCP related actions such as retransmitting a packet that has not been acknowledged for example. If you called tcp_tmr() more frequently, these actions would happen sooner, which while if it was only a few tens of milliseconds different it might not have much effect, if it was significantly more frequent you could start to see things breaking the TCP RFC standards for how long you should wait before sending packets etc. Hope that helps, Kieran _______________________________________________ lwip-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/lwip-users
