Circuit Switching and Packet Switching
In questa pagina 5
The problem
A network cannot join every pair of nodes with a cable (a mesh needs links: Network Types and TopologiesNetworks are classified by extent (BAN, WLAN, LAN, MAN, WAN, WSN), by transmission medium (air, fibre, copper, visible light) and by topology: bus (shared medium, collisions), star (central node, bottleneck), ring (each node forwards to the next), mesh (a direct link between every pair: n(n-1)/2 links). The choice depends on reliability, scalability, protocol and physical medium.Network Types and Topologies →). The intermediate nodes, the switches (or routers), must therefore switch: connect an incoming link to an outgoing one. The switching paradigm is the rule used to do it. There are three: circuit, packet (with two variants: virtual circuit and datagram) and, historically, message (the whole message is received and then forwarded: the limit case of packet switching with a single packet).
Circuit switching (CS)
Definition (circuit-switched network). A physical connection between two nodes is created before communication: once established, a line (a circuit) is reserved for the two parties for the whole duration. Example: the old telephone network.
Phases: setup (the request crosses the nodes reserving resources; the confirmation comes back), transfer (data flow on the reserved circuit, with no address headers and no queues), teardown.
Formula (delivery time in CS). With links (hops) between sender and receiver, propagation time per link, switching time per node, a message of bits and bitrate :
Why: the setup request crosses links () and at each node the switch is configured (); the confirmation comes back (); then data start, and after the transmission time the last bit still has to propagate across links (): three crossings in total. There is no store-and-forward: after setup the bits flow like in a pipe, so appears only once.
Example. links, ms, ms, Mbit, Mbit/s. Three crossings ms; switching ms; transmission s ms (convert to seconds before adding). Total ms.
Pros: guaranteed performance, no loss from congestion. Cons: the resource is dedicated even when nobody transmits (low utilization), costly, adaptive routing is hard, switches are very complex, and the setup time weighs on short messages.
Packet switching (PS)
Definition (packet-switched network). The message is divided into smaller units, the packets; intermediate nodes are store-and-forward: the node stores the packet (receives it entirely) and then decides to which node to forward it. No confirmation that a connection is established is needed.
Datagram approach
- No setup at the network layer; routers keep no state about end-to-end connections: there is no notion of "connection" at the network layer.
- Each packet carries the global destination address (and the source) and is forwarded according to it: a header (overhead) is needed.
- Packets between the same source and destination may follow different paths (and arrive out of order).
- Resources are used statistically: on average it works, sometimes it goes badly (queues, losses).
Formula (delivery time in datagram PS). A message of bits split into packets, each with a header of bits (so packets of bits), equal links of bitrate and propagation , no queues or processing:
Why: the first packet crosses links in series and at each hop must be retransmitted in full: transmission times . The other packets follow one transmission time apart (pipeline: while a packet is on the second link the next one is already on the first). The last arrives after , plus the propagation .
The number of packets has two opposite effects: more packets means smaller packets and so less time wasted waiting for a packet to be fully received before forwarding it, but more headers ( extra bits).
Formula (optimal number of packets). Expanding, ; differentiating with respect to and setting to zero: , hence
Step by step: of the four addends, and do not depend on and vanish in the derivative; what is left is (decreases with : smaller packets, less waiting at each hop) and (grows with : more headers). It is a minimum (second derivative ). At the optimum the two terms are equal, : waiting cost and header cost balance. Since is an integer, try the two nearest integers and keep the smaller .
Example. Same , ms, Mbit, Mbit/s, header bit: . With : packet of bit, transmission time ms, number of times , so ms. Other values: gives ms; gives ms; gives ms. The minimum is flat near the optimum. Here PS ( ms) beats CS ( ms) because CS pays the setup.
Grafico interattivo: Delivery time T_PS (seconds) versus number of packets K, with N = 4, M = 1 Mbit, H = 400 bit, R = 10 Mbit/s, tp = 1 ms: minimum near K = 87 (about 0.111 s); at K = 1 it is 0.404 s
If the links have different bitrates the formula no longer holds: follow the packet link by link and account for queues.
Virtual circuit (VC) approach
A middle way between circuit and datagram:
- as in packet switching, the message is divided into small units (in ATM they are called cells);
- as in circuit switching, communication needs three phases: setup, data transfer, teardown; it is a dedicated logical connection, without dedicated resources;
- the global address is needed only in the setup phase, not for every packet;
- each cell carries a short local identifier (VC identifier) that changes at each hop;
- all packets follow the same path, in order.
Virtual circuit versus datagram
| Feature | Virtual circuit | Datagram |
|---|---|---|
| Setup | required | not required |
| Addressing (overhead) | each packet has a (short) VC identifier | each packet has full source and destination addresses |
| State information (router memory) | each VC takes an entry in the table | the network keeps no connection state |
| Routing (delay) | path chosen at setup, all packets follow it | each packet routed independently |
| Router failure | all VCs through it are lost | no consequence, except packets lost during the failure |
| Congestion control (QoS) | easy if space can be allocated per VC | complex |
Circuit versus packet
| Circuit | Packet | |
|---|---|---|
| Line resource | dedicated | shared |
| Performance | guaranteed | average (statistical) |
| Cost | high | lower |
| Adaptive routing | hard | easy |
| Switching device | very complex | simpler |
| Reliability | high | higher |
| Utilization | low | higher |
Example (why packets use links better). A Mbit/s link serves users who, when transmitting, use kbit/s but are active only of the time. With circuits at most users can be admitted (capacity is reserved even when they are silent). With packets one can connect e.g. . If users are independent and each is active with probability , the number of active users is binomial with parameters and , mean . The link is congested (queues form) only if more than are active together: , negligible. This is the statistical advantage of packet switching with bursty traffic, the historical reason for its adoption (History and Structure of the InternetThe Internet grew from ARPANET (1969), a packet-switched network; TCP/IP (1972-77) moved error control from the network nodes to the end hosts, which is what makes it scalable; today it is a network of networks made of local, regional and national ISPs that exchange traffic by peering at IXPs, with IANA, IETF, IRTF, IAB and ISOC coordinating addresses and standards.History and Structure of the Internet →).
The devices that perform switching are described in Network Devices - Hub, Switch and RouterDevices that interconnect networks differ by the highest layer of the stack they read. Hub (layer 1): a repeater, regenerates the signal and sends it out of all ports, all stations share the capacity. Bridge and switch (layer 2): read the MAC address and forward only to the right port, learning the table (FDB) from source addresses. Router (layer 3): reads the IP address and joins independent networks (internetwork). Switches and bridges isolate traffic and are plug and play; the router gives optimal routing but must be configured.Network Devices - Hub, Switch and Router →. The queueing delay when several packets reach a router together is modelled in Introduction to Queueing TheoryA queueing system is made of an arrival process (Poisson, rate lambda), a queue and one or more servers with service rate mu. Offered load G = lambda/mu, load factor rho = lambda/(m mu): the system is stable only if rho < 1, and then the throughput is lambda (otherwise m mu). Little's law E[x] = lambda E[s] holds for any discipline. M/M/1: E[x] = rho/(1-rho), E[s] = (1/mu)/(1-rho), E[w] = (rho/mu)/(1-rho). With deterministic service (M/D/1, a special case of Pollaczek-Khinchin): E[w] = rho/(2 mu (1-rho)). The delay grows without bound as rho tends to 1.Introduction to Queueing Theory →.
Versione ripasso
Three paradigms.
- Circuit (CS): physical connection reserved before communication (telephone network): setup, transfer, teardown.
- Datagram packet switching: packets with a global address, store-and-forward, independent paths.
- Virtual circuit (VC): packets as in datagram, but with three phases as in circuit; logical connection without dedicated resources.
Circuit.
- Setup reserves resources along the nodes and the confirmation returns; then data flow with no address headers.
- Formula: , with links, propagation, switching per node, bits, bitrate. Three crossings (setup, confirmation, last bit); appears once, as there is no store-and-forward.
- Example: , ms, ms, Mbit, Mbit/s: ms.
- Pros: guaranteed performance, no loss from congestion. Cons: resource dedicated while idle, high cost, adaptive routing hard.
Datagram.
- Store-and-forward: each node receives the whole packet before forwarding. No setup, no router state, full addresses in every packet, different paths and possible reordering, statistical resources.
- Formula: , with bits split into packets of bits. The first needs transmission times, the others follow in pipeline.
- Optimum: . More packets cut the wait at each hop but add headers.
- Example: , Mbit, bit: ; with : ms; with : ms. PS beats CS ( ms) because CS pays the setup.
- With different bitrates on the links the formula fails: follow the packet link by link and consider queues.
Virtual circuit.
- The global address is used only at setup; each packet carries a local identifier that changes at each hop. All packets follow the same path, in order.
- Router failure: all VCs through it fail.
Comparison.
- VC versus datagram: setup required versus none; one state entry per VC in routers versus no state; congestion control and QoS easy in VC.
- Circuit versus packet: dedicated versus shared line, guaranteed versus average performance, high versus lower cost, low versus high utilization.
- Statistical example: Mbit/s link, users of kbit/s active of the time: users with circuits, with packets, with probability that more than are active together.
Typical mistakes:
- counting times in circuit switching;
- forgetting the headers in packet switching;
- giving dedicated resources to a virtual circuit, or a setup to datagram.