AP CSP Big Idea 4 Packet Switching

AP CSP Topics › Packet Switching

AP CSP Packet Switching: Complete Guide (2025‑2026)

Packet switching is the method by which the internet transmits data. Instead of reserving a dedicated connection between sender and receiver (circuit switching), packet switching breaks data into small chunks called packets, routes each packet independently, and reassembles them at the destination. This makes the internet efficient, resilient, and scalable — but means packets may arrive out of order, requiring reassembly.

1500Bytes in a typical maximum packet size (MTU) on the internet
~msTime for each router to make a forwarding decision per packet
NPaths a message’s packets can take — no fixed route required

How Packet Switching Works

Packet Switching: Different Packets, Different Paths SENDER splits data PKT 1 PKT 2 PKT 3 Router A Router B Router C Router D Router E RECEIVER reassembles Packets 1 and 3 take the top path; Packet 2 takes the bottom path. All arrive and are reassembled in order.

Each packet is routed independently based on current network conditions. If a node fails, packets automatically route around it. Packets from the same message may arrive out of order and must be reassembled.

Scenario — Trace a Packet

You send a 9KB email. The network’s maximum packet size is 1,500 bytes. The email is split into 6 packets numbered 1–6.

What happens if packet 4 takes a slower route and arrives after packet 5? Can the email still be read?

Answer

Yes — TCP handles this. Each packet carries a sequence number in its header. The receiving device buffers all arriving packets, then uses sequence numbers to reassemble them in the correct order regardless of arrival sequence. If packet 4 never arrives (dropped by an overloaded router), TCP detects the missing acknowledgment and requests retransmission. The email is reconstructed perfectly — the out-of-order arrival is invisible to the user.

Packet vs. Circuit Switching

Circuit Switching (Old Telephone System)
Dedicated connection reserved
  • Full path reserved before any data sent
  • Path held exclusively for duration of call
  • Guaranteed capacity and consistent quality
  • Idle time wastes reserved bandwidth
  • Fails completely if any node on path fails
Packet Switching (The Internet)
Shared network, independent routing
  • No dedicated path reserved in advance
  • Network capacity shared among all users
  • Efficient: idle bandwidth used by others
  • Quality can vary based on congestion
  • Reroutes automatically around failures
Scenario — Which Approach?

Compare two scenarios: (A) A 1990s telephone call from New York to Los Angeles, where a dedicated circuit is established for the call’s duration. (B) A video stream from a server in California to a viewer in New York, where data is broken into packets and routed independently.

Which approach is circuit switching, which is packet switching, and what is the key difference in how they handle a link failure?

Answer

(A) is circuit switching: the call fails completely if any part of the reserved circuit breaks — you hear silence and must redial. (B) is packet switching: if one router fails, subsequent packets are automatically routed around it through alternative paths. The video may pause briefly but does not fail permanently. This resilience to failure is the core reason packet switching was chosen for ARPANET (which needed to survive node failures in a military conflict).

Packet Headers and Metadata

What a Packet Contains
Two main parts
  • Header: Source IP, destination IP, sequence number, protocol, TTL (time to live)
  • Payload: The actual data being transmitted
  • Headers are readable by every router along the path
  • Payload is encrypted by HTTPS (headers usually not)
  • Header overhead is why packet switching isn’t 100% efficient
What Routers Do with Headers
The forwarding decision
  • Read the destination IP in the header
  • Look up the best next hop in routing table
  • Forward the packet to the next router
  • Decrement TTL (prevents infinite loops)
  • Do NOT read payload — just route by header
Scenario — Metadata vs. Content

A security researcher argues: ‘Even if the payload is encrypted by HTTPS, packet headers reveal useful information about communication patterns.’ What specific information do headers expose even when content is encrypted?

What can an observer learn from headers alone?

Answer

Headers reveal: source and destination IP addresses (who is communicating), timing (when and how often), packet volume (how much data), and protocol information. From this metadata, an observer can infer: which websites you visit (via destination IP/domain), how long you spend there, whether you are video streaming vs. text browsing, and communication patterns between parties. This is why privacy advocates argue that metadata protection is as important as content encryption — headers tell a story even without the payload.

Common Exam Pitfalls

1
Thinking packets always travel the same path

Each packet is routed independently based on current network conditions. Packets from the same message can and do take different paths. TCP reassembles them in order at the destination.

2
Thinking out-of-order arrival means data is corrupted

TCP sequence numbers allow correct reassembly regardless of arrival order. Out-of-order arrival is normal and expected — it is not data corruption.

3
Confusing packet switching with circuit switching

Packet switching shares network capacity and routes independently. Circuit switching reserves a dedicated path. The internet uses packet switching; traditional telephone systems used circuit switching.

4
Thinking packet headers are encrypted by HTTPS

HTTPS encrypts the payload (content). Headers — including source and destination IP addresses — are generally not encrypted and are readable by every router along the path.

Check for Understanding

1. In packet switching, if one router along a packet’s route fails, what most likely happens?

  • The entire transmission fails and must be restarted from the beginning.
  • The packet is lost permanently because it has no alternative path.
  • Subsequent packets are routed around the failed node through alternative paths.
  • The transmission pauses until the failed router is repaired.
Packet switching routes each packet independently. If a router fails, routing protocols detect the failure and update routing tables. Subsequent packets are forwarded through alternative paths. This is the resilience advantage of packet switching over circuit switching.

2. A file is split into 5 packets numbered 1–5. They arrive in the order 1, 3, 5, 2, 4. What happens?

  • The file is corrupted because the packets arrived out of order.
  • Only packets 1, 3, and 5 are kept; 2 and 4 must be retransmitted.
  • TCP uses the sequence numbers to reassemble the packets in the correct order.
  • The file transfer restarts from packet 1 because of the out-of-order arrival.
