What fields in network packets should be converted to network byte order

I know that endianess on hosts and networks may be different, but why is the byte order important?

I think there are two reasons:

1 for the router to check the IP header (for example, addresses), routers only recognize the byte sequence number (byte order) 2 for the receiving host to determine the byte order of the packets. Since the receiving host does not know the byte order of the sending host, if the byte order is not converted to the network byte order, it does not know the byte order of the packets.

I'm right?

so for the following fields that need to be converted to byte order, and why?

1 TCP/UDP Header options, like MSS, timestamps 2 TCP/UDP header checksum 3 TCP sequence number 4 UDP/TCP data fields 
+4
source share
1 answer

Each field that is sent / stored as binary data (and not ASCII in particular), longer than one byte, must have a clearly defined byte order. Otherwise, as you indicated, the receiver does not know how to interpret what the sender sent.

The answer to your specific question: # 1, # 2 and # 3 should be in network order. As for the fields in the UDP / TCP payload (# 4), then you. A network byte order (large end) is suggested for consistency with almost all other protocols, but if you define a protocol, you can choose a small endian if you want. Some of them.

+3
source

All Articles