Author Topic: TCP/IP Offload problem with Vista  (Read 14483 times)

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3232
    • View Profile
    • uTasker
TCP/IP Offload problem with Vista
« on: February 16, 2008, 09:14:43 PM »
Hi All

I had a case where the uTasker project was not operating correctly together with a PC running Vista. Thinking that it must be due to an incompatibility with the simulator somewhere I offered to debug it (not actually using Vista myself just yet). It turned out to be due to the fact that the PC was not sending a check sum in its transmitted IP frames (sending 0x0000 in place) and so all IP frames to the uTasker simulator were being rejected.

Strangely it was not doing this to all connections - which I didn't managed to understand - but it turned out that there is a setting in Vista for the characteristics of the network adapter which allows IPV4 offload settings to not work with the check-sum of rx, tx or both direction of IP frames. This offload setting was enabled and disabling it solved the issue.

I am not entirely sure whether it was an incorrect setting for the network card or whether someone had been playing around with it but I didn't find anything similar on my XP based PC.

The reasons for this feature (including pros and cons) can be discovered at the following link:
http://en.wikipedia.org/wiki/TCP_Offload_Engine

Searching the Internet for more references turned up a lot of cases of unreliability or intermittent Internet problems which were eventually tracked down to these settings - so it may be good to know about them just in case.... in fact a few cases do spring to mind which were quite similar: ARP works correctly since it is not built on IP so the ARP entry is seen, but communication just isn't possible.

Regards

Mark


Follow-up:
On a new Vista PC I had a problem but didn't see that any checksums were missing. Well, not using Ethereal on the network, but the simulator was really receiving 0x0000 in place fo the IP checksum (presumable because WinPCap is sniffing before and hardware which is adding this).
The minimum setting change can be performed by:
- System -> network connections -> NIC configuration -> Characteristics -> Configuration -> Extended -> IPV4 Checksum offload -> change from "Rx & Tx Enabled" to "Tx Enabled"

Additional note: there are in fact settings for different protocols too. (TCP and UDP) For example I found that NETBios was not working correctly when simulator (but stangly was to other devices on the network). Looking more closely it was evident that the UDP check-sum was being sent incorrectly (although the IP check-sum was OK). After disabling rx and tx offloading for UDP it worked correctly.
« Last Edit: January 21, 2009, 03:17:21 PM by mark »

Offline risototh

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • risko.org
Re: TCP/IP Offload problem with Vista
« Reply #1 on: June 25, 2008, 10:51:13 PM »
this solved my problem with w2003 described in http://www.utasker.com/forum/index.php?topic=310.0
i have intel pro/1000 nic, which has the ability doing the hw tcp/ip offload. because it's a ftp server, it was turned on. but, i solved this with turning off the the offload engine on transmit rather than receive side.
in the driver is written on Offload Transmit TCP Checksum: Disable this feature when the server is supporting DOS-based clients.
maybe the windows DOS mode networking is written like pcap?
« Last Edit: June 25, 2008, 10:53:26 PM by risototh »
There are only two things necessary in life - WD-40 and duct tape….
WD-40 for things that don't move that should, and duct tape for things that do move but shouldn't.

Offline Richard

  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: TCP/IP Offload problem with Vista
« Reply #2 on: May 07, 2009, 06:18:45 AM »
My cure for the checksum problem is the following alteration to the uTasker ip.c code, in the routine fnHandleIP().  I've not checked it thoroughly, but it seems to work for PINGs and displaying web pages.  I prefer this change, which affects only the simulator version of uTasker, to making changes to OS parameters that could slow all networking activities on my PC.

Code: [Select]
#ifndef _WINDOWS
// The header checksum on some Windows machines, especially those with high-speed NICs, is incorrectly calculated,
// presumably expecting a TCP Offload Engine to perform the calculation -- see
// http://en.wikipedia.org/wiki/TCP_Offload_Engine and http://www.utasker.com/forum/index.php?topic=180.

    if (IP_GOOD_CS != fnCalcIP_CS(0, frame->ptEth->ucData, (unsigned short)(IP_MIN_HLEN + olen))) {
        return(0);                                                       // check sum error - quit
    }
#endif // ! _WINDOWS   

There is a second place where the checksum is tested (search for IP_GOOD_CS), but from my experiments with Wireshark, on my machine at least, the body of the PING packet has the correct checksum, so I found no need to remove the second test.  Other people may find it necessary to do so.

Cheers,
    Richard

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3232
    • View Profile
    • uTasker
Re: TCP/IP Offload problem with Vista
« Reply #3 on: May 07, 2009, 12:57:29 PM »
Hi Richard

Yes, this is a useful method to avoid adjusting OS settings, since it is only really an issue when working with the simulator.

There is a project define ETHEREAL, which was originally used to enable playing back recordings through the simulator. This is already used in TCP to ignore the TCP check sum due to the fact that Ethereal (and also Wireshark) declares many TCP frames as having invalid check sums (and the value is also really incorrect in the Wireshark display and subsequently in the recording), even though the computes communicating didn't have any errors (???). Since this is in fact always active I may replace it with the general _WINDOWS define.

An alternative modification would be to ALSO accept check sum values of 0 when simulating (as well as correct values) since the offloading always sends 0.

I will have a think and make appropriate changes in the master version.

Regards and thanks

Mark


Offline Richard

  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: TCP/IP Offload problem with Vista
« Reply #4 on: May 07, 2009, 04:36:38 PM »
Hi, Mark.
Quote
An alternative modification would be to ALSO accept check sum values of 0 when simulating (as well as correct values) since the offloading always sends 0.

I thought of something similar, so I checked the value fnCalcIP_CS() returns.  It was neither 0 nor some other constant.  It didn't seem worth bothering to try to figure out why, but if you program a way to check that the packet's header checksum was 0, I'd be happy to modify my code.

Cheers,
    Richard

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3232
    • View Profile
    • uTasker
Re: TCP/IP Offload problem with Vista
« Reply #5 on: May 07, 2009, 07:37:59 PM »
Hi Richard

I think that the CS in the incoming frame is 0 when the IP offloading is on. This means that the value in the incoming frame could be checked for zero, rather than the check sum result.

But any of the solutions should do the trick (I will have a go at enabling the offloading again and check before making such a solution).

Regards

Mark