By the end of this lesson you will be able to
- Explain with an analogy how ports let one device run many network programs at once.
- Name three well-known port numbers and what they are used for.
- Contrast TCP and UDP and choose which suits a file download and which a video call.
- Run ping on your own computer and read the replies, loss and times.
- Describe what traceroute shows and why some lines may be blank.
Your laptop may have a browser open, a chat app, an email program and a software update all running at once, yet it has only one IP address. How does each packet find the right program? And when something is wrong, how do you test whether the other end is even reachable? Ports, the TCP and UDP rules and the ping tool answer these questions.
Ports: doors in a building
The IP address gets a packet to the right device, like the street address of a large block of flats. But the flats inside have different residents. A network port is a number from 0 to 65,535 that picks the program on the device that should receive the packet, like a flat number.
A server listens on a well-known port for its job. A web server using HTTPS listens on port 443, so your browser sends its request to the server's address, port 443. Your own computer also uses a port for each conversation, picked at random, so that replies come back to the right program. This is why your browser and your chat app do not receive each other's data.
| Port | Used for | Protocol name |
|---|---|---|
| 53 | Looking up names | DNS |
| 80 | Web pages without encryption | HTTP |
| 443 | Web pages with encryption | HTTPS |
| 22 | Secure remote command line | SSH |
| 587 | Sending email from a mail program | SMTP submission |
Read this figure as text
A network diagram of a server with three labelled ports leading to a web program, a mail program and a name program.
A laptop on the left sends three packets to one server at 198.51.100.40 (a made-up address). The first packet is marked port 443 and arrives at the web program (HTTPS). The second is marked port 587 and arrives at the mail program. The third is marked port 53 and arrives at the name-lookup program (DNS). The address is the same for all three; the port number decides which program receives each one.
TCP and UDP: careful or fast
Two protocols sit on top of IP and decide how a conversation behaves. TCP is the careful one. It first sets up a connection with a quick greeting, numbers every packet, and checks that each arrives. If one is lost it is sent again, and the pieces are put in the right order before the program sees them. This is like a registered delivery with a signature.
UDP is the fast one. It just sends packets with no greeting, no checking and no resending, like throwing postcards over a fence. That sounds careless but is ideal when speed matters more than perfection. In a video call, a late packet is useless: it is better to skip a tiny part of the sound than to wait for it.
- Sets up a connection first
- Checks and resends lost packets
- Keeps packets in order
- Used for web, email, downloads
Every piece must arrive.
- No connection set-up
- No checking or resending
- Some packets may be lost
- Used for calls, games, streams
Speed matters more.
Read this figure as text
A two-column comparison of TCP and UDP with examples of each.
TCP: sets up a connection first; numbers packets and checks that each arrives; resends lost packets; keeps the packets in order; slightly slower. Used for web pages, email and file downloads, where every piece must arrive. UDP: no connection set-up; no checking or resending; packets may be lost or out of order; very fast and light. Used for video calls, online games, live streams and simple DNS questions, where speed matters more than a perfect copy.
Ping: are you there?
Ping sends a tiny test message to another computer and waits for a reply, like calling out in a dark room and listening for an answer. It tells you three things: whether the other end is reachable, how long the round trip took (the Round-trip time, in milliseconds), and whether any messages were lost.
Run a ping
Replace 192.168.1.1 with your own router address if it is different (the previous lesson showed how to find it).
On Ubuntu, ping keeps going until you stop it, so we add -c 4, which means 'count 4': send four messages, then stop and summarise. 192.168.1.1 is the address to test.
ping -c 4 192.168.1.1- Marker 1: Command: four test messages
- Marker 2: One reply and its round-trip time
- Marker 3: Summary: nothing lost
Read this figure as text
A simulated Ubuntu terminal running ping -c 4 and showing four replies and a summary.
A simulated terminal. Marker 1 is the command ping -c 4 192.168.1.1. Four reply lines follow, each saying 64 bytes from 192.168.1.1 with a sequence number and a time in milliseconds, between 2 and 3 ms (marker 2: the round-trip time). A summary then says 4 packets transmitted, 4 received, 0% packet loss (marker 3). The last line gives the minimum, average and maximum times. All values are made up. Zero loss and low times are healthy.
On Windows, ping sends four messages by default and then stops, so no extra option is needed.
ping 192.168.1.1- Marker 1: Command: four test messages
- Marker 2: One reply and its time
- Marker 3: Summary: nothing lost
Read this figure as text
A simulated PowerShell window running ping and showing four replies and statistics.
A simulated PowerShell window. Marker 1 is the command ping 192.168.1.1. It prints Pinging 192.168.1.1 with 32 bytes of data, then four lines saying Reply from 192.168.1.1 with the time in milliseconds, 2 to 4 ms (marker 2). The statistics then say Packets: Sent = 4, Received = 4, Lost = 0 (0% loss) (marker 3), with the minimum, maximum and average times. All values are made up.
| What you see | What it usually means |
|---|---|
| Replies with small times (under about 20 ms to your router) | A healthy local connection |
| Replies for the router but not for example.org | Your home network is fine; the problem is beyond it, or with DNS if the name will not resolve |
| Request timed out. (Windows) or no replies (Linux) | No answer came back: the device is off, a firewall is blocking ping, or the path is broken |
| Destination host unreachable | Your computer or a router on the way knows there is no route to that address |
| Some replies lost (for example 25% loss) | An unreliable link, often a weak Wi-Fi signal |
Traceroute: the route taken
Traceroute (named tracert on Windows) shows the path a packet takes. It works by sending messages that are allowed to travel only one Hop, then two hops, then three, and noting which router sends back a note each time. Each line of the result is one router on the route, with the times for three tries. A line of stars means that router did not answer, which is common and not always a fault: some routers are set to stay quiet.
- Marker 1: Hop 1: your own router
- Marker 2: Hop 2: the provider's first router
- Marker 3: A quiet router; not always a fault
Read this figure as text
A simulated Windows command window showing a tracert result with four hops to a made-up address.
A simulated command window running tracert 198.51.100.40, a made-up address. Hop 1 is 192.168.1.1 (marker 1, your own router), taking 2 ms. Hop 2 is 203.0.113.1 (marker 2, the first router at the provider), taking 9 ms. Hop 3 shows three stars and the message Request timed out (marker 3: that router did not answer, which is not always a fault). Hop 4 is the destination 198.51.100.40, taking 31 ms. Times usually rise as the distance grows.
You will use these tools again in the lesson on diagnostic tools. For now, the idea is enough: ping asks whether something is reachable, and traceroute shows where along the route the answer stops or slows down.
Common mistakes
✖ Instead of: Concluding that a site is down because ping shows 'Request timed out'.
✔ Do this: Many servers and routers are set to ignore ping. Try opening the site in a browser too before deciding.
✖ Instead of: Using ping or traceroute on computers you do not own to see if they are 'alive'.
✔ Do this: Test only your own devices and well-known example sites. Probing other people's systems is not appropriate.
✖ Instead of: Thinking a high ping time to a distant site means your internet is slow.
✔ Do this: Time grows with distance. Compare with your router first: a small time there and a larger one far away is normal.
If something goes wrong
- Ping on Ubuntu never stops.
- Press Ctrl and C together to stop it, and use
-c 4next time to send just four. - Ping works with a number but not with a name.
- That is a DNS problem. Revisit the DNS section of the previous lesson and check which DNS server your computer uses.
tracerouteis not found on Ubuntu.- It is not installed by default. The command
tracepath example.orgdoes a similar job and is included. Installing software comes later in the academy.
Key terms
- Network port
- A numbered door on a computer that tells it which program should receive incoming data.
- Round-trip time
- How long a message takes to reach another computer and for the reply to come back.
- Traceroute
- A tool that lists the routers a packet passes through on its way to a destination.
Practise it for real
Reading is not the same as being able to do it. Complete these on your own computer, then tick only what you have actually done. These ticks are your own honest record: nothing checks them for you.
Ping your router and a website
On your real computer, open the Terminal (Ubuntu) or PowerShell (Windows). Ping your router's address. Then ping example.org. Write down the average time for each and the percentage of packets lost. Do not ping any other address.
Challenge: choose TCP or UDP
For each activity, say whether TCP or UDP is the better fit and give one reason: (a) downloading a PDF; (b) a live video call with a relative; (c) sending an email; (d) an online game where positions update many times a second. Then say which port a normal HTTPS website uses.
Knowledge check
6 questions. You need 80% to pass. Mistakes here are part of learning, and you can retry as often as you like.
Summary
- A port number chooses the program on a device; well-known ports include 443 for HTTPS and 53 for DNS.
- TCP is careful and reliable; UDP is quick and tolerant of loss.
- Ping tests reachability, loss and round-trip time.
- Traceroute lists the routers on the way; a line of stars is not always a fault.
Checklist: can you do these?
Marking a lesson as read does not prove you can do it. Skills count as demonstrated when you pass the quiz (not yet) and complete the practical tasks (not yet).
Related lessons
References and further reading
Official sources for details that can change between versions.
- ping command reference (Microsoft Learn)
- tracert command reference (Microsoft Learn)
- Transmission Control Protocol (TCP) (MDN Web Docs)