Sub topic 2
Circuit switching: setup, dedicated path, teardown
This chapter assumes you know what a network link is, can convert bits and bytes, and can read rates such as Mbps.
Circuit switching
A circuit-switched network reserves a fixed path before any data flows. The connection has three phases:
- Setup: a request travels the route, and each switch reserves capacity for the connection.
- Data transfer: data flows over the reserved path, with no routing decision for each unit of data.
- Teardown: a release message frees the reserved resources.
Reserved capacity stays unavailable to other users even when idle. This wastes capacity for bursty traffic, which is why packet switching exists.
Packet switching and store-and-forward
Packet switching splits a message into packets, and no capacity is reserved. Each switch receives a whole packet, stores it, and then forwards it on the next link. This is called store-and-forward. A packet therefore pays the transmission time at every link it crosses.
Datagram and virtual-circuit forwarding compared
In a datagram network, each packet carries the full destination address, and each switch looks up that address on its own. Packets can take different paths and arrive out of order.
In a virtual-circuit network, setup creates a connection identifier in each switch along the path. Packets carry a short label, and each switch forwards by that label. All packets follow one path in order.
| Property | Datagram | Virtual circuit |
|---|---|---|
| Setup phase | None | Required |
| Packet header | Full address | Short label |
| Path | May vary per packet | Fixed |
| Order | May be reordered | Preserved |
How a learning switch fills and uses its table
A layer-2 switch learns which port reaches each MAC address by reading the source address of every arriving frame. It forwards frames for known destinations out the learned port, and it floods frames for unknown destinations.
table = {} # MAC address -> port
def receive(port, src, dst):
table[src] = port # learn the sender's port
if dst in table:
return f"forward to port {table[dst]}"
return "flood to all ports except " + str(port)
print(receive(1, "AA", "BB")) # flood to all ports except 1
print(receive(2, "BB", "AA")) # forward to port 1Processing, queuing, transmission and propagation delay
Delay at each hop has four parts. Processing is reading headers. Queuing is waiting in a buffer. Transmission is L/R, the time to push L bits onto a link of rate R. Propagation is d/s, the time for the signal to cross distance d at speed s. The code below computes end-to-end delay for store-and-forward links and ignores queuing and processing.
def end_to_end_delay(packet_bits, rate_bps, links, distance_m, prop_speed_mps):
transmission = packet_bits / rate_bps
propagation = distance_m / prop_speed_mps
return links * transmission + propagation
print(round(end_to_end_delay(12_000, 10_000_000, 3, 3_000_000, 2e8), 6)) # 0.0186Exercise
A 1,000-bit packet crosses 2 store-and-forward links of 1 Mbps each. The total cable length is 200 km, and the signal speed is 2e8 m/s. What is the end-to-end delay, ignoring queuing and processing?
Show answer
Transmission per link is 1000 / 1e6 = 0.001 s, so two links take 0.002 s. Propagation is 2e5 / 2e8 = 0.001 s. The total is 0.003 s (3 ms).