lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Checksum (FCS) on outgoing IP packets always zero - how


From: Nathan Martin
Subject: Re: [lwip-users] Checksum (FCS) on outgoing IP packets always zero - how to fix?
Date: Fri, 11 Apr 2025 20:02:55 -0500
User-agent: Betterbird (Windows)

lwIP does not generate the Ethernet frame check sequence (FCS) value on packet output. That responsbility is on the Ethernet / Wi-Fi driver or hardware MAC. lwIP also does not check the Ethernet FCS value on packet input processing either. Both cases are so commonly handled by MAC+PHY hardware side its probably why it wasn't implemented in LwIP.

However I can confirm that the UDP checksum is being generated successfully in your packet dump:

000028 59 A9 01 01 06 00 01 00

May I ask what MAC+PHY you're using?


        -Nathan


On 4/11/2025 6:38 PM, Van Hooft, Frank via lwip-users wrote:
I have a single ethernet netif and have it configured (I believe) to calculate & generate checksums.  This is in a no-OS environment. I am trying to use DHCP. But packets generated by LwIP always have zeros at the end.

Here's what I see, from a start-up, with some logging enabled:


netif: added interface A0 IP addr 0.0.0.0 netmask 0.0.0.0 gw 0.0.0.0
netif: setting default interface A0
dhcp_start(netif=0x200001a0) A00
dhcp_start(): mallocing new DHCP client
dhcp_start(): allocated dhcp
dhcp_start(): starting DHCP configuration
udp_bind(ipaddr = 0.0.0.0, port = 68)
udp_bind: bound to 0.0.0.0, port 68)
udp_connect: connected to 0.0.0.0, port 67)
dhcp_discover()
transaction id xid(abcd0001)
dhcp_discover: making request
dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, LWIP_IANA_PORT_DHCP_SERVER)
udp_send: added header in given pbuf 0x20003124
udp_send: sending datagram of length 316
udp_send: UDP packet length 316
udp_send: UDP checksum 0xa959
udp_send: ip_output_if (,,,,0x11,)
ethernet_output: sending packet 0x20003124


000000 FF FF FF FF FF FF 38 24
000008 31 06 C6 C3 00 08 45 00
000010 50 01 00 00 00 00 FF 11
000018 6B EC 00 00 00 00 FF FF
000020 FF FF 44 00 43 00 3C 01
000028 59 A9 01 01 06 00 01 00
000030 CD AB 00 00 00 00 00 00
000038 00 00 00 00 00 00 00 00
000040 00 00 00 00 00 00 38 24
000048 31 06 C6 C3 00 00 00 00
000050 00 00 00 00 00 00 00 00
000058 00 00 00 00 00 00 00 00
000060 00 00 00 00 00 00 00 00
000068 00 00 00 00 00 00 00 00
000070 00 00 00 00 00 00 00 00
000078 00 00 00 00 00 00 00 00
000080 00 00 00 00 00 00 00 00
000088 00 00 00 00 00 00 00 00
000090 00 00 00 00 00 00 00 00
000098 00 00 00 00 00 00 00 00
0000A0 00 00 00 00 00 00 00 00
0000A8 00 00 00 00 00 00 00 00
0000B0 00 00 00 00 00 00 00 00
0000B8 00 00 00 00 00 00 00 00
0000C0 00 00 00 00 00 00 00 00
0000C8 00 00 00 00 00 00 00 00
0000D0 00 00 00 00 00 00 00 00
0000D8 00 00 00 00 00 00 00 00
0000E0 00 00 00 00 00 00 00 00
0000E8 00 00 00 00 00 00 00 00
0000F0 00 00 00 00 00 00 00 00
0000F8 00 00 00 00 00 00 00 00
000100 00 00 00 00 00 00 00 00
000108 00 00 00 00 00 00 00 00
000110 00 00 00 00 00 00 63 53
000118 82 63 35 01 01 39 02 05
000120 DC 0C 08 53 50 45 5F 54
000128 65 73 74 37 03 01 03 1C
000130 FF 00 00 00 00 00 00 00
000138 00 00 00 00 00 00 00 00
000140 00 00 00 00 00 00 00 00
000148 00 00 00 00 00 00 00 00
000150 00 00 00 00 00 00 00 00
000158 00 00 00 00 00 00


dhcp_discover: deleting()
dhcp_discover: SELECTING
dhcp_discover(): set request timeout 2000 msecs

NETIF
MTU=0x5DC
CkhSum Flgs=0xFFFF
Flags=0x3F
IP=0x0
NetMask=0x0
GW=0x0


The packet printout and some netif contents printout is debugging I've added. This packet is transmitted, as-is, onto the line. Wireshark sees this packet (unchanged as above), and wireshark complains about the invalid FCS.

I am new to LwIP, so I assume I'm doing something wrong in my setup.

I'm assuming the above is a DHCP discover packet?

Any idea how to get the FCS working at the end of the packet?



My lwipopts.h file contents looks like this:


#define PROCESSOR_LITTLE_ENDIAN

#define LWIP_DEBUG 1
#define ETHARP_DEBUG  LWIP_DBG_ON
#define NETIF_DEBUG LWIP_DBG_ON
#define DHCP_DEBUG LWIP_DBG_ON
#define UDP_DEBUG  LWIP_DBG_ON
#define MEMP_DEBUG LWIP_DBG_ON
#define MEM_DEBUG LWIP_DBG_ON
//#define ICMP_DEBUG LWIP_DBG_ON

#define NO_SYS                                        1
#define MEM_LIBC_MALLOC                         0
#define MEM_CUSTOM_ALLOCATOR              0
#define MEMP_MEM_INIT                     1
#define MEM_ALIGNMENT                     4
#define MEM_SIZE                          1600

#define MEM_USE_POOLS                     1
#define MEM_USE_POOLS_TRY_BIGGER_POOL     1
#define MEMP_USE_CUSTOM_POOLS           1

#define LWIP_IPV4                       1
#define LWIP_IPV6                       0
#define LWIP_UDP                        1
#define LWIP_TCP                        0
#define LWIP_ARP                        1
#define LWIP_ICMP                       1
#define LWIP_DHCP                       1
#define LWIP_AUTOIP                                   0
// LWIP_ARP enables LWIP_ETHERNET in opt.h

#define IP_REASSEMBLY                   0
#define IP_FRAG                         0

#define LWIP_RAW                        1
#define LWIP_NETCONN                    0
#define LWIP_SOCKET                     0

#define LWIP_NETIF_TX_SINGLE_PBUF         1
#define LWIP_SINGLE_NETIF               1

// This defaults to 0, but it can be nice to
// have a hostname, for human readability
#define LWIP_NETIF_HOSTNAME                     1

#define LWIP_CHECKSUM_CTRL_PER_NETIF      1
#define CHECKSUM_GEN_IP                         1
#define     CHECKSUM_GEN_UDP                          1
#define CHECKSUM_GEN_TCP                        1
#define CHECKSUM_GEN_ICMP                 1
#define CHECKSUM_GEN_ICMP6                1
#define CHECKSUM_CHECK_IP                 1
#define CHECKSUM_CHECK_UDP                1
#define CHECKSUM_CHECK_TCP                1
#define CHECKSUM_CHECK_ICMP                     1
#define CHECKSUM_CHECK_ICMP6                    1
#define LWIP_CHECKSUM_ON_COPY             0



Many thanks.

Frank


_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users


reply via email to

[Prev in Thread] Current Thread [Next in Thread]