通过蜂窝网络Webify基于Linux的嵌入式控制器

发布于 2024-10-17 21:18:52 字数 541 浏览 2 评论 0原文

需要以下项目的基本方向。

有一个基于Linux的控制器做一些工业控制的事情。 该盒子配备了蜂窝调制解调器,能够通过蜂窝运营商上网。使用蜂窝通信是因为控制器大多安装在没有电缆或短距离无线电的地方。阳光通常照射不到的地方:)

任务是允许互联网客户端直接连接到盒子以进行一些基本的控制/监视。问题是连接性——客户端如何发现盒子? - 我想让盒子充当服务器(如果可能的话)。假设移动运营商允许盒子上网并不一定意味着盒子将获得公共 IP,以便任何人都能够连接。据我了解,蜂窝网络充当在其内部工作的人员的网关,从外部联系该网络中的某人是不可能的。我错了吗?我们正在寻找通用解决方案,而不是围绕特定蜂窝提供商的解决方案。控制器安装在不同的国家,我们需要找到标准方式将其“网络化”。

盒子里的软件(和硬件)是我们的,我们基本上可以做任何事情,但我正在寻找正确的方法来做到这一点,以避免以后与不同的提供商发生意外。顺便说一句,解决方案不一定是技术性的,也许可以为每个盒子购买永久 IP,或者设置 VPN。我应该采用哪种方式?要问什么问题?

欢迎您的想法!

Need a basic direction in the following project.

There is a linux based controller doing some industrial control stuff.
The box is equipped with cellular modem and is capable to get online through cellular carrier. Cellular communication is used because controller is mostly installed where no cables or short range radio is available. Places where sun don't normally shine :)

The task is to allow internet clients to connect directly to the box for some basic control/monitoring stuff. The problem is connectivity - how clients will discover the box? - I'd like to have the box act as a server (if possible). Assuming that cellular carrier allows the box to get online doesn't necessarily mean that the box will get public IP so that anyone would be able to get connected. To my understanding the cellular network acts as a gateway from those who are working inside of it, and reaching someone in that network from outside isn't possible. Am I wrong? We are looking for a generic solution, not a solution around particular cellular provider. The controller is installed in different countries, we need to find the standard way to "webify" it.

The software (and hardware) in the box is ours, we can basically do anything, but I am looking for the right way to do it in order to avoid surprises with different providers later. BTW, the solution doesn't necessarily have to be technical, may be it's possible to buy a permanent IP's per box, or setup VPNs.. Which way should I dig to? What questions to ask?

Your ideas are welcome!

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

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

发布评论

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

