A Network Switch is a small hardware device in a network that connects multiple computers or devices within one Local Area Network (LAN). Switch filters and forwards data packets between different LAN devices (or computers). Network switches work at Layer two (Data Link Layer) of the OSI Model (Open Systems Interconnection Model).
In an Ethernet Local Area Network (LAN), a switch determines from the physical device address (Also known as Media Access Control or MAC Address) in each incoming message (data) frame, which output port to forward it to and out of. In a wide area packet-switched network such as the internet (refer the section 'Circuit-Switching and Packet-Switching), a switch determines from the IP address in each data (message) packet, which output port to use for the next part of its trip to the intended destination.
Various models of network switches support various numbers of connected devices (on a network). Most consumer-grade network switches provide either four or eight connections for Ethernet devices. Switches can be connected to each other in order to add progressively larger number of devices to a LAN, this method is called 'Daisy Chaining'.
Network switch appears nearly identical to network hub, but a switch usually contains more intelligence than a hub, and consequently a switch is more in cost than a hub. Switch is capable of inspecting the data packets and it can determine the source and the destination device of each packet, and depending on this information it can forward the data packets appropriately. Whereas, hub does not transport the data throughout the network with this much sophistication. By delivering the messages only to the intended (connected) device, a network switch conserves network bandwidth and consequently, usually offers better performance than a hub.
Circuit Switching and Packet Switching
Circuit-Switching: Network's paths can be utilised exclusively for a certain duration by two or more parties and then switched for use to another set of parties, this type of "switching" is known as Circuit-Switching and it is really a dedicated and continuously connected path for its duration of utilisation. An ordinary voice phone call usually utilises circuit-switching.
Packet-Switching: Using packet-switching, all network users can share the same paths at the same time and the particular route a data unit travels can be varied as conditions differ. In Packet-Switching, a message is divided into packets, and these packets are units of a certain number of bytes. The network address of the sender and of the destination are added to the (data) packet. Each network point looks at the packet to figure out where to send it next. The packets in the same message may travel different routes and may not arrive in the same order that they were sent. The packets in a message are collected and reassembled into the original message at the destination.
As explained above, a switch performs the layer 2, i.e. Data-link Layer function in the OSI communications model. It means, a switch simply looks at each data (or message) packet or data unit and determines from a physical address (MAC Address), which device a data unit is intended for and switches it out toward that device. However, in wide area networks such as the internet, the destination address requires a look-up in a routing table by a device known as a router. Some newer switches also perform routing functions (i.e., Layer 3 or the Network Layer functions in OSI communication model), and therefore, these type of switches are sometimes called IP Switches.
Hop Count and Latency
In a packet-switching network (such as internet), the journey a data packet takes from one intermediate point to another (such as router or switch) in the network is known as hop. On the internet or a network that uses TCP/IP, the number of hops a data packet has taken toward its destination is called the 'hop count'. Hop count is kept in the data packet header.
The time taken by switch to decide where to forward a data unit is known as Latency.