Search code examples
linuxnetwork-programmingtcpraw-sockets

If I use a raw socket on Linux, will incoming packets with bad TCP checksums be dropped by the kernel?


Right now I'm writing a program that uses a raw TCP socket. If there are any incoming packets with bad TCP checksums, will the kernel pass them to the program or drop them? The reason I want to know is to figure out if I'll need to manually do that check or not.


Solution

  • Since you are writing TCP youself (working with an "IP" Socket/Layer) will have to handle the TCP Checksums. Any layers below or any checksums, will be handled by the underlying OS.

    With the TCP/IP Stack you have (bottom to top order)

    Link

    Internet <- Socket Here Anything here and below will be handled. Essentially you are saying I am writing my own Transport protocol and it happens to be TCP.

    Transport <- TCP Here

    Application