Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zhang-stephen opened this issue May 29, 2023 · 5 comments
Open

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

zhang-stephen opened this issue May 29, 2023 · 5 comments

Comments

@zhang-stephen
Copy link

zhang-stephen commented May 29, 2023

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

image

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

以下是wireshark的捕获:

image

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

@Neutree
Copy link
Owner

Neutree commented May 29, 2023

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

@zhang-stephen
Copy link
Author

zhang-stephen commented May 29, 2023

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

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

@Neutree
Copy link
Owner

Neutree commented May 30, 2023

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

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

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

@zhang-stephen
Copy link
Author

看了下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

@Neutree
Copy link
Owner

Neutree commented May 30, 2023

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

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants