如何在Socket客户端/服务器的java程序中设置ECN(显式拥塞通知)位
我已经为服务器和客户端编写了基本的套接字程序。我想知道如何使用java将数据从服务器传输到客户端,并且当服务器发送数据时,如果客户端缓冲区溢出,服务器应该降低其发送速率(拥塞应由 tcp/ip 中的 ECN 位指示)...感谢您的帮助。
I have written the basic socket program for the server and the client.I would like to know how to transfer data from server to client using java and also while the server is sending data if the client buffer overflows the server should reduce its sending rate(the congestion should be indicated by ECN bit in tcp/ip).....thank you for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ECN 字段是 IP 和 传输层。因此,我认为您无法从普通应用程序中设置它。一种方法是创建 RAW Socket 并使用正确的字段集(ECN在你的情况下)在 TCP/IP 标头中。
您还应该注意,所有路由器和参与的终端主机都必须有 ECN 支持。否则,路由器可能会丢弃数据包或任意将 ECN 值设置为零。
Google 为我找到了一些支持原始套接字的 Java 库,您可以找到这些库 此处。
ECN field is a property of IP and Transport layer. Therefore, I don't think you can set it from an ordinary application. One way to do it would be to create RAW Socket and craft packets yourself with proper fields set (ECN in your case) in TCP/IP header.
You should also note, all routers and participating end-hosts will have to have ECN support. Otherwise, routers may just drop the packet or arbitrarily set the ECN value to zero.
Google was able to find me some Java libraries with raw socket support which you would find here.
您可以使用 cmd 命令启用或禁用 ECN 功能 -
netsh interface tcp set global ecncapability=enabled
当您启用 ECN 功能时,TCP 标头会自动设置 ECN 和 CWR 标志。
https://www.saotn.org/explicit-congestion -notification-ecn-slows-outbound-connections/
You can enable or disable ECN capabilities using cmd command -
netsh interface tcp set global ecncapability=enabled
When you enable ECN capabilities TCP header automatically set ECN and CWR flag.
https://www.saotn.org/explicit-congestion-notification-ecn-slows-outbound-connections/