TCP numbers every packet with a sequence number. The receiving device buffers all arriving packets and reassembles them in the correct order based on sequence numbers, regardless of arrival order.

3. Consider statements about packet switching:
I. Packets from the same message may travel different routes through the network.
II. Circuit switching provides better fault tolerance than packet switching.
III. Each packet contains a header with source and destination address information.

Which are correct?

  • I only
  • I and III only
  • II and III only
  • I, II, and III
Statement I is correct — independent routing per packet is the defining feature. Statement III is correct — headers carry addressing information routers need to forward packets. Statement II is false — packet switching provides better fault tolerance; circuit switching fails completely if any node on the reserved path fails.

4. What is the primary advantage of packet switching over circuit switching for data networks?

  • Packet switching guarantees consistent delivery speed.
  • Packet switching uses dedicated bandwidth, ensuring no congestion.
  • Packet switching shares network capacity efficiently and reroutes around failures automatically.
  • Packet switching eliminates the need for routers.
Packet switching’s two main advantages: (1) efficient bandwidth use — idle bandwidth is shared rather than reserved; (2) resilience — packets route around failures automatically without requiring a new connection.

5. A HTTPS-encrypted message travels from a browser to a web server. Each router along the path can read:

  • The full content of the message, because routers must decrypt to forward.
  • The source and destination IP addresses in the packet header, but not the encrypted payload.
  • Nothing — the entire packet including headers is encrypted by HTTPS.
  • Only the sequence number — all other header fields are also encrypted.
HTTPS encrypts the payload. Packet headers (including IP addresses) must remain readable for routers to forward packets. Routers read headers to make forwarding decisions; they do not need to (and cannot) read the encrypted payload.

6. What is the purpose of the TTL (Time to Live) field in a packet header?

  • It specifies how long the payload data should be considered current.
  • It limits the number of hops a packet can make, preventing it from circulating indefinitely if routing loops occur.
  • It encrypts the packet for a set number of seconds during transmission.
  • It reserves bandwidth on each router for the packet’s duration.
TTL starts at a set value (e.g., 64) and is decremented by each router. If TTL reaches zero, the packet is dropped. This prevents routing loops — packets that would otherwise circulate indefinitely if the routing table had a cycle.

Frequently Asked Questions

How large is a packet?
Packets have a maximum size called the Maximum Transmission Unit (MTU). On most internet links, MTU is 1,500 bytes. Larger data is fragmented into multiple packets. The choice of 1,500 bytes dates to Ethernet’s original specification and has persisted because changing it would require updating billions of devices.
What happens to a packet that gets lost?
If a TCP packet is lost (dropped by an overloaded router), the sender detects this because it does not receive an acknowledgment within a timeout period. TCP then retransmits the lost packet. The receiver holds subsequent packets in a buffer while waiting for the missing one, then delivers all packets in order once the gap is filled.
Does the AP CSP exam test specific packet header fields?
No. You should understand conceptually that packets have headers containing addressing information (source/destination IP, sequence numbers) and a payload containing the data. You do not need to memorize specific field names, sizes, or formats beyond this conceptual level.

How the AP Exam Tests This

  • Identify a property of packet switching that enables fault tolerance
  • Explain why packets from the same message may travel different routes
  • Determine what a router reads in a packet header to make forwarding decisions
  • I/II/III: which statements about packet switching are correct
  • Compare packet switching and circuit switching for a given scenario

7. A file is split into 4 packets. They arrive in order 1, 3, 2, 4. What happens to the file?

  • The file is corrupted because packets arrived out of order.
  • TCP uses sequence numbers to reassemble the packets in the correct order.
  • Packets 1 and 4 are kept; 2 and 3 must be retransmitted.
  • The file transfer restarts from packet 1.
TCP sequence numbers enable correct reassembly regardless of arrival order.

8. What is the primary purpose of the TTL (Time to Live) field in a packet header?

  • It encrypts the packet for a set time duration.
  • It limits the number of hops, preventing packets from circulating indefinitely in routing loops.
  • It reserves bandwidth for the packet on each router.
  • It specifies how long the payload data should be considered valid.
TTL decrements at each router. When it reaches zero, the packet is dropped, preventing infinite loops.

9. Consider: I. Each packet is routed independently based on current network conditions. II. Circuit switching provides better fault tolerance than packet switching. III. Packet headers contain source and destination addressing information.

  • I and III only
  • I only
  • I, II, and III
  • II and III only
I and III correct. II is false — packet switching reroutes around failures; circuit switching fails completely if any node on the reserved path fails.

10. An HTTPS-encrypted message travels across the internet. Each router can read:

  • The full message content to route it accurately.
  • Only the source and destination IP addresses in the header, not the encrypted payload.
  • Nothing — the entire packet is encrypted including headers.
  • Only the sequence number.
Routers need headers to forward packets. HTTPS encrypts payload only; headers remain readable.

Get in Touch

Whether you're a student, parent, or teacher — I'd love to hear from you.

Just want free AP CS resources?

Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.

Typically responds within 24 hours

Message Sent!

Thanks for reaching out. I'll get back to you within 24 hours.

🏫 Welcome, fellow educator!

I offer curriculum resources, practice materials, and study guides designed for AP CS teachers. Let me know what you're looking for — whether it's classroom materials, a guest speaker, or Teachers Pay Teachers resources.

Email

[email protected]

📚

Courses

AP CSA, CSP, & Cybersecurity

Response Time

Within 24 hours

Prefer email? Reach me directly at [email protected]