@portfast

News & views, serious business.

Monday 17 September 2018 - Ethernet

This post has grown out of an off the cuff tweet I did that got a few more likes than my usual whitterings, so I shall expand upon it here.

Whether you"re on the internet at home, sat in a public space or in a top data centre, one thing common to all these locations is Ethernet.

Back in the day, there were a number of technologies used for interconnection like SDH, ATM and so forth, these were expensive and the preserve of the telcos that wanted to act as gatekeepers to the internet, however over time we realised that ethernet was suitable for long links as well as connecting your PC to a hub under the desk.

The protocol grew up from experimental implementations in the late 70s into equipment that would still link with modern day switches in the 80s, initially at 10Mbps, the standard has grown up to to 100 gigabits and beyond.

It's not just used in homes, offices, data centres, telecoms, for controlling traffic lights, relaying phone calls, you'll even find it in your car.

This post explores the protocol at the most basic level, that of electrical signals on a cable. We're only looking at 10Mbit on twisted pair cable (IEEE 802.3i) here as 100Mbit is a much more complex affair which uses multiple levels to signal more than one bit per baud and gigabit and above take this even further and really aren't easy to make sense of with just an oscilloscope, however the format of the ethernet frame is still the same however quick the bearer that transports it.

First, the link pulse. This occurs every 17ms on our sample equipment, according to the RFC it can be spaced anything from 8 to 24ms on an idle line. This maintains the link state as at 10Mbps an idle line would otherwise have no signal.

[Figure 1: An oscilloscope trace of a link pulse on an idle 10Mbps line.]

The next trace shows the start of an Ethernet frame. Every frame begins with a Preamble (a repeating pattern that clocks the receiver's synchronisation), followed by a 6-byte Destination MAC address and then a 6-byte Source MAC address. In this example the destination address is all ones (hex ffffffff), the Ethernet broadcast address meaning every host on the segment will accept the frame; the source address is a normal unicast address and so its bit pattern looks quite different on the scope. The Ethertype field that follows tells the receiver what protocol the payload carries.

[Figure 2: The Ethernet frame structure, showing the Preamble, Destination MAC (DST), and Source MAC (SRC) fields.]

The Ethertype field is 2 bytes long and tells the receiver what protocol sits inside the frame. The next two traces show each byte at the bit level, encoded using Manchester coding. If you look at the waveforms you will see a transition in the middle of every bit period. A "0" bit goes low then high in the middle of the period, a "1" bit goes high then low. This guarantees a transition in every bit period so the receiver can recover the clock from the signal itself. The oscilloscope has done the decoding for us and displayed the resulting bit values below each trace. Ethernet sends bits least-significant-bit first so the bits read left-to-right on the scope need to be read in reverse to give the normal MSB-first byte value. The first byte reads 00010000 on the scope which is 0x08 reversed, the second reads 01100000 which is 0x06 reversed, giving an ethertype of 0x0806 which identifies an ARP packet.

[Figure 3: The first byte of the Ethertype field in Manchester encoding, with the oscilloscope-decoded bit pattern displayed below.]

[Figure 4: The second byte of the Ethertype field in Manchester encoding, with the oscilloscope-decoded bit pattern displayed below.]

So there you have it, a complete Ethernet frame built up from nothing more than electrical pulses on a cable. The same frame format that started in the 70s is still running between your PC and the server you are reading this on, only the bearer has got a lot faster and a lot more complicated in the intervening decades.


All prices are exclusive of VAT.
Portfast Ltd :: Registered in England #6061075, 331 Millhouses Lane, Sheffield, S11 9HY