Networking

Networking

Networking questions are mostly definitions, protocols, ports, and differences.

Network basics

Computer network:

A group of connected devices that exchange data and share resources.

OSI model

Remember:

Please Do Not Throw Sausage Pizza Away
Layer Name Function
7 Application user services: HTTP, FTP, DNS
6 Presentation encryption, compression, format
5 Session session management
4 Transport end-to-end delivery, TCP/UDP
3 Network routing, IP
2 Data Link MAC, frames, switches
1 Physical bits, cables, signals

TCP/IP model

Layer Examples
Application HTTP, DNS, FTP, SMTP
Transport TCP, UDP
Internet IP, ICMP
Link Ethernet, Wi-Fi

TCP vs UDP

TCP UDP
Connection-oriented Connectionless
Reliable Not guaranteed reliable
Ordered delivery No ordering guarantee
Slower Faster
Uses ACK/retransmission No ACK by default
HTTP/HTTPS, FTP, email streaming, gaming, DNS

Common ports

Protocol Port
FTP data 20
FTP control 21
SSH 22
Telnet 23
SMTP 25
DNS 53
HTTP 80
POP3 110
IMAP 143
HTTPS 443

IP address

IP address identifies a device on a network.

IPv4 example:

192.168.1.1

IPv6 example:

2001:0db8::1

MAC address

MAC is hardware address of network interface.

Works at Data Link layer.

Router, switch, hub

Device Layer Function
Hub Physical broadcasts to all ports
Switch Data Link forwards using MAC address
Router Network forwards using IP address

DNS

DNS converts domain names to IP addresses.

Example:

google.com -> IP address

DHCP

DHCP automatically assigns IP addresses to devices.

ARP

ARP maps IP address to MAC address.

HTTP vs HTTPS

HTTP is plain text.
HTTPS uses TLS/SSL encryption.

Firewall

Firewall filters network traffic based on rules.

Subnetting basics

Subnet mask separates network part and host part.

Example:

192.168.1.10/24

/24 means first 24 bits are network bits.

Common MCQ traps

  • DNS uses port 53.
  • HTTPS uses port 443.
  • Switch uses MAC address.
  • Router uses IP address.
  • TCP is reliable; UDP is faster but unreliable.
  • ARP finds MAC from IP.