2023-05-08 12:45 AM
Hey,
I Have STM32H743Zi
I'm new at this, so please forgive me if I'm unclear.
I'm trying to receive 4k UDP packets but I'm getting only 1k each time.
I did a Google search and understand that if I want to receive a UDP packet of 4k I need to use fragmentation due to the MTU being 1500.
I tried to enable the below parameters:
IP_REASSEMBLY - enabled
MEMP_NUM_REASSDATA - 5
IP_REASS_MAX_PBUFS - 10
MEMP_NUM_FRAG_PBUF - 4
inside my callback function, I'm trying to read all the 4k data, I'm getting 1k in the first node but the next node in the pbuf is always NULL.
I also see on Wirshak messages with 1k
while I'm sending using Hrecules 4k for sure.
this is the callback function code:
void UDP_TX_RECEIVE_CALLBACK(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
{
char TxUdpPacket[SPI_PACKET_SIZE] = {0, };
// Process each received fragment
while (p != NULL)
{
// Copy fragment data to appropriate position in udpPacket array
memcpy(&TxUdpPacket[p->tot_len - p->len], p->payload, p->len);
// Move to the next fragment
struct pbuf *next = p->next;
pbuf_free(p);
p = next;
}
}
pls, help!!
thank you :)
2023-05-08 04:10 AM
> I also see on Wirshak messages with 1k
> while I'm sending using Hrecules 4k for sure.
If Wireshark does not see 4k packets, why would STM32 see them?
JW
2023-05-08 05:35 AM
@Community member
sorry you are right, my mistake.
I see 4k on Wireshark as well now.
still no change...
but if I'm adding a breakpoint in the callback method, it won't stop if the message is more than 1500 bytes.
2023-05-08 07:51 AM
@Community member any idea what I'm doing wrong?
2023-05-08 11:12 AM
Depends on how the other party is connected to the network. The ETH controller of STM32743 supports jumbo (a.k.a. giant) packets up to ~9 KB. So you can send the whole 4KB in one piece if the switch allows this or the connection is direct.
2023-05-08 11:47 AM
@Pavel A.
This is interesting...
I ran the below command with Python:
>>> import psutil
>>> print(psutil.net_if_stats())
and got this information on the STM network adapter in the PC:
snicstats(isup=True, duplex=<NicDuplex.NIC_DUPLEX_FULL: 2>, speed=100, mtu=9000)
the connection is direct to the PC (between the PC and the STM)
is this what you meant?
if so, do you have any extra information that explains this "jumbo (a.k.a. giant) packets up to ~9 KB", and how you use it?
thank you for your answer!!
2023-05-08 12:15 PM
@Mz.1 what is 'STM network adapter in the PC'?
The jumbo packet size is not unique for the STM32 ETH. Many ethernet controllers found in desktop or notebook PCs have it too. For example Realtek PCIe GBe supports jumbo frame up to 9 KB as well.
For more info on jumbo frames in general, please google.
For STM32H743, search the ETH section of RM0433 for "jumbo".
It can be enabled by bit 16 in ETH_MACCR register.
Existing examples unfortunately do not demonstrate this feature.
2023-05-10 04:02 PM
The code in UDP_TX_RECEIVE_CALLBACK() is broken. The pbuf_free() has to be called once on the whole buffer chain, not on every segment.
While it's technically possible, nobody fragments UDP packets, because UDP does not guarantee neither the delivery, nor the order of the fragments. Therefore such a requirement sounds like just a wrong approach to the problem. If you would describe the requirements and goals, probably users would give you some better ideas for solutions. Generally with 4 KB packets, most likely one should implement an application layer protocol over TCP or UDP.
2023-05-11 12:08 AM
@Piranha Hi, thanks for the answer!
Regarding the UDP_TX_RECEIVE_CALLBACK() method, you are right but that was just an example of what I'm trying to implement and not the final code.
I will describe the task:
We have a Python code that runs on a Windows machine that sends every 1 sec UDP packet - size 4k (can be less than 4k, but the max size is 4k) to the STM32H743Zi device.
the PC and the STM are connected directly (RJ45)
The STM code uses LWIP and DMA.
I have this callback function that is called every time when there is an incoming UDP packet.
if the UDP packet the PC sends is more than 1500 bytes (due to the MTU limit) the callback function isn't called otherwise I see packets.
I need a solution for receiving UDP packets of more than 1500 bytes.
you said that packet fragmentation with UDP is not a good solution and that makes sense to me.
@Pavel A. mentioned above an interesting solution with the "Jumbo frames" - I looked online and I didn't find an example or lots of information about how to implement this.
if anybody has an idea/solution I would appreciate the help...
thanks :)
2023-05-11 01:03 AM
When you send fragmented 4K UDP, will you see at least one fragment received in the low_level_input() ?
The easiest: send from PC 3 * 1.4K packets.