Linux:socket:packet raw sockets 相关(raw packets、原生包,原生socket)

239 篇文章 ¥59.90 ¥99.00

简介

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mzhan017

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值