简体   繁体   English

TCP / IP应用程序Keepalive大小和带宽开销

[英]TCP/IP application Keepalive size, and bandwidth overhead

I'm writing a Java server ( java.net.Socket , java.net.ServerSocket , java.io.ObjectOutputStream , java.io.ObjectInputStream ) and I know I'm going to have limited bandwidth allocated for it. 我正在编写一个Java服务器( java.net.Socketjava.net.ServerSocketjava.io.ObjectOutputStreamjava.io.ObjectInputStream ),我知道我将为它分配有限的带宽。

I've written a decorator object for my output and input streams so I can count how many bytes go through it for profiling purposes. 我为输出和输入流编写了一个装饰器对象,因此我可以计算通过它的多少字节用于分析目的。 But this won't give me any indication of the amount of overhead I'm using for the connection. 但这不会给我任何关于我用于连接的开销量的指示。

I don't anticipate it will be much, but I'd like to prepare for it. 我不认为它会有多大,但我想为它做好准备。 I'm not going try to optimize it, I just want to know how much it will be for logistical reasons (how much bandwidth must I request, etc.) 我不打算尝试对其进行优化,我只是想知道出于后勤原因会有多少(我必须要求多少带宽等)

I can't be the first person to try to get this information, but I can't seem to find good resources on the overhead of Java Sockets and TCP/IP in general. 我不能成为第一个尝试获取此信息的人,但我似乎无法在Java套接字和TCP / IP的开销上找到很好的资源。 (Perhaps that's because there's nothing noteworthy to find... If we're on the order of kb per minute, it's really not much of a concern, but I'd still like to know!) (也许那是因为没有什么值得注意的......如果我们的每分钟大约为kb,那真的不是什么问题,但我还是想知道!)

Thanks! 谢谢!

This question is challenging to answer with the information we have right now... for instance, what are you calling 'overhead'? 这个问题很难回答我们现在掌握的信息......例如,你称之为“开销”的是什么? Is it only TCP ACK packets, or all packet overhead (for instance ethernet, IP and tcp headers) for anything other than your data payload? 是否只有TCP ACK数据包,或者除了数据有效负载之外的所有数据包开销(例如以太网,IP和tcp标头)?

How many connections per minute? 每分钟有多少连接? What is the average data transfer, per connection? 每个连接的平均数据传输是多少? If there are many very short-lived connections, your overhead requirements go up (due to 3-way handshake, and connection close requirements)... you could also have high overhead if the clients don't read much data, but many clients keep the connections open for days at a time. 如果存在许多非常短暂的连接,则您的开销要求会上升(由于3次握手和连接关闭要求)...如果客户端不读取大量数据,您可能也会有很高的开销,但是很多客户端保持连接一次打开几天。

Honestly, you're 50x better off modeling this in a lab and making some assumptions about hit rate per minute and concurrent clients... that will give you some ballpark numbers. 老实说,你在实验室中对这个进行建模并且对每分钟命中率和并发客户进行一些假设会有50倍的好处......这会给你一些大概的数字。 Play around with limiting the bandwidth afforded to the application to the maximum your budget would allow... then start backing off... you can throttle bandwidth by using wanem on a dual-port linux machine. 将限制提供给应用程序的带宽限制在您的预算允许的最大值...然后开始退出...您可以通过在双端口Linux机器上使用wanem来限制带宽。

Getting lab results like this is far better than theoretical calculations. 像这样获得实验室结果远比理论计算好。

HTH, \\mike (who spends all day testing network gear) HTH,\\ mike(谁花了一整天测试网络设备)

TCP overhead varies based on a number of factors, but is typically around 5% at full capacity. TCP开销根据许多因素而变化,但在满容量时通常约为5%。

Basically each "packet" has 20 bytes of IP header (and 20 more if IPv6) plus 20-32 bytes of TCP header. 基本上每个“数据包”都有20个字节的IP报头(如果是IPv6,还有20个字节)加上20-32个字节的TCP报头。 Packet sizes vary based on the network devices and conditions, but are often in the neighborhood of 1500 bytes. 数据包大小因网络设备和条件而异,但通常在1500字节附近。

This page has some detail: http://sd.wareonearth.com/~phil/net/overhead/ 这个页面有一些细节: http//sd.wareonearth.com/~phil/net/overhead/

In my opinion you can completely ignore keep-alives, as they are only used when the connection is idle anyway. 在我看来,你可以完全忽略保持活动,因为它们只在连接闲置时使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM