Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!coral.com!greene From: greene@coral.com (Jeremy Greene) Newsgroups: comp.protocols.tcp-ip Subject: Byte and bit order within packet headers Message-ID: <9104252242.AA28673@taipan.coral.com> Date: 25 Apr 91 22:42:44 GMT References: <9104241753.AA21589@dino.alias.com> Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 48 ) This is a small problem for little endian machines (most significant byte is ) on the right). They must correct their byte order before the packet is ) transmitted. In BSD systems, this job is performed by the htonl() and htons() ) functions (host to network long, host to network short), but what about the ) bit order? It is still little-endian (bits are numbered right to left instead ) of left to right)! What order is are the bits transmitted in? ) Byte order is a host to host issue. One host has a different view of byte order than the other. Fortunately, there is an agreed upon inter-host (network) format which is big-endian. Bit order is not a host problem; it is only network related, and more specifically, MAC layer related. In otherwords, you always have the same hardware at both ends of the connection and from the host perspective the bit order is treated the same. If you send 0x01 on fddi you will receive 0x01 on some other fddi interface. Same for Ethernet. Unlike the byte order issue, you never send from fddi to Ethernet, which would make a big mess. The fact that bits are sent in a different order do not present a problem in getting data from one host to another. The problem is that the actual network hardware interprets the mac address. Given that: - the address on both rings and Ethernets are the same: group bit first and, - rings transmit the left most bit from a byte first, Ethernet transmits the right most bit the same address has to be placed in memory in a different bit order depending on the media type. So, if the address starts 0x01 in Ehternet land (which is a group address) then it must start 0x80 for a fddi interface. From the network perspective it's the same address. In other words, similar to the byte order problem, you want to have the macros 'ntomac' and 'macton'. To do this, there has to be a canonical foramt, which IEEE has (recently) stated is the Ethernet format. The bottom line is that you only have to worry about bit order if you're wokring at the MAC layer. Jeremy