2024-07-15 08:57 PM - edited 2024-07-15 09:56 PM
My work
I have been experimenting with ethernet with tcp server, and i got some good referance to start the basic level of communication from the follwoing pages.
What i have done
What i want to do
Planning to push it to maximum number of server that i can do communication simultaneously (upto 50).
Issue i faced
When increasing the number of instance intitilized, during communication controller will either run into hardfault or on the client side transmission will fail, from this i have learnt it is because of wrong memory configuration.
Currently my configuration is able to run on a maximum number of 9 clients at a time.
Assist i need
Still it is unclear to me what are the paramter that will have an impact on number of instances, especially on the memory configuration side
Update
Iam able to run the 50 server simultaneously, for optimizing memmory i want to understand the exact memory configuration required.
My Findings and configurations
Correct me if iam wrong, each instance requires there own tx and rx descriptors for simultaneous communication minimum 96 bytes for each.
Pbuf is for handling all the incoming and outgoing data which highly depends on the number of bytes incoming
Rx pool i dont have a clear differenciation on this with Pbuf,
The configurations are based on the referance from the above link, and i have modified some parameters which thought necessary for increasing the number of instancs.
MPU configuration
Linker configuration
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
.lwip_sec (NOLOAD) :
{
. = ABSOLUTE(0x30000000);
*(.RxDecripSection)
. = ABSOLUTE(0x30001400);
*(.TxDecripSection)
. = ABSOLUTE(0x30002800);
*(.Rx_PoolSection)
} >RAM_D2
I want to have have a clear understanding of the memory configuration parameters, if you have any answer/referarances I would appreciate your assistance.
Solved! Go to Solution.
2024-07-22 05:21 AM
Hello @sarun ,
lwip heap memory size is the amount of memory allocated for the lwip stack to handle network data. It can be configured by the macro MEM_SIZE, which defines the size of the heap memory in bytes. The default value of MEM_SIZE is 1600 bytes, but it can be increased if the application sends a lot of data that needs to be copied. The heap memory can also be assigned to a specific region by using the macro LWIP_RAM_HEAP_POINTER, which points to the start address of the heap memory.
Each TCP PCB consumes a certain amount of memory. Increasing MEMP_NUM_TCP_PCB will directly increase the memory usage of the lwIP stack. This includes memory for the PCB structures themselves and associated buffers for data transmission and reception.
lwIP uses memory pools for various structures, including PCBs. Increasing the number of PCBs will require larger memory pools, which can lead to higher static memory allocation.
to summarize memory usage with Ethernet is divided by DMA descriptors and Tx/Rx buffers followed by the Lwip Heap which may vary in size but needs to respect your physical memory boundaries and RAM sizes ...
you can also get a deeper understanding of the memory requirement in this link .
Regards
2024-07-22 05:21 AM
Hello @sarun ,
lwip heap memory size is the amount of memory allocated for the lwip stack to handle network data. It can be configured by the macro MEM_SIZE, which defines the size of the heap memory in bytes. The default value of MEM_SIZE is 1600 bytes, but it can be increased if the application sends a lot of data that needs to be copied. The heap memory can also be assigned to a specific region by using the macro LWIP_RAM_HEAP_POINTER, which points to the start address of the heap memory.
Each TCP PCB consumes a certain amount of memory. Increasing MEMP_NUM_TCP_PCB will directly increase the memory usage of the lwIP stack. This includes memory for the PCB structures themselves and associated buffers for data transmission and reception.
lwIP uses memory pools for various structures, including PCBs. Increasing the number of PCBs will require larger memory pools, which can lead to higher static memory allocation.
to summarize memory usage with Ethernet is divided by DMA descriptors and Tx/Rx buffers followed by the Lwip Heap which may vary in size but needs to respect your physical memory boundaries and RAM sizes ...
you can also get a deeper understanding of the memory requirement in this link .
Regards
2024-07-24 06:20 AM
Hello @STea Thanks for the replay,
I have done some digging and understood that
Descriptor Size :
RX Pool Configuration:
TX Data :
PBUF :
|
Memory Required For a single SOCKET is 156 bytes (tcp_pcb variable)
Amount of memmory required for a single client/server is= TX descriptor(fixed)+Rx descriptor(fixed)+socket size(fixed)+TXPbuf(variable)+RXPbuf
Here I am assuming a payload size of 110 bytes for transmitting and reception
96+96+156+110+110= 568 bytes
I was following that same referance you provided in the link and so far that is the only material i found to get some good inputs.
With the said understandings i was able to run 50 clients/servers in both TCP and UDP. Still i feel like more can be optimized and i will try to obtain more info.
Thanks for the input @STea
and i have a small doubt are PCBs allocated in the LWIP heap?
2024-08-01 04:14 AM
Hello @sarun ,
answering "and i have a small doubt are PCBs allocated in the LWIP heap?"
in fact, it is indeed allocated in the LWIP Heap using the tcp_alloc() function in for TCP as an example that function calls memp_malloc() which allocates memory in the LWIP Heap(dynamically).
Regards