Introduction

A network is a mesh of links and switches, and switching is the way data from one link is moved onto the next on its way to the destination. There are two fundamentally different answers. Circuit switching reserves a path and a fixed share of every link on it before any data flows, as the telephone network did. Packet switching reserves nothing: data is cut into packets, each packet is stored at every switch and forwarded when the next link is free.

Packet switching itself comes in two forms. In a datagram network (the Internet's IP layer) every packet carries the full destination address and is forwarded independently. In a virtual-circuit network a connection is set up first, the switches on the path keep state for it, and packets carry only a short circuit label.

The choice decides the delay formula, the use of capacity, the amount of state in switches, and what happens when a switch fails. The calculations are delay formulas (circuit set-up, message switching, packet pipelining, optimal packet size); the rest is comparison statements.

Prerequisites

  • Layering, OSI and TCP/IP Reference Models: packets, headers and the network layer.
  • Transmission delay L/RL/R (time to push LL bits onto a link of rate RR) and propagation delay d/vd/v (time for a bit to travel distance dd at signal speed vv).

Core concepts

Circuit switching

A circuit goes through three phases: set-up (signalling reserves a channel on every link of the path), data transfer, and teardown. On each link the reserved share is either a frequency band (FDM) or a time slot in every frame (TDM). With TDM, a link of rate RR divided into nn slots gives each circuit a rate R/nR/n.

Properties: guaranteed constant rate and delay once set up; no per-packet header; bits flow through switches without being stored; capacity reserved for a circuit is wasted while that circuit is silent; set-up time is paid before the first bit moves.

Message switching

The whole message is received at each switch, stored, then sent on. No reservation, no splitting. A long message occupies each link for its full transmission time, and the next link cannot start until the last bit has arrived. It is mainly a reference point for showing why packets are better.

Packet switching

The message is cut into packets of bounded size, each with a header. Every switch performs store-and-forward: it must receive the whole packet (to check it and read its header) before it starts sending it on. Because packets are small, different packets are on different links at the same moment, which is pipelining. Links are shared on demand (statistical multiplexing); when packets arrive faster than a link can send them, they wait in a queue, and a full buffer means loss.

Datagram versus virtual circuit

IssueDatagram (for example IP)Virtual circuit (for example ATM, MPLS)
Set-up before dataNoneRequired
Address in each packetFull destination addressShort VC identifier, local to each link
State in switchesNone per flow (only a routing table)One entry per VC passing through
Routing decisionFor every packetOnce, at set-up
Order of arrivalMay be reorderedIn order along the fixed path
Effect of a switch failurePackets reroute; only queued packets lostEvery VC through that switch is broken
Quality of service and congestion controlHardEasier: resources can be reserved at set-up

Label swapping. A VC identifier has meaning only on one link. Each switch has a table mapping (incoming interface, incoming VC number) to (outgoing interface, outgoing VC number) and rewrites the label as it forwards. This keeps labels short and lets each switch choose free numbers on its own links.

Incoming interfaceIncoming VCOutgoing interfaceOutgoing VC
112322
263118
37217

A packet arriving on interface 1 with label 12 leaves on interface 3 with label 22.

Virtual circuit is different from circuit switching. A virtual circuit fixes the path but reserves nothing by default: packets are still stored and forwarded and still queue. Circuit switching reserves capacity, so there is no queueing inside the network.

How it works: the three timelines

Take three links in series (host A, routers R1 and R2, host B), each of rate RR, with propagation delay ignored. The message is 3 packets of the same size, each needing 1 ms to transmit.

  • Message switching: the whole message (3 ms of transmission) crosses each link in turn. Last bit at B at 3×3=93 \times 3 = 9 ms.
  • Packet switching: packet 1 reaches B at 3 ms; packets 2 and 3 follow 1 ms apart. Last bit at B at 5 ms.
  • Circuit switching: after a set-up phase (take 2 ms here), bits stream through the switches without being stored, so the 3 ms of data reaches B at 2+3=52 + 3 = 5 ms.
Three panels side by side, each with four vertical time lines labelled A, R1, R2, B and time increasing downward in milliseconds. Panel Circuit: a set-up exchange from 0 to 2 ms, then one band of data leaving A from 2 to 5 ms and arriving at B by 5 ms. Panel Message: one block of 3 ms crossing link A to R1 from 0 to 3, R1 to R2 from 3 to 6, R2 to B from 6 to 9 ms. Panel Packet: packets 1, 2, 3 of 1 ms each, pipelined, with packet 3 reaching B at 5 ms.
Figure 1. Circuit, message and packet switching over three links: 3 ms of data arrives at 5 ms (circuit, after 2 ms set-up), 9 ms (message) and 5 ms (packets).

Mathematical explanation

Notation: NN links in series (so N−1N - 1 intermediate switches), each of rate RR bit/s and propagation delay tpt_p; a message of MM bits; packets of LL bits each (header included), PP packets in all. Processing and queueing are taken as zero unless a question says otherwise.

Circuit switching. After set-up time tst_s, the message is pushed once at the circuit rate RcR_c (for example R/nR/n for an nn-slot TDM link) and the bits propagate across all links:

Tcircuit=ts+MRc+Ntp.T_{\text{circuit}} = t_s + \frac{M}{R_c} + N t_p .

Message switching. Each of the NN links carries the full message after the previous link has finished:

Tmessage=NMR+Ntp.T_{\text{message}} = N \frac{M}{R} + N t_p .

Packet switching (store-and-forward, pipelined). The first packet needs NN transmission times to reach the destination; each later packet arrives one transmission time after the one before it:

Tpacket=(N+P−1)LR+Ntp.T_{\text{packet}} = (N + P - 1) \frac{L}{R} + N t_p .

Proof sketch: with equal link rates, packet ii (counting from 1) finishes on link jj at time (i+j−1)L/R(i + j - 1) L/R plus propagation, because link jj is busy with packet i−1i - 1 until (i+j−2)L/R(i + j - 2)L/R and receives packet ii from link j−1j - 1 at the same moment. Set i=Pi = P and j=Nj = N.

Optimal packet size. The expression below assumes every packet, including the last, is padded to pp payload bits, so every packet has p+hp+h bits. An unpadded last packet requires its actual length and packet-by-packet timing. Restrict payload to the allowed integer range, normally 1≤p≤M1\le p\le M. If a message of MM payload bits is cut into packets carrying pp payload bits plus an hh-bit header, then P=⌈M/p⌉P = \lceil M/p \rceil and

T(p)=(⌈Mp⌉+N−1)p+hR+Ntp.T(p) = \left(\left\lceil \frac{M}{p} \right\rceil + N - 1\right)\frac{p + h}{R} + N t_p .

Small packets pipeline well but pay many headers; large packets pay few headers but pipeline badly. Ignoring the ceiling and differentiating (M/p+N−1)(p+h)(M/p + N - 1)(p + h) gives an interior stationary minimum for N>1N>1, h>0h>0 at

p∗=MhN−1.p^{*} = \sqrt{\frac{M h}{N - 1}} .

For this padded model, p∗p^* is a candidate/guide, not a substitute for the feasible integer search: evaluate allowed payloads (or packet-count breakpoints) and boundaries; if p∗p^* exceeds the maximum, test that boundary. If p∗p^* is feasible and M/p∗M/p^* is an integer, it attains the continuous lower bound. For N=1N=1, use one packet; for h=0h=0, there is no positive interior stationary minimum. An unpadded last packet requires its actual length in a packet-by-packet calculation.

Statistical multiplexing. If nn users each are active independently with probability qq, the number active is binomial, and the chance that more than cc are active at once is ∑j=c+1n(nj)qj(1−q)n−j\sum_{j=c+1}^{n} \binom{n}{j} q^j (1-q)^{n-j}.

Worked examples

Example 1: a TDM circuit

A file of 1,000,000 bits is sent over a circuit on links of 2.048 Mbps, each divided by TDM into 32 slots; set-up takes 250 ms; propagation is ignored. Circuit rate 2.048×106/32=64,0002.048 \times 10^6 / 32 = 64{,}000 bit/s. Transfer time 106/64,000=15.62510^6 / 64{,}000 = 15.625 s. Total 0.25+15.625=15.8750.25 + 15.625 = 15.875 s. The answer does not depend on the number of links, because the bits are not stored at switches.

Example 2: message switching against packet switching

A 1,200,000-bit message crosses 3 links of 1 Mbps, propagation ignored. Message switching: 3×1.2=3.63 \times 1.2 = 3.6 s. Packet switching with 1000 packets of 1200 bits (headers ignored): (3+1000−1)×1.2(3 + 1000 - 1) \times 1.2 ms =1.2024= 1.2024 s. Pipelining makes the total close to one transmission of the message plus two packet times.

Example 3: optimal packet size

A 30,000-bit payload crosses N=4N = 4 links of 1 Mbps; every packet has a 100-bit header; propagation ignored. Then p∗=30,000×100/3=1000p^{*} = \sqrt{30{,}000 \times 100 / 3} = 1000 bits, giving 30 packets of 1100 bits and T=33×1.1=36.3T = 33 \times 1.1 = 36.3 ms.

Payload per packet pp (bits)PacketsT(p)T(p) (ms)
5006037.8
10003036.3
15002036.8
20001537.8
30,000 (one packet)1120.4

Because p∗=1000p^{*} = 1000 divides 30,000 exactly, the formula's optimum is also the best integer packet size.

Example 4: why packet switching admits more users

A 1 Mbps link; each user sends at 100 kbps while active and is active 10% of the time, independently. Circuit switching can admit 10 users. With packet switching and 40 users, the probability that more than 10 are active at once is about 0.0015, so 40 users share the link with rare overload.

Example 5: label swapping

Using the table in "Core concepts", a packet that enters on interface 3 with VC 7 leaves on interface 2 carrying VC 17. The next switch looks up (its incoming interface, 17), not 7.

Three 1000-bit packets cross two links, 1 Mbps then 0.5 Mbps (1 ms and 2 ms per packet), with propagation ignored. Packet 1 reaches the router at 1 ms and the destination at 3 ms. Packet 2 reaches the router at 2 ms but waits until the slow link is free at 3 ms, so it arrives at 5 ms; packet 3 arrives at 7 ms. With all packets ready at the source, the pipelined formula becomes

T=∑j=1NLRj+(P−1)Lmin⁡jRj,T = \sum_{j=1}^{N} \frac{L}{R_j} + (P - 1)\frac{L}{\min_j R_j},

one packet's time across every link plus one slowest-link time for each further packet: 3+2×2=73 + 2 \times 2 = 7 ms. The order of the links does not matter (slow link first also gives 7 ms), and with equal rates the formula reduces to (N+P−1)L/R(N + P - 1)L/R.

Important properties and observations

  • Store-and-forward is per packet, not per bit. A switch cannot start sending a packet until it has the last bit. This is why message switching multiplies the full message time by the number of links.
  • Equal link rates assumed. (N+P−1)L/R(N + P - 1)L/R needs equal rates. With different rates, simulate packet by packet: the slowest link sets the spacing between arrivals.
  • Header overhead cuts both ways. Splitting into more packets always adds header bits; the gain comes only from pipelining, and it vanishes when N=1N = 1 (one link: one big packet is best).
  • Circuit switching has no per-hop transmission term. Its delay is set-up plus one transmission at the circuit rate plus propagation.
  • Virtual circuits still queue. Fixed path, in-order delivery, but no reserved capacity unless the set-up also reserves it.

Common misconceptions.

  • "Packet switching is always faster." Not for one link with headers, and not against a circuit whose set-up time is negligible compared with the transfer.
  • "A virtual-circuit number identifies the connection end to end." It is local to one link and is rewritten at every switch.
  • "Datagram networks keep no state." Routers keep routing tables, but no per-connection state.

GATE examination perspective

  • Pipelined packet delay. Count links, not routers: NN links means N−1N - 1 routers. Use (N+P−1)L/R(N + P - 1)L/R plus NN propagation delays, and include the header in LL.
  • Optimal packet size. Write T(p)T(p), then test the candidate values given in the problem rather than trusting the square-root formula when M/pM/p is not an integer.
  • Circuit set-up. The set-up time is added once; the TDM slot share divides the rate.
  • Comparison statements. Datagram: no set-up, independent routing, reordering possible, robust to failure. VC: set-up, per-VC state, in-order, failure breaks circuits.
  • Message versus packet. Message switching multiplies the full message time by the number of links.

Summary

Sources

  1. J. F. Kurose, K. W. Ross, Computer Networking: A Top-Down Approach, 8th ed., Pearson, 2021: Sections 1.3.1 (Packet Switching) and 1.3.2 (Circuit Switching).
  2. A. S. Tanenbaum, D. J. Wetherall, Computer Networks, 5th ed., Pearson, 2011: Section 2.6.5 (Switching), Sections 5.1.1 (Store-and-Forward Packet Switching), 5.1.3 and 5.1.4 (connectionless and connection-oriented service) and 5.1.5 (Comparison of Virtual-Circuit and Datagram Networks).
  3. B. A. Forouzan, Data Communications and Networking, 5th ed., McGraw-Hill, 2013: Chapter 8 (Switching).

Next steps