3 ms·
It it also weird that "network byte order" is considered as BE. Is there any advantage of BE when it is transferred over the network?
by kbumsik 7y ago
It it also weird that "network byte order" is considered as BE. Is there any advantage of BE when it is transferred over the network?
- garmaine 7y agoNo. In this context it simply means "network-standard." And the standard has always been big endian for network applications. Not because of any advantage, but simply because that was the standard.
- rhn_mk1 7y agoIf I remember correctly, BE helps in switching networks for routing packets. A packet would start with the big-endian destination address. If that address was hierarchical, i.e. most significant bytes signify the network (interface) it was in (like IP), then only a few of the first bits need to be processed in order to find which interface to direct the packet to. The transmission out therefore begins just after the few first bits are received. E.g. for a switch connected to networks A: 0xa, B: 0x1, C: 0x3, a only the first byte 0x1 of the packet destined to 0x1234 needs to be processed before forwarding, saving some time compared to LE, where the entire address 0x4321 would have to be processed to find out that it's at the 0x1 network.
- baybal2 7y agoRegisters on anything today will be way wider than few bytes, moreover on network hardware. The gate savings on doing endiannes specific circuits are close to zero in comparison to many many other things a typical logic block comes with today.
- bestouff 7y agoIt's not intended to save gates but time. Bits are (were) serially encoded on the wire, so you could start switching sooner, before even having received the whole header.
- baybal2 7y agoI understand the rationale, but all that hardware today will probably get more bits on input in a single clock cycle than at the time this was a concern. Today, you have to process way way more bytes in a single clock cycle anyways. Internally, for a chip designer, almost all modern high speed serial busses look way wider than a single byte. And all of its serialness is kept inside the transmitter/serdes/interface blocks without any external exposure.
- jleahy 7y agoIt makes no difference when you look at the hardware, but an interesting side-note is that Ethernet is natively little bit-endian. That is, if you're sending a byte of data the least significant bit is sent first (think of the pulses of laser light going down a cable). In fact this is true for pretty much all physical layer protocols, as it makes computing the CRC vastly easier. So if you use big-endian byte orders you're actually sending your bits all jumbled up (bits from the most significant byte first, then the least significant bit from within each byte first).