How Networks Work — How Data Reaches the Right Destination

This article is part of the IT Foundations course, which builds up from scratch the practical IT knowledge you need at a minimum for programming and vibe coding.
What a network does is deliver data to the right destination. Network diagrams show how the route splits between inside the same LAN and outside it.

This article covers the network.

A network does one thing: deliver data to the right destination.

Three things are decided before data arrives
Data you wantto sendDecide thedestinationChoosethe routeIt arrivesIP addressIn the same LANOutside the LANvia the routerStops on the way,never arrives
Left to right. The boxes above and below are what is used at that point and the route taken. The bottom right is the case where one of these steps fails and nothing arrives.

The number that decides the destination is the IP address, and the device standing at the boundary where routes split is the router.

The purpose of a network is to deliver data to the right destination

A network — a group of devices connected by cable or radio that can send data to each other — is nested, not laid out side by side.

Networks are nested
The Internet (all the world's LANs connected together)
  • LANs all over the world are connected to each other
Company LAN
  • Your computer, a colleague's computer, the printer
  • Data can be sent directly only within this box
Home LAN
  • Your phone, the TV
  • It cannot see inside the company LAN
Where the public server sits
  • It is inside a data center
  • Reachable from any LAN
The outside is the Internet. Inside it are company and home LANs, and inside those are the individual devices.

The small one you build inside a home or a company is a LAN (Local Area Network), and the outside that connects them all around the world is the Internet.

Wi-Fi is the method of joining a LAN by radio instead of by cable.

Devices inside the same box can send data directly to each other; devices in different boxes cannot.

"Connect to the same network" in setup instructions means getting inside the same box.

What to look atLANThe Internet
RangeInside one home or companyThe whole world
Who you can send data to directlyDevices in the same buildingYou cannot send directly
Going outsideThrough the routerAlready outside

Networks are nested, not parallel

A network is a group of devices that can send data to each other.

The small group inside a home or a company is a LAN, and the outside that connects them all around the world is the Internet; within the same group data goes directly, and to a different group it goes out first and then arrives.

Within the same network, data goes straight to the destination number

Each device has a number.

That is the IP address — the number assigned to each device on a network.

The network layout of a company LAN
Your computer192.168.1.10Colleague's PC192.168.1.11Printer192.168.1.20Phone192.168.1.31RouterInner 192.168.1.1Outer number203.0.113.5The InternetPublic server198.51.100.7
The four devices on the left all have numbers starting with 192.168.1 and are in the same LAN. Going out to the right always passes through the router, and from the outside world they look like the single number on the router's outer side.

Devices whose number shares the same first part (192.168.1) form one LAN.

The sender looks at the first part of the destination number and decides the route.

The sender decides the route from the destination number
Sending from192.168.1.10Destination192.168.1.20Destination198.51.100.7First part matches→ insideFirst part differs→ outsideArrives at theprinter directlyVia the router,then it arrives
The left is the data being sent out. If the first part of the destination number matches your own it goes up; if not, it goes down. The upper path does not pass through the router; the lower one always does.

Within the same LAN, data reaches the other side directly, without passing through the router.

A printer is usable right away from a computer in the same room because it takes this route.

When you see "IP address", check which one it means

"IP address" on a settings screen or in setup instructions sometimes does not say whether it is the number inside the LAN or the number used outside.

If the number starts with 192.168 it is about the inside of the LAN; otherwise it is about the outside.

The router relays data going outside

The device standing at the boundary between two boxes is the router — a device that stands between two networks and passes data it receives on to the next network.

It is a single device, but it has a different name depending on whether you look at it from inside or from outside.

The same single router looks different from inside and outside
==The router seenfrom inside the LANFirst hand-offwhen going outDefaultgatewayThe same deviceThe router seenfrom the InternetThe device thatrepresents the LANThe device withthe global IP
The top row is the router seen from inside the LAN, the bottom row is the router seen from outside, and as the = shows they are the same single device. Left to right: the name, the role, and the number it has.

The first hand-off when going outside is the default gateway, and "gateway" on a settings screen usually means this router.

A number that works only inside the LAN is a private IP address, and a number that is unique across the whole Internet is a global IP address.

What to look atPrivate IPGlobal IP
Where it worksOnly inside that LANThe whole Internet
DuplicatesThe same number exists in another LANOne in the world
What has oneDevices inside the LANThe router's outer side, public servers

All that is visible from outside is the single global IP address the router holds.

The only thing you decide is the destination; which devices it passes through along the way varies each time.

There is one way out, and it goes through the router

The router stands at the boundary between two networks and relays both the data going out and the data coming back in.

The first hand-off when going out is the default gateway, and all that is visible from outside is the router's single global IP.

When data does not arrive, look at where it stopped

Data can go from inside to outside, but the other direction does not get through on its own.

Devices outside do not know the numbers inside the LAN, and the router cannot decide which device to hand incoming data to.

Whether it gets through or stops depends on the direction
Direction of dataInside → outsideYou send itOutside → insideSent from outsideThe routerrelays itStops atthe routerIt arrivesIt does not arrive
The top is the direction from inside to outside, where the router relays it and it arrives. The bottom is from outside to inside, where it stops at the router. That is why anything you publish is placed outside from the start.

This is why people outside cannot connect to a my-app you run on your own computer.

To let people outside use it as well, you move the files to a computer that is outside from the start.

That computer is the public server, and the work of moving them is deployment.

A public server is a computer that has been placed outside the box from the start.

The work of moving files is covered in this course's article on deployment and environment variables.

When data does not arrive, where you look depends on where the other side is
Data does notarriveThe other side isin the same LANThe other side isoutside the LANCheck if the firstparts matchCheck if itreached the routerNot connected, orwrong numberCheck the gatewaysetting
The left is the symptom. It splits on whether the other side is inside the same LAN or outside, and the further right you go, the narrower the place to check.

If the other side is inside the same LAN, the router is not involved.

Only when data does not reach something outside do you check the gateway setting.

A public server is needed because nothing gets in from outside

Data can go from inside to outside, but from outside to inside it stops at the router.

Your own computer is inside the LAN, so people outside cannot reach it; to make something usable by anyone, you move the files to a public server that is outside from the start.

QUIZ

Knowledge Check

Answer each question one by one.

Q1When you send data to a printer inside the same LAN, does it pass through the router?

Q2When a device inside a LAN sends data to a server outside, what does it hand the data to first?

Q3Why can't people outside connect to a my-app you run on your own computer?