In this case, you need to use Raw Sockets, or you can use some lib to simplify this, the recommended lib for this is libpcap, below I wrote a simple example for sending a package using libpcap.
const int packet_size = 40;
char *packet = (char *) malloc(packet_size)
pcap_t *handle = NULL;
char errbuf[PCAP_ERRBUF_SIZE], *device = NULL;
if ((device = pcap_lookupdev(errbuf)) == NULL) {
fprintf(stderr, "Error lookup device", device, errbuf);
exit(1);
}
if ((handle = pcap_open_live(device, BUFSIZ, 1, 0, errbuf)) == NULL) {
fprintf(stderr, "ERRO: %s\n", errbuf);
exit(1);
}
int result = pcap_inject(handle, packet, packet_size);
, http://www.cse.ohio-state.edu/cgi-bin/rfc/rfc1293.html ARP http://en.wikipedia.org/wiki/Ethernet_frame ethernet