Quiz 2

Networking Models — OSI & TCP/IP, Application Layer

768 words
4 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# Networking Models — OSI & TCP/IP, Application Layer ## 🎯 Learning Objectives - Compare OSI (7-layer) and TCP/IP (5-layer) models - Explain the role of each layer - Trace HTTP request/response flow, DNS resolution, SMTP mail delivery - Analyze protocol headers * * * ## 1. Network Models ### 1.1 Intuition Networkin...

Networking Models — OSI & TCP/IP, Application Layer

🎯 Learning Objectives

  • Compare OSI (7-layer) and TCP/IP (5-layer) models
  • Explain the role of each layer
  • Trace HTTP request/response flow, DNS resolution, SMTP mail delivery
  • Analyze protocol headers

1. Network Models

1.1 Intuition

Networking is complex — layers break it into manageable pieces. Each layer provides services to the layer above and receives services from the layer below. Like a government hierarchy: the president (Application) doesn't worry about carrier pigeons (Physical).

1.2 OSI vs TCP/IP

(Diagram)
OSI LayerTCP/IP LayerProtocol Data Unit (PDU)Example Protocols
ApplicationApplicationMessageHTTP, DNS, SMTP, FTP
Presentation(merged into Application)TLS/SSL
Session(merged into Application)SOCKS
TransportTransportSegment (TCP) / Datagram (UDP)TCP, UDP
NetworkNetwork/InternetPacketIP, ICMP, ARP, OSPF
Data LinkData LinkFrameEthernet, WiFi
PhysicalPhysicalBit1000BASE-T, 802.11

1.3 Encapsulation

(Diagram) Each layer adds its own header (and sometimes trailer) around the data from the layer above.

2. Application Layer Protocols

2.1 HTTP (HyperText Transfer Protocol)

(Diagram) HTTP Methods:
MethodPurposeSafe?Idempotent?
GETRetrieve resourceYesYes
HEADGet headers onlyYesYes
POSTSubmit dataNoNo
PUTReplace resourceNoYes
DELETERemove resourceNoYes
PATCHPartial updateNoNo

2.2 DNS (Domain Name System)

(Diagram) DNS Record Types:
TypeDescriptionExample
AIPv4 addressexample.com → 93.184.216.34
AAAAIPv6 addressexample.com → 2606:2800:220:1:248:1893:25c8:1946
CNAMECanonical name (alias)www.example.com → example.com
MXMail exchange@ → mail.example.com (priority 10)
NSName serverexample.com → ns1.example.com
TXTText record (verification)SPF, DKIM keys

2.3 SMTP (Simple Mail Transfer Protocol)

(Diagram)

2.4 FTP (File Transfer Protocol)

  • Control connection: Port 21 (commands)
  • Data connection: Port 20 (data)
  • Active mode: Server connects back to client for data
  • Passive mode: Client connects to server for data

3. Transport Layer: UDP

3.1 UDP Header

pseudo
 0      7 8     15 16    23 24    31
+--------+--------+--------+--------+
|     Source Port    |  Destination  |
|                    |     Port      |
+--------+--------+--------+--------+
|      Length       |    Checksum   |
+--------+--------+--------+--------+
|           Data (payload)           |
+------------------------------------+

3.2 UDP Properties

PropertyDescription
ConnectionlessNo handshake, just send
UnreliableNo retransmission, no ordering
Low overhead8-byte header
No flow controlSender can overwhelm receiver
No congestion controlCan send at any rate
Used by: DNS, DHCP, VoIP, streaming, SNMP, QUIC (HTTP/3)

4. Common Pitfalls

Pitfall 1: Confusing OSI layers

Mistake: "TCP is a network layer protocol." Correction: TCP is transport layer (Layer 4). IP is network layer (Layer 3). Remember: TCP segments, IP packets, Ethernet frames.

Pitfall 2: DNS uses UDP AND TCP

Fact: DNS uses UDP for standard queries (≤ 512 bytes), but switches to TCP for zone transfers and large responses (DNSSEC, > 512 bytes).

Pitfall 3: HTTP is stateless

Correction: HTTP is stateless by design, but cookies, sessions, and tokens add state on top of HTTP.

5. 📐 Key Formulas / Concepts

ConceptDescription
EncapsulationEach layer adds a header to the data
PDULayer-specific data unit (segment, packet, frame)
Port numbersIdentify application (0-65535)
Well-known portsHTTP(80), HTTPS(443), DNS(53), SMTP(25), FTP(21)

6. 📝 Practice Questions

Q1: What is the difference between a TCP segment and an IP packet?
Answer: A TCP segment is the transport layer PDU — it contains a TCP header and application data. An IP packet is the network layer PDU — it contains an IP header, and its payload is typically a TCP segment or UDP datagram. The IP packet is encapsulated inside an Ethernet frame at the data link layer. Q2: Why does DNS use UDP for most queries?
Answer: DNS queries are typically small (one request, one response). UDP avoids the overhead of TCP's connection establishment (3-way handshake). If the response exceeds 512 bytes (or EDNS0 limit), DNS falls back to TCP. Q3: Trace the layers involved when you type http://example.com in a browser.
Answer:
  1. Application: HTTP GET request formed
  2. Transport: TCP connection established to 93.184.216.34:80
  3. Network: IP packets routed through the internet
  4. Data Link: Ethernet frames on local network
  5. Physical: Electrical/optical signals
Before this, DNS (Application/UDP) resolved the domain. Q4: What is the difference between HTTP and HTTPS?
Answer: HTTPS is HTTP over TLS/SSL. TLS provides encryption, authentication (server certificate), and integrity checking. HTTPS uses port 443 instead of 80. Q5: List three protocols at each layer of the TCP/IP model.
Answer:
  • Application: HTTP, DNS, SMTP, FTP, SSH
  • Transport: TCP, UDP, QUIC
  • Network: IP (v4/v6), ICMP, OSPF, ARP (sometimes in Network)
  • Data Link: Ethernet, WiFi (802.11), PPP

7. 🔗 Cross-References

  • Week 2 - Transport Layer: TCP in detail
  • Week 3 - Network Layer: IP addressing, routing
  • Week 4 - Data Link: Ethernet, MAC
  • BSCS4003 (Privacy & Security): TLS/SSL, HTTPS Join Discord NextTCP & UDP
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.