Ethereal-dev: Re: [Ethereal-dev] TCP checksum over IPV6

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: "Martin Regner" <martin.regner@xxxxxxxxx>
Date: Sat, 2 Nov 2002 16:21:47 +0100
Tony Wang wrote:
>I downloaded the latest ethereal from the site and start using it to
>check some captured TCP packets over IPv6. 
>I noticed that it suggest that the TCP checksum is incocrrect. The packet
>that I was looking at has Routing Options 
>enabled in the IPV6 header with 8 nodes. So the True Destination in the
>Pseudo Header Checksum calculation should look at
>the last nodes DA instead of the DA listed in the IP header. 

IPv6  RFC 2460  chapter 8.1 says 
"If the IPv6 packet contains a Routing header, the Destination
 Address used in the pseudo-header is that of the final
 destination.  At the originating node, that address will be in
 the last element of the Routing header; at the recipient(s),
 that address will be in the Destination Address field of the
 IPv6 header."

In the capture you enclosed Segments Left=0, so then 
actually the true destination is in the Destination Address field as I understand
from the example in chapter 4.4 of RFC 2460 (see below), but if Segments Left had been
greater than 0 then the "true destination" should have been the last element of the
Routing header.

However it seems that you are correct that the calculated TCP checksum may not be
correct in Ethereal when using IPv6 Routing header (when Segments Left > 0).

I made some experiments with text2pcap and changed the value of the last address
in Routing header, Destination Address and Segments Left and could see that
Ethereal (I used version 0.9.7) doesn't seem to care about IPv6 Routing header entries when 
calculating upper-layer checksums (probably not only for TCP, but also for UDP, ICMPv6 etc.).

Right now pinfo->dst is used when calculating these checksums. Maybe there should be 
a pinfo->true_dst  (or similar) that could be used by the upper-layer dissectors when calculating
checksum or maybe pinfo->dst  should be set to the true destination. 

I'm not so experienced with IPv6 so it might be that I have missed or misunderstood something
regarding this.


Example in RFC 2460 chapter 4.4:
------------------------------------------------

As the packet travels from S to I1:
        Source Address = S                  Hdr Ext Len = 6
        Destination Address = I1            Segments Left = 3
                                            Address[1] = I2
                                            Address[2] = I3
                                            Address[3] = D

   As the packet travels from I1 to I2:
        Source Address = S                  Hdr Ext Len = 6
        Destination Address = I2            Segments Left = 2
                                            Address[1] = I1
                                            Address[2] = I3
                                            Address[3] = D

   As the packet travels from I2 to I3:
        Source Address = S                  Hdr Ext Len = 6
        Destination Address = I3            Segments Left = 1
                                            Address[1] = I1
                                            Address[2] = I2
                                            Address[3] = D

   As the packet travels from I3 to D:
        Source Address = S                  Hdr Ext Len = 6
        Destination Address = D             Segments Left = 0
                                            Address[1] = I1
                                            Address[2] = I2
                                            Address[3] = I3