Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 79 ยท Getting Started with Networks

What Is a Computer Network?

Start Computer Networks here: nodes, links, hosts, LAN, MAN and WAN, the Internet as a network of networks, client-server versus peer-to-peer, and topologies.

A computer network is a set of devices that can send data to one another over connections. That is the whole definition, and it covers a lot: two phones sharing a file over Bluetooth, the computers of a school, and the billions of machines that make up the Internet. What makes all of them "networks" is that data leaves one device, crosses some medium (a wire, a fiber, a radio wave) and arrives at another device that understands it.

Networks matter because almost every program you will write or use depends on one. Web pages, chat, video calls, cloud storage, online games and mobile apps all assume that some other machine is reachable. In this tutorial you will go from the first vocabulary to the protocols that run the Internet, layer by layer. If you have read Networking Basics in the Computer Fundamentals tutorial, this lesson revisits the ideas with more precision and prepares the chapters that follow.

Every network can be drawn as a graph: dots connected by lines.

  • A node is any device attached to the network: a laptop, a phone, a printer, a server, a switch, a router.
  • A link is a connection between two nodes. It can be a copper cable, an optical fiber, or a radio channel.
  • A host (or end system) is a node that runs applications and is the source or final destination of data: your laptop, a web server, a smart thermostat.
  • An intermediate device is a node that only moves other people's data along: a switch inside a LAN, a router between networks. Hosts and intermediate devices together make up the network.

The word "host" trips up beginners. A host does not have to be big or fancy. A tiny sensor that reports its temperature is a host as long as it sends and receives data as an endpoint. A router, on the other hand, usually is not a host for your traffic: it just passes your packets on.

flowchart LR
  A["Host: laptop"] --- S["Switch"]
  B["Host: printer"] --- S
  C["Host: phone via Wi-Fi"] --- AP["Access point"]
  AP --- S
  S --- R["Router"]
  R --- I(["Internet"])

Hosts sit at the edges; switches and routers in the middle carry their data.

Networks by size: PAN, LAN, MAN, WAN

Networks are often named by how much area they cover, because distance changes the technology, the cost and who owns the cables.

Type Covers Typical example Typical owner
PAN (personal area) A few meters Phone and wireless earbuds One person
LAN (local area) A room, a home, a building or a campus Office Ethernet and Wi-Fi One organization
MAN (metropolitan area) A city A city-wide fiber ring A city or a carrier
WAN (wide area) Countries and continents A company linking its offices Telecom carriers, leased by customers

A LAN is usually fast, cheap and under your own control. A WAN stretches across land you do not own, so you rent capacity from a carrier, and delay grows with distance. The boundaries are fuzzy: a university campus can be called a LAN or a MAN depending on who is talking. Do not memorize the labels as strict categories. Use them as shorthand for "how far and who runs it".

LANs, MANs and internetworks in practice

A LAN is built from a few standard parts: end devices, a switch (and often a wireless access point) to join them, a router to reach other networks, a modem or an optical terminal to connect to the ISP, and Ethernet cables (or Wi-Fi). It is inexpensive and simple, and it comes in two arrangements: in a peer-to-peer LAN every computer shares resources equally, and in a client/server LAN a central server holds files, accounts and services. Larger sites use cloud-managed LANs, where the access points and switches are configured from a web dashboard.

A MAN is built by a city, a university or a carrier, typically with a ring of optical fiber (SONET/SDH or Metro Ethernet) that joins buildings. Rings give redundancy and failover: if the fiber is cut, traffic goes the other way around. A MAN can grow by adding nodes to the ring, but the cost of laying fiber is high, bandwidth is shared among the connected sites, and a very wide area can raise delay and complexity. Typical uses are linking branch offices, campuses, cable TV and Internet service to a town.

An internetwork is several networks joined by routers so that hosts in different networks can communicate. The Internet is the largest example: an internetwork of internetworks. The word intranet means a private internetwork that uses Internet technology for one organization, and an extranet extends it to selected partners.

