TCP packet size limitation

Hello,

I am currently working with the Nordic nRF7002-DK board running the Zephyr operating system, and my objective is to transmit data over TCP. However, I have encountered an issue in configuring the maximum data packet size for transmission.

Currently, I am limited to sending up to 1460 bytes per packet, but I would like to increase this capacity. I am having difficulties configuring my prj.conf file correctly to achieve this.

Below, you will find what I believe to be the relevant section of the prj.conf file:

CONFIG_NET_TC_TX_COUNT=4
CONFIG_NET_PKT_RX_COUNT=32
CONFIG_NET_PKT_TX_COUNT=32
CONFIG_NET_BUF_RX_COUNT=32
CONFIG_NET_BUF_TX_COUNT=32
CONFIG_HEAP_MEM_POOL_SIZE=153600
CONFIG_NET_BUF_DATA_SIZE=256


I kindly request your assistance in resolving this matter. Please do not hesitate to contact me for any additional information you may require.

I appreciate your time and wish you a productive day.

Parents
  • Hi,

    Could you please provide more information about your application and your setup? How do you send TCP data?

    Best regards,
    Dejan

  • Hello,

    Thank you for your prompt response. Here's the detailed setup I'm using for my program:

    On the client side, I'm utilizing the nRF7002-DK board, which operates as the sender of data in a unidirectional manner. The socket setup is as follows:

    struct sockaddr_in tcp_sockaddr;
    int tcp_socket = socket(AF_INET, SOCK_STREAM, 0);
    
    memset(&tcp_sockaddr, 0, sizeof(tcp_sockaddr));
    tcp_sockaddr.sin_family = AF_INET;
    tcp_sockaddr.sin_addr.s_addr = INADDR_ANY;
    tcp_sockaddr.sin_port = htons(HC_SERVER_PORT);
    zsock_inet_pton(AF_INET, HC_SERVER_ADDR, &tcp_sockaddr.sin_addr);
    connect(tcp_socket, (struct sockaddr *)&tcp_sockaddr, sizeof(struct sockaddr_in))
    struct net_if *interface = net_if_get_default();
    net_if_set_mtu(interface, PACKET_SIZE + 48); // I'm uncertain about this part


    To send data, I'm using the following code:

    send(tcp_socket, buf, PACKET_SIZE, 0);


    On the server side, I'm running a program in C. Here's the server setup:

    struct sockaddr_in socket_addr;
    int socket_fd = socket(AF_INET, SOCK_STREAM, 0);
    
    memset(&socket_addr, 0, sizeof(socket_addr));
    socket_addr.sin_family = AF_INET;
    socket_addr.sin_addr.s_addr = INADDR_ANY;
    socket_addr.sin_port = htons(PORT);


    To receive data, I'm using the following code:

    int _addr_len = sizeof(socket_addr);
    int _client_fd = -1;
    void *_buffer = malloc(PACKET_SIZE);
    
    listen(socket_fd, 1);
    _client_fd = accept(socket_fd, (struct sockaddr *)&socket_addr, (socklen_t *)&_addr_len);
    recv(_client_fd, _buffer, PACKET_SIZE, 0);



    When I set the value of PACKET_SIZE to 4096, I observed the following behavior:

    - send() returns 4096.
    - recv() receives the data in three packets: two packets of length 1460 and one packet of size 284.

    Please feel free to reach out if you need more information or if you have any suggestions. Your time and assistance are greatly appreciated. Have a wonderful day.

  • Hi,

    Maximum size of 1460 bytes comes from Maximum Transmission Unit (MTU) limitation which is normally 1500 bytes for Ethernet. 

    Best regards,
    Dejan

Reply Children
No Data
Related