Lesson 01 / 12
What Is a Network
Endpoints, links, and switching; why packet switching was chosen over circuit switching, and the consequences of best-effort delivery.
Contents
When you type http://example.test/ into an address bar and send the request, a page
appears within a fraction of a second. What happens in between cannot be summarized in a
single sentence: a name must be translated into an address, a connection established
between two machines, a request formatted and sent, and the returned response rendered.
This course unpacks that journey piece by piece. Each lesson builds one link of the chain; the last lesson joins them all, start to finish. At the bottom of the chain stands the most concrete question: how does data move between two machines?
Endpoints, Links, and Switches
A network is a structure made of machines that can carry data between each other. It is defined by three components.
Hosts are the endpoint machines that produce and consume data. The machine where you
typed the request is a host; the machine holding the example.test page is also a host.
The network exists for the hosts; the hosts do not exist for the network.
Links are the medium that physically joins two points: copper wire, glass fiber, radio waves. Every link has two measurable properties. Bandwidth is the amount of data that can be carried per unit of time. Latency is the time it takes for data to travel from one end to the other. The two are independent: a link with wide bandwidth can still have high latency. Part of latency is bounded by the laws of physics; a signal cannot travel faster than the medium’s propagation speed.
Switching nodes connect more than two hosts to each other. Attaching every host to every other with a separate link is unworkable: for hosts the number of links needed is , which quickly becomes impossible as grows. Instead, hosts connect to shared nodes, the nodes connect to each other, and data passes from node to node. The node that makes this forwarding decision is called a router.
Two Switching Models
There are two different ways to pass data through the nodes, and the choice between them is the most fundamental of the decisions that shape the internet’s design.
Circuit Switching
In the circuit switching model, a path is established between two endpoints before communication begins, and the resources along that path are reserved for those two endpoints for the duration of the communication. Once the path is established, data flows through the reserved capacity.
This model has one advantage: because the resource is reserved, performance is predictable. If the circuit is established, the reserved capacity is guaranteed.
The cost is wasted resources. While reading a page you send no data; while typing text you pause. Data communication is bursty: short dense intervals, long silences. The reserved circuit stays reserved through the silence too, and no one else can use that capacity. The second cost is setup time: a single page request requires first establishing a path, then sending the data, then tearing the path down.
Packet Switching
In the packet switching model, no path is established in advance. The data being sent is split into pieces called packets. Each packet carries its own destination on itself, and the nodes forward each packet separately, the moment it arrives.
Every packet has two parts. The header carries the information needed for routing, such as where the packet came from and where it is going. The payload is the data being carried itself. The envelope-and-letter analogy holds: the nodes look at the envelope, they do not open the letter.
This model’s gain is statistical multiplexing: a link is shared by everyone who has data to send at that moment. A silent host holds no capacity. Because average total demand is far smaller than the sum of peak demands, the same link serves far more hosts.
The second gain is resilience. With no path established in advance, a broken link brings down no “circuit”; the next packets travel a different route instead. Failure of part of the network causes communication to be rerouted rather than stopped entirely.
The cost is uncertainty. Because no capacity is reserved, when many packets arrive at the same node at once, queues form; if a queue fills up, packets are dropped. Delivery time varies from packet to packet.
The Reason for the Choice
The internet is built on packet switching. The reason is the nature of the traffic carried: computer communication is bursty and the number of hosts is enormous. Reserving resources in advance leaves most of the resource idle. Packet switching gives up predictability to buy efficiency and resilience.
| Criterion | Circuit switching | Packet switching |
|---|---|---|
| Resource reservation | Before communication, for its duration | None; shared per packet |
| Idle capacity | Stays reserved, unusable | Used by others |
| Setup cost | A path is built for each communication | None |
| Failure behavior | Communication drops when the path breaks | Packets take another route |
| Delivery time | Predictable | Variable with load |
| Under load | New circuits are refused | Queues grow, packets may drop |
This trade-off also names the promise the network makes: best-effort delivery. The network does everything it can to forward the packet, but it makes no promise that it will arrive, that it will arrive in order, or that it will arrive only once.
Splitting a Message into Packets
With such a weak promise, how does a reliable page get displayed? The answer is that the hosts complete what the promise leaves out. The sending endpoint splits the data into numbered packets; the receiving endpoint uses the numbers to restore the order and detect what is missing.
The program below shows this splitting and reassembly. Without using the network layer itself, only the operation performed on the data is examined.
MESSAGE = "Hello Example Page!" PACKET_SIZE = 5 packets: list[tuple[int, str]] = [ (seq, MESSAGE[i:i + PACKET_SIZE]) for seq, i in enumerate(range(0, len(MESSAGE), PACKET_SIZE)) ] for seq, payload in packets: print(f"seq={seq} payload={payload!r}") print() # Packets can take different routes; arrival order is not send order. arrival_order = [2, 0, 3, 1] received = [packets[i] for i in arrival_order] print("order seen on arrival:", [seq for seq, _ in received]) reassembled = "".join(payload for seq, payload in sorted(received)) print("reassembled:", repr(reassembled)) print("lossless:", reassembled == MESSAGE)
Output:
seq=0 payload='Hello' seq=1 payload=' Exam' seq=2 payload='ple P' seq=3 payload='age!' order seen on arrival: [2, 0, 3, 1] reassembled: 'Hello Example Page!' lossless: True
The packets arrived out of order; thanks to the sequence number, the original message was reassembled without loss. Without the number, the scrambled arrival would have been unrecoverable corruption.
This is an example of a principle in network design: hard guarantees are built at the endpoints. Asking intermediate nodes to preserve order would complicate and slow them down; the endpoints, meanwhile, already have to see the data as a whole. Reordering, re-requesting a missing piece, and discarding a duplicate are all left to the endpoints. The protocols that carry out this work are the subject of the Network Models and Protocols course.
In real packets, the payload’s bytes are interpreted according to the rules defined in the How Computers Work course: text is converted to bytes with a specific character encoding, and the numeric fields in the header are written in a specific byte order. The big-endian layout used in network headers was covered there under the name network byte order; that is where the name comes from.
Packet Size and Fragmentation
How large a packet can be is not free to choose. Every type of link has a maximum packet size it can carry. Data exceeding that limit must be split.
Both directions of that limit carry a cost. As packets get smaller, the proportion of header overhead rises: every packet carries its own header, so more headers are sent to carry the same data. As packets get larger, the cost of a single loss rises, and the time a packet occupies the link grows longer.
In the example above, splitting the 19-character message into 5-byte packets produced four packets, and the last one carried only four bytes. It is normal for the last packet to be under-filled; the data size does not have to be a multiple of the packet size.
Summary
- A network is made of hosts, links, and switching nodes that make the forwarding decision; links are characterized by bandwidth and latency.
- Circuit switching reserves resources before communication and provides predictability, but leaves capacity idle under bursty traffic.
- Packet switching does not reserve resources in advance; it gains efficiency through statistical multiplexing and fault tolerance from not having a fixed path.
- The cost of this choice is best-effort delivery: the network makes no promise that a packet will arrive, arrive in order, or arrive only once.
- A message is split into numbered packets carrying a header and a payload; reordering and detecting loss happen at the endpoints, not the intermediate nodes.
Next Step
This lesson established how packets are carried, but it did not say who starts the
carrying. The machine holding the example.test page and the machine where you typed
the request are equal hosts as far as the network is concerned; their roles, however, are
not symmetric. One waits continuously, the other starts talking whenever it wants. The
next lesson defines that role distinction and runs a real server to show how the two
machines find each other.
To keep your progress and take notes, Log in
My notes
Log in to take notes.