Network Devices - Hub, Switch and Router
In questa pagina 5
A real network is made of different segments (LANs) joined by different devices, e.g. three LANs connected by hubs, switches, bridges and a router toward the Internet. Each device is defined by the highest layer of the stack it implements (ISO-OSI Model and TCP-IP StackCommunication between two computers is too varied a problem (signals, errors, medium access, routing, flow control, data representation) for a single protocol, so it is divided into layers. The ISO/OSI model has 7 layers (physical, data link, network, transport, session, presentation, application); the TCP/IP stack merges the top three into one application layer, so it has 5. Each layer offers a service to the one above and talks only to its peer layer through PDUs; going down a header (PCI) is added: encapsulation. Addresses: MAC (link, local), IP (network, global), port (transport).ISO-OSI Model and TCP-IP Stack →): the higher it goes, the more it "understands" of the packet and the more decisions it can take.
Hub (layer 1, physical)
Definition (hub). Device working only at the physical layer: it has no link-layer (MAC) addresses. Physically it is a star, but it behaves as a repeater: it is a connection point and regenerates and retimes the original bit sequence (the signal is attenuated and distorted along the cable, hence beyond a certain length it must be regenerated).
- It does not filter: it does not know which port a frame must leave from, so it sends it out of all ports except the incoming one (broadcast). The frame is "kept" on the other ports and "discarded" by the stations it is not addressed to.
- All stations share the total capacity and only one station at a time can transmit; two simultaneous transmissions collide (medium access with CSMA/CD, LAN - Ethernet and Wi-FiA LAN covers a limited area and is defined by the IEEE 802.x family (802.3 Ethernet, 802.11 Wi-Fi), which splits the link layer into LLC and MAC. Ethernet is connectionless, with no flow control and no ACK; it uses 1-persistent CSMA/CD; the frame is 64 to 1518 bytes (6-byte addresses, type/length, data 46-1500, 4-byte CRC) and the 64 B minimum comes from t_F >= 2 tau_p. From 10 Mbit/s on coax up to 10 Gbit/s on fibre, with full-duplex switches removing collisions. Wi-Fi (802.11) uses CSMA/CA, has BSS (with access point) and ad hoc modes, EBSS with a distribution system, adapts its bitrate to the SNR, and has hidden and exposed terminal problems, partly solved by RTS/CTS and NAV.LAN - Ethernet and Wi-Fi →).
Example. stations on a Mbit/s hub: there is a single channel. If all transmit all the time, each gets on average Mbit/s (capacity split equally: the shared link of Network Performance AnalysisNetwork performance is measured by traffic metrics (bitrate R0, the link maximum; throughput S <= R0, data delivered successfully; goodput at the application layer), delay (end-to-end d = d_proc + d_queue + d_trans + d_prop with d_trans = L/R and d_prop = d/v; jitter; RTT), pipe capacity (BDP = rate times delay) and reliability (PER, PDR, PLR). The throughput of a path is that of its bottleneck link, the minimum bitrate, remembering that shared links split their capacity.Network Performance Analysis →), and two pairs and cannot communicate in parallel. Moreover, since the medium is shared, the efficiency limits of random access apply (Performance of Multiple Access ProtocolsWith Poisson arrivals, the success probability of a frame is the probability that no other frame arrives in the vulnerable time: pure ALOHA P_S = e^(-2G), throughput S = G e^(-2G) with maximum 1/(2e) = 0.18 at G = 1/2; slotted ALOHA S = G e^(-G) with maximum 1/e = 0.37 at G = 1; non-persistent CSMA with a = tau_p/t_F: S = G e^(-aG) / (G(1+2a) + e^(-aG)), which tends to 1 as a tends to 0 but collapses for large a, where slotted ALOHA is better. For TDMA (M/D/1) E[T] = t_F (N_u/2 + S N_u / (2(1-S)) + 1 + a) and for FDMA E[T] = t_F (N_u + S N_u / (2(1-S)) + a): FDMA is slower by t_F (N_u/2 - 1).Performance of Multiple Access Protocols →): the useful throughput is below Mbit/s even at maximum load.
Bridge (layer 2)
Definition (bridge). Data-link device (an "intelligent" hub) that splits the network into two subnetworks (LANs) to reduce traffic in each or for security, managing the flow between them.
Advantage: it reduces traffic on a segment: if the destination is not on the other side of the bridge, the bridge blocks the frame. It usually connects very few networks (typically two).
Switch (layer 2)
Definition (switch). Device working at the physical and link layers (a more flexible bridge). It has filtering capability: it checks the destination MAC address of each frame and decides which port to send it out of, using a local table called forwarding/filtering database (FDB), associating MAC addresses (48 bit: Data Link Layer and FramingThe data link layer (DLL) delivers a frame from a node to an adjacent node over a link. Services: framing, medium access (MAC) with 48-bit MAC addresses, flow control, error detection and correction. It splits into DLC (framing, error and flow control) and MAC (shared medium access). Framing delimits frames with a flag: byte-oriented protocols (8-bit flag, ESC) use byte stuffing, bit-oriented ones (flag 01111110) use bit stuffing, which inserts a 0 after every five consecutive 1s.Data Link Layer and Framing →) with ports.
The first tables were static: if a station was added or removed the table had to be edited by hand, so they were impractical. The solution is a dynamic table that builds itself, i.e. a learning switch:
- the destination address of the frame is used for the forwarding decision (table lookup);
- the source address is used to add or update table entries: "the station with this MAC sits behind the port the frame came from".
Forwarding rule for a frame arriving from port :
- learn: entry (source MAC );
- if the destination MAC is in the table with port : if discard (destination on the same segment), otherwise forward only on ;
- if the destination is not in the table or is broadcast (
FF:FF:FF:FF:FF:FF): forward on all ports except (flooding).
Example. A -port switch with on port 1, on 2, on 3 and an empty table.
| Frame | Action | Table afterwards |
|---|---|---|
| learn ; unknown flooding on ports 2 and 3 | ||
| learn ; known only port 1 ( sees nothing) | ||
| known only port 2 | unchanged | |
| learn ; known only port 1 |
Entries normally expire, so the table follows stations that change port. The switch works in full-duplex mode and is not a shared medium: several pairs of stations communicate in parallel and non-flooded frames do not reach those they do not concern (fewer collisions, more security).
Example. In the same scenario as the hub ( stations at Mbit/s) with a switch, and run in parallel, each at Mbit/s: Mbit/s overall. With flows between different pairs the hub stays at Mbit/s in total, the switch reaches .
Grafico interattivo: Overall capacity with k simultaneous flows between different pairs of stations on 100 Mbit/s ports: the hub stays at 100 Mbit/s (shared medium), the switch reaches 100*k (200 Mbit/s with k = 2)
The switch implements a different switching paradigm depending on how it forwards (circuit, packet with virtual circuit or datagram): see Circuit Switching and Packet SwitchingA switching node can connect input to output in three ways. Circuit switching sets up a dedicated physical connection first (telephone network), delivery time T = 3N t_p + N t_s + M/R. Datagram packet switching splits the message into K packets with a header, each routed independently with store-and-forward, T = N t_p + (N+K-1)(M/K+H)/R, with optimal K = sqrt((N-1)M/H). Virtual circuit has three phases (setup, data, teardown): a dedicated logical connection without dedicated resources, with a local identifier that changes at each hop.Circuit Switching and Packet Switching →.
Router (layer 3)
Definition (router). Device working at three layers (physical, link, network): it regenerates the signal (PHY), checks the source and destination physical addresses of the frame (DLL) and checks network addresses (network layer). It is the "gateway" of a network and interconnects independent networks forming an internetwork (INTERNET).
The router reads the destination IP address, consults its routing table to learn the next node, finds that node's MAC address with ARP (ARP - Address Resolution ProtocolTo place an IP datagram in a frame a node needs the MAC address of the next hop, obtained with ARP: a broadcast request (destination MAC FF:FF:FF:FF:FF:FF, carrying the sender's IP and MAC and the wanted IP) and a unicast reply with the wanted MAC, stored in the ARP cache; ARP always resolves the next hop (destination host or router), never the final destination, and since broadcasts do not leave the subnet a router can answer with its own MAC (proxy ARP).ARP - Address Resolution Protocol →) and builds a new frame for the next hop. It creates paths (routes) to send packets and is more sophisticated: it may have software to raise throughput (e.g. with a cache).
Comparison
| Hub | Bridge | Router | Switch | |
|---|---|---|---|---|
| Layer | 1 | 2 | 3 | 2 |
| Traffic isolation | no | yes | yes | yes |
| Plug and play | yes | yes | no | yes |
| Optimal routing | no | no | yes | no |
| "Intelligent" device | no | yes | yes | yes |
- Switch versus hub. The hub is a shared-medium device: it broadcasts data to all ports, one station transmits at a time. The switch is not shared, it sends a frame with known destination only to the right port.
- Switch versus bridge. The bridge connects fewer LANs (usually ) than the switch.
- Switch (hub) versus router. Switch and hub connect devices of the same network (they do not see IP addresses); the router connects different networks by looking at IP addresses. The router uses IP addresses, the switch MAC addresses, the hub looks at nothing (it is a repeater).
- Why the router is not plug and play: it needs network IP addresses assigned and routing tables (static or learned).
Versione ripasso
- Criterion. A device is told apart by the highest layer of the stack it reads (ISO-OSI Model and TCP-IP StackCommunication between two computers is too varied a problem (signals, errors, medium access, routing, flow control, data representation) for a single protocol, so it is divided into layers. The ISO/OSI model has 7 layers (physical, data link, network, transport, session, presentation, application); the TCP/IP stack merges the top three into one application layer, so it has 5. Each layer offers a service to the one above and talks only to its peer layer through PDUs; going down a header (PCI) is added: encapsulation. Addresses: MAC (link, local), IP (network, global), port (transport).ISO-OSI Model and TCP-IP Stack →): hub L1, bridge and switch L2, router L3.
- Hub (L1). No MAC. Regenerates bits and sends them out of all ports except the incoming one: no filtering. Shared capacity, one station at a time, otherwise collision (LAN - Ethernet and Wi-FiA LAN covers a limited area and is defined by the IEEE 802.x family (802.3 Ethernet, 802.11 Wi-Fi), which splits the link layer into LLC and MAC. Ethernet is connectionless, with no flow control and no ACK; it uses 1-persistent CSMA/CD; the frame is 64 to 1518 bytes (6-byte addresses, type/length, data 46-1500, 4-byte CRC) and the 64 B minimum comes from t_F >= 2 tau_p. From 10 Mbit/s on coax up to 10 Gbit/s on fibre, with full-duplex switches removing collisions. Wi-Fi (802.11) uses CSMA/CA, has BSS (with access point) and ad hoc modes, EBSS with a distribution system, adapts its bitrate to the SNR, and has hidden and exposed terminal problems, partly solved by RTS/CTS and NAV.LAN - Ethernet and Wi-Fi →).
- Hub example. 4 saturated stations on a 100 Mbit/s hub: Mbit/s each; and cannot run in parallel.
- Bridge (L2). Splits the network into two subnetworks and blocks frames that need not cross.
- Switch (L2), learning switch. Uses the FDB table (MAC port), built by itself:
- source MAC: adds or updates the entry "this MAC sits behind the incoming port";
- destination MAC: decides the forwarding.
- Rule for a frame from port : 1) learn (source MAC, ); 2) destination in the table with port : if discard, otherwise forward only on ; 3) destination unknown or broadcast
FF:FF:FF:FF:FF:FF: flooding on all ports except . - Learning example. 3-port switch, on 1, on 2, on 3, empty table:
| Frame | Action | Table afterwards |
|---|---|---|
| learn ; unknown: flooding on 2 and 3 | ||
| learn ; known: only port 1 |
- Full-duplex switch. Not shared: and in parallel, Mbit/s overall with 4 stations at 100 Mbit/s. Non-flooded frames do not reach unconcerned stations.
- Router (L3). Reads the destination IP, consults the routing table, finds the next hop's MAC with ARP and builds a new frame for that hop. Interconnects independent networks (internetwork).
- Comparison. Traffic isolation: hub no, others yes. Plug and play: all except the router, which needs IPs and tables. Optimal routing: only the router.
- Switch and hub versus router. They connect devices of the same network (the switch looks at MACs, the hub at nothing). The router connects different networks by looking at IPs.
- Typical mistakes: the switch looks at MACs, not IPs; the hub does not filter; on a hub two pairs cannot communicate in parallel.