lwip-devel
[Top][All Lists]
Advanced

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

Re: [lwip-devel] Bypassing checksums


From: Joel Cunningham
Subject: Re: [lwip-devel] Bypassing checksums
Date: Wed, 18 Jan 2017 14:42:20 -0600

> On Jan 18, 2017, at 10:29 AM, Gisle Vanem <address@hidden> wrote:
> 
> While building lwIP on Windows and testing using e.g. Google Chrome
> on the same Windows machine I build lwIP on, the lwIP application sense-fully
> ignores incoming packets with wrong checksums.
> 
> AFAICS, since IP+UDP+TCP checksum routines are most often implemented in the
> NIC driver, packets coming from 'WinPap' will have wrong (no?) checksums. Or
> is there another reason?

The problem is that most NICs implement checksum offloading so when your host 
machine is
doing a TX, the Windows TCP/IP stack doesn’t calculate the checksum.  WinPcap 
captures the packets in the transmit path before the NIC can add the checksum, 
thus why you get invalid checksums when your virtual LwIP stack captures the 
packets originating from the host machine

> 
> Hence in my lwipopts.h I set these to 0 to ignore wrong checksums:
>  #if (LWIP_DEBUG > 0)
>    #define CHECKSUM_CHECK_IP       0
>    #define CHECKSUM_CHECK_TCP      0
>    #define CHECKSUM_CHECK_UDP      0
>    #define CHECKSUM_CHECK_ICMP     0
>    #define CHECKSUM_CHECK_ICMP6    0
>    ...
>  #endif
> 
> Without modifying the NIC-driver to NOT use this checksum
> off-loading feature, is there a better way for my lwip test-app
> to accept packets from my local machine?
> 

I turn off TX checksum offloading for my NIC, forcing Windows TCP/IP stack to 
do the checksum.  You can leave RX checksum offloading enabled since WinPcap is 
capturing RX packets (from external hosts) after they have come from the chip.  
My computer is plenty fast that this doesn’t realistically matter.

> Is there was a way to accept wrong checksums from a certain
> source IP only? That would be perfect.
> 

Joel




reply via email to

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