Compact Framework 连接到 Web 服务 - 如何使用源端口随机化
紧凑框架3.5
Windows CE 6.0 R3
基于 Atmel 的 BSP
情况:来自单个网关的多个设备连接到位于防火墙后面的 Web 服务。所有设备都使用相同的 IP 和源端口开始连接。
问题:基本上一个新设备正在尝试连接到 Web 服务,防火墙认为它是现有连接,发送 RST 数据包。设备按顺序递增源端口,然后重试。如果有 100 个设备,则需要连续 100 个 RST,这需要很长时间。 (参见http://www.fuzeqna.com/sonicwallkb /consumer/kbdetail.asp?kbid=8013&formaction=catalert)
根据该文章,解决方案是随机化源端口。源端口是如何确定的以及如何设置?我什至不确定它是在哪里完成的(CE、CF、BSP)。
编辑:
找到这篇有关 ServicePoint 的文章。 HttpWebRequest 类上的 ServicePoint 看起来很有前途,但规范说:
适用于 Pocket PC、Windows 的 Windows Mobile 适用于智能手机的移动设备、Windows CE 平台注意:该属性为空 直到发送请求,因为 额外的网络传输 必填。
Compact Framework 3.5
Windows CE 6.0 R3
Atmel-based BSP
Situation: Multiple devices from a single gateway connecting to a web service that's behind a firewall. All devices start the connection with the same IP and source port.
Problem: Basically a new device is trying to connect to the web service, firewall thinks it's the existing connection, send a RST packet. The device sequentially increments the source port, tries again. If there are 100 devices, it's a 100 RSTs in row, which takes a really long time. (see http://www.fuzeqna.com/sonicwallkb/consumer/kbdetail.asp?kbid=8013&formaction=catalert)
The solution, according to the article, is to randomize the source port. How is the source port determined and how can I set it? I'm not even sure where it's being done (CE, CF, BSP).
Edit:
Found this article about ServicePoint. ServicePoint on the HttpWebRequest class looks promising, but the spec says:
Windows Mobile for Pocket PC, Windows
Mobile for Smartphone, Windows CE
Platform Note: This property is null
until the request is sent because of
the additional network transmission
required.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,所以问题似乎出在winsock.dll 中。我们最终实例化了 Socket 类并将其随机绑定到 Loopback 端点。
Ok, so the problem appears to be in winsock.dll. What we ended up doing instantiating the Socket class and binding it to the Loopback endpoint a random number of times.