gpt4 book ai didi

python-3.x - 尝试在Python 3中使用原始套接字盲目发送IP程序包,但不断获取ARP查询如何禁用

转载 作者:行者123 更新时间:2023-12-03 12:07:55 24 4
gpt4 key购买 nike

我正在尝试通过点对点网络IE Host和Client通过静态IP彼此直接连接来在Python 3中发送IP包。

我正在使用以下代码:

import socket

class Client:

def __init__(self):
self._sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW)
self._sock.bind(('192.168.1.10',0))

def send(self, data):
data_to_send = bytes([0x0,0x1C,0x23,0x17,0x4A,0xCB,0x00,0x50,0xB6,0x0D,0x35,0x9F,0x08,0x00,0x45,0x00,0x00,0x2E,0x00,0x00,0x40,0x00,0x40,0x00,0xB7,0x6A,0xC0,0xA8,0x01,0x0A,0xC0,0xA8,0x01,0x0B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00])
self._sock.sendto(data_to_send, ('192.168.1.11', 0))

但是,每次我尝试发送该程序包时,我总是会得到ARP查找(并且该程序包永远不会被发送)。
1   0.000000    GoodWayI_0d:35:9f   Broadcast   ARP 42  Who has 192.168.1.11? Tell 192.168.1.10
2 0.981801 GoodWayI_0d:35:9f Broadcast ARP 42 Who has 192.168.1.11? Tell 192.168.1.10
3 1.981830 GoodWayI_0d:35:9f Broadcast ARP 42 Who has 192.168.1.11? Tell 192.168.1.10

我如何避免这些查找,而只是盲目地发送包裹?

看来我的搜索引擎坏了,因为我找不到关于Python 3套接字的大量文档。

问候

最佳答案

我确实通过将IP/MAC添加到ARP列表来解决此问题

使用

netsh interface ip add neighbors "Ethernet 3" "192.168.1.11" "00-1C-23-17-4A-CB"

但是我希望能够在python中将其关闭

问候

关于python-3.x - 尝试在Python 3中使用原始套接字盲目发送IP程序包,但不断获取ARP查询如何禁用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59764583/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com