Find the answer to your Linux question:
Results 1 to 3 of 3
I used raw socket to create some udp packets and then send them to a udp server I notice that when I put a wrong udp checksum number the udp ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2012
    Posts
    87

    how is tcp/udp checksum working?


    I used raw socket to create some udp packets
    and then send them to a udp server

    I notice that when I put a wrong udp checksum number
    the udp server doesn't accept it

    but if I put all 0 on the checksum, the udp server accept it?

    why?

    besides, I notice a pheonomenum: checksum offloading
    I checked my machine:
    Code:
    [root@kit temp]# ethtool --show-offload  eth0
    Offload parameters for eth0:
    rx-checksumming: on
    tx-checksumming: on
    scatter-gather: on
    tcp-segmentation-offload: off
    udp-fragmentation-offload: off
    generic-segmentation-offload: on
    generic-receive-offload: on
    large-receive-offload: off
    rx-vlan-offload: on
    tx-vlan-offload: on
    ntuple-filters: off
    receive-hashing: on
    it seems there is checksum offloading on my machine
    when the checksum is 0, why the NIC doesn't modify the checksum of the outgoing packet?


    finally, packets may get modified when they are in transmission
    for example, TTL will decrease by number of hops
    NAT may also modify the source ip addresses,
    then the checksum will be obsolete,
    in these cases, how checksum works?
    the router will modify the checksum accordingly?
    or the destination machine can smartly detect these and calculate the checksum accordingly?

    thanks!!
    Last edited by esolve; 03-18-2013 at 10:44 PM.

  2. #2
    Just Joined!
    Join Date
    Sep 2012
    Location
    Nashville, TN
    Posts
    98
    I don't think UDP uses a checksum. It is a connectionless oriented protocol. TCP uses the checksum so that it can provided retransmission of packets. You will see faults as CRC errors normally.

    *** NOTE ***
    I actually stand corrected. After looking through cisco documentation it does use checksum but only for packet validity and to let the other host know wether or not to discard the packet.

  3. #3
    Linux Engineer Kloschüssel's Avatar
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    773
    Quote Originally Posted by esolve View Post
    but if I put all 0 on the checksum, the udp server accept it?
    If the checksum is entirely 0 (0x0), it is ignored on UDP packets. Checksums are optional on UDP packets according to this.

    Quote Originally Posted by esolve View Post
    the router will modify the checksum accordingly?
    When NAT is active it will either recalculate the checksum or zero it. What exactly the router does probably depends on the router model and firmware. IMHO a router should recalculate the checksum if the checksum is not 0 or ignore the checksum if it is 0. Maybe someone else can quote a specification here that I am not aware of.

    EDIT: according to this RFC, NAT modifies the checksums on TCP packets. But I was unable to find any reference to how it should behave with UDP packets.

    Quote Originally Posted by esolve View Post
    the destination machine can smartly detect these and calculate the checksum accordingly?
    Absolutely not. The destination cannot "guess" if the checksum has been modified. Either the checksum or the packet itself was somehow obstructed during transfer. The receiver cannot distinguish which one (or both) are obstructed.

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •