factor out writing ethernet, IP and UDP frames (since the netmap socket needs to do the same thing)