Neutree / COMTool

Cross platform communicate assistant(Serial/network/terminal tool)( 跨平台 串口调试助手 网络调试助手 终端工具 linux windows mac Raspberry Pi )支持插件和二次开发

Home Page:https://neucrack.com/p/186

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Enhancement] TCP/UDP支持多网卡或者绑定指定网卡

zhang-stephen opened this issue · comments

如题,如果PC上有两个或者更多网卡时,comtool无法选择数据发送到/接收自哪个网卡,一般表现为无数据

image

如图,以太网地址是192.168.111.1,Wifi地址是192.168.31.xxx(具体多少忘记了),此时某芯片正在向以太网发送UDP数据包,这些数据包可以被wireshark捕获,但是comtool无法接收。

以下是wireshark的捕获:

image

现在有无什么workaround暂时解决一下这种需求?

你这是 15在向.1网关发送数据呀,跟comtool有啥关系

你这是 15在向.1网关发送数据呀,跟comtool有啥关系

15是外部设备,.1是PC的网口,comtool却收不到这些数据?是我的comtool配置的不太对?

这个跟多网卡应该没关系。

.1是PC的话理论上应该可以才对,我这里测试两台之间通信是没问题的,
image

没办法复现你的现象,暂时不太清楚问题在哪儿

看了下UDP部分的实现,socket是绑定到0.0.0.0:<port>上的,这里没有问题

但是在onReceiveProcess函数中,收到的data会附加到buffer,然后丢给self.onReceived()处理,这个方法继承自Comm.onReceived,这个lambda方法是空的?收到的数据没有被处理嘛?

我不太了解pyqt的开发,不过尝试复现了一下UDP的接收,如有疏漏,请指出。

附:

我自己写的socket测试代码:

import socket
from datetime import datetime

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

sock.bind(("0.0.0.0", 7000))

while True:
    recv, addr = sock.recvfrom(1024)
    now = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
    print(f"{now}: client: {addr}, data size: {len(recv)}")

测试结果:
image

lambda是默认值,在这里设置的 https://github.com/Neutree/COMTool/blob/d7bb5aa087cc58d94c36c3442196b318dfc97c10/COMTool/pluginItems.py#LL204C43-L204C53
然后会在这里

self.plugin.onReceived(data)
调用具体插件的 onRecieved 方法

既然你可以调试,方便的话可以调试一下应该就能发现问题了