简介
https://www.man7.org/linux/man-pages/man7/packet.7.html
Documentation/networking/packet_mmap.txt, 原生socket,加速功能。
man 7 raw ; Linux IPv4 raw sockets,这里说是 ip4层的raw socket;和二层的不一样
man 7 packet;这个是二层上的raw sockets;
设备层面的包接口。就是可以设定mac层地址的一种socket。
需要的头文件
#include <sys/socket.h>
#include <linux/if_packet.h>
#include <net/ethernet.h> /* the L2 protocols */
packet_socket = socket(AF_PACKET, int socket_type, int protocol);
IP_HDRINCL 的出现是因为操纵的任意性,又暗含了人类的懒惰
man 7 raw;里有一句话,比较有深意,既然用户选择了原生的IP层socket,也就意味中开发者可以任意的修改IP头;所以为了节省开发者的工作,才设置了这么一个开关,还可以让系统自动生成这个IP头。
A protocol of IPPROTO_RAW implies enabled IP_HDRINCL and is able to send any IP protocol