
AI Computing
TCP/IP Protocol Suite and Internet Fundamentals
TCP/IP Model
The TCP/IP model is a practical 4-layer framework that powers the Internet.
4 Layers
- Application Layer (HTTP, FTP, DNS, SMTP)
- Transport Layer (TCP, UDP)
- Internet Layer (IP, ICMP, ARP)
- Network Access Layer (Ethernet, Wi-Fi)
vs OSI: More practical, fewer layers, real-world protocols
IP Addressing
IPv4 Addressing
Format: Four octets (0-255) separated by dots
code192.168.1.100
Binary Representation:
code192 .168 .1 .100 11000000.10101000.00000001.01100100
Total Addresses: 2³² = 4,294,967,296
IP Address Classes
Class A (1.0.0.0 to 126.255.255.255)
- First bit: 0
- Network bits: 8
- Host bits: 24
- Networks: 126
- Hosts per network: 16,777,214
- Use: Very large organizations
Class B (128.0.0.0 to 191.255.255.255)
- First bits: 10
- Network bits: 16
- Host bits: 16
- Networks: 16,384
- Hosts per network: 65,534
- Use: Medium organizations
Class C (192.0.0.0 to 223.255.255.255)
- First bits: 110
- Network bits: 24
- Host bits: 8
- Networks: 2,097,152
- Hosts per network: 254
- Use: Small networks
Class D (224.0.0.0 to 239.255.255.255)
- Use: Multicast
Class E (240.0.0.0 to 255.255.255.255)
- Use: Reserved/Experimental
Private IP Addresses
RFC 1918 reserves these for internal use:
code10.0.0.0 to 10.255.255.255 (Class A) 172.16.0.0 to 172.31.255.255 (Class B) 192.168.0.0 to 192.168.255.255 (Class C)
Use: Home networks, company LANs NAT: Translates private → public IP
Special IP Addresses
code0.0.0.0 Default route 127.0.0.1 Localhost (loopback) 255.255.255.255 Broadcast 169.254.x.x APIPA (auto-config when DHCP fails)
Subnet Masks
What is a Subnet Mask?
Divides IP address into network and host portions.
Format: Same as IP (4 octets) Binary: Contiguous 1s (network), then 0s (host)
Default Masks
codeClass A: 255.0.0.0 = /8 = 11111111.00000000.00000000.00000000 Class B: 255.255.0.0 = /16 = 11111111.11111111.00000000.00000000 Class C: 255.255.255.0 = /24 = 11111111.11111111.11111111.00000000
CIDR Notation
CIDR: Classless Inter-Domain Routing
code192.168.1.0/24 = 255.255.255.0 10.0.0.0/8 = 255.0.0.0 172.16.0.0/12 = 255.240.0.0
/24 means first 24 bits are network portion
Calculating Network Info
Example: 192.168.1.100/24
- Network Address: 192.168.1.0
- Broadcast Address: 192.168.1.255
- First Host: 192.168.1.1
- Last Host: 192.168.1.254
- Total Hosts: 254 (2⁸ - 2)
Why -2? Network address & broadcast address
Subnetting
Why Subnet?
- Efficient IP usage
- Better network organization
- Improved security (isolate networks)
- Reduced broadcast traffic
Subnetting Example
Problem: Divide 192.168.1.0/24 into 4 subnets
Solution:
- Need 2² = 4 subnets
- Borrow 2 bits from host portion
- New mask: /26 (255.255.255.192)
Subnets:
code1. 192.168.1.0/26 (Hosts: 1-62) 2. 192.168.1.64/26 (Hosts: 65-126) 3. 192.168.1.128/26 (Hosts: 129-190) 4. 192.168.1.192/26 (Hosts: 193-254)
Each subnet: 62 usable hosts
Subnet Calculation Steps
- Determine requirements: How many subnets? Hosts per subnet?
- Borrow bits: n bits → 2ⁿ subnets
- New mask: Original + borrowed bits
- Block size: 256 - last octet of mask
- List subnets: Increment by block size
Common Subnet Masks
| CIDR | Mask | Hosts | |------|------|-------| | /30 | 255.255.255.252 | 2 | | /29 | 255.255.255.248 | 6 | | /28 | 255.255.255.240 | 14 | | /27 | 255.255.255.224 | 30 | | /26 | 255.255.255.192 | 62 | | /25 | 255.255.255.128 | 126 | | /24 | 255.255.255.0 | 254 |
IPv6
Why IPv6?
- IPv4 exhaustion: Running out of addresses
- More addresses: 340 undecillion (340 × 10³⁶)
- Better security: IPsec built-in
- Simpler header: Faster routing
IPv6 Address Format
128 bits in 8 groups of 16 bits (hexadecimal)
code2001:0db8:85a3:0000:0000:8a2e:0370:7334
IPv6 Shortening Rules
1. Remove leading zeros:
code2001:0db8:85a3:0000:0000:8a2e:0370:7334 ↓ 2001:db8:85a3:0:0:8a2e:370:7334
2. Replace consecutive zeros with :::
code2001:db8:85a3:0:0:8a2e:370:7334 ↓ 2001:db8:85a3::8a2e:370:7334
Note: Use :: only once per address
IPv6 Address Types
Unicast: One device
code2001:db8::1
Multicast: Group of devices
codeff00::/8
Anycast: Nearest device in group
Link-Local: Same network segment
codefe80::/10
Loopback: This device
code::1 (equivalent to 127.0.0.1)
Key Protocols
TCP (Transmission Control Protocol)
Characteristics: ✅ Connection-oriented ✅ Reliable ✅ Ordered ✅ Error checking ✅ Flow control
Three-Way Handshake:
code1. Client → Server: SYN 2. Server → Client: SYN-ACK 3. Client → Server: ACK → Connection established
TCP Header Fields:
- Source/Destination Port (16 bits each)
- Sequence Number (32 bits)
- Acknowledgment Number (32 bits)
- Flags (SYN, ACK, FIN, RST, PSH, URG)
- Window Size (16 bits)
- Checksum (16 bits)
Use Cases:
- HTTP/HTTPS (web)
- Email (SMTP, POP3, IMAP)
- FTP (file transfer)
- SSH (remote access)
UDP (User Datagram Protocol)
Characteristics: ✅ Connectionless ✅ Fast ✅ Low overhead ❌ No reliability ❌ No ordering ❌ No error recovery
UDP Header (8 bytes only!):
- Source Port
- Destination Port
- Length
- Checksum
Use Cases:
- DNS queries
- Video streaming (YouTube, Netflix)
- Online gaming
- VoIP (Zoom, Skype)
- DHCP
When to use UDP? Speed > Reliability (can tolerate packet loss)
ICMP (Internet Control Message Protocol)
Purpose: Error reporting and diagnostics
Tools:
- ping: Test connectivity
- traceroute: Show network path
Message Types:
- Echo Request/Reply (ping)
- Destination Unreachable
- Time Exceeded
- Redirect
code# Test connectivity ping google.com # Trace route traceroute google.com
ARP (Address Resolution Protocol)
Purpose: Map IP address → MAC address
Process:
- Device needs MAC for IP 192.168.1.5
- Broadcasts: "Who has 192.168.1.5?"
- Device with that IP replies: "I do! My MAC is XX:XX:XX"
- Sender caches the mapping
code# View ARP cache arp -a
DNS (Domain Name System)
Purpose
Translate domain names → IP addresses
codewww.google.com → 142.250.185.78
DNS Hierarchy
code. (root) | com org net edu | google | www mail drive
DNS Record Types
A Record: IPv4 address
codewww.example.com → 93.184.216.34
AAAA Record: IPv6 address
codewww.example.com → 2606:2800:220:1:248:1893:25c8:1946
CNAME: Alias
codewww.example.com → example.com
MX: Mail server
codeexample.com → mail.example.com (priority 10)
NS: Name server TXT: Text data (SPF, DKIM) PTR: Reverse DNS (IP → domain)
DNS Query Process
- Type www.google.com
- Check local cache
- Query DNS resolver (ISP)
- Resolver queries root server
- Root refers to .com server
- .com refers to google.com server
- google.com server returns IP
- IP cached and returned
code# DNS lookup nslookup google.com dig google.com
DHCP (Dynamic Host Configuration Protocol)
Purpose
Automatically assign IP addresses and network config
DORA Process
- Discover: Client broadcasts "I need an IP!"
- Offer: DHCP server offers IP address
- Request: Client requests offered IP
- Acknowledge: Server confirms assignment
DHCP Provides:
- IP address
- Subnet mask
- Default gateway
- DNS servers
- Lease time
Lease: How long you can use the IP
Static vs DHCP
Static IP:
- Manually configured
- Never changes
- Use for servers
DHCP:
- Automatically assigned
- Can change
- Use for clients (laptops, phones)
NAT (Network Address Translation)
Purpose
Translate private IPs → public IP
Why? IPv4 address shortage
How NAT Works
code[Home Network - Private IPs] ├─ PC1: 192.168.1.10 ├─ PC2: 192.168.1.11 └─ Phone: 192.168.1.12 | [Router/NAT] | Public IP: 203.0.113.5 | [Internet]
Outbound:
- PC1 (192.168.1.10) requests website
- Router changes source IP to 203.0.113.5
- Tracks connection in NAT table
- Sends to internet
Inbound:
- Reply comes to 203.0.113.5
- Router checks NAT table
- Forwards to 192.168.1.10
NAT Types
Static NAT: 1 private ↔ 1 public Dynamic NAT: Pool of public IPs PAT: Port Address Translation (most common)
Port Numbers
Well-Known Ports (0-1023)
| Port | Protocol | Service | |------|----------|----------| | 20/21 | TCP | FTP | | 22 | TCP | SSH | | 23 | TCP | Telnet | | 25 | TCP | SMTP | | 53 | TCP/UDP | DNS | | 67/68 | UDP | DHCP | | 80 | TCP | HTTP | | 110 | TCP | POP3 | | 143 | TCP | IMAP | | 443 | TCP | HTTPS | | 3389 | TCP | RDP |
Registered Ports (1024-49151)
Assigned by IANA for specific apps:
- 3306: MySQL
- 5432: PostgreSQL
- 27017: MongoDB
- 6379: Redis
Dynamic/Private (49152-65535)
Temporary client ports
Network Tools
ping
Test connectivity
codeping 8.8.8.8 ping google.com
traceroute/tracert
Show network path
codetraceroute google.com # Linux/Mac tracert google.com # Windows
nslookup/dig
DNS queries
codenslookup google.com dig google.com
netstat
Network connections
codenetstat -an # All connections netstat -r # Routing table
ipconfig/ifconfig
View IP configuration
codeipconfig /all # Windows ifconfig # Linux/Mac ip addr # Modern Linux
Practice Problems
- What's the network address of 192.168.50.100/26?
- How many usable hosts in a /28 subnet?
- Subnet 10.0.0.0/8 into 4 equal networks
- Convert 172.16.0.0/12 to subnet mask
- What's the broadcast address of 192.168.1.64/27?
- Which ports does HTTPS use?
- Explain the DNS resolution process
- What's the difference between TCP and UDP?