networking · beginner · ~15 min
Split a payload into MTU-sized datagrams.
Implement int datagrams_needed(int total_bytes, int mtu) returning how many datagrams of at most mtu bytes are needed (ceiling division), 0 if mtu <= 0.
int datagrams_needed(int total_bytes, int mtu) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.