Hacker News new | ask | show | jobs
by immibis 481 days ago
This gives you a raw Ethernet socket. For a raw IP socket, use AF_INET,SOCK_RAW,0.

A raw Ethernet socket sends packets at the Ethernet level while a raw IP socket sends packets at the IP level. If you want to play on your local network you want Ethernet (maybe). If you want to send weird packets across the Internet you probably want IP, so that you don't have to waste effort doing route lookups and MAC address lookups and your code will still work on non-Ethernet networks, including VPNs.

There are some protocols that run on top of Ethernet but Internet-compatible protocols all run on IP by definition.

This comment was delayed several hours due to HN rate limiting.

1 comments

Yeah, this was intended to eliminate the problems with protocol=0, but yeah you need to implement IP and maybe ARP to do a similar thing at this level. Thankfully IP is pretty simple to implement.