This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

TCP dropping data

I have a simple TCP client application running on the nRF9160. After connection to the server,  recv is called and writes the data over Segger RTT channel 1, where on the host JLinkRTTLogger.exe logs the data to a file.

The server is the unix netcat utility that is sending a binary file of random data (256kB) from stdin.

Fullscreen
1
cat rand.bin | nc -l PORT
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

If revc is called with no latency, the file is received in its entirety and verified with the original file using the diff utility. However, if a sleep statement is added in the recv loop, simulating processing the chunk of data (like erasing and writing to flash) the stream drops data to the application in 708 byte chunks and the received file is corrupted. The connection is monitored with wireshark on the server and shows the entire file is sent, indicated by the acknowledgment byte count.

My expectation with the TCP would be the flow-control/backpressure mechanism to throttle the connection and the sender would send data when the receiver has availability in its Receive Window. It does seem to be doing this in the modem firmware as I can see the Receive Window for the client shrink and grow dynamically in wireshark. The current behavior through the entire stack to the application violates the TCP protocol of reliable transmission. I can hack around this limitation by adding complexity to the application layer ... but this problem has been solved with the TCP standard. I would also rather the connection be closed than random data in the TCP stream be dropped and not sent to the application.

Is there an option/configuration I am missing that would fix this issue?

Modem firmware: 0.7.0-2.9alpha
SW version: see west.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <zephyr.h>
#include <net/socket.h>
#include <lte_lc.h>
#include <SEGGER_RTT.h>
static uint8_t rtt_buf[1024];
static uint8_t recv_buf[1024];
#ifdef CONFIG_BSD_LIBRARY
void bsd_recoverable_error_handler(uint32_t err)
{
printk("bsdlib recoverable error: %u\n", err);
}
void bsd_irrecoverable_error_handler(uint32_t err)
{
printk("bsdlib irrecoverable error: %u\n", err);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# General config
CONFIG_TRUSTED_EXECUTION_NONSECURE=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_ASSERT=y
CONFIG_REBOOT=y
CONFIG_NO_OPTIMIZATIONS=y
CONFIG_HEAP_MEM_POOL_SIZE=1024
# Logging
CONFIG_LOG=y
CONFIG_PRINTK=y
CONFIG_CONSOLE=y
CONFIG_STDOUT_CONSOLE=y
CONFIG_LOG_BUFFER_SIZE=2048
# Segger RTT
CONFIG_UART_CONSOLE=n
CONFIG_HAS_SEGGER_RTT=y
CONFIG_USE_SEGGER_RTT=y
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# The west manifest file for RED firmware
west:
url: https://github.com/zephyrproject-rtos/west
revision: v0.5.8
manifest:
remotes:
- name: red
url-base: git@git.deltaxp.io:bbr/red
- name: ncs
url-base: https://github.com/NordicPlayground
- name: zephyrproject
url-base: https://github.com/zephyrproject-rtos
- name: throwtheswitch
url-base: https://github.com/ThrowTheSwitch
- name: armmbed
url-base: https://github.com/ARMmbed
projects:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX