C++ TCP over IPv4 的最小数据包大小是多少
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14526139/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the minimum packet size for TCP over IPv4
提问by user1916580
What is the minimum packet size for TCP over IPv4 ?
TCP over IPv4 的最小数据包大小是多少?
Hi guys, i am quite stuck on this very question.
嗨,伙计们,我对这个问题很困惑。
Assume i wanna transmit a data of 12KB
假设我想传输 12KB 的数据
and through IPv4 TCP
并通过 IPv4 TCP
I did the following calculation
我做了以下计算
20 Bytes for TCP Headers
4 Bytes for Source Address
4 Bytes for Destination Address
4 Bytes on Zeros, Protocol and TCP Length
2 Bytes on Checksum
12 Bytes on Data
But i try check my friend result with mine, we get the different one..
但是我试着用我的朋友检查结果,我们得到了不同的结果..
I use the example on wikipedia on TCP, and i just assume
我在 TCP 上使用维基百科上的示例,我只是假设
TCP header is 20Bytes and the calculation above ( i use all the TCP Pseudo Header that is pink ) .
TCP 标头是 20 字节,上面的计算(我使用所有粉红色的 TCP 伪标头)。
What did i do wrong in my calculation. as 2 of my friends answer is 6 bytes more than me
我在计算中做错了什么。因为我的两个朋友回答比我多 6 个字节
My TCP header is 20 bytes IPV4 is 14 bytes Data is 12 Bytes
我的 TCP 标头是 20 字节 IPV4 是 14 字节数据是 12 字节
The only difference between us is my fren IPv4 is 20 bytes. which field did i do wrongly on my ipv4 calculation?
我们之间唯一的区别是我的 fren IPv4 是 20 字节。我在计算 ipv4 时做错了哪个领域?
Thanks
谢谢
回答by Coincoin
The minimum TCP header size is 20 bytes and the minimum IPv4 header size is 20 bytes. So a TCP/IPv4 packet containing 0 byte of data would be at the minimum 40 bytes assuming you can actually send 0 byte over TCP, which you can't. So, the minimum would be 41 bytes.
最小 TCP 报头大小为 20 字节,最小 IPv4 报头大小为 20 字节。因此,假设您实际上可以通过 TCP 发送 0 字节,则包含 0 字节数据的 TCP/IPv4 数据包将至少为 40 字节,而您不能。因此,最小值为 41 个字节。
回答by jeremy
A quick Google search yields this diagram of the TCP header.
在 Google 上快速搜索会得到这个TCP 标头图。
It looks like you're missing the following fields.
您似乎缺少以下字段。
- 2 Bytes congestion window
- 4 bytes sequence
- 2 Bytes Urgent Pointer
- 2字节拥塞窗口
- 4字节序列
- 2 字节紧急指针
Not sure which you are classifying as "Protocol", etc, but the main one missing looks like sequence number. Minimum should be 20 bytes for the TCP header.
不确定您将哪个归类为“协议”等,但缺少的主要内容看起来像序列号。TCP 标头的最小值应为 20 字节。