Difference between a L2 Switch and a Repeater
While a repeater is a physical layer device operating on electromagnetic and optical signals, a L2 Switch is a data link layer device that operates on L2 frames.
Also a repeater is mainly used to extend the length of a LAN segment or to increase the number of nodes in a LAN, while a L2 Switch is much more powerful and is actually used to intelligently transfer frames between the source and destination nodes of a LAN.
If a repeater is used to connect two segments of a LAN, then both segments form a single collision domain, as the repeater forwards every frame transmitted on one segment, unconditionally onto the other segment. On the other hand, if a L2 Switch is used to connect multiple segments of a LAN, then it helps to keep each segment as a separate collision domain. If nodes inside a same segment communicate with each other, then the traffic is confined to the segment by the L2 Switch. Only traffic between nodes across segments are forwarded across ports of a L2 Switch. This is illustrated in the diagram given below:
Another difference is, though a Repeater comes with number of ports, all the ports are of the same speed, while a L2 Switch can have ports with different speeds. Additionally a single port in a L2 Switch is capable of working in different speeds based on the operating speed of the peer node connected to the port. Since L2 Switch supports multiple interface types, it can be even used to connect segments of a LAN with different technologies (e.g. a Ethernet segment and a Token ring segment).
Difference between a L2 Switch and a Bridge (Is there any?)
The answer is quite simple. A L2 Switch and a Bridge are not different and are one and the same. It is just that there are two terms for the same functionality.
Some time back, when internet was invented, the frame forwarding functionality of a L2 Switch was actually implemented in software and the device was known as a Bridge. Later when the same functionality was implemented in dedicated hardware, it was termed as a L2 Switch.
Additionally, in those days, a Bridge used to be one more device on the Ethernet bus just like any other device on the shared bus, with end nodes and the bridge tapping onto a common bus or connected to a hub. The Bridge was mainly used to connect different segments of a LAN in order to extend the LAN and also to keep each segment of a LAN as a separate collision domain. See the diagram given below that illustrates how a bridge was used to connect two segments of the same LAN.
With the advent of dedicated hardware in the form of L2 Switches, end nodes could directly connect to ports of the L2 Switch through a dedicated point to point connection instead of tapping into a shared bus. See the diagram below that illustrates how a L2 Switch was seen:
This was perceived as one more difference between the original bridge and the L2 Switch.
All these differences no longer exist and now both the bridge and a L2 switch are functionally one and the same.
Difference between a L2 Switch and a L3 Router
Both L2 Switch and L3 Router are basically packet switches and both switch data based on a small header present in the data unit. The difference is that an L2 switch is a data link layer packet switch and switches data based on frame headers, whereas a L3 Router is a network layer packet switch and switches data based on the network header. Terminology wise, the functionality of a L2 Switch is typically known as Switching or Bridging and the functionality of a Router is typically known as Routing.
Also a L2 Switch is used to interconnect different segments of a same LAN or WAN, whereas a L3 Router is used to interconnect different networks or sub-networks.
While a L2 switch needs to implement only the physical and data link layer functionality, a L3 Router needs to implement the physical, data link layer and the network layer functionality. Due to this additional overhead, L2 Switches are typically faster than L3 Routers.
Another difference between a L2 Switch and a L3 Router is with respect to treatment of broadcast frames. While a L2 Switch forwards broadcast frames, a L3 Router does not forward broadcast frames, thereby limiting flooding of broadcasts over the network.
Typically, L2 Switches are used within a LAN, to extend the number of hosts in a LAN and also to reduce the collision domains in a LAN, whereas a L3 Router is used to connect the LAN to external networks.