EthicsComputerCourses
Join training +91 90532 10052

Network Types & Topologies

Computer Networks · Lesson 2 of 32 Beginner 7 min read Updated

By the end of this lesson you will be able to sort networks into PAN, LAN, MAN and WAN, draw the common topologies, and work out how many cables a design needs and what happens when one breaks.

Networks come in many sizes, from your earbuds talking to your phone to a bank joining branches in every state. They also come in different shapes. The size and the shape decide the cost, the speed and how well the network survives a fault.

Network types by size

Networks are usually grouped by the area they cover.

TypeFull nameCoversEveryday example
PANPersonal Area NetworkA few metres around one personPhone linked to earbuds or a smartwatch by Bluetooth
LANLocal Area NetworkA room, a floor or one buildingComputer lab in a college in Kochi
CANCampus Area NetworkSeveral buildings on one siteHostels, library and labs on one university campus
MANMetropolitan Area NetworkA cityA city's traffic cameras joined to one control room
WANWide Area NetworkStates, countries, the worldA bank joining its branches across India

A LAN is usually owned and run by one organisation. It is fast and cheap per device. A WAN usually runs over links rented from telecom companies, so it costs more and is slower per rupee. The internet is the largest WAN of all.

Here is a simple rule of thumb: if you can walk to every device in a few minutes, it is a LAN. If you need a train ticket, it is a WAN.

What is a topology?

A topology is the layout of a network: which node connects to which. There are two views of it:

  • Physical topology is how the cables and devices are really laid out.
  • Logical topology is how data actually flows between them.

The two can differ. For example, a network can be wired as a star but still pass data like a bus. For exams, know both words.

The common topologies

These are the main shapes, drawn with characters:

Text
Bus:     A----B----C----D        (one shared cable, the backbone)

Star:        B                   (every node joins one central device)
             |
        C -- S -- A
             |
             D

Ring:    A -- B                  (each node joins two neighbours)
         |    |
         D -- C

Mesh:    every node has a direct link to every other node

Each one has strengths and weaknesses.

TopologyHow it worksGoodBad
BusAll nodes share one cableCheap, little cableOne cable break stops everyone; collisions
StarAll nodes join a central switchEasy to add nodes; one cable fault hits one nodeThe centre is a single point of failure
RingEach node joins two neighbours in a loopOrderly, predictableOne break can stop the ring (unless it is a dual ring)
MeshNodes have many direct linksVery reliable, many pathsLots of cable and ports, costly
TreeStars joined in a hierarchyGrows well, easy to manageA fault high in the tree cuts off a whole branch
HybridA mix of the aboveFits real buildingsHarder to design

Almost every office and home LAN today is a star: each computer runs a cable to a switch, or talks by radio to a Wi-Fi access point. Large networks are trees of stars. The internet core between big routers is a partial mesh, with several paths between important points.

In a full mesh of n devices, each device connects to the other n - 1 devices. Each link joins two devices, so we divide by 2:

  • links = n × (n - 1) / 2
  • ports needed on each device = n - 1

A star with n devices needs only n links (one per device to the centre). A ring needs n links. A bus needs one backbone plus a short drop cable per device.

Let us compare them in Python.

PythonRun it yourself
print(f"{'Devices':>8} {'Mesh links':>11} {'Star links':>11} {'Ring links':>11}")
for n in [4, 6, 10, 20]:
    mesh = n * (n - 1) // 2
    print(f"{n:>8} {mesh:>11} {n:>11} {n:>11}")
Output
Devices  Mesh links  Star links  Ring links
      4           6           4           4
      6          15           6           6
     10          45          10          10
     20         190          20          20

Look how fast the mesh grows. With 20 devices it needs 190 cables. That is why full meshes are kept small and used only where reliability matters most, such as between a few core routers.

Reliability is about one question: if one cable fails, can every node still reach every other node? We can answer it with a simple search.

Step 1: describe each topology as a list of links.

Step 2: remove one link to simulate a cut cable.

Step 3: start from one node and visit every node you can reach. If you reach all of them, the network survived.

