heinbali01 wrote on Friday, September 28, 2018:
Hi Erik,
That is right, I can write PCAP’s to a USB drive.
Very good, it can come handy. I sometimes write a PCAP on a RAM-disk.
It would appear that 2.0.7 is doing better.
It has lot of improvements, mostly on security and boundary checks.
For instance, there is a better checking of the correctness of DHCP or DNS packets.
I am setting this socket up with
> WinProperties_t xWinProps = {
> .lRxBufSize = 131072,
> .lRxWinSize = 32,
> .lTxBufSize = 5000,
> .lTxWinSize = 2
> };
When your MP3 audio has 320 Kbps, and if you want 10 seconds of buffer space, you will need 400 KByte of buffering.
I have plenty of memory here, so it is more about setting the optimal values for tcp.
Lucky you! So yes, try a 10-second buffer or more, and before playing, wait until the buffer is filled about 80%.
Would it help recovery to have a larger window?
No.
A lRxWinSize
of 32 means that you can have 32 outstanding packets ( of in your case 1400 bytes ).
I would use less. On a fast LAN/WiFi and with fast CPU’s, you will have no more than 10 outstanding packets.
On a WAN, when the quality of an ISP is less than optimal, a value of 4 would be optimal.
FreeRTOS+TCP had a mechanism which will make the window very small when there are too many errors.
A large TCP window and a bad transporter = complete chaos In the worst case, a windows size of 2 packets is optimal.
I would propose these settings:
WinProperties_t xWinProps = {
.lRxBufSize = 409600, // 10 seconds of MP3 audio
.lRxWinSize = 10, // At most 10 outstanding packets
.lTxBufSize = 2 * ipconfigTCP_MSS, // There is no returning data
.lTxWinSize = 2
};
The audio buffer is a couple minutes large.
So much won’t be necessary. The socket is already buffering audio data. Why not reserve 409,600 bytes as well?
If I were your I would produce some statistics of the buffer spaces while playing audio. Write every second one record of how much both buffers are filled.
I have a capture here http://aercon.net/Public/StreamSample.pcap
Thanks. For readability, I truncated it to a smaller file ( record 23150 and further ), attached below. ( as pcap_erik.zip )
I guess you have a very fast CPU!
You see that most of the time the actual TCP window is only filled with 1 segment?
There are some retransmissions and delays of up to 20 seconds.
Packet 11 is out of order. It had already received and acknowledged.
Packet 15 one packet is missing:
expected 9801
received 11201
The response is correct: ACK=9801 SLE=11201 SRE=12601
After packet, packets are coming in very slowly: delays of 6 and 20 seconds
Packet 21 is the expected retransmission of 9801, good
Packet 25 two packets is missing:
expected 16801
received 30801
The response is correct: ACK=16801 SLE=30801 SRE=32201
Packet 21 is the expected retransmission of 16801, good
Packet 27 a retransmission comes after a delay of 20.7 seconds
Packet 29 thirteen packets is missing:
expected 18201
received 36401 ( missing 13 packets )
The response is correct: ACK=18201 SLE=36401 SRE=37801
Packet 52 TCP has fully recovered
Packet 99 a long awaited packet is retransmitted after 20 seconds
Packet 101 After 30 seconds of silence, +TCP is giving up on this connection
Summary: nothing wrong with the +TCP responses. The big delays cause a problem: delays of 20 up to 30 seconds.
That example is what the wifi interface sees. This test was with
very poor signal, the antenna off the router.
Ah, that is why.
It looks like WiFi got lost sometimes and needed to re-established which takes about 20 seconds.