UPI Study › Courses › Introduction to Operating Systems › Free lessons › Lesson 8.3 Free with a free account
Internet Packets
Introduction to Operating Systems · Chapter 8: The Internet, Connectivity, and Network OperationsSection 8.3 · lesson 64 of 8310 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: Network Protocols →← The History of the InternetNext lesson: Network Protocols →
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 IPv4 packets carry headers, count hops, and split into fragments.
- Describe the two parts of a packet and which part routers read
- Explain the IPv4 header fields for TTL, protocol, and checksum
- Calculate fragment sizes and offsets for a given MTU
- Explain why modern systems avoid fragmentation
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,401 words). Read along, or search it.
Opening Story
A Photo Split Into Chunks
Sam, who runs a small online bakery, sends a photo of a new cake to a customer. The photo is far too big to travel in one piece. So the network chops it up, and puts a small address label on each chunk. The chunks travel on separate trips. Some may even take different roads. At the other end, they're glued back together. This lesson opens one of those chunks, and reads what's on the label.
Analogy
Header and Payload Like an Envelope
Think about posting a letter. The letter inside is what you care about. The envelope carries the address and the stamp, which is what the postal workers care about. Data crosses the internet the same way, in small units called packets. Each packet has two parts. The header is the label, with the delivery information. The payload is the real data being carried. Routers on the way read the header to decide where to send it. Only the receiving computer cares about the payload.
Why Packets
Small Packets Share the Wires
Why not send the photo whole? If one giant message fails halfway, everything has to start again. And a giant message on a busy router blocks everyone behind it. Small packets let many conversations share the same wires, and only a damaged packet is sent again. Packets of one message may even take different routes, and arrive out of order. The receiver sorts them, using numbers carried in the headers.
IPv4 Header
Five Rows of 32 Bits
At the network layer, from lesson 7.4, the header is defined by the Internet Protocol, IP. The common version today is IPv4. Its header is 20 bytes long when it carries no options. The standard draws it in rows of 32 bits, so each row is four bytes wide. Row one starts with the version and the header length. Then comes the total length: header plus payload, in bytes. Row two holds three fields for fragments, which you'll meet in a few minutes. Row three: the time to live, the protocol, and a checksum. Rows four and five hold the source and destination addresses, four bytes each.
Key Fields
Version, TTL, Protocol, and Addresses
Here's what the key fields do. Version is 4, for IPv4. IPv6 uses a different header. Time to live, or TTL, is a countdown. Every router lowers it by one. When it reaches zero, the packet is discarded, so lost packets can't circle forever. Protocol says which transport protocol owns the payload: 6 means TCP, and 17 means UDP, from lesson 7.6. The header checksum is a small number that lets a receiver notice damage to the header. And the two addresses say who sent the packet, and who should get it.
Worked Example
Reading Twenty Header Bytes in Hex
A short Python program builds a real header, for a 100-byte TCP payload going from Sam's laptop to the shop server. Here are its 20 bytes in hexadecimal, four to a row, just like the drawing. The first byte, 45, packs two fields. The 4 is the version, and the 5 is the header length, in four-byte words. Five words make twenty bytes. Then 00 78 is the total length. Hexadecimal 78 is 120: twenty bytes of header, plus a hundred of payload. In row three, 40 is the TTL, 64 in decimal. And 06 is the protocol: TCP. The last eight bytes are the addresses: 192.168.10.25 for Sam's laptop, and 192.0.2.7 for the shop server.
Error Detection
How the Header Checksum Catches Damage
The checksum works like this. Add up all the header's 16-bit words, fold any overflow back in, and flip every bit. The sender stores the result: e d b 6, here. A receiver repeats the sum with the checksum included, and a perfect header gives zero. Now suppose a router lowers the TTL to 63, but forgets to fix the checksum. The receiver's check gives 256, not zero, so the damage is noticed. That's why a router recomputes the checksum every time it lowers the TTL. One clever use of TTL: the traceroute tool sends packets with a TTL of one, then two, then three. Each router that discards one reports back, which reveals the route, hop by hop.
Quick Check
A TTL of 3 Meets Five Routers
Quick check. A packet leaves Sam's laptop with a TTL of 3. The shop server is five routers away. What happens to the packet? Pause, and decide. Router 3 throws it away. The first router lowers the TTL from 3 to 2, the second to 1, and the third to 0. At zero, the packet is discarded, two routers short of the server. Nothing ever arrives with a TTL of zero. And no router hands out a fresh TTL. Only the sender sets it.
Link Limits
The 1,500-Byte Ethernet MTU
Every link also limits how big one packet may be. That limit is the maximum transmission unit, or MTU. On Ethernet, from lesson 7.3, the usual MTU is 1,500 bytes, and it counts the header and the payload together. So with a 20-byte header, one packet carries at most 1,480 bytes of data. What if a router has to send a bigger packet onto a link with a smaller MTU? In IPv4, it can fragment the packet. It cuts the payload into pieces, and gives each piece its own copy of the header. The receiving computer puts them back together.
Fragment Fields
Identification, Offset, and More Fragments
Three fields from row two make that possible. Identification: the same number on every fragment of one original packet, so the receiver knows which pieces belong together. Fragment offset: where this piece starts in the original payload, counted in units of eight bytes. And the More Fragments flag. One means more pieces follow, and zero marks the last one. Why units of eight? The offset field has only 13 bits. Counted in single bytes, it could only reach 8,191. Counted in eight-byte units, it reaches the end of even the largest packet, 65,535 bytes. The price: every fragment except the last must hold a multiple of 8 data bytes. 1,480 already is one, so on Ethernet it works out neatly.
Worked Example
Splitting a 4,000-Byte Payload
Now a worked example. Sam's laptop sends a 4,000-byte payload, over a link with a 1,500-byte MTU and 20-byte headers. Fragment one carries 1,480 data bytes, at offset zero, with More Fragments set to one. Fragment two carries another 1,480. It starts at byte 1,480, and 1,480 divided by eight is 185. So its offset is 185. Fragment three carries the 1,040 bytes left over, at offset 370, with More Fragments zero: the last piece. The payload was 4,000 bytes, but 4,060 crossed the wire. Each added piece costs one more header. And if even one fragment is lost, the receiver can't rebuild the packet. It waits a while, then throws the other pieces away.
Quick Check
Fragmenting onto a 576-Byte Link
Quick check. An old link has an MTU of 576 bytes, and headers are still 20 bytes. A router must fragment a 1,200-byte payload onto it. How many data bytes go in the first fragment? Pause, and predict. 552. The room is 576 minus 20, which is 556. But 556 isn't a multiple of 8, so it's rounded down to 552. 556 is the tempting pick. But then the next piece would start at byte 556, which can't be written in eight-byte units. And 400 shares the payload out evenly. Fragments aren't cut evenly: each is filled as full as it can be, and the leftover goes last. So the pieces hold 552, 552, and 96 bytes.
Modern Practice
Why Systems Avoid Fragmenting
Fragmenting costs routers time, and one lost piece ruins the whole packet. So today's systems try hard not to fragment. TCP, from lesson 7.6, picks a segment size that fits the smallest MTU on the path, so each segment already fits in one packet. A sender can also set the Don't Fragment flag. A router that meets a too-big packet then drops it and reports back, and the sender learns to send smaller ones. IPv6 goes further. Its routers never fragment at all. Only the sender may.
Story Ending
A Jigsaw Mailed in Many Envelopes
Back to Sam's cake photo. The customer said it loaded slowly. Ivy, who looks after the computers at a school, explained. The photo traveled as many packets, and a few were sent again when the Wi-Fi dropped them. Think of a jigsaw mailed in many envelopes, she said. The picture appears only when the last piece arrives.
Key Takeaways
Packets, Headers, and Fragments Reviewed
To recap. A packet is a header, the label, and a payload, the data. The IPv4 header's TTL counts down the hops, and its checksum catches damage. The MTU is the biggest packet a link will carry. Fragments share an identification, carry an offset in eight-byte units, and a More Fragments flag. And modern systems avoid them.
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 Internet Packets
What is the difference between a packet header and a payload?
What does the time to live field do in an IPv4 packet?
How do you calculate IPv4 fragment offsets?
Why do modern networks try to avoid IP fragmentation?
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 →