Disabling Fragmented Packets on NWConnection - What Is Expected from disableFragmentation?

Hello everyone,

We have a use case where we need to disable the sending and receiving of fragmented packets on the network while using NWConnection.

However, even after setting the disableFragmentation flag to true, the connection still sends fragmented packets.We’ve tried setting the flag as follows, but the packets are still being fragmented:

var connection : NWConnection

var udp_options : NWProtocolUDP.Optionsudp_options = NWProtocolUDP.Options()
var connection_parameters = NWParameters(dtls: nil, udp: udp_options)

let ip_options = connection_parameters.defaultProtocolStack.internetProtocol! as! NWProtocolIP.Options

ip_options.disableFragmentation = true

connection = NWConnection (host: "XX.XX.XX.***", port: NWEndpoint.Port(25000), using: connection_parameters)

The issue we are encountering is that even though we’ve set disableFragmentation to true on the sender, the receiver still receives fragmented UDP packets. This can be observed using Wireshark, where we are sending a 10k byte data from the sender and receiving the fragmented datagram packets on the receiver end while both the devices are on the same WiFi network. Additionally, Wireshark shows that the packet has the "DF" bit set to '0', indicating that fragmentation is allowed.

What is exactly expected from the disableFragmentation flag? Are we misunderstanding how this flag works? Or is there something else we should be doing to ensure that fragmentation is completely disabled?

Looking forward to your insights!

I recommend that you put your networking questions in App & System Services > Networking rather than Programming Languages > Swift. Feel free to add the Swift tag if you think that’s critical to the issue.

What is exactly expected from the disableFragmentation flag?

I would expect that it’d set the DF bit in the IPv4 header, indicating to routers that they should drop rather than fragment the datagram.

Wireshark shows that the packet has the "DF" bit set to '0', indicating that fragmentation is allowed.

Well, that’s not good.

Where in the network path are you running this packet trace?

I want to confirm that you’re looking at the source of the packets. So:

  • If you’re sending from a Mac, run the packet on the Mac.

  • If you’re sending from iOS, use an RVI trace, as explained in Recording a Packet Trace.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Disabling Fragmented Packets on NWConnection - What Is Expected from disableFragmentation?
 
 
Q