[ixp1200] Ip checksum?

Øyvind Hvamstad oyvindh at ifi.uio.no
Mon Jun 21 15:35:28 EDT 2004


On man, 2004-06-21 at 17:26, Yitzchak M. Gottlieb wrote:

> No.  The properties of the IP checksum are such that if you modify a 16-bit
> value in the packet the new checksum is:
> 
> newsum = ~(~oldsum + ~oldvalue + newvalue)
> 
> see RFC 1624.  Also, if you can precompute the difference you can eliminate
> an addition.

Thanks, this is great! I am however having some problems when trying to
verify that this is correct. It may be my lack in C knowledge or that
I'm failing to do this correctly. My test program (attached source)
spits out different values when doing the checksum incrementally
compared to calculating the whole thing.

I'm sure it my mistake, please correct me!

Test output:
Incremental checksum:           f5a9
Header checksum after change:   f5a8
Difference (incr - calc):       1
Incremental checksum:           26aa
Header checksum after change:   26a9
Difference (incr - calc):       1
Incremental checksum:           23aa
Header checksum after change:   23a8
Difference (incr - calc):       2
Incremental checksum:           54ab
Header checksum after change:   54a8
Difference (incr - calc):       3

> Zuki
-- 
Øyvind Hvamstad <oyvindh at ifi.uio.no>


More information about the ixp1200 mailing list