Returning a pointer to a static buffer in an object that is later deleted results in an empty IP header, depending on the compiler and optimisation level. Instead we can write directly inside the packet buffer.
The encapsulated IP packed was missing source/destination addresses and the UDP datagram had size 0.