- If Layer-2 has a checksum, shouldn't this validation be enough?
- Why we are having checksum validation in different OSI Layers?
Simply put, different layers of the OSI model have checksums so you can assign blame appropriately.
- Suppose there is a webserver running on some system (assume TCP port 80, i.e. OSI Layer 4)
- Suppose there is a software error in the Operating System of that webserver that corrupts certain IP payloads. (IPv4 OSI Layer 3)
Case 1: Only use Ethernet checksums
If we only rely on Ethernet (i.e. OSI Layer 2) checksums, then that error would go un-noticed until something crashes or throws an error, because the Ethernet NIC would simply transmit the (already corrupted) data that it received from the Operating System IP stack. For sake of argument, let's assume the TCP payload is corrupted, but the Ethernet checksum is fine.
When the IP stack on the other side receives the Ethernet frame, it unpacks the IP payload and delivers it to the webserver. However, the TCP payload in this packet is corrupted. When the web server crashes from data corruption, the developer has no way to isolate whether this was an IP-level failure or a TCP failure (or perhaps something else farther up the application stack).
Case 2: Layered checksums
However, if TCP, IP and Ethernet all have checksums, we can isolate the layer where the error occurred, and notify the appropriate Operating System or application component of the error.