IB COMPUTER SCIENCE | A2.3.3 Packet Switching

Lesson objective

Explain packet preparation, headers, independent forwarding and destination reconstruction, and the roles of switches, routers and transport recovery.

Learn

A2.3.3 | PACKET SWITCHING

01 | SHARE THE NETWORK A PIECE AT A TIME

Imagine sending a large photograph while someone else sends a short message. If one transfer occupied every link until its complete file had passed, the short message could wait a long time. Packet switching lets networks share link capacity in smaller units.

In a packet-switched network, data is carried in packets with control information that supports delivery. Packets from different transfers can use the same links at different times. A separate dedicated end-to-end circuit is not reserved for every ordinary IP exchange.

A useful first picture is: prepare data chunks, attach delivery information, forward each packet through the network, then process the arriving data at the destination. Different protocols perform different parts of that work.

This lesson explains the journey carefully, including the roles of switches and routers. It also distinguishes packet forwarding from TCP’s ordering and recovery so you do not accidentally give IP guarantees it does not provide.

02 | FROM ONE MESSAGE TO SMALLER UNITS

A large application message usually cannot be carried as one enormous link frame. The sending software and network stack arrange its data into suitable units for transmission. With TCP, application bytes are carried in segments, which IP then carries in packets.

A payload is the data a protocol unit carries. A header is control information before that payload. An IP packet includes an IP header and its payload; that payload can contain a TCP segment with its own header and application bytes.

The different terms describe different layers. “Packet” is sometimes used broadly in teaching, but a precise TCP example is application bytes → TCP segment → IP packet → link frame. The receiver processes the layers in the opposite direction.

This does not imply one application write becomes one segment, or one packet contains an entire web page. The stack can split or combine application data according to its protocols and limits.

03 | WHAT IS IN THE CONTROL INFORMATION?

A packet needs addressing so intermediate devices can move it toward its destination. In IP, the header includes source and destination IP addresses. Routers use the destination address with their forwarding information to select an appropriate next hop.

Other control information supports the protocol. IPv4 includes a time-to-live field that is reduced during forwarding to limit persistent circulation. It also identifies the carried upper-layer protocol. TCP has separate transport fields such as ports, sequence information and acknowledgements.

For a reliable TCP stream, sequence information identifies byte positions so the receiver can detect gaps and provide ordered delivery. A simple “packet number 1, 2, 3” is a teaching label, not a universal sequence field in every IP header.

The header travels with the data unit so it can be handled on its own as it crosses the network. Control protocols and acknowledgements can also send separate messages, but the IP delivery header is not normally detached and sent ahead as a separate instruction sheet.

Control informationWhere it belongs in this examplePurpose
Source/destination IPIP headerAddress the packet and support forwarding
TTL, for IPv4IP headerLimit persistent packet circulation
PortsTCP header inside the IP payloadIdentify transport endpoints
Byte sequence informationTCP header inside the IP payloadSupport ordered stream delivery and recovery

04 | SEE THE WRAPPERS WITHOUT CONFUSING THE JOBS

Suppose the application sends the nine ASCII characters NETWORKS!. We display three teaching chunks, NET, WOR and KS!, at relative byte positions 0, 3 and 6. Real TCP sequence numbers are not normally zero-based labels like these; the offsets simply make this small stream easy to follow.

TEACHING CHUNK P1

NET

Relative bytes 0–2

TEACHING CHUNK P2

WOR

Relative bytes 3–5

TEACHING CHUNK P3

KS!

Relative bytes 6–8

LINK FRAME

Local link control information

IP PACKET

IP source and destination; other IP fields

TCP SEGMENT

Transport endpoints and byte-position information

NET

One small illustrated payload

The labels P1–P3 help us discuss the diagram. They are not a claim that IP itself reconstructs an application file from a universal packet-number field. Encryption, normal packet sizes and detailed connection setup are omitted.

05 | THE FIRST LINK: HOST TO LOCAL SWITCH

The source host decides whether the IP destination is local or reached through a router. For a remote network in this ordinary example, the next link recipient is the local router, usually selected through a matching route or the default gateway.

The host places the IP packet in a suitable link frame. On Ethernet, the frame’s destination MAC address identifies the next local link recipient. For a remote IP destination, that is ordinarily the router’s local interface, not the distant server’s MAC address.

A basic Ethernet switch uses link-layer destination information and its forwarding table to move frames within the local VLAN. It does not normally choose the full internet route or interpret the application’s message to perform this job.

MAC learning, broadcast handling and unknown-destination handling have their own rules. The key distinction here is that the local switch handles link forwarding, while the IP destination can be much farther away.

