UPI Study › Courses › Introduction to Operating Systems › Free lessons › Lesson 7.3 Free with a free account
The Data Link Layer
Introduction to Operating Systems · Chapter 7: Computer Networks: Architecture, Layers, and ProtocolsSection 7.3 · lesson 58 of 838 min · free with a free account
Free preview
Create a free account to keep watching
It takes a minute and costs nothing. Your free account unlocks all of Chapter 1 and 3 more lessons of Introduction to Operating Systems.
Lesson complete
Earn the 3 college credits for Introduction to Operating Systems
Enrolling adds a quiz after each lesson, the graded work and the official transcript. Recommended for credit by NCCRS.
Next lesson: The Network Layer and IP →← The Seven-Layer OSI ModelNext lesson: The Network Layer and IP →
A free account plays all of Chapter 1 and 3 more lessons of Introduction to Operating Systems. Create a free account →
In this lesson
How frames, MAC addresses, switches and CRCs move data one hop.
- Describe the parts of an Ethernet frame and the role of MAC addresses
- Explain how a switch learns MAC addresses and forwards frames
- Compute even parity and a simple checksum, and explain where each fails
- Explain why a CRC catches errors that parity and checksums miss, and how correction differs from detection
Free study notes
Get this lesson's notes by email
The key points and 4 practice questions with answers, in your inbox. One email, free.
One email. Unsubscribe in one click.
Transcript
Everything said in the video, section by section (1,173 words). Read along, or search it.
Opening Puzzle
A Print Job Finds Its Printer
Sam, who runs a small online bakery, sends a print job from the laptop to the shop printer. A second later, a sheet slides out. But the shop network also holds a phone, a tablet, and the till. How does the job reach the printer, and nobody else? And what if electrical noise flips a 0 into a 1 on the way? The data link layer solves both problems, one hop at a time.
Scope
One Link at a Time
The data link layer, layer 2, moves data across one single link: from a laptop to a switch, or from one router to the next. It doesn't care where the data finally ends up. That's the network layer's job, in lesson 7.4. Think of a relay race. Each runner carries the baton only as far as the next runner.
Frame Structure
Header, Payload and Trailer
To do this, the layer packs the data into frames. A frame is a header, a payload, and a trailer. The header says who the frame is for, and who it's from: the destination and source hardware addresses, six bytes each. Then a two-byte type field. The payload is the packet from layer 3: on Ethernet, from forty-six to fifteen hundred bytes. And the trailer carries a four-byte check value, so the receiver can tell whether the frame arrived intact.
MAC Addresses
Hardware Names Versus IP Locations
Those hardware addresses are MAC addresses, short for Media Access Control. Most network cards get one at the factory. A MAC address is 48 bits, written as six bytes in hexadecimal, like this one, which the standards set aside for examples. The first three bytes name the maker of the card. The last three pick out the individual card. Software can change it, though, and many phones and laptops now give each Wi-Fi network a random, private one. Now compare an IP address, coming in lesson 7.4. The MAC names the card. The IP address says where the computer sits right now. Think of a person's name, versus their current mailing address.
How Switches Work
Learning Which Port Leads Where
Early shared networks sent every frame to every computer, and each card quietly ignored the frames meant for others. A switch does better. It has many ports, one for each device, and it keeps a table. It watches the source address of every frame that arrives, so it learns which MAC address sits behind which port. When a frame comes in, it reads the destination MAC, and sends the frame out of that one port only. If the destination isn't in its table yet, it sends the frame out of all the other ports, once. When that device sends something back, the switch learns where it sits. A switch reads only the frame header, so it's called a layer 2 device.
Quick Check
A Reply After a Switch Restart
Quick check. The shop's switch has just restarted, so its table is empty. A, on port 1, sends a frame to C, on port 3. Then C replies to A. Which ports does that reply go out of: ports 1, 2 and 4; only port 1; or all four ports? Pause, and decide. Only port 1. When A's frame came in on port 1, the switch read its source address, and learned that A sits behind port 1. So the reply has a known destination, and goes out of that port alone. Ports 1, 2 and 4 would be right only if the switch had never learned A.
Error Detection
Even Parity Catches One Flipped Bit
Now the second problem. Wires pick up noise, and radio is noisier still. Now and then, a bit flips. So the data link layer adds error detection: extra bits computed from the data, which the receiver computes again and compares. The simplest is a parity bit. With even parity, the sender adds one bit so the total number of 1s is even. The letter C is 1000011: three 1s. So the parity bit is 1, making four. If one bit flips on the way, the count turns odd, and the receiver knows something's wrong. But if two bits flip, the count is even again, and parity is fooled.
Stronger Checks
From Checksums to CRCs
A checksum is a bit smarter. Add up all the bytes, and keep the remainder after dividing by 256. The bytes of CAKE add up to 276, which leaves 20. Change one letter, to CAKF, and the sum becomes 21. The damage is caught. But changes can cancel out. In CBKD, one letter went up by one, and another went down by one. The sum is still 20, and the damage is missed. Real frames use a stronger check: a CRC, a cyclic redundancy check. It treats the data as one huge number, and divides it by a fixed value. The remainder depends on every bit, and on their order. Ethernet puts a 32-bit CRC in its 4-byte trailer. Worked out with Python's zlib on this Mac, all three words give completely different CRCs.
Quick Check
Catching Two Swapped Letters
Quick check. A frame carries the word BREAD. On the way, two letters swap places, and BRAED arrives. Which check notices: parity on each byte, the add-up checksum, or the CRC in the trailer? Pause, and decide. The CRC. A swap keeps every byte, so each byte's parity is unchanged, and so is the sum. Only the order differs. And the CRC depends on the order of the bits. BREAD and BRAED give completely different values, so the frame is thrown away.
Error Correction
Resending or Repairing Damaged Data
Detecting damage is half the story. A receiver that sees a bad CRC usually throws the frame away. A higher layer, transport, then gets the data sent again. Where resending is slow, like talking to a space probe, the sender adds enough extra bits to correct errors on the spot. The simplest correcting code sends each bit three times, and the receiver takes a vote. The message 1011 goes out as twelve bits. Noise flips one bit, so one group of three arrives as 010. The vote in that group still says 0, and the message is repaired. But that's twelve bits for four. Cleverer codes, like the well-known Hamming code, repair a single flipped bit with far fewer extra bits. And none of these checks stop someone who changes data on purpose. That takes cryptography, in lessons 7.5 and 8.7.
Real Example
A Noisy Link Near the Microwave
Back to Sam's shop. Later, the old Wi-Fi stick kept dropping the printer. So Sam called Ivy, who looks after the computers at a school. She checked the interface counters, and saw many frames discarded for bad checks. The link was noisy: every damaged frame failed its CRC. She moved the stick, on a USB extension cable, away from the microwave oven, and the discards stopped. So, both questions answered. MAC addresses and the switch steer each frame to the printer alone, and the CRC catches the noise.
Key Takeaways
Frames, Switches and Error Checks
To recap. The data link layer moves frames across one link at a time. A frame has a header with two MAC addresses, the packet, and a CRC trailer. A switch learns which MAC sits behind each port, and sends each frame out of one port. Parity and checksums catch some damage. A CRC catches far more, and a bad frame is dropped and sent again.
About Introduction to Operating Systems at UPI Study
Introduction to Operating Systems (Computer Science 354) is a self-paced online course of 83 video lessons in 10 chapters, from what an operating system does and process scheduling to concurrency, memory, devices, file systems, networks, the internet, security and virtual machines. It carries a NCCRS credit recommendation for 3 semester credits.
Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Enroll now → Course details Download the syllabus All Computer Science courses Every course with PRO →
Compare: Linux vs Operating Systems
Why take it here
Why students take Introduction to Operating Systems with UPI Study
Where the credit goes
Universities that work with NCCRS
Introduction to Operating Systems carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.
FAQ
Questions students ask us
About The Data Link Layer
What is a MAC address?
How does a network switch know where to send a frame?
What is the difference between parity, a checksum and a CRC?
How does error correction differ from error detection?
About the Introduction to Operating Systems course
How many college credits is Introduction to Operating Systems?
How much does Introduction to Operating Systems cost and what is included?
Which universities accept UPI Study credits?
How long does Introduction to Operating Systems take?
How are the exams done?
How do my credits reach my college?
Ready for the full course? Earn 3 credits in Introduction to Operating Systems.
83 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.
Updated
3 credits · NCCRSEnroll →