Skip to content

Commit b9488e8

Browse files
Merge pull request #2 from Coding-Moves/lesson/00-01-01-what-is-computer-networking
Lesson 00.01.01 — What is computer networking?
2 parents 4b32f6c + 9463474 commit b9488e8

4 files changed

Lines changed: 210 additions & 3 deletions

File tree

‎ROADMAP.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<!-- This file is generated from course.yml. Do not edit by hand.
44
Change course.yml, then run: python scripts/build_roadmap.py -->
55

6-
**Progress: 0 / 78 lessons published**
6+
**Progress: 1 / 78 lessons published**
77

88
✅ = published · ⬜ = coming soon
99

@@ -12,7 +12,7 @@
1212
## 00 — Getting Started
1313

1414
### Introduction
15-
- ⬜ What is computer networking?
15+
- ✅ [What is computer networking?](lessons/00-getting-started/01-introduction/01-what-is-computer-networking.md)
1616
- ⬜ What is cybersecurity?
1717
- ⬜ What is ethical hacking?
1818
- ⬜ Security vs hacking — what's the difference?
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# What is computer networking?
2+
3+
> **Phase:** 00 — Getting Started
4+
> **Module:** Introduction
5+
> **Lesson:** 01
6+
> **Tested on:** Ubuntu 24.04, Windows 11, macOS 14 · Python 3.12
7+
8+
## Objective
9+
Understand what a computer network is, what it is made of, and see your own network with a few simple commands.
10+
11+
## Explanation
12+
A **computer network** is two or more devices connected so they can share data.
13+
14+
That's it. Your phone talking to your Wi-Fi router is a network. Your laptop opening a website on a server in another country is also a network — just a much bigger one.
15+
16+
A network needs three things:
17+
18+
1. **Devices** that send or receive data — laptops, phones, servers, printers, smart TVs. In networking we call them **hosts** or **nodes**.
19+
2. **A connection** between them — a cable (Ethernet, fibre) or wireless (Wi-Fi, mobile data).
20+
3. **Rules** that everyone follows so they understand each other. These rules are called **protocols**. You will meet many of them in this course: IP, TCP, DNS, HTTP and more.
21+
22+
Networks come in different sizes:
23+
24+
| Type | Size | Example |
25+
| ---- | ---- | ------- |
26+
| **PAN** — Personal Area Network | A few metres | Phone + Bluetooth earbuds |
27+
| **LAN** — Local Area Network | One home, office or building | Everything on your home Wi-Fi |
28+
| **WAN** — Wide Area Network | Cities, countries | A company linking offices in Lahore and London |
29+
| **The Internet** | The whole world | A network of networks |
30+
31+
The **Internet** is not one big network. It is millions of separate networks — homes, companies, universities, internet providers — all connected together and following the same rules.
32+
33+
## How it works
34+
When you send something over a network, it doesn't travel as one big piece. It is cut into small pieces called **packets**.
35+
36+
Each packet carries:
37+
- **the data** — a small part of your message, photo or web page
38+
- **an address of where it's going** and **where it came from** — like an envelope
39+
40+
A few devices move these packets around:
41+
42+
- **Network card (NIC)** — the part inside your device that connects it to a network (Wi-Fi or cable).
43+
- **Switch** — connects devices *inside* one local network and sends each packet to the right device.
44+
- **Router** — connects *different* networks together and picks the path to the destination. Your home router connects your LAN to your internet provider.
45+
- **Access point** — gives Wi-Fi to devices. In most homes the router, switch and access point are all inside one box.
46+
47+
A simple trip, opening a website from home:
48+
49+
```
50+
Your laptop → Wi-Fi → home router → internet provider → many routers → website's server
51+
(LAN) (the Internet / WAN)
52+
```
53+
54+
The server sends the page back the same way, in packets. Your laptop puts the packets back together and shows the page.
55+
56+
## Examples
57+
- **Printing at home:** your laptop sends a document to the printer. Both are on the same LAN, so the packets never leave your house.
58+
- **Video call:** your voice is cut into packets, sent across the Internet to your friend's device, and joined back together — many times per second.
59+
- **Smart TV streaming:** the TV is a host on your LAN. It asks a server on the Internet for video, and the router passes the packets in and out.
60+
61+
## Commands
62+
These commands are safe — they only show information about **your own** device.
63+
64+
**See your device's network details**
65+
66+
```bash
67+
# Linux
68+
ip addr # your network cards and addresses
69+
ip route # your default gateway (the router)
70+
71+
# macOS
72+
ifconfig
73+
netstat -nr # routing table, look for "default"
74+
75+
# Windows (Command Prompt or PowerShell)
76+
ipconfig # address, subnet mask, default gateway
77+
```
78+
79+
**Check if another device can be reached**
80+
81+
```bash
82+
ping -c 4 1.1.1.1 # Linux / macOS — send 4 test packets
83+
ping 1.1.1.1 # Windows — sends 4 by default
84+
```
85+
86+
`ping` sends a tiny packet and waits for a reply. If replies come back, the path works. The `time=` number shows how long the round trip took, in milliseconds.
87+
88+
## Practical work
89+
Map your own home network on paper.
90+
91+
1. Run the command for your system from **Commands** and find:
92+
- your device's address (looks like `192.168.x.x` or `10.x.x.x`)
93+
- your **default gateway** — this is your router
94+
2. `ping` your router's address. Then `ping 1.1.1.1` (a public server). Compare the `time=` values — which is faster, and why?
95+
3. Run the small Python script for this lesson with `python3 my_network_info.py`. It shows your device name, its local address, and the network commands for your system: [my_network_info.py](code/01-what-is-computer-networking/my_network_info.py)
96+
4. Draw a simple picture: your devices → router → internet provider → Internet. Write each device's name next to it.
97+
98+
> Only look at networks you own or are allowed to use. Don't scan or test other people's networks — even "just to look". You'll learn safe lab setups later in this phase.
99+
100+
## Common mistakes
101+
- **"The Internet and the web are the same."** No. The **Internet** is the network. The **web** (websites) is just one service that runs on it — like email, games and video calls.
102+
- **"Wi-Fi is the Internet."** Wi-Fi only connects you to your local router. You can have Wi-Fi with no internet if the router's connection to the provider is down.
103+
- **"Data travels in one piece."** It is always cut into packets, and packets can even take different paths.
104+
- **Mixing up router and switch.** Switch = inside one network. Router = between networks.
105+
- **`ping` fails, so the device is off.** Not always. Many devices and firewalls block ping on purpose.
106+
107+
## Why it matters for security
108+
Almost every attack and every defence happens **over a network**.
109+
110+
- To protect a system, you first need to know what is connected and how data flows.
111+
- Attackers look for weak devices on a network — an old router, an unprotected camera, a shared printer.
112+
- Defences like firewalls, VPNs and network segmentation (all later in this course) only make sense once you understand what a network is.
113+
114+
Rule of thumb: **you can't secure what you don't understand.** This lesson is the first step.
115+
116+
## Check your understanding
117+
1. What three things does every network need?
118+
2. What is the difference between a LAN and a WAN? Give one example of each from your own life.
119+
3. What is a packet, and why is data split into packets?
120+
4. Your laptop has Wi-Fi but websites won't load. Using what you learned, where could the problem be?
121+
5. **Task:** Find your default gateway and ping it. Write down your address, the gateway address and the average ping time.
122+
123+
## References
124+
- [RFC 1122 — Requirements for Internet Hosts: Communication Layers](https://www.rfc-editor.org/rfc/rfc1122) (IETF)
125+
- [What is a LAN?](https://www.cloudflare.com/learning/network-layer/what-is-a-lan/) (Cloudflare Learning Center)
126+
- [How does the Internet work?](https://www.cloudflare.com/learning/network-layer/how-does-the-internet-work/) (Cloudflare Learning Center)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
"""Lesson 00.01.01 — What is computer networking?
2+
3+
Shows basic network information about YOUR OWN device.
4+
It does not scan or contact other devices on your network.
5+
6+
Run: python3 my_network_info.py
7+
"""
8+
9+
import platform
10+
import socket
11+
12+
13+
def local_ip() -> str:
14+
"""Find the address this device uses on the local network.
15+
16+
Connecting a UDP socket does not send any packet. It only asks the
17+
operating system which network card and address it would use.
18+
"""
19+
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
20+
try:
21+
s.connect(("1.1.1.1", 80))
22+
return s.getsockname()[0]
23+
except OSError:
24+
return "not connected"
25+
finally:
26+
s.close()
27+
28+
29+
def main() -> None:
30+
system = platform.system()
31+
32+
print("=== My network info ===")
33+
print(f"Device name : {socket.gethostname()}")
34+
print(f"System : {system} {platform.release()}")
35+
print(f"Local IP : {local_ip()}")
36+
37+
print("\nTo see more, run these on your system:")
38+
if system == "Windows":
39+
print(" ipconfig → address, subnet mask, default gateway")
40+
print(" ping 1.1.1.1 → test the path to a public server")
41+
elif system == "Darwin":
42+
print(" ifconfig → network cards and addresses")
43+
print(" netstat -nr → routing table ('default' = your router)")
44+
print(" ping -c 4 1.1.1.1 → test the path to a public server")
45+
else:
46+
print(" ip addr → network cards and addresses")
47+
print(" ip route → 'default via ...' = your router")
48+
print(" ping -c 4 1.1.1.1 → test the path to a public server")
49+
50+
51+
if __name__ == "__main__":
52+
main()

‎scripts/build_pdf.py‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,41 @@ def esc(s: str) -> str:
4040
MD_CFG = {"codehilite": {"guess_lang": False, "css_class": "hl"}}
4141

4242

43+
LIST_RE = re.compile(r"^(\s*)([-*+]|\d+\.)\s+")
44+
45+
46+
def github_style(text: str) -> str:
47+
"""Make GitHub-flavoured lists work with Python-Markdown.
48+
49+
GitHub allows a list right after a paragraph line and nested items
50+
indented by 2-3 spaces. Python-Markdown needs a blank line first and
51+
4-space indents, so we add those (outside code blocks).
52+
"""
53+
out: list[str] = []
54+
in_code = False
55+
for line in text.splitlines():
56+
if line.lstrip().startswith("```"):
57+
in_code = not in_code
58+
out.append(line)
59+
continue
60+
m = None if in_code else LIST_RE.match(line)
61+
if m:
62+
indent = len(m.group(1).replace("\t", " "))
63+
if 0 < indent < 4:
64+
line = " " + line.lstrip()
65+
prev = out[-1] if out else ""
66+
if prev.strip() and not LIST_RE.match(prev) and not prev.startswith(" ") and indent == 0:
67+
out.append("")
68+
out.append(line)
69+
return "\n".join(out) + "\n"
70+
71+
4372
def lesson_html(lesson) -> str:
4473
text = lesson.path.read_text(encoding="utf-8").lstrip("")
4574
# drop the title line and the info block — the PDF prints its own header
4675
text = re.sub(r"\A#\s+.*\n", "", text)
4776
text = re.sub(r"\A\s*(>.*\n)+", "", text)
48-
body = markdown.markdown(text, extensions=MD_EXT, extension_configs=MD_CFG)
77+
body = markdown.markdown(github_style(text), extensions=MD_EXT, extension_configs=MD_CFG)
4978
# lesson "## Section" becomes h4 under the lesson's h3
5079
for n in (3, 2, 1):
5180
body = re.sub(rf"<(/?)h{n}([ >])", rf"<\1h{n + 2}\2", body)

0 commit comments

Comments
 (0)