06 | THE ROUTER: SELECT A NEXT HOP

A router receives the incoming link frame, processes the IP packet and selects a next hop or outgoing interface from its forwarding information. A routing table records information about reaching destination networks; forwarding uses the relevant installed routes.

The next hop is the next forwarding destination, not necessarily the final receiver. A router usually makes a local decision rather than calculating and attaching a complete new end-to-end path to every ordinary IP packet.

The router builds suitable outgoing link framing. In a simple routed example without NAT or tunnelling, the source and destination IP addresses remain the end hosts’ addresses, while local link addresses change at routed link boundaries. Some IP control fields, such as IPv4 TTL and its header checksum, change too.

If there is no usable route, or a packet cannot be handled under the applicable rules, it can be dropped. Packet switching is not a promise that an available route always exists.

07 | SWITCH AND ROUTER: COMPARE THEIR FORWARDING ROLES

QuestionBasic Ethernet switchIP router
What unit is the local decision about?Link frameIP packet carried by the received link frame
Which destination information is central?Destination MAC within the relevant VLANDestination IP and matching forwarding information
Typical scopeLocal Layer 2 forwardingMovement between IP networks
What happens at a routed boundary?Carries the frame to the relevant local recipientProcesses incoming framing and creates appropriate outgoing framing

These are functions rather than rigid product categories. A Layer 3 switch can also route. A home networking box can combine switching, routing and wireless access in one case. Explain the operation being performed instead of assuming each physical device has only one possible role.

For one remote transfer, local switches and routers cooperate: switches deliver frames on local LAN sections, while routers forward packets between networks.

08 | LINKS ARE SHARED THROUGH TIME

At a shared outgoing link, packets from several sources can be transmitted one after another. This is often called statistical multiplexing: capacity is shared according to current demand rather than reserved as a fixed private circuit for each user.

A packet can wait in a buffer while another is being transmitted. That creates queueing delay. If arrivals exceed the device’s available resources, congestion can build and some packets can be discarded.

Smaller units allow other transfers to use a link between packets of a large transfer. However, packet headers, buffering and per-packet processing add overhead, and delays can vary. There is no unconditional guarantee that every application receives a fixed bandwidth.

A typical store-and-forward device receives a unit before transmitting it onward; some switches use other forwarding methods such as cut-through. The central learning point is shared packet-based forwarding, not that every implementation buffers an entire application message.

09 | CAN PACKETS TAKE DIFFERENT ROUTES?

IP packets are handled using forwarding information at each hop. Successive packets can encounter a changed route, different queueing conditions or different traffic distribution decisions, so their paths and arrival times can differ.

They do not have to follow different paths. In many networks, packets belonging to one flow usually follow the same path while routing is stable. This can reduce reordering. “Every packet takes a different route” is therefore an incorrect rule.

A usable alternative path can support continued communication after a failure, but routing or forwarding must detect and accommodate the change. Recovery may take time, and some in-flight packets may be lost. The next lesson develops static and dynamic routing.

The diagrams below use upper and lower routes deliberately to illustrate variation. They are planned teaching events, not a real routing algorithm that always finds the fastest or least busy path.

10 | STEP THROUGH ARRIVAL, REORDERING AND RECOVERY

Choose a delivery example and advance one event at a time. Each event highlights an illustrated path or attempted path. Received chunks are shown separately from bytes released to the application.

In the loss example, P2’s first transmission is dropped on the lower route. A later TCP recovery event sends the missing byte range again. TCP can use a different segmentation for real retransmissions; this model repeats the same small chunk for clarity.

No timing, handshake, checksum or congestion-control algorithm is simulated. The graph depicts IP routing paths between source and destination; local switches are omitted here and explained above.

11 | ARRIVAL ORDER IS NOT ALWAYS APPLICATION ORDER

Suppose the receiver observes chunks containing bytes 0–2, then 6–8, then 3–5. It has received NET, KS! and WOR in that arrival order. Simply concatenating arrivals would produce the wrong message.

For a TCP connection, the receiver uses TCP byte sequence information to identify where each range belongs. It can hold later bytes while waiting for an earlier gap, then release the contiguous stream in order. The resulting application stream is NETWORKS!.

This work belongs to the transport implementation, not to a router somewhere in the middle. Applications using TCP also need their own message boundaries if those matter, because TCP supplies a stream rather than preserving the boundaries of application write calls.

