Constructing a UDP packet with libnet
The User Datagram Protocol (UDP) sends datagrams to other hosts on an IP network without any prior handshaking to set up the communication channel between the devices. A datagram is just a packet (like an ICMP or TCP packet), except that the delivery, arrival time, and sequence are not guaranteed. The UDP protocol is considered to be an unreliable protocol because there is no guarantee of delivery.
The minimalist approach of UDP makes it ideal for real-time applications, such as Voice over IP, online games and streaming media, where dropping of packets is preferred over waiting for delayed packets. If guarantee of delivery is needed so that packets are not dropped, applications should use TCP or SCTP instead of UDP.
In this recipe, we will be creating a UDP packet and sending it to a remote device. We will use Wireshark (http://www.wireshark.org) to see the packets that we send out, however, we will not see any return packet because UDP on its own does...