如何使用 HTTP 在 C# 中控制设备的嵌入式控制软件?

发布于 2024-09-19 22:26:26 字数 568 浏览 12 评论 0原文

我有一个带有嵌入式用户控件的硬件,可以通过在网络浏览器中输入设备的 IP 地址来访问该控件。该设备通过以太网电缆和静态 IP 直接连接到我的电脑。我需要将设备的控制集成到我的 C# 应用程序中。

我的想法是使用数据包嗅探器来监视我的电脑和设备之间的流量,同时在我的网络浏览器中使用设备的控件。然后找出我的电脑发送的哪些数据包与我当时使用的哪些控件相对应。然后,我可以在 C# 应用程序中创建 HTTP 或 TCP 数据包类,并使用 Socket 类将它们发送到设备。

然而,我对网络协议没有太多经验,所以当我使用 Wireshark 监控我的电脑和设备之间的流量时,我什至不知道从哪里开始找出哪些数据包做了什么。有人有什么想法吗?我对任何事情都持开放态度。谢谢!!

编辑: 很难准确解释我的设备是什么,但它基本上是一个复杂的传感器,通常用于工业应用,因此它很可能使用我比较熟悉的 Modbus。您知道如何通过检查数据包来判断正在使用哪种协议吗?我注意到(使用 Wireshark)从我的 PC 发送到设备的数据包以 1 个 HTTP 数据包、然后 5 个 TCP 数据包的模式发生,只要控件在浏览器中打开,就会重复相同的序列。是否有任何资源可以让我更好地了解正在发生的事情?

I have a piece of hardware with an embedded user control accessed by typing the device's IP Address into a web browser. The device is connected directly to my PC via x-over ethernet cable and static IP's. I need to integrate the control of the device into my C# application.

My thought was to use a packet sniffer to monitor the traffic between my PC and the device while at the same time playing with the device's controls in my web browser. Then finding out which packets that my PC is sending correspond with which controls I am using at that time. Then I can create a class of HTTP or TCP packets in my C# application and send them to the device using the Socket class.

However, I dont have much expereince with network protocols, so when I am using Wireshark to monitor the traffic between my PC and the device, I am not sure where to even start when finding out which packets do what. Does anyone have any ideas? I am open to anything. Thanks!!

EDIT:
Its hard to explain exactly what my device is, but its basically an elaborate sensor and typically used in industrial applications, so it could likely be using Modbus, which I am moderately familiar with. Do you know how I can tell which protocol is being used by examining the packets? I noticed (using Wireshark) that the packets being sent from my PC to the device occur in a pattern of 1 HTTP packet, then 5 TCP packets and repeat that same sequence as long as the control is open in my browser. Are there any resources that might give me a better understanding of what is going on?

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

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

发布评论

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

评论(2

万劫不复 2024-09-26 22:26:27

如果这是浏览器控制的,我的第一个想法是检查设备发送到浏览器的网页,看看当您操作控件时浏览器被指示做什么 - 这似乎比摆弄 Wireshark 容易得多。

我是否遗漏了一些东西,使得这变得不可能(例如基于闪存的控制系统)?如果只是使用 HTML 或 Javascript、HTML POST 消息或 Ajax 等更复杂的东西来完成,那么设计界面应该相对容易。

If this is browser controlled, my first thought would be to examine the web pages the device sends to your browser and see what the browser is instructed to do when you manipulate the controls - this seems much easier than messing around with Wireshark.

Is there something I'm missing that makes this impossible (such as a Flash-based control system)? If it's just done with HTML or Javascript, and HTML POST messages or something a bit more sophisticated like Ajax, it should be relatively easy to work out the interface.

月隐月明月朦胧 2024-09-26 22:26:27

根据设备的不同,它将使用 modbus 协议的变体 (http://en.wikipedia。 org/wiki/Modbus)或一些晦涩且专有的东西。

最好的办法是不断地向设备发送相同的命令,直到您能够识别数据包中的相似之处。

如果它是专有的,它可能是一些简单的东西,例如命令/数据对或可能是 XML blob。如果你真的不走运,它会被压缩或编码,但除非你正在破解游戏或提款机,否则这是不可能的。

询问设备制造商是否可以为您提供规格通常也是有效的。

Depending on the device it will either be using a variant of the modbus protocol (http://en.wikipedia.org/wiki/Modbus) or something obscure and propriatory.

The best thing to do is to keep sending the same command to the device over and over again until you can recognise similarities in the packets.

If it is propriatory it will probably be something simple like a command/data pair or possibly an XML blob. If you're really unlucky it will be compressed or encoded but unless you're hacking a game or a cash machine this is unlikely.

Asking the manufacturer of the device if they can give you the spec often works as well.

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