AF_INET is the normal IP family whit this you can have TCP, UDP, or raw sockets in the classic InterNet based network (IP).
AF_PACKET is the Linux-specific packet family, designed for creating link-level packets.
With an AF_PACKET socket, you can make not only IP traffic, but anything else ...
If you capture some packet with wireshark you can see several headers in the packet:
2. Ethernet II
3. Internet Protocol
4. Transmission Control Protocol (or UDP)
With AF_PACKET you can handle them all.
If you use SOCK_RAW you can use your own structures for UDP and TCP packet headers.(But I think that the standard structures can be used too)
Last edited by hua; 08-31-2010 at 04:25 AM.