Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
OnSent dependency on lwip timer? #38
On an otherwise idle system, OnSent() does not seem to appear at a reasonable rate, it seem to come at ~250ms intervals.
If the system is doing something else, like receiving, the OnSent()s seem to appear at a rate related to how quickly the packets were actually sent, ie, much faster.
Is OnSent() somehow processed by the tcp timer or some other timer? Minar gets sleepy if nothing happening? It's a known issue or you need some way to reproduce it?`
I'll need to look into the LwIP stack some more to determine the cause of this. 250ms is the rate that LwIP recommends for the periodic timer.
OnSent is only triggered when an acknowledge is received, so it should be triggered when the ACK packet comes in.
Here's a tcpdump of the k64f in a loop sending a websocket packet containing an incrementing number every time it gets an onSent(). So it should spam these packets at a good rate regulated by the ack, you can see the peer acks it one time and within 30us of receiving it.
Basically it seems to stall for almost exactly 500ms (not my guesstimate of 250ms, sorry), when the ack receipt should have triggered the next send as soon as the ack was seen.
The error is not related to ws because serving a PNG (using the same "send more when onSent() came" scheme) he also doles out the PNG to the browser visibly in 500ms chunks.
However as I say if he is receiving on that socket at that time, he sends at the fast rate.
Later I'll modify the simple sample app from before and confirm it can be reproduced there, in case it's something specific to libwebsockets.
Just a little clue... if I modify the test code to have two or three packets "in flight" - still only firing one new packet per onSent() - the transfer finishes 2 or 3 x faster.
So it's like there's always one event left in the queue that gets missed until it's caught by some 500ms polling action in the stack.