PythonRun it yourself
def reachable(links, start):
    seen = {start}
    todo = [start]
    while todo:
        node = todo.pop()
        for a, b in links:
            for x, y in ((a, b), (b, a)):
                if x == node and y not in seen:
                    seen.add(y)
                    todo.append(y)
    return seen

nodes = {"A", "B", "C", "D", "E"}
ring = [("A", "B"), ("B", "C"), ("C", "D"), ("D", "E"), ("E", "A")]
star = [("S", n) for n in sorted(nodes)]

ring_cut = [l for l in ring if l != ("B", "C")]
star_cut = [l for l in star if l != ("S", "C")]

print("Ring after B-C cut reaches:", sorted(reachable(ring_cut, "A")))
print("Star after S-C cut reaches:", sorted(reachable(star_cut, "A")))
Output
Ring after B-C cut reaches: ['A', 'B', 'C', 'D', 'E']
Star after S-C cut reaches: ['A', 'B', 'D', 'E', 'S']

Here is what the result tells you:

  • In the ring, cutting one link still leaves a path the other way round, so everyone is reachable. (A second cut would split it.)
  • In the star, cutting the cable to C cuts off only C. Everyone else is fine.
  • In the star, if the central switch S itself fails, everything stops. That is its single point of failure.

Advanced: choosing a design

Real design is a trade-off between cost and reliability. Aarav is wiring a small shop in Rohtak with 6 computers. A star with one switch is the obvious choice: 6 cables, one cheap switch. A school with 3 buildings might use a tree: one switch per building, all linked to a main switch in the office. A company with two data centres would add two separate links between them, so one fibre cut does not stop the business. This is called redundancy.

PythonRun it yourself
cable_cost = 450   # rupees per cable run, an example figure
for name, links in [("Star (6 PCs)", 6), ("Full mesh (6 PCs)", 6 * 5 // 2)]:
    print(f"{name}: {links} cables, about Rs {links * cable_cost:,}")
Output
Star (6 PCs): 6 cables, about Rs 2,700
Full mesh (6 PCs): 15 cables, about Rs 6,750

Common mistakes

  • Mixing up MAN and WAN. A MAN covers one city. A WAN covers a larger area such as a country.
  • Forgetting to divide by 2 in mesh questions. Each link is shared by two devices. 6 devices need 15 links, not 30.
  • Calling Wi-Fi a different network type. Wi-Fi in a home or office is a LAN that uses radio.
  • Assuming a star never fails. The central device is a single point of failure.

Key points

  • PAN, LAN, CAN, MAN and WAN are grouped by the area they cover.
  • Topology is the layout: physical (cables) and logical (data flow).
  • Star is the normal LAN layout today; big networks are trees of stars with some mesh links.
  • A full mesh of n devices needs n(n - 1)/2 links and n - 1 ports per device.
  • A ring survives one link cut; a star loses only the node whose cable was cut.
  • Redundant links remove single points of failure, at extra cost.

Exercise

A college wants a full mesh between 12 core routers. Write Python that prints the number of links, the ports needed on each router, and the total cable cost if each link costs ₹1,800 (an example figure). Then print how many links a star with the same 12 routers would need.

Show solution
Python
n = 12
links = n * (n - 1) // 2
print("Mesh links:", links)
print("Ports per router:", n - 1)
print(f"Cable cost: Rs {links * 1800:,}")
print("Star links:", n)
Output
Mesh links: 66
Ports per router: 11
Cable cost: Rs 118,800
Star links: 12

The mesh needs 66 links because 12 × 11 / 2 = 66. Python's :, format groups digits in thousands, so it prints 118,800. Written the Indian way, that is ₹1,18,800.

Quick Quiz

1. A network that joins a company's offices in Delhi, Mumbai and Chennai is a:

2. How many links does a full mesh of 5 devices need?

3. What is the main weakness of a star topology?

4. Which topology do most office LANs use today?

Learn Computer Networks with a mentor

Free lessons get you started. Our Computer Science Fundamentals training adds real projects and code reviews from working developers.

  • Project-based learning
  • Mentor code reviews
  • Free counselling call