Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UDP max payload size should depend on the MTU #3199

Open
stevenengler opened this issue Oct 4, 2023 · 0 comments
Open

UDP max payload size should depend on the MTU #3199

stevenengler opened this issue Oct 4, 2023 · 0 comments
Labels
Type: Enhancement New functionality or improved design

Comments

@stevenengler
Copy link
Contributor

stevenengler commented Oct 4, 2023

The maximum theoretic UDP payload size is 65,507: 65,535 (2^16 - 1) - 20 (ip header) - 8 (udp header). In practice Linux should limit the size of a message sent by userspace so that it fits within the MTU for the egress interface, and return EMSGSIZE if the packet wouldn't fit within the MTU (even if IP fragmentation is supported).

Shadow currently uses the 65,507 byte message limit and ignores the MTU. This means that 65,535 byte UDP packets can be sent over Shadow's network interface and they aren't fragmented since Shadow doesn't support IP fragmentation.

A fix wouldn't be as straightforward as simply limiting sendmsg calls to 1500 - 20 - 8 bytes though. While currently both the eth0 and loopback interfaces in Shadow use an MTU of 1500, on Linux loopback uses an MTU of 65,536 (see #3200). We also have integration tests that check if we can send a ~65,000 bytes UDP message over loopback. If we wanted to properly support the MTU, we'd need to get the MTU for the interface that the message would be sent over. For example an unbound UDP socket can send messages to both external addresses and a localhost address. I don't know what Linux does, but I'm guessing it uses the routing table to figure out what interface the message would be sent on, and then looks up the MTU of that interface before deciding if it should return EMSGSIZE or not. In Shadow, sometimes loopback packets are sent over the Internet interface, so it gets a bit complicated if the two interfaces have different MTUs.

@stevenengler stevenengler added the Type: Enhancement New functionality or improved design label Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement New functionality or improved design
Projects
None yet
Development

No branches or pull requests

1 participant