1

I have some software written in C++ which acts differently on 2 separate machines. The software sends UDP packets out using:

m_socketHandle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)

Both machines are using WIN 7 SP1

According to Wireshark:

Machine 1: the Don't fragment section of the IP header is set to 0 "Don't Fragment: Not SET".

Machine 2: it is set to 1 "Don't Fragment: SET".

enter image description here

So this led me to try and explicitly set it myself using: This Stack Question

and

int val = 1;
setsockopt(sd, IPPROTO_IP, IP_DONTFRAGMENT, (char *)&val, sizeof(val));

But it has no effect what so ever with the result always being "Don't Fragment: Not SET".

Am i missing something here, why would it be different on different machines even though the code wasn't explicitly setting it?

  • Windows documentation say that paramater type of IP_DONTFRAGMENT should be DWORD. Maybe sizeof int is different than sizeof DWORD in the env. And setsockopt fails because the latest parameter is not sizeof(DWORD). So try: `DWORD val = 1` – SKi Aug 22 '18 at 10:55
  • Thanks, still nothing. I currently looking at [This MS Documentaion](https://learn.microsoft.com/en-us/windows/desktop/winsock/ipproto-ip-socket-options) which has the IP_MTU_DISCOVER flag which looks promising but i can't seem to find it anywhere in my include files. –  Aug 22 '18 at 11:18
  • Ah, IP_MTU_DISCOVER isn't listed in the Windows supported ones! –  Aug 22 '18 at 11:28
  • As for the differing behaviour, [this flag is often autonomously determined by complex and intelligent algorithms that are trying to make your network run as fast as possible](https://serverfault.com/a/84981). I would caution you against trying to beat that system. – Lightness Races in Orbit Aug 22 '18 at 11:40
  • @LightnessRacesinOrbit That's for TCP, not UDP. With UDP, you have to either perform PMTU discovery yourself or restrict length to mimumum supported MTU, which is payload of 548 bytes. Otherwise, your UDP packet might be fragmented. – quartzsaber Sep 05 '21 at 04:03

0 Answers0