Packets received from Ethernet Interface getting discarded due to incorrect packet_type (and other issues)

Sulav Lal Shrestha 361 Reputation points
2021-10-13T23:09:00.47+00:00

I am getting started with Azure RTOS. I managed to get the threadx working and for netx the netx driver also seems to be *working (I have not been able to do anything meaningful with netx yet).

I am using the netxdriver ATSAME54-XPRO and ported it to SAME70Q21B microcontroller (SAME70-Xplained board). However, even though the board receives the ethernet messages, it discards the messages.

Steps:

  1. Configure the microcontroller board as DHCP client.
  2. DHCP client sends DHCP discover message.
  3. DHCP server replies back with offer.
  4. The microcontroller board receives the DHCP offer but discards it in the function _nx_driver_transfer_to_netx.

I found some issues like:

  1. In the function _nx_driver_transfer_to_netx, the nx_packet_prepend_ptr member in NX_PACKET *packet_ptr has address 2 greater than it should be.
  2. The nx_packet_length is 4 more than it should be.
  3. The nx_packet_append_ptr is 6 more than it should be.

140922-image.png

This is causing the packet type to be calculated wrongly and hence getting discarded.

I manually fixed the above 3 parameters for this particular case. With this, the packet is getting identified as IP packet, but then it goes to ip packet handler and finds that the checksum is wrong and discards the packet.

Any ideas on why this is happening and how I can fix it?

Azure RTOS
Azure RTOS
An Azure embedded development suite including a small but powerful operating system for resource-constrained devices.
341 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sulav Lal Shrestha 361 Reputation points
    2021-10-15T14:00:11.427+00:00

    The 4 bytes at the end seem to be ethernet padding. By copying the entire buffer two bytes to the right, so that the pointers align, the issue seems to be fixed. However, I am not sure yet why this was needed in the first place.


1 additional answer

Sort by: Most helpful
  1. Scott Larson 451 Reputation points
    2021-10-14T15:52:40.38+00:00

    Does the ethernet controller apply hardware padding to the packet? This is a common feature in ethernet controllers to help with alignment.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.