Be precise about “reassembly”. Reconstructing a transport stream is not the same as IP fragment reassembly. If an IP packet has been fragmented under the relevant IP rules, its fragments require IP-level reconstruction at the destination. That is a separate mechanism from the TCP ordering example here.

12 | WHAT IF A PACKET IS LOST OR DAMAGED?

IP is a best-effort service. Packets may be lost because of damaged transmissions, congestion, unavailable routes or other failures. IP does not automatically provide reliable ordered delivery of the application stream.

Link and transport mechanisms can detect certain errors using their control fields. Their coverage differs: an Ethernet frame check concerns its frame, while TCP’s checksum covers its transport data and relevant addressing information. An IPv4 header checksum is not an application-payload correctness guarantee.

TCP uses acknowledgements, sequence information and retransmission mechanisms to recover data when possible. Acknowledgements report transport progress; a sender can retransmit missing ranges according to its protocol rules. If recovery ultimately fails, the connection can fail.

An application using UDP does not gain TCP-style recovery merely because IP carries its datagrams. It or a higher-level protocol can add its own handling, or tolerate some losses where the application allows. Packet switching alone guarantees neither reliability nor a fixed deadline.

13 | DUPLICATES AND LATE DATA

Recovery can create duplicate arrivals. For example, an original transmission might be delayed long enough that the sender retransmits before the original arrives. Both copies could later reach the destination.

TCP uses sequence information and its receive rules so the application is not given duplicated bytes as if they were new data. A later range may remain buffered while an earlier missing range is recovered.

The application consequences depend on the service. A correct file needs all required bytes, while a live audio application may choose not to use an update that arrives too late. Protocol design must match those requirements.

Do not confuse transport delivery with task success. A transport acknowledgement is not proof that a server saved the document or completed a payment. Application responses and application-level reliability measures address those outcomes.

14 | BENEFITS AND TRADE-OFFS OF PACKET SWITCHING

FeaturePractical benefitRelevant limit
Shared linksDifferent transfers can use capacity as neededCongestion and varying delay can occur
Packet-sized forwardingOther traffic can use the link between units of a large transferHeaders and forwarding work add overhead
Hop-by-hop decisionsNetworks can use suitable forwarding pathsRoutes must exist; changes can lose in-flight packets
Destination control processingUpper protocols can reconstruct the intended dataReliability and order depend on the selected protocol
No ordinary dedicated end-to-end circuitUseful for bursty data from many usersDoes not reserve constant capacity or a deadline by itself

Avoid saying packet switching “has no connection setup” in every sense. IP forwarding does not require reserving a dedicated circuit for each exchange, but TCP may still establish a transport connection and applications may establish sessions. These are different concepts.

15 | WORKED JOURNEY: A STUDENT OPENS A LESSON

Assume a student already knows the lesson server’s address and has a working TCP connection over ordinary routed IP links. The server’s response bytes are carried in TCP segments inside IP packets, which are carried by link frames.

A local switch forwards each frame to the relevant local recipient. Routers inspect IP destinations and use installed forwarding information to send the packets toward the student’s network. At each routed boundary, new local framing is used. Other users’ packets can share those links.

At the destination, the network stack processes link and IP information and passes transport data to TCP. TCP handles ordering and recovery, where possible, so that upper software receives the ordered stream. The browser then interprets the application content.

A real lesson page can require several resources, cached content or a different transport arrangement such as HTTP/3. The worked assumptions let you explain packet switching without claiming every page view is one identical transfer.

16 | MATCH THE MECHANISM TO THE JOB

Choose the function directly responsible for each situation. The complete system relies on several layers, so focus on the particular operation in the question.

17 | CORRECT THE COMMON MISCONCEPTIONS

ClaimMore precise explanation
Every packet takes a different routePaths can differ, but packets of a flow often share a stable path
The router reconstructs the fileRouters forward packets; destination transport/application processing reconstructs the intended data
Every IP header numbers the application’s packetsTCP uses byte sequence information; IP has no universal application-packet sequence field
Packet switching automatically resends lossesRecovery depends on mechanisms such as TCP or application handling
The original frame crosses every router unchangedLink framing is processed and rebuilt at routed boundaries
All packets arriving proves the business task succeededTransport delivery and application task completion are different outcomes

A simplified school explanation can say “data is split, addressed, independently forwarded and reassembled at the destination”. Improve it by identifying which protocol supplies the addressing, ordering and recovery in the stated example.

18 | EXPLAIN THE PROCESS AS A CONNECTED ANSWER

For explain, connect the mechanism to its purpose. Begin with suitable data units and their headers, describe forwarding and shared links, then explain destination processing and the relevant reliability mechanisms.

