LWIP TCP_TIMER INTERVAL - Page 1
Forum section: electronics / general

author: muthukural001
author_rank: Regular Contributor
timestamp: April 04, 2017, 11:48:31 am
content: Hello,I am doing a project which has transmitters and Receiver. In the receiver side, I am using LWIP protocol to send received data through Ethernet cable to PC. Receiver will send data of 80 bytes for every 20ms for Ethernet transmission .If I use tcp_write function followed by tcp_output function for every 80 bytes transmission, which Value should I use for TCP_TIMER_INTERVAL for better throughput.Thanks,Muthu

author: westfw
author_rank: Super Contributor
timestamp: April 07, 2017, 06:28:54 am
content: Quotewell, I don't know much of anything about LWIP, but since no one else has said anything...If LWIP is like most TCP implementations, then it has a TCP_TIMER process that is essentially a background process to handle the TIMED parts of TCP: state transitions, packet retransmissions, and stuff like that. TCP_TIMER_INTERVAL would reflect (perhaps) how often that process is run. This has a couple important implications:The TCP_TIMER process does not directly affect throughput of a correctly operating TCP connection. If you're in an environment where there are a lot of retransmissions, it's value might have an effect, but in that environment you might want to consider a protocol other than TCP.The intervals involved tend to be a lot longer than you might think. The initial TCP Retransmission timeout is supposed to be 3 SECONDS, and shorter timeouts like delayed ACK are around 200ms. State changes by the timer process can take up to 255 seconds, at least theoretically.The default value (250ms) should be fine...

author: muthukural001
author_rank: Regular Contributor
timestamp: May 20, 2017, 01:14:46 pm
content: Hi,Sorry for this much late reply. Ok, I am using Passive tcp connection. Right now, I am using tcp_write followed by tcp ouput to send out 80 bytes over ethernet. I don't know how much time it takes to send . In our project, I will continuously receive series of 80 bytes for tcp send. So, I have to acheive maximum throughput. Like, every 80 bytes send has to be less than 1ms. How to acheive it?Please suggest a solutionThanks,Muthu

author: westfw
author_rank: Super Contributor
timestamp: May 21, 2017, 01:12:59 am
content: I would say that TCP is the wrong protocol if you want to send an 80byte message every millisecond. But this might be "old-school" thinking (I'm checking...) TCP isn't even a message-oriented protocol; it operates on byte streams, and it would much rather aggregate your 80byte messages into 1500 byte packets and send them every 18ms or so (and that would have a much better chance of working well.You might want to look at RTP instead. LWIP does include RTP as well as TCP (RTP is the protocol used by VoIP, so it's aimed at low-latency data streams with less-than-max-sized packets.)Most of the TCP work in the last 20 years has been WRT bulk transfers of large amounts of data, and in being "fair" via attempts to avoid network congestion (including protocols like "slow start", which I think is a particularly bad thing for applications that send small packets.

author: muthukural001
author_rank: Regular Contributor
timestamp: May 21, 2017, 05:32:41 am
content: Hi,Problem is that I have to poll my wireless module continuously to receive wireless data. Then I have to send these wireless data over ethernet. So, this ethernet transmission should not take more than 2-3ms. If it takes more than this, I would lose Wireless data to be receieved due to polling not happen at right time.Right now I am using tcp_write() followed by tcp_output() for immediate 80bytes transmission.Q1:I read tcp_output to send the queued bytes forcefully. Can you tell me how it works?Q2: As you said, I can accumulate multiple 80 bytes and send in 1 tcp packets which have payload size of 1500 bytes right?Q3: why 18ms send ?Q4: What is the round trip time for 1 packet transmission with payload size of 1500 bytes?Thanks,Muthu

author: westfw
author_rank: Super Contributor
timestamp: May 21, 2017, 06:27:35 am
content: I think you are underestimating the amount of buffering that happens, or can happen.TCP is a bytestream-oriented protocol.Typically, you would call a tcp_write() with 80 bytes of data, every millisecond. Most of the time, the 80 bytes would be added to a TCP packet buffer, but when the packet is actually full, it would be sent on the network. With 80 bytes/ms, it takes about 18 writes to fill a 1500 byte packet (well, probably 17, because overhead.) I don't know for sure that this is how lwip works, though...The tcp_output() function says "send whatever is buffered NOW, rather than waiting for a full packet."The actual "send packet" SHOULD be quick, depending on your actual hardware. Give the buffer to the EMAC and let it fly. This might not be true with something like a Wiznet or ESP8266, where transferring the data from microcontroller memory to ethernet controller memory can be slow (and can block.) (You haven't said what kind of hardware you're using...) (On the other hand, that sort of device might put the buffer in the controller memory, so it's getting copied out gradually (ever tcp_write()) anyway.)QuoteIndeterminate, because it depends on ACKing algorithms in the the destination, how many routers are between the endpoints, the bandwidth and delay of each link between the endpoints, and a bunch of other stuff. (Networking is complicated!)With a 10Mbps ethernet, the actual transmission time for a 1500 byte packet is less than 2ms (~1500*8/10e6, right?)Note that most TCP implementations don't require a round-trip to finish before they can send the next packet; you can theoretically transmit a full window size worth of data (trivially up to 64kbytes) each round trip delay...

author: muthukural001
author_rank: Regular Contributor
timestamp: May 24, 2017, 03:50:17 am
content: Hi,I have attached opts.h and lwipopts.h . To acheive maximum throughput, which of the included parameters should I change?Thanks,Muthu