0
0
Computer-networksComparisonBeginner · 4 min read

Bus vs Star vs Ring vs Mesh Topology: Key Differences and Uses

A bus topology connects all devices on a single cable, making it simple but prone to failure. A star topology links devices to a central hub, offering easy management and better fault tolerance. Ring topology connects devices in a circle for orderly data flow, while mesh topology connects every device to many others, maximizing reliability but increasing complexity and cost.
⚖️

Quick Comparison

Here is a quick overview comparing the four common network topologies based on key factors.

FactorBus TopologyStar TopologyRing TopologyMesh Topology
StructureSingle central cableCentral hub with spokesClosed loop ringEvery device connected to others
ReliabilityLow - cable failure affects allMedium - hub failure affects allMedium - one break can disruptVery high - multiple paths available
CostLow - less cablingMedium - hub and cablesMedium - cables in ringHigh - many cables and ports
PerformanceSlower with more devicesGood - hub manages trafficConsistent - token passingBest - direct device links
ScalabilityLimited - cable lengthGood - add devices to hubLimited - ring sizeComplex - many connections
⚖️

Key Differences

Bus topology uses a single backbone cable to which all devices connect. It is simple and cheap but if the main cable breaks, the entire network fails. It also suffers from data collisions as devices share the same line.

Star topology connects each device to a central hub or switch. This makes it easy to add or remove devices without affecting others. However, if the hub fails, the whole network goes down.

Ring topology arranges devices in a circular path where data travels in one direction. It avoids collisions by passing a token but a single break can stop communication unless there is a backup ring. Mesh topology connects devices with multiple links, providing high fault tolerance and direct paths for data. This makes it reliable but expensive and complex to set up.

⚖️

Code Comparison

Here is a simple Python example simulating message passing in a bus topology where all devices listen on the same line.

python
class BusTopology:
    def __init__(self):
        self.devices = []

    def connect(self, device):
        self.devices.append(device)

    def broadcast(self, sender, message):
        for device in self.devices:
            if device != sender:
                device.receive(message)

class Device:
    def __init__(self, name):
        self.name = name

    def receive(self, message):
        print(f"{self.name} received: {message}")

bus = BusTopology()
d1 = Device('Device1')
d2 = Device('Device2')
d3 = Device('Device3')

bus.connect(d1)
bus.connect(d2)
bus.connect(d3)

bus.broadcast(d1, 'Hello from Device1')
Output
Device2 received: Hello from Device1 Device3 received: Hello from Device1
↔️

Star Topology Equivalent

This Python example simulates message passing in a star topology where a central hub relays messages between devices.

python
class StarTopology:
    def __init__(self):
        self.hub = Hub()

    def connect(self, device):
        self.hub.add_device(device)

    def send(self, sender, message):
        self.hub.relay(sender, message)

class Hub:
    def __init__(self):
        self.devices = []

    def add_device(self, device):
        self.devices.append(device)

    def relay(self, sender, message):
        for device in self.devices:
            if device != sender:
                device.receive(message)

class Device:
    def __init__(self, name):
        self.name = name

    def receive(self, message):
        print(f"{self.name} received: {message}")

star = StarTopology()
d1 = Device('Device1')
d2 = Device('Device2')
d3 = Device('Device3')

star.connect(d1)
star.connect(d2)
star.connect(d3)

star.send(d1, 'Hello from Device1')
Output
Device2 received: Hello from Device1 Device3 received: Hello from Device1
🎯

When to Use Which

Choose bus topology for small, simple networks with minimal devices and low cost needs.

Choose star topology when you want easy management, good performance, and moderate cost, especially in offices.

Choose ring topology if you need orderly data flow and can tolerate moderate complexity, often in token ring networks.

Choose mesh topology for critical networks requiring high reliability and fault tolerance, such as data centers or military systems, despite higher cost and complexity.

Key Takeaways

Star topology offers the best balance of reliability and ease of management for most networks.
Bus topology is simple and cheap but vulnerable to cable failures and collisions.
Ring topology ensures orderly data flow but can be disrupted by a single break.
Mesh topology provides maximum reliability with many connections but is costly and complex.
Choose topology based on network size, cost, reliability needs, and ease of maintenance.