Skip to content
简体中文
All chapters
CHAPTER 039 min

Network

Deliver information to the right device and service

A network is more than a cable that magically gives you internet. It delivers data to a device and then to a service. Addresses, ports, and connections explain common problems such as a server running but not being reachable.

By the end, you can
Distinguish device addresses from service ports
Understand switches, routers, and wireless connections
Separate a disconnected network from a wrong address or listening port
03.01

Start with a connection and small packets

Connected devices exchange data according to shared rules. At different layers, information is organized into smaller units; for now, think of packets carrying pieces of data and delivery information.

Packets may be delayed, lost, or reordered. Protocols such as TCP provide a reliable ordered byte stream; other situations use other protocols. A remote request cannot be assumed to succeed as quickly as a local operation.

In a familiar situation

An image loading on your screen involves transmitted data being assembled and decoded by software.

Take this with you · Networked programs need waiting and failure behavior as well as a successful path.

PacketProtocolTCPLatency
03.02

IP addresses and local switching

An IP address helps locate a network interface. IPv4 commonly uses four dotted numbers; IPv6 looks different. Addresses can change and are not permanent names for devices.

An ordinary layer-2 switch mainly forwards Ethernet frames using MAC addresses within a local network. Routers forward between networks using IP information. One household box often combines several roles.

In a familiar situation

Office computers can connect through a switch. Sending data to a distant network involves routing as well.

Take this with you · First distinguish your local network from other networks; protocol details can come later.

IP addressIPv4IPv6MACSwitch
03.03

Ports: which service is listening?

One computer can run multiple network services. A port number, together with protocol and address information, helps deliver data to the right endpoint. Services generally listen on specified addresses and ports.

localhost normally means the current device. In localhost:3000, 3000 is the port. A phone's localhost points to the phone, not your computer. Reaching an address does not prove a service is listening at that port.

In a familiar situation

A service listening on 8080 won't answer merely because you tried 3000. You've reached the building but tried the wrong door.

Take this with you · Keep the full address and startup output, including the port, when reporting connection problems.

PortlocalhostListenConnection
Test the idea yourself

Send a packet to the right door

The destination has a service listening on port 8080. Change the connection and destination port to compare outcomes.

Try this · Enable the connection, choose the correct port, and deliver a message.
Your computer192.0.2.2
Connection
List service192.0.2.10:8080

Predict: will a wrong port and a disconnected network fail in the same way?

A local diagram only: it neither scans ports nor sends requests to external devices.

03.04

Wi-Fi changes the medium, not the whole story

Wi-Fi uses radio instead of a cable for part of the connection. IP, ports, and application protocols still matter. Joining a wireless network is different from reaching the internet.

The radio link, router, internet connection, or destination server can each be responsible for a failure. Comparing local and external access can narrow the search.

In a familiar situation

A hotel Wi-Fi icon may show a connection while a sign-in page still blocks internet access.

Take this with you · Connected to Wi-Fi means one part of the connection is working.

Wi-FiEthernetLAN
03.05

Routers connect networks

A router chooses a next hop using routing information. Your home network connects through an internet provider and multiple networks to a destination. Responses need a usable path back as well.

Home devices often use private addresses and address translation at the edge. For now, distinguish access from this computer, access from the local network, and access from the wider internet.

In a familiar situation

A friend failing to open your development address doesn't prove the webpage code is wrong. The service may never have been made reachable outside your machine.

Take this with you · When asking whether a service is reachable, say from which device and network.

RouterRoutingPrivate addressNATISP
A new situation. What do you think?

Your server runs at localhost:3000. A friend opens the same address on their computer and it fails. What should you understand first?

Choose an answer before reading the explanation.

Turn your knowledge into a useful brief

Turn “the page won't open” into a useful report about devices, addresses, and ports.

Think first, then uncover help as needed. Later chapters expect more complete descriptions and clearer checks.

1 A direction2 A framework3 An example prompt
Distinguish the classroom preview from a shareable project address.Use it in a project
Give your curiosity another turnGo further

Bring this chapter's context to your AI. Going deeper is optional; you can keep reading without it.

Explain IP, ports, and routers using mail delivery, including the limits of the comparison.

One approach you can make your own
I'm learning computers and AI-assisted programming from scratch. In this chapter I learned:
Network:Distinguish device addresses from service ports;Understand switches, routers, and wireless connections;Separate a disconnected network from a wrong address or listening port

Explain IP, ports, and routers using mail delivery, including the limits of the comparison.

Check my understanding first. Explain one small question at a time with a concrete example and the limits of any analogy. Ask a scenario question, then adapt to my answer. Distinguish facts, guesses, and uncertainty; suggest hands-on ways to check. Confirm the version before giving tool-specific advice, and don't invent features or references.

Complete this chapter

Mark the sections as read, finish the experiment, and pass the scenario check to record completion. You can visit the next chapter at any time.

0/5 sectionsTest a principleExplain a situation

Read the original references

This is an introduction. These official resources help you check details and explore further.

MDN · How does the Internet work?Cloudflare · Switch vs. router

Data can reach another machine. Next, connect names, requests, and pages into a complete web visit.