评论(3

朦胧时间 2024-10-24 21:18:52

你对问题的总结基本上是正确的。我已经实现了几个可以做到这一点的系统,并且成功的可能性很大。

您解决此问题的方式取决于您期望单个用户与之交互的远程单元的数量。如果每个用户只处理一两个设备,那么在远程设备上实现 Web 服务器是可行的。如果每个用户处理许多设备,请考虑尽可能集中管理。我使用 Zenoss 进行数据记录和自定义控制服务器来实现这一点。

如果 Web 服务器位于远程设备上,您可以购买具有静态 IP 的 SIM 卡,或使用代理服务器。我建议设置代理服务器,除非设备数量非常少。

SIM 卡有三种选择:

  • 具有公共互联网地址的静态 IP 价格昂贵,而且与每个国家/地区的每个提供商协商交易也很麻烦。不需要代理服务器。
  • 专用 APN SIM 将为您提供静态地址选项,但位于专用地址范围内。仍然需要与移动网络进行协商,并且您需要在公共互联网和专用地址范围之间放置代理服务器,
  • 标准数据 SIM 卡将通过 NAT 连接到互联网。您可以通过打开到您的服务器的 VPN 连接(我们使用 openvpn)来使用它们来托管您的服务。您现在可以通过连接到同一 VPN 或通过代理服务器直接访问设备。

如果您使用 openvpn,这里还有一些提示:

  • 为每个设备提供一个公共序列号和一个私钥。将它们存储在设备的固件和中央数据库中。将公共序列号贴在设备外部。您可以使用 openvpn 登录脚本来确保特定设备始终显示在正确的 IP 地址上,从而使代理配置保持静态。
  • 您可以通过调整其 keepalive 行为以及重新协商的频率来控制 openvpn 的带宽使用情况。在大规模部署之前对此进行测量和调整。
  • 移动网络中的 NAT 超时通常在 5 到 15 分钟之间。设备必须足够频繁地向服务器发送数据包才能保持 NAT 处于活动状态。
  • 便宜的 SIM 交易可能仅在网络上进行,端口有限。

其他提示:

  • GPRS 调制解调器固件可能(很少)发生内部崩溃。如果您的硬件支持,请提供能够重新启动调制解调器的软件。
  • 在发送国际货件之前,请在您所在国家/地区信号覆盖较差的地区测试您的盒子。

Your summary of the problem is basically correct. I've implemented several systems that do this, and the odds of success are good.

The way you tackle this will depend on the number of remote units you expect a single user to interact with. If each user will handle only one or two devices, it's plausible to implement the web server on the remote device. If each user handles many devices, consider centralising as much administration as possible. I've implemented this using Zenoss for data logging, and a custom control server.

If the web server sits on the remote device, you can either buy a SIM with a static IP, or use a proxy server. I recommend setting up a proxy server unless the number of devices is very small.

There are three options for SIMs:

  • Static IP with an address on the public Internet will be expensive, and negotiating the deal with each provider in each country will be irksome. No proxy server is required.
  • Private APN SIMs will give you the option of a static address, but in a private address range. Negotiation with the mobile network is still required, and you will require a proxy server to sit between the public Internet and the private address range,
  • Standard data SIMs will connect to the Internet through NAT. You can use these to host your service by opening a VPN connection (we used openvpn) to your server. You can now reach the devices directly by connecting to the same VPN, or through a proxy server.

If you use openvpn, here are some more tips:

  • Give each unit a public serial number, and a private key. Store these in the firmware of the unit, and in a central database. Put the public serial number on the outside of the unit. You can use an openvpn login script to ensure that a particular unit always appears at the correct IP address, which keeps the proxy configuration static.
  • You can control openvpn's bandwidth usage by adjusting its keepalive behaviour, and how often it renegotiates. Measure and tune this before a large deployment.
  • The NAT timeouts in the mobile networks are generally between 5 and 15 minutes. The device must send a packet to the server often enough to keep NAT alive.
  • Cheap SIM deals may be web only with limited ports.

Other tips:

  • GPRS modem firmware can (rarely) crash internally. If your hardware supports it, provide software with the ability to power cycle the modem.
  • Test your box in areas with poor coverage in your own country before you send out international shipments.
她比我温柔 2024-10-24 21:18:52

这是“移动代理”出现在不同地方或使用不同提供商(在这种情况下只有一个提供商,但几乎相同)的典型问题。通常,它是使用某种归属代理来解决的 - 移动设备连接到的服务器,并提供有关如何到达它的详细信息,或者如果无法直接到达,则归属代理充当代理。

客户端总是首先联系本地代理,然后如果可能,他们会联系移动设备,如果不可能,他们会使用服务器作为代理。

在某些情况下,动态 dns 可能就足够了,而在其他情况下,您需要真正的代理/外观。

有一本好书:Andrew S. Tanenbaum & Maarten van Steen:“分布式系统:原则和范式”

This is a typical problem with "mobile agent" appearing in different places or using different providers (in this case just one provider, but it's almost the same). Usually it's solved using some kind of home agent - a server that the mobile connects to and gives details about how to reach it or if it can't be reached directly then the home agent acts as a proxy.

Client always contact the home agent first and then if it is possible they contact the mobile or if it's not they use the server as a proxy.

In some cases dynamic dns might be sufficient in other you need real proxy/ façade.

There's a good book: Andrew S. Tanenbaum & Maarten van Steen :"Distributed Systems: Principles and Paradigms"

雪花飘飘的天空 2024-10-24 21:18:52

您可以要求移动运营商为您提供一张可以访问互联网和固定 IP 地址的 SIM 卡。然后您可以托管任何您喜欢的服务器。不要忘记您正在处理有限的带宽。

You can ask cellular provider to give you a SIM card with internet access and fixed IP address. Then you can host any server you like. Do not forget that you are dealing with limited bandwidth.

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