Networking Examples

Practical Networking Examples

Hands-on code demonstrations of network communication principles at different model layers.

Real-World Tools

Demonstrates core networking utilities like ping, traceroute, and netcat in action.

Code Samples

Python/Shell examples that visualize layer-specific functions like TCP connection and IP routing.

Layered Network Examples

🔹Layer 7

Application Layer

HTTP/HTTPS Request


$ curl -v https://api.hackclub.com/data
> GET /data HTTP/1.1
> Host: api.hackclub.com
> ...
Demonstrates how web browsers interact with servers using HTTP at the application layer.
🔹Layer 4

Transport Layer

TCP Socket Communication


import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('example.com', 80))
s.send(b'GET / HTTP/1.1\\r\\nHost: example.com\\r\\n\\r\\n')
print(s.recv(4096))
Shows TCP's role in establishing reliable connections for data exchange.
🔹Layer 3

Network Layer

IP Routing & Traceroute


$ traceroute hackclub.com
1  192.168.1.1 (192.168.1.1)  0.878 ms
2  10.10.10.1 (10.10.10.1)  1.896 ms
3  142.250.179.74 (142.250.179.74)  2.104 ms
Visualizes IP packet routing across network hops.
🔹Layer 2

Data Link Layer

ARP Table & Ethernet Frame


$ arp -a
? (192.168.1.1) at 00:1d:84:55:39:25 [ether] on eth0
Demonstrates MAC address mapping for local network communication.
🔹Layer 1

Physical Layer

Network Interface Details


$ ethtool eth0
Settings for eth0:
Speed: 1000Mb/s
Duplex: full
Link detected: yes
Checks physical network interface status like speed and duplex mode.

Live Network Simulation

🧪 Interactive

Packet Transfer Demo

Type a URL and see how its data passes through the OSI model

Packet analysis will appear here showing layer transitions

More Network Tool Demos

DNS Lookup

Resolves domain names to IP addresses

$ dig hackclub.com
;; ANSWER SECTION:
hackclub.com.		600 IN A	142.251.176.113
                
View explanation
Port Scanning

Detects open network services

$ nmap hackclub.com
Starting Nmap 7.94
PORT   STATE SERVICE
80/tcp open  http
                
View explanation
WiFi Networks

Lists wireless access points

$ iwlist wlan0 scan
ESSIDs: 1
      HackClub
      HomeWiFi
      Starbucks-6G
                
View explanation