How to set the don’t fragment (DF) flag on a socket?

You do it with the setsockopt() call, by using the IP_DONTFRAG option: int val = 1; setsockopt(sd, IPPROTO_IP, IP_DONTFRAG, &val, sizeof(val)); Here’s a page explaining this in further detail. For Linux, it appears you have to use the IP_MTU_DISCOVER option with the value IP_PMTUDISC_DO (or IP_PMTUDISC_DONT to turn it off): int val = IP_PMTUDISC_DO; setsockopt(sd, … Read more

Identification of packets in a byte stream

… can’t really grasp how the checksum can be used as an identifier for the start of the package (wouldn’t the checksum change all the time?). Yes, the checksum would change since it is derived from the data. But even a fixed-value start-of-packet nibble would (by itself) not be sufficient to (initially) identify (or verify) … Read more