A model answer could say: “Data is carried in packets with IP headers containing source and destination addressing. Routers use the destination with forwarding information to select successive next hops, while local switches forward the link frames on LAN sections. Packets from different transfers share links, so queueing, loss and varying arrival order can occur.”

Then complete the TCP example: “At the destination, TCP uses sequence information to provide the correct byte order and acknowledgements and retransmission mechanisms to recover missing data where possible. Therefore later bytes may wait for an earlier gap before the application receives the contiguous stream.”

Use because, so that, therefore and resulting in to explain consequences. Do not attribute all of these functions to the word “packet” alone.

MATCH THE PACKET-SWITCHING IDEA TO ITS ROLE

Terminology

Terminology

Packet switching

Carrying data in packets that share links with other transfers rather than reserving an ordinary dedicated circuit for each exchange.

Packet

A network-layer data unit with control information and a payload.

Payload

The data carried inside a protocol unit.

Header

Control information before a unit’s payload.

Encapsulation

Carrying a higher-layer unit inside another layer’s unit with its control information.

TCP segment

A TCP unit containing transport control information and any carried stream bytes.

IP packet

A unit containing an IP header and its payload.

Link frame

A link-layer unit carrying local control information and a payload.

Source address

Address information identifying the sender in the relevant protocol context.

Destination address

Address information used to identify the intended recipient in the relevant context.

Switch

A basic Ethernet switch forwards local frames using link information within a VLAN.

Router

A device performing IP packet forwarding between networks.

Next hop

The next forwarding destination on a packet’s path.

Routing table

Information about reaching destination networks, used to install or support forwarding choices.

Forwarding

Moving a received unit toward the selected outgoing interface or next hop.

Default gateway

A local router used by a host when no more specific route applies.

Statistical multiplexing

Sharing link capacity among packet transfers according to current demand.

Buffer

Memory temporarily holding units or data awaiting processing or transmission.

Queueing delay

Waiting time before a unit can be handled or transmitted.

Congestion

Demand exceeding available resources, potentially creating delay or loss.

Best effort

Service without guaranteed delivery or in-order arrival.

TCP sequence information

Information identifying byte positions in a TCP stream.

Acknowledgement

Protocol information reporting receipt or transport progress.

Retransmission

Sending data again as part of recovery.

Out-of-order arrival

Data arriving in a different order from its position in the intended stream.

Duplicate arrival

Another copy of data already received.

Stream reconstruction

Processing received byte ranges to provide the intended ordered stream.

IP fragment reassembly

Reconstructing a fragmented IP packet at the destination under the relevant IP rules.

TTL

IPv4 time-to-live field reduced during forwarding to limit persistent circulation.

Protocol overhead

Control information and processing beyond the application’s useful content.

Questions

Questions

CHECK YOUR UNDERSTANDING

Select all correct choices. Each exact set earns one point.

1. Which describe packet switching?
2. Which correctly identify protocol units?
3. Which information is correctly placed?
4. Which describe basic Ethernet switching?
5. Which describe IP forwarding?
6. Which are accurate about paths?
7. Which describe TCP reception?
8. Which are realistic reliability statements?
9. Which concern shared capacity?
10. Which distinguish related processes?

EXPLAIN AND COMPARE

Write your answers before revealing each sample.

1. Explain how packet switching shares a network.

2. Explain why headers are needed.

3. Describe the units in a TCP-over-IP-over-Ethernet example.

4. Explain the role of a local switch.

5. Explain the role of a router.

6. Explain why the destination IP and first-hop MAC can identify different devices.

7. Explain how packets can arrive out of order.

8. Explain the receiver behaviour for NET, KS!, then WOR in the TCP example.

9. Explain recovery from missing data in a TCP connection.

10. Explain why packet switching can introduce variable delay.

11. Explain why reassembly must be described carefully.

12. Explain the benefits and limitations for a large file transfer.

EXPLAIN IT | A FILE CROSSING TWO NETWORKS

Draw a sender, a local switch, at least two routers and a receiver. Explain how suitable data units and control information allow the file data to cross the network. Distinguish local link addressing from the IP destination, describe a possible delay or loss, and explain TCP ordering and recovery at the destination. State one thing this does not guarantee about the application task.

Flashcards

Flashcards

Click to flip. Select the ideas you need to revisit.

0 cards selected for revision.

    Selections are kept while this page is open.

    Workbook

    Workbook

    COMING SOON

    The workbook for A2.3.3 Packet Switching is coming soon. Complete the matching task and written questions in your exercise book.