Magic numbers are better than nothing, but "next protocol" fields accomplish the same thing without magic. Usually the steward of each protocol maintains a registry of protocol IDs. For example, IEEE maintains a list of Ethernet protocols: http://standards-oui.ieee.org/ethertype/eth.txt and IANA tracks IP protocols: https://www.iana.org/assignments/protocol-numbers/protocol-n... and TCP/UDP port numbers: https://www.iana.org/assignments/service-names-port-numbers/... and MIME types are used for HTTP and email: https://www.iana.org/assignments/media-types/media-types.xht...
In classic Mac OS and BeOS, file inodes carried file types so you didn't have to guess about file types either.
Re:How not to design a wire protocol
by AnimalMuppet on Tuesday March 05, 2019 @04:56PM
(#19314632)
IIRC, it was magic numbers and offsets. And you could run the charmingly-named magic program on a file to find out if the system knew what it was...
If you want something like that, using an IEEE OUI/CID would be a good start.
https://standards.ieee.org/content/dam/ieee-standards/standa...
Re:How not to design a wire protocol
by richardwhiuk on Wednesday March 06, 2019 @11:48AM
(#19320297)
https://github.com/file/file/tree/master/magic/Magdir exists for file types.
I wonder if there's merit to recreating such a thing under ICANN, where the issued serial numbers are useful for file types, wire protocols, etc.
Then anyone needing to reliably interpret a packet could (1) look for the format serial number at some well-known location, and then (2) consult the well-publicized registry for whatever information has been provided regarding the format.