The Internet is a network of networks

The Internet is not one giant network. It is thousands of independently operated networks that agree to exchange data using a shared set of rules, the Internet protocols, of which IP (the Internet Protocol) is the glue. Your home network, your phone carrier, a university, a bank and a cloud provider each run their own part. No single company or government runs all of it.

The word is also easy to confuse with the web. The web is one service that runs on the Internet (pages fetched with HTTP). Email, online games, video calls and software updates also use the Internet but are not "the web". Other terms you will meet:

  • An intranet is a private network that uses Internet technology, such as a company's internal websites.
  • An extranet shares part of an intranet with trusted outsiders such as partners.
  • A VPN (virtual private network) builds a private, encrypted path across a public network.

The next lessons show how the pieces fit: packets, delay and bandwidth, layers and who runs which part.

Client-server and peer-to-peer

Two arrangements describe how programs on hosts divide the work.

In the client-server model, a server waits for requests and a client starts them. A web browser (client) asks a web server for a page, and the server answers. The server is always on and has a well-known address; clients come and go. This makes things easy to manage and secure, but the server is a single point of failure and a bottleneck: if a million clients ask at once, one machine has to cope, so large services spread the load over many servers.

In the peer-to-peer (P2P) model, every host acts as both client and server. Each peer shares resources (files, processing power, bandwidth) directly with other peers. File-sharing systems and some video-call technology work this way. P2P scales naturally, since more users bring more capacity, but it is harder to find peers, harder to secure, and harder to control.

Real systems often mix the two. A video call may use a server to introduce the participants and then send the video directly between them.

Topologies: the shape of a network

The topology is the pattern in which nodes and links are arranged. There are two views: the physical topology (where the cables really run) and the logical topology (how data flows). Four classic shapes appear in textbooks.

flowchart TB
  subgraph Star
    sc["Switch"] --- s1["A"]
    sc --- s2["B"]
    sc --- s3["C"]
    sc --- s4["D"]
  end
  subgraph Ring
    r1["A"] --- r2["B"]
    r2 --- r3["C"]
    r3 --- r4["D"]
    r4 --- r1
  end
  subgraph Mesh
    m1["A"] --- m2["B"]
    m1 --- m3["C"]
    m1 --- m4["D"]
    m2 --- m3
    m2 --- m4
    m3 --- m4
  end

Star, ring and full mesh with four devices each. The bus topology (one shared cable) is not drawn.

  • Bus. All devices tap into a single shared cable. Cheap, but one break stops everyone and only one device can talk at a time. It is historical for wired LANs.
  • Star. Every device connects to a central switch. This is how almost every wired and Wi-Fi LAN works today. A broken cable affects only one device, but the center is a single point of failure.
  • Ring. Each device connects to two neighbors and data circles around. Rings return in fiber networks, where a cut in one direction can be survived by sending data the other way.
  • Mesh. Many or all devices link to many others. A full mesh needs n ร— (n โˆ’ 1) / 2 links for n devices, which is very reliable and very expensive. A partial mesh keeps some extra links; the Internet's core is a partial mesh.

A hybrid or tree topology combines these: stars connected to a larger star or to a ring. That is the real shape of most company networks.

Run the next example to see how quickly a full mesh becomes impractical.

Python Cables needed by each topology

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Four devices need 6 mesh links, but 50 devices need 1,225. This growth (roughly proportional to the square of the number of devices) is why big networks are never full meshes. The star and ring grow in step with the number of devices.

The same pattern appears in software. The second example models a small star LAN as a graph and counts links with a breadth-first search, then compares how many connections client-server and full peer-to-peer need.

Python A network as a graph

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The last line prints None: with the central switch gone, the laptop and the printer have no path at all. That is the weakness of the star topology in one number.

