有没有一种简单的方法可以将 IP 数据包从用户空间 Windows 应用程序路由到网络?

发布于 2024-10-03 14:38:21 字数 552 浏览 1 评论 0原文

我正在开发一个涉及 USB 设备的项目,通过该设备我们将从远程 PC 接收 ip 数据包。我们为远程电脑分配 IP 地址。我一直在尝试通过几种方法发送原始 ip 数据包:

1 - 原始套接字:ping 工作正常,发送 tcp 时出现问题

2 - tun/tap W32:我设法让这个工作足以发送 ping 并将 ping 返回到 phy以太网设备,但无法使用驱动程序 GUID 上的 ReadFile(...) 读取它们。

3 - winpcap:ping工作正常,外出tcp显示在wireshark上(所以我假设它正在离开电脑),但我从未收到对我的syn的确认。我还担心如果我确实得到了一个确认,Windows TCP 堆栈会首先发送一个确认。

我们的目标是实现从客户端电脑到网络的透明传递。 客户端<-包裹的ip数据包-> [设备] <-包裹的ip数据包-> WinPC <- IP -> IpNetwork

我可能会犯这个错误,看起来这应该更容易。

我意识到 Windows 可能不是理想的操作系统,但我无法控制操作系统。

提前致谢

I am working on a project that involves a usb device, through which we will receive ip packets from a remote pc. We assign the remote pc its IP Address. I have been experimenting with sending raw ip packets via several methods:

1 - raw sockets: ping works fine, problems sending tcp

2 - tun/tap W32: I managed to get this working enough to send pings out and get pings back to the phy ethernet device, but could not read them using ReadFile(...) on the driver guid.

3 - winpcap: ping works, out going tcp shows up on wireshark(so I assume it is leaving the pc), but i never get an ack to my syn. Im also worried that if I did get an ack the windows TCP stack would send a rst.

Our goal is to be a transparent pass through from the client pc to the network.
Client <-wrapped ip packet-> [device] <-wrapped ip packet-> WinPC <- IP -> IpNetwork

Its possible that im going about this wrong, seems like this should be easier.

I realize that windows is prob not the ideal OS for this, however I have no control over the OS.

thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

聊慰 2024-10-10 14:38:21

修复了 TCP Syn 数据包未得到确认的问题,结果是我在计算 TCP 标头校验和时忘记包含伪标头。现在看起来 TCP 握手已完成,所以我称这个问题已解决。如果有人想推荐更好的方法来完成此任务,请随时回复。现在看起来我们将使用 winpcap 方法。

更新:
为了在 Windows 不不断 RST'ing tcp 连接的情况下实现此功能,您必须在发送数据包的适配器上启用互联网连接共享 (ICS)。除此之外,这最终对我们有用。

Fixed my issue with TCP Syn packets not getting acked, turns out I forgot to include the pseudo-header when calculating the TCP header checksum. Now it looks like the tcp handshake completes, so im calling this problem solved. If anyone feels like recomending a better way to accomplish this, feel free to reply. For now looks like we will use the winpcap method.

Update:
For this to work without windows constantly RST'ing tcp connections, you have to enable internet connection sharing(ICS) on the adapter you are sending packets out of. Other than that this ended up working for us.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文