Ethernet and switching · Introduction · Module 1
Ethernet frames and MAC addresses
Show topologyHide topology
Interfaces and addresses · MAC addresses are written as IOS prints them.
- 10.0.1.0/24SW1 Et0/0R1 Et0/0 10.0.1.1 aabb.cc00.0200
- 10.0.1.0/24SW1 Et0/1H1 Et0/0 10.0.1.10 aabb.cc00.0300
- 10.0.1.0/24SW1 Et0/2H2 eth0 10.0.1.20 5254.0000.5320
- 10.0.2.0/24R1 Et0/1 10.0.2.1 aabb.cc00.0210H3 eth0 10.0.2.30 5254.0000.5330
Five device icons joined by four plain cables. At the top the host H1, MAC address aabb.cc00.0300: its Et0/0, address ending .10, is cabled down to the switch SW1’s Et0/1. To the right of SW1, the host H2, MAC address 5254.0000.5320: its eth0, address ending .20, is cabled to SW1’s Et0/2. Under SW1, the router R1: its Et0/0, address ending .1, is cabled up to SW1’s Et0/0. SW1’s three cables are one network, 10.0.1.0/24; SW1 has no address of its own, and its fourth port, Et0/3, has no cable. At the bottom the host H3, MAC address 5254.0000.5330: its eth0, address ending .30, is cabled up to R1’s Et0/1, address ending .1, in the network 10.0.2.0/24.
What Ethernet is
A frame and its addresses
The fields of an Ethernet frame
H2 sends R1 one small packet. On the cable it travels inside a frame, with two addresses that are not IP addresses. What are they?
They are MAC addresses, held in the frame’s header. A frame is how the data link layer carries a packet across one network, with the header in front and a trailer behind.
Ethernet is the standard most wired networks use for their cables and frames, this one included, and IP packets travel in Ethernet frames. A computer you plug in by cable most likely sends them too.
Each field’s size is counted in bytes (Figure 1.1). A byte is eight bits, the same as one octet of an IPv4 address.
Five boxes in two rows, read left to right and then down. First row, the header: the destination MAC address (6 bytes, highlighted), the source MAC address (6 bytes) and the type (2 bytes), with the value 0800. Second row: the payload, which carries the packet, 46 to 1500 bytes; then the FCS (4 bytes), marked as the trailer. A note at the bottom says that a fixed pattern, the preamble, is sent before the frame.
The destination MAC address names the interface, or the interfaces, the frame is for. A receiving interface reads it to decide whether the frame is for it.
The source MAC address names the interface that sent the frame.
How does R1 know what the frame carries? The EtherType, or type for short, comes right after the destination and source MAC addresses, and its two bytes, written as four digits, say what the payload is. 0800 stands for an IPv4 packet, and 0806 for ARP, the protocol that finds the MAC address for an IP address.
In the type’s place, the Ethernet standard also allows a field that gives the frame length, but IP seldom uses that form.
The payload carries the packet. It is 46 to 1500 bytes; a shorter packet is padded to 46.
How can a receiver tell that a frame was damaged? The sender works out a check value from the rest of the frame and sends it as the trailer, the FCS (frame check sequence), four bytes at the end. The receiver works it out again, and a value that does not match means damage.
Before each frame the sender sends a fixed bit pattern, the preamble, so the receiver can match its timing to the signal. It is not part of the frame, and show commands do not list it.
Reading a MAC address
A MAC address is 48 bits long. How is it written, and what do its parts say?
For easier reading, MAC addresses are written in hexadecimal, or hex, with sixteen digits, zero to nine and then a to f. One hex digit stands for four bits, so two digits make one byte. Twelve hex digits make six bytes, the whole address.
Take one address apart, 00-00-5E-00-53-20 (Figure 1.2). It comes from a block set aside for examples, so no device in this network has it. Its first three bytes are IANA’s number in a list kept by the IEEE, the body that gives these numbers to organizations. IANA is the Internet Assigned Numbers Authority.
When you read an address, its first three bytes usually name who numbered it. They are the OUI (Organizationally Unique Identifier), a number the IEEE gives to one organization, which numbers its own interfaces with the last three bytes. In the IEEE’s list, 00-00-0C is Cisco’s.
Six boxes in a row, one byte each: 00, 00, 5E, a gap, then 00, 53, 20. Under the first three a highlighted bracket reads “the OUI: IANA’s number”; under the last three, “the interface’s own number”. Under them, two rows: the IEEE writes the address 00-00-5E-00-53-20, and IOS prints it 0000.5e00.5320. At the bottom, two addresses of this network as IOS prints them: R1’s interface Et0/0 aabb.cc00.0200 and H2’s interface eth0 5254.0000.5320, with a note that these two addresses were set locally, so their first bytes are not an OUI.
IOS prints the same twelve digits in three groups of four, with dots and small letters, so the example reads 0000.5e00.5320.
An address can also be set locally, and then its first bytes are not an OUI. R1’s and H2’s addresses were set that way.
IOS shows the MAC address of an interface and, after the letters bia, its burned-in address, the address the interface starts with, before anyone changes it. On R1 the two are the same.
Key idea
A MAC address is six bytes, written in hex. Usually the first three bytes, the OUI, name the organization that numbered the address; an address set locally has no OUI.
One interface, every interface, or a group
A destination address can name one interface, every interface on the network, or a group of interfaces. How can you tell which?
Each interface in this network has a unicast MAC address, which names that one interface, such as H2’s 5254.0000.5320.
The broadcast MAC address, ffff.ffff.ffff, names every interface on the network. SW1 sends a frame for this address out of every other port that is up in the same network, and every interface that gets it takes it in. By default, a router does not pass a broadcast frame on to its other networks.
A multicast MAC address names a group, and only interfaces that listen for it take its frames in. Addresses for IPv4 groups start with 01-00-5E. An example address, 0100.5e90.1000, is in a multicast block set aside for examples, outside the range for IPv4 groups.
One bit in the first byte marks a group address, 0 in a unicast address and 1 in a group address. It is the lowest bit of that byte, so it makes the second hex digit odd or even. If the second digit is odd, the address names a group, multicast or broadcast. If it is even, the address names one interface.
| Kind | Address | Who takes the frame in |
|---|---|---|
| Unicast | Second digit even, such as 5254.0000.5320 | That one interface |
| Broadcast | ffff.ffff.ffff | Every host and router interface on the network |
| Multicast | Second digit odd, such as 0100.5e90.1000 | Interfaces that listen for that group |
H2 sends a unicast and a broadcast frame (Figure 1.3).
Two panels of the network. Panel (a): H1, SW1, H2 and R1. An arrow beside the cable from H2 points to SW1, with the highlighted note “to R1’s MAC” above it, and an arrow beside the cable from SW1 points down to R1. Panel (b): the whole network with H3 under R1. Arrows go from H2 to SW1, with the note “to ffff.ffff.ffff” above it, and from SW1 up to H1 and down to R1. Beside the cable from R1 to H3 a cross and the highlighted note “not passed on”.
A frame stays in one network; the packet goes end to end
H1 sends a packet to H3, in another network. How many frames carry it?
Two, because a frame travels within one network. SW1 passes a frame from H1 on to R1 unchanged. Then R1 removes the frame header and puts on a new one for the next network (Figure 1.4).
The network with H2 dimmed. Arrows beside the cables go from H1 down to SW1 and on to R1, marked “first frame: H1 → R1 Et0/0”, and from R1 down to H3, marked “second frame: R1 Et0/1 → H3”. Under the drawing a highlighted chip reads “packet inside both frames”, with 10.0.1.10 → 10.0.2.30 under it.
The first frame goes from H1, aabb.cc00.0300, to R1’s Et0/0 (Ethernet0/0), aabb.cc00.0200. The second frame goes from R1’s Et0/1, aabb.cc00.0210, to H3, 5254.0000.5330. Both frames carry H1’s packet. Its addresses are 10.0.1.10 and 10.0.2.30 on both links.
| What | Frame | Packet |
|---|---|---|
| Layer | Data link layer | Network layer |
| Its addresses | MAC: interfaces in one network | IP: the two hosts at the ends |
| How far it goes | Across one network | End to end |
| At a router | Replaced by a new frame | Same IP addresses |
Key idea
A frame stays in one network: at every router the MAC addresses change. The packet inside keeps its IP addresses from end to end.
How it works
R1 takes in two frames
Two frames from H2 reach R1’s Ethernet0/0, a question asking for R1’s MAC address, then a test packet. What does R1 do with each?
R1 checks three things in each, as any host or router interface does: whether the frame is undamaged, whether it is for this interface, and which type it is.
R1 takes a frame in only if the destination is its own MAC address, the broadcast address, or a group it listens to. Each of its interfaces drops any other frame.
How can you see what R1 did? A debug makes a device print lines about what it does. While H2 sent its packet, R1 had two debugs on, debug arp and debug ip packet. show logging | include ARP|IP: lists only the lines that hold IP: or ARP.
Step 1 of 6
H2 does not know R1’s MAC address yet, so its first frame goes to everyone, ffff.ffff.ffff. The type, 0806, says the payload is an ARP message, a question that asks which MAC address belongs to 10.0.1.1, R1’s IP address.
Step 2 of 6
R1 checks the FCS, and the frame is undamaged. The destination is the broadcast address, so R1 takes the frame in.
Step 3 of 6
The type is 0806, so R1 hands the payload to its ARP part. ARP answers H2 with R1’s MAC address, aabb.cc00.0200.
Step 4 of 6
Now H2 knows R1’s MAC address and writes it as the destination. The second frame carries the test packet, type 0800, and goes to R1.
This frame’s destination is R1’s own MAC address, and its FCS is correct. What does R1 do with it?
- It takes the frame in and hands the payload to IPv4. (Correct): The frame is undamaged and addressed to R1’s own MAC address, so R1 takes it in. The type then decides which part of R1 reads the payload.
- It passes the frame on to H3 on its other network.: As a router, R1 does not pass frames from one network to another. A frame for its own MAC address is for R1 itself.
- It drops the frame: only broadcasts are taken in.: R1 takes in frames for its own MAC address too. That is the usual case; a broadcast is the exception.
Step 5 of 6
The frame is for R1, so R1 takes it in. The type is 0800, so R1 hands the payload to IPv4, which reads a packet from 10.0.1.20 to 10.0.1.1, R1’s own IP address.
Step 6 of 6
Two frames, the same three checks. R1 drops a frame that fails the FCS check or the destination check.
H1 at the top, SW1 under it with H2 to its right, and R1 under SW1, joined by plain cables. Under the drawing, a strip of five fields of the current frame: destination, source, type, payload and FCS. Step 1: arrows beside the cables go from H2 to SW1 and on to both R1 and H1; the strip reads destination ffff.ffff.ffff, source 5254.0000.5320, type 0806, payload an ARP question. Step 2: a note beside R1 reads “FCS ok · broadcast: take in”. Step 3: “type 0806: to ARP”. Step 4: arrows go from H2 to SW1 and on to R1 only; the strip reads destination aabb.cc00.0200, type 0800, payload an IPv4 packet. Step 5: “type 0800: to IPv4”. Step 6: “FCS · destination · type”.
Answer here to see step 5, or tap “Skip, show me”.
On R1, three of the lines its debugs printed while H2 sent its packet:
Lines appear as you step through.
R1#show logging | include ARP|IP:3IP ARP: rcvd req src 10.0.1.20 5254.0000.5320, dst 10.0.1.1 Ethernet0/0 tableid 0… 1 more line (see Full output)3IP ARP: sent rep src 10.0.1.1 aabb.cc00.0200,… 1 more line (see Full output)5IP: s=10.0.1.20 (Ethernet0/0), d=10.0.1.1 (nil), len 84, rcvd 2… 5 more lines (see Full output)
Full output · 10 lines
R1#show logging | include ARP|IP:IP ARP: rcvd req src 10.0.1.20 5254.0000.5320, dst 10.0.1.1 Ethernet0/0 tableid 0IP ARP: creating entry for IP address: 10.0.1.20, hw: 5254.0000.5320 tableid 0IP ARP: sent rep src 10.0.1.1 aabb.cc00.0200,IP: s=10.0.1.20 (Ethernet0/0), d=10.0.1.1 (nil), len 84, input feature, MCI Check(110), rtype 0, forus FALSE, sendself FALSE, mtu 0, fwdchk FALSEIP: s=10.0.1.20 (Ethernet0/0), d=10.0.1.1 (nil), len 84, rcvd 2IP: s=10.0.1.20 (Ethernet0/0), d=10.0.1.1 (nil), len 84, stop process pak for forus packetIP: tableid=0, s=10.0.1.20 (Ethernet0/0), d=10.0.1.1 (Ethernet0/0) nexthop=10.0.1.1, routed via RIBIP: tableid=0, s=10.0.1.1 (local), d=10.0.1.20 (Ethernet0/0) nexthop=10.0.1.20, routed via FIBIP: s=10.0.1.1 (local), d=10.0.1.20 (Ethernet0/0), len 84, sendingIP: s=10.0.1.1 (local), d=10.0.1.20 (Ethernet0/0), len 84, sending full packet
Impact debug ip packet uses a lot of system resources. Keep debugs on for a few seconds only, then turn them off again.
rcvd req is R1’s ARP part taking in H2’s question, and sent rep is its answer. The line that starts IP: s=10.0.1.20 and ends in rcvd 2 is IPv4 taking in the packet from 10.0.1.20 to 10.0.1.1, on Ethernet0/0.
Did R1 really take H2’s broadcast in? Its Ethernet0/0 counts the broadcasts it takes in.
On R1, just before H2 sends:
R1#show interfaces Ethernet0/0 | include broadcasts1 Received 26 broadcasts (0 IP multicasts) Output 6 broadcasts (0 IP multicasts)
- Received 26 broadcasts: before H2 sends.
On R1, just after:
One more broadcast taken in, 27 now, from H2’s ARP question.
R1#show interfaces Ethernet0/0 | include broadcasts1 Received 27 broadcasts (0 IP multicasts) Output 6 broadcasts (0 IP multicasts)
- Received 27 broadcasts.
If the FCS check fails, the frame was damaged on the way. R1 counts it under CRC (cyclic redundancy check) in show interfaces and drops it.
On R1, after H2’s two frames:
R1 has counted no damaged frame on Ethernet0/0.
R1#show interfaces Ethernet0/0 | include CRC1 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
- 0 CRC: the count of frames whose FCS did not match.
Key idea
R1 takes a frame in only if it is undamaged and addressed to R1’s own MAC address, to everyone, or to a group R1 listens to. The type then says which part of R1 reads the payload.
Use the steps of Figure 1.5. Step 1, the frame arriving, is done for you; choose step 2 and step 3.
Verify
R1’s MAC addresses
Where does R1 show its MAC addresses?
R1 has four Ethernet interfaces, two with cables here (Figure 1.6).
R1’s router icon with four rows beside it, one per interface: Et0/0 aabb.cc00.0200, Et0/1 aabb.cc00.0210, and two other interfaces, aabb.cc00.0220 and aabb.cc00.0230. A note says that these two have no cable here. Under the rows, highlighted: “4 interfaces · 4 MAC addresses”.
show interfaces | include bia prints only the lines of show interfaces that hold the letters bia, one for each interface with a MAC address.
On R1:
Four interfaces, four MAC addresses. On each line the address in use and the burned-in address are the same.
R1#show interfaces | include bia1 Hardware is AmdP2, address is aabb.cc00.0200 (bia aabb.cc00.0200) Hardware is AmdP2, address is aabb.cc00.0210 (bia aabb.cc00.0210) Hardware is AmdP2, address is aabb.cc00.0220 (bia aabb.cc00.0220) Hardware is AmdP2, address is aabb.cc00.0230 (bia aabb.cc00.0230)
- Et0/0, toward SW1: aabb.cc00.0200.
show interfaces Ethernet0/0 prints one interface in full, so you look for the MAC address among many lines.
On R1, its interface toward SW1:
Tap a line, or “Not in the output”, then submit.
Find the line that gives the MAC address R1 writes as the source of its frames on this link.
R1#show interfaces Ethernet0/0… 1 more line (see Full output)… 12 more lines (see Full output)… 8 more lines (see Full output)
Et0/0’s MAC address is aabb.cc00.0200, the same as its burned-in address.
- The address in use and, after bia, the burned-in address: the same, aabb.cc00.0200.
- MTU 1500 bytes: the largest payload R1 puts in one frame.
- ARPA is IOS’s name for the standard encapsulation of an Ethernet interface, the frame with a type field.
- 0 CRC: no damaged frame so far.
Full output · 27 lines
R1#show interfaces Ethernet0/0Ethernet0/0 is up, line protocol is up Hardware is AmdP2, address is aabb.cc00.0200 (bia aabb.cc00.0200) Internet address is 10.0.1.1/24 MTU 1500 bytes, BW 10000 Kbit/sec, DLY 1000 usec, reliability 255/255, txload 1/255, rxload 1/255 Encapsulation ARPA, loopback not set Keepalive not set ARP type: ARPA, ARP Timeout 04:00:00 Last input 00:05:57, output 00:05:52, output hang never Last clearing of "show interface" counters never Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0 Queueing strategy: fifo Output queue: 0/40 (size/max) 5 minute input rate 0 bits/sec, 0 packets/sec 5 minute output rate 0 bits/sec, 0 packets/sec 58 packets input, 7632 bytes, 0 no buffer Received 35 broadcasts (0 IP multicasts) 0 runts, 0 giants, 0 throttles 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored 0 input packets with dribble condition detected 34 packets output, 3304 bytes, 0 underruns Output 6 broadcasts (0 IP multicasts) 0 output errors, 0 collisions, 2 interface resets 0 unknown protocol drops 0 babbles, 0 late collision, 0 deferred 0 lost carrier, 0 no carrier 0 output buffer failures, 0 output buffers swapped out
Key idea
show interfaces gives each interface’s MAC address on its Hardware line, one address per interface.
Check
On R1, its interface toward H3:
Tap a line, or “Not in the output”, then submit.
Find the line that gives the MAC address R1 writes as the source of its frames to H3.
R1#show interfaces Ethernet0/1… 1 more line (see Full output)… 21 more lines (see Full output)
Full output · 27 lines
R1#show interfaces Ethernet0/1Ethernet0/1 is up, line protocol is up Hardware is AmdP2, address is aabb.cc00.0210 (bia aabb.cc00.0210) Internet address is 10.0.2.1/24 MTU 1500 bytes, BW 10000 Kbit/sec, DLY 1000 usec, reliability 255/255, txload 1/255, rxload 1/255 Encapsulation ARPA, loopback not set Keepalive not set ARP type: ARPA, ARP Timeout 04:00:00 Last input 00:13:23, output 00:13:19, output hang never Last clearing of "show interface" counters never Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0 Queueing strategy: fifo Output queue: 0/40 (size/max) 5 minute input rate 0 bits/sec, 0 packets/sec 5 minute output rate 0 bits/sec, 0 packets/sec 25 packets input, 4730 bytes, 0 no buffer Received 18 broadcasts (0 IP multicasts) 0 runts, 0 giants, 0 throttles 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored 0 input packets with dribble condition detected 13 packets output, 1050 bytes, 0 underruns Output 7 broadcasts (0 IP multicasts) 0 output errors, 0 collisions, 2 interface resets 0 unknown protocol drops 0 babbles, 0 late collision, 0 deferred 0 lost carrier, 0 no carrier 0 output buffer failures, 0 output buffers swapped out
Summary
H1, SW1, H2 and R1 with arrows from H2 through SW1 to R1. Beside R1 the note “FCS · destination · type”. The strip under the drawing reads destination aabb.cc00.0200, source 5254.0000.5320, type 0800, payload an IPv4 packet, FCS ok.
- An Ethernet frame carries a destination and a source MAC address and a type in front of the packet, and the FCS behind it.
- A MAC address is six bytes in hex; usually the first three, the OUI, name the organization that numbered it.
- A unicast address names one interface, the broadcast address every interface on the network, a multicast address a group.
- A frame stays in one network; at a router the packet gets a new frame and keeps its IP addresses.
- A host or router interface takes a frame in only if it is undamaged and addressed to it, to everyone or to a group it listens to, and hands the payload on by its type.
show interfacesshows each interface’s MAC address on its Hardware line.