What is real and what is a stand-in? The vocabulary, the topologies and the link counts are real. A real network does not keep a Python dictionary of neighbors; switches and routers learn the shape of the network with protocols you will meet in the data link and routing chapters. A peer-to-peer system also does not keep a full mesh of connections; it connects each peer to a handful of others.

Topologies in depth

The four shapes above are easier to judge when you look at each one's advantages, drawbacks and where it is still used.

Bus. All stations share one cable, closed at both ends by terminators that absorb the signal. Original Ethernet (10BASE5 and 10BASE2 coaxial cable) worked this way, with CSMA/CD deciding who may talk. Cheap and simple to extend, but a cable break or loose connector stops everyone, faults are hard to locate, and all stations share the bandwidth. Gone from LANs, though a bus survives inside cars (the CAN bus) and industrial systems.

Star. Each station has its own cable to a central switch (formerly a hub). Adding or removing a device does not disturb others, faults are easy to isolate, and the center can manage and monitor traffic. The cost is more cable and the center as a single point of failure. A star in cable terms can still behave as a bus logically, as with a hub: physical and logical topology are different questions. Today's switched Ethernet and Wi-Fi are both physical and logical stars (Wi-Fi's "cable" is the radio link to the access point).

Ring. Each station connects to exactly two neighbors and data circulates in one direction, often controlled by a token that gives permission to send (token ring, 802.5). Behavior under load is predictable, but one broken link or station stops a simple ring. FDDI and modern metro fiber rings use two counter-rotating rings so a cut is bypassed by sending data the other way around, healing within milliseconds (SONET/SDH rings do this).

Mesh. In a full mesh every node links to all others: n(n-1)/2 links, as the first example showed. It gives the most fault tolerance and the shortest paths, and costs the most cable and ports. A partial mesh adds only a few cross-links. Data-center fabrics and the Internet backbone are partial meshes, and wireless mesh networks link access points to each other without cables.

Tree (hierarchical). A tree is stars connected to stars: a core switch at the top, distribution switches below, access switches near the users. It scales well and traffic stays local, but links near the root are bottlenecks and failures high in the tree cut off whole branches, so important links are duplicated. Most campus and office networks are trees with some redundancy.

Hybrid networks combine these. A real company might have star-shaped floors, joined by a tree backbone with a redundant ring or mesh at its core.

Topology Links for n nodes Fault tolerance Typical use today
Bus 1 shared cable Poor CAN bus in vehicles, legacy
Star n - 1 The center is a single point of failure Wired and Wi-Fi LANs
Ring n One cut survivable if dual ring Metro fiber, SONET/SDH
Full mesh n(n-1)/2 Excellent Small cores; partial meshes in data centers
Tree n - 1 Poor near the root unless duplicated Campus and enterprise LANs

The simulation below builds seven-node versions as graphs and measures what the table claims: link count, diameter (the longest shortest path, which sets the worst-case hop count) and whether any single failed link or node leaves the rest connected.

Python Measuring topologies as graphs

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The ring and the mesh survive any single failure, while star, tree and line (the bus drawn as a chain) do not; the mesh pays with 21 links for seven nodes, the ring with a diameter of 3. Choosing a topology is choosing a point on that trade-off between cost, delay and resilience.

Strengths and weaknesses of each topology

