Reputation: 33
When a packet is sent from source to destination,it has to pass by through several routers and each router decreases the value of TTL of packet by 1. So header checksum is to be recomputed at each router since one of the header field i.e. TTL surely changes. Then how does the destination verifies the presence of error by calculating the checksum ,though the checksum it got has changed than that of checksum of source side?
Upvotes: 2
Views: 2599
Reputation: 1666
When the packet leaves the source, it has some initial TTL and (hopefully) a valid checksum.
When the packet arrives at a router, the router checks only the IPv4 header checksum. If it is incorrect, it drops the packet. If it is correct, it (1) decrements the TTL; (2) checks that the TTL is higher than zero (otherwise the packet is dropped) and (3) computes and fills in the new IP header checksum.
Interestingly, the new checksum can be computed directly from the old checksum and the old and new value of the TTL, with some clever math: https://www.rfc-editor.org/rfc/rfc1624 so reading the whole IPv4 header again is not necessary.
Note that IPv6 has a hop limit (which works like the TTL) but no header checksum.
Upvotes: 2
Reputation: 5907
Every router calculates and verifies the checksum before routing, if there is a mismatch the router drops the datagram.
Upvotes: 1