Salta al contenuto
Note per Studenti Circuit Switching and Packet Switching Report

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 n(n−1)/2n(n-1)/2 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 NN links (hops) between sender and receiver, propagation time tpt_p per link, switching time tst_s per node, a message of MM bits and bitrate RR: TCS=3 N tp+N ts+MR.T_{CS}=3\,N\,t_p+N\,t_s+\frac MR.

Why: the setup request crosses NN links (N tpN\,t_p) and at each node the switch is configured (N tsN\,t_s); the confirmation comes back (N tpN\,t_p); then data start, and after the transmission time M/RM/R the last bit still has to propagate across NN links (N tpN\,t_p): three crossings in total. There is no store-and-forward: after setup the bits flow like in a pipe, so M/RM/R appears only once.

Example. N=4N=4 links, tp=1t_p=1 ms, ts=0.5t_s=0.5 ms, M=1M=1 Mbit, R=10R=10 Mbit/s. Three crossings 3Ntp=3⋅4⋅1=123Nt_p=3\cdot4\cdot1=12 ms; switching Nts=4⋅0.5=2Nt_s=4\cdot0.5=2 ms; transmission M/R=106/107=0.1M/R=10^{6}/10^{7}=0.1 s =100=100 ms (convert to seconds before adding). Total TCS=12+2+100=114T_{CS}=12+2+100=114 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 MM bits split into KK packets, each with a header of HH bits (so packets of M/K+HM/K+H bits), NN equal links of bitrate RR and propagation tpt_p, no queues or processing: TPS=N tp+(N+K−1) M/K+HR.T_{PS}=N\,t_p+(N+K-1)\,\frac{M/K+H}{R}.

Why: the first packet crosses NN links in series and at each hop must be retransmitted in full: NN transmission times tpkt=M/K+HRt_{pkt}=\frac{M/K+H}{R}. The other K−1K-1 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 N tpkt+(K−1) tpktN\,t_{pkt}+(K-1)\,t_{pkt}, plus the propagation N tpN\,t_p.

The number of packets KK 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 (K HK\,H extra bits).

Formula (optimal number of packets). Expanding, (N+K−1)(M/K+H)=M+(N−1)MK+(N−1)H+KH(N+K-1)(M/K+H)=M+(N-1)\frac MK+(N-1)H+KH; differentiating with respect to KK and setting to zero: −(N−1)MK2+H=0-(N-1)\frac M{K^2}+H=0, hence Kopt=(N−1) MH.K_{opt}=\sqrt{\frac{(N-1)\,M}{H}}.

Step by step: of the four addends, MM and (N−1)H(N-1)H do not depend on KK and vanish in the derivative; what is left is (N−1)MK(N-1)\frac MK (decreases with KK: smaller packets, less waiting at each hop) and KHKH (grows with KK: more headers). It is a minimum (second derivative 2(N−1)MK3>0\frac{2(N-1)M}{K^3}>0). At the optimum the two terms are equal, (N−1)MK=KH(N-1)\frac MK=KH: waiting cost and header cost balance. Since KK is an integer, try the two nearest integers and keep the smaller TT.

Example. Same N=4N=4, tp=1t_p=1 ms, M=1M=1 Mbit, R=10R=10 Mbit/s, header H=400H=400 bit: Kopt=3⋅106/400=86.6K_{opt}=\sqrt{3\cdot10^{6}/400}=86.6. With K=87K=87: packet of M/K+H=11 494+400=11 894M/K+H=11\,494+400=11\,894 bit, transmission time 11 894/107=1.189411\,894/10^{7}=1.1894 ms, number of times N+K−1=90N+K-1=90, so TPS=4+90⋅1.1894=111.05T_{PS}=4+90\cdot1.1894=111.05 ms. Other values: K=1K=1 gives 404404 ms; K=1000K=1000 gives 144144 ms; K=100K=100 gives 111.12111.12 ms. The minimum is flat near the optimum. Here PS (111.05111.05 ms) beats CS (114114 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 11 Mbit/s link serves users who, when transmitting, use 100100 kbit/s but are active only 10 %10\,\% of the time. With circuits at most 1000/100=101000/100=10 users can be admitted (capacity is reserved even when they are silent). With packets one can connect e.g. 3535. If users are independent and each is active with probability p=0.1p=0.1, the number of active users is binomial with parameters 3535 and 0.10.1, mean 35⋅0.1=3.535\cdot0.1=3.5. The link is congested (queues form) only if more than 1010 are active together: P=∑k=1135(35k)0.1k0.935−k=4.2⋅10−4P=\sum_{k=11}^{35}\binom{35}{k}0.1^k0.9^{35-k}=4.2\cdot10^{-4}, 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: TCS=3 N tp+N ts+MRT_{CS}=3\,N\,t_p+N\,t_s+\dfrac MR, with NN links, tpt_p propagation, tst_s switching per node, MM bits, RR bitrate. Three crossings (setup, confirmation, last bit); M/RM/R appears once, as there is no store-and-forward.
    • Example: N=4N=4, tp=1t_p=1 ms, ts=0.5t_s=0.5 ms, M=1M=1 Mbit, R=10R=10 Mbit/s: 12+2+100=11412+2+100=114 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: TPS=N tp+(N+K−1)M/K+HRT_{PS}=N\,t_p+(N+K-1)\dfrac{M/K+H}{R}, with MM bits split into KK packets of M/K+HM/K+H bits. The first needs NN transmission times, the others follow in pipeline.
  • Optimum: Kopt=(N−1)MHK_{opt}=\sqrt{\dfrac{(N-1)M}{H}}. More packets cut the wait at each hop but add headers.
    • Example: N=4N=4, M=1M=1 Mbit, H=400H=400 bit: Kopt=86.6K_{opt}=86.6; with K=87K=87: TPS≈111.05T_{PS}\approx111.05 ms; with K=1K=1: 404404 ms. PS beats CS (114114 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: 11 Mbit/s link, users of 100100 kbit/s active 10 %10\,\% of the time: 1010 users with circuits, 3535 with packets, with probability 4.2⋅10−44.2\cdot10^{-4} that more than 1010 are active together.

Typical mistakes:

  • counting M/RM/R NN times in circuit switching;
  • forgetting the KK headers in packet switching;
  • giving dedicated resources to a virtual circuit, or a setup to datagram.

Teoria collegata