Every topology trades cost, resilience and ease of management. Reading the list below next to the graph measurements above helps you pick one for a job.

  • Bus. One shared cable with a tap per device. For: very little cable, cheap, easy to extend a short distance. Against: a break in the main cable splits or kills the network, only one station may send at a time, performance drops as stations are added, and faults are hard to locate. It survives today mostly in field buses such as CAN in cars and in old coaxial Ethernet. To lengthen a bus you can cascade segments with repeaters.
  • Star. Every device has its own link to a central hub or switch. For: easy to manage and to grow (plug in one more cable), a broken cable only isolates one device, and faults are easy to find. Typical uses are offices, homes and CCTV camera systems. Against: the central device is a single point of failure, and the amount of cable and the cost of the central switch grow with the device count.
  • Ring. Each device has two neighbors. For: orderly access (a token decides who sends), predictable delay, and no collisions. Against: in a simple ring a single failed station or cable breaks the loop (dual rings fix this), and adding or removing a station disturbs the ring.
  • Mesh. Many links between devices. For: very resilient, with several paths between any two nodes, and no shared medium so each link is private. It fits industrial plants, military radio networks and the core of the Internet. Against: cost and complexity, since a full mesh needs n(n-1)/2 links and every device needs many ports.
  • Tree. Stars arranged in a hierarchy. For: easy to expand by branching, matches the structure of buildings and organizations, and a failed branch leaves the rest alone. Against: the root and the upper links are bottlenecks and single points of failure, and the cabling gets complicated.
  • Hybrid. Any mix of the above, which is what real networks are. Common examples are the star-bus (several star clusters joined by a bus backbone) and the star-ring (stars whose hubs are connected in a ring). Hybrids let you place resilience where it matters, but they are the most complex to design, cost the most, and need staff who know several technologies.

Peer-to-peer networks in more detail

A pure client-server design concentrates cost in the server. A P2P design spreads it, and several variations exist:

  • Centralized index. Peers transfer files directly, but a central server keeps the directory of who has what. Searching is quick, but the index server is a single point of failure and an easy target for legal or technical attack.
  • Unstructured P2P. There is no index. Peers connect to a few random neighbors and a search is flooded through the overlay, with a hop limit (a time-to-live) so it does not travel forever. It is robust but wastes traffic, and rare files may not be found.
  • Structured P2P. Peers and keys are placed on a ring by hashing, and each peer knows a small number of others, so any key can be found in about log2(n) steps. This is the idea behind distributed hash tables (DHTs), which are used for trackerless file sharing and in some distributed storage systems.

The benefits of P2P are that it scales without a big server, it has no single point of failure (when structured or unstructured), and it can reduce cost for software distribution and live streaming. The disadvantages: peers come and go ("churn"), security is harder (any peer may serve bad data or leak what it is requesting), performance is uneven, and content can be shared that the owner does not want shared. If you run or use P2P software, keep it updated, download only from trusted sources, and do not share folders that contain private data.

Python Finding a key in a tiny structured P2P ring

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

When a new peer joins, it takes over only the keys between itself and the peer before it. That locality is why consistent hashing lets P2P networks and distributed caches grow and shrink without reshuffling everything.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which description fits a host?

    Hosts (end systems) run applications and are the endpoints of communication. Switches and routers are intermediate devices that move data along.
  2. 2. A company links its offices in three countries using lines rented from carriers. What kind of network is this?

    Connecting sites across countries over rented long-distance links is a wide area network. A bus is a topology, not a size category.
  3. 3. How many links does a full mesh of 10 devices need?

    n ร— (n โˆ’ 1) / 2 = 10 ร— 9 / 2 = 45. Counting 90 would count every cable twice.
  4. 4. What is the main weakness of the star topology?

    A broken cable cuts off only one device, but if the central switch fails the whole LAN stops.
  5. 5. Which statement about the Internet is correct?

    The Internet is made of thousands of separately operated networks; the web is only one service that runs on top of it.

Summary

  • A network is a set of nodes joined by links; hosts are the endpoints, switches and routers move the data in between.
  • PAN, LAN, MAN and WAN describe how far a network reaches and who usually owns it.
  • The Internet is a network of independently run networks that share common protocols; the web is just one service on it.
  • In client-server, servers wait and clients ask; in peer-to-peer, every host plays both roles; many systems mix the two.
  • Topologies (bus, star, ring, mesh) trade cost against reliability; a full mesh needs n ร— (n โˆ’ 1) / 2 links.
  • Real networks are hybrids: physical and logical topologies can differ, star and tree dominate the LAN, rings and partial meshes the backbone, and adding links buys fault tolerance and short paths at a price.

Next: How Data Travels: Packets and Switching.