0
0
Computer-networksConceptBeginner · 3 min read

What is Hub in Networking: Definition and Usage

A hub in networking is a simple device that connects multiple computers or devices in a network by broadcasting data to all connected ports. It works like a basic signal repeater without filtering or directing data to specific devices.
⚙️

How It Works

A hub acts like a central meeting point for devices in a network. Imagine a room where everyone talks loudly, and whatever one person says, everyone else hears it. When one device sends data to the hub, the hub copies that data and sends it to all other connected devices.

This means the hub does not know which device actually needs the data; it just repeats the message to all. This can cause network traffic to slow down if many devices communicate at once, because all devices receive all messages, even if they are not the intended recipient.

💻

Example

This simple Python example simulates how a hub broadcasts a message from one device to all others connected.

python
class Hub:
    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}")

# Create hub and devices
hub = Hub()
device1 = Device('Device 1')
device2 = Device('Device 2')
device3 = Device('Device 3')

# Connect devices to hub
hub.connect(device1)
hub.connect(device2)
hub.connect(device3)

# Device 1 sends a message
hub.broadcast(device1, 'Hello from Device 1')
Output
Device 2 received: Hello from Device 1 Device 3 received: Hello from Device 1
🎯

When to Use

Hubs are mostly used in small or simple networks where cost is a concern and network traffic is low. They are easy to set up and do not require configuration.

However, hubs are largely replaced by switches in modern networks because switches send data only to the intended device, reducing unnecessary traffic and improving speed.

Use a hub when you need a basic, inexpensive way to connect a few devices and network performance is not critical.

Key Points

  • A hub broadcasts data to all connected devices.
  • It does not filter or direct data to specific devices.
  • Hubs can cause network slowdowns due to unnecessary data traffic.
  • They are simple and inexpensive but mostly replaced by switches today.

Key Takeaways

A hub connects multiple devices by broadcasting data to all ports.
It does not direct data to specific devices, causing possible network congestion.
Hubs are simple and cheap but mostly replaced by switches in modern networks.
Use hubs only in small, low-traffic networks where cost is a priority.