Packet-crafting tools like hping3 and Scapy build UDP datagrams field-by-field exactly as you do here, including the RFC 768 pseudo-header trick for checksumming data that never actually goes on the wire. This same technique underlies UDP-based DNS amplification attacks, where spoofed source addresses turn a small forged query into a large reflected flood.