Reputation: 71
I encounter some problem when I develop a network card driver in Linux. As we all know the MTU refers to the MAX size of IP packet without fragment. And the skb sent to xmit function will be added 14bytes including dst mac addr,src mac addr and lengh. but it's very odd that when I use different values for MTU, the added size to it is different, sometime it's 10bytes, sometime it's 14bytes. It's depending the size of MTU. For example, I use 7828 as the size of UDP payload, when MTU is 7700, the size of skb in xmit function is 7714, while when MTU is 7800, the size of skb is 7810. Can anyone explain this? I guess maybe there are some align limitation for IP packets, but I didn't find that.
Upvotes: 1
Views: 589
Reputation: 71
I searched the answer from the internet, and I found that there is an align limitation for payload field of IP frame. The payload field must be align to 8 bytes. So if the MTU is 7700, the true size of IP frame should be 7680+20 = 7700 because 7680 can be divisible by 8. While if the MTU is 7800, the true size of IP frame should be 7776+20 = 7796 because 7780 can't be divisible by 8, the last 4 bytes will be assigned to next IP fragment.
Upvotes: 1