简体   繁体   English

发送原始以太网数据包,其中数据字段的长度在类型字段中

[英]Send raw ethernet packet with data field length in type field

I'm trying to send a raw ethernet frame with the length of my data written in the type field. 我正在尝试发送原始以太网帧,并将其数据长度写在类型字段中。 This should be a valid ethernet frame. 这应该是有效的以太网帧。 My code for this looks like this: 我的代码如下所示:

ethData = "foobar"

proto =len(ethData)

if proto < 46:
  proto = 46

soc = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, proto)
soc.bind((iface, proto))

For some reason I cant read package on the other end. 由于某种原因,我无法读取另一端的软件包。 I wonder why. 我想知道为什么。 I try to get this package in the interrupt handler of my wireless driver, so this packet has to be droped by my hardware directly or it doesn't get send at all. 我尝试在无线驱动程序的中断处理程序中获取此程序包,因此该数据包必须直接由我的硬件丢弃,否则将根本无法发送。 The question is why. 问题是为什么。

Sorry, my fault. 对不起,我的错。 I just parsed the wrong portion of the packet and didn't get any output. 我只是解析了数据包的错误部分,没有得到任何输出。 My bad. 我的错。 The package gets there just like it is supposed to. 包到达那里就像它应该的那样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM