0% revised

Computer Networks

OSI/TCP-IP · protocols · security

0 / 13 revised
OSI vs TCP/IP Model 🎯
CN
▾
Quick Recall
OSI=7 layers (theoretical); TCP/IP=4 layers (practical); map: App+Pres+Sess→Application
OSI LayerFunctionProtocolPDUTCP/IP
7 ApplicationUser interfaceHTTP, FTP, SMTP, DNSDataApplication
6 PresentationEncryption, compressionSSL/TLS, JPEGData
5 SessionSession managementNetBIOS, RPCData
4 TransportReliable deliveryTCP, UDPSegmentTransport
3 NetworkRouting, logical addressingIP, ICMP, ARPPacketInternet
2 Data LinkFraming, MACEthernet, Wi-FiFrameNetwork Access
1 PhysicalBits on wireCables, signalsBits
Encapsulation / Decapsulation
CN
▾
Quick Recall
Data→Segment→Packet→Frame→Bits (going down); reverse going up
Sending: Each layer adds its header (and trailer at data link).
Application data → TCP adds port header (segment) → IP adds IP header (packet) → Ethernet adds MAC header + trailer (frame) → Physical sends bits.
Receiving: Each layer strips its header and passes payload up.
TCP vs UDP 🎯
CN
▾
Quick Recall
TCP = reliable, ordered, connection-oriented; UDP = fast, fire-and-forget
TCPUDP
ConnectionConnection-oriented (3-way handshake)Connectionless
ReliabilityGuaranteed (ACK, retransmit)No guarantee
OrderingOrdered (sequence numbers)No ordering
Flow ControlYes (sliding window)No
SpeedSlower (overhead)Faster
Header20-60 bytes8 bytes
Use casesHTTP, SSH, email, file transferDNS, video streaming, gaming, VoIP
TCP 3-Way Handshake 🎯
CN
▾
Quick Recall
SYN → SYN-ACK → ACK (open); FIN → ACK → FIN → ACK (close)
Connection setup (3-way):
1. Client → SYN (seq=x) → Server
2. Server → SYN-ACK (seq=y, ack=x+1) → Client
3. Client → ACK (ack=y+1) → Server

Connection teardown (4-way):
1. Client → FIN → Server
2. Server → ACK → Client
3. Server → FIN → Client
4. Client → ACK → Server (enters TIME_WAIT)

Flow control: Sliding window — receiver advertises window size.
Congestion control: Slow Start (exponential) → Congestion Avoidance (linear/AIMD). On loss: halve window (fast recovery) or reset to 1 (timeout).
IP Addressing & Subnetting 🎯
CN
▾
Quick Recall
IPv4=32-bit; CIDR /n → 2^(32-n) - 2 usable hosts; subnet mask determines network portion
ClassRangeDefault MaskNetworks
A1-126.x.x.x/8 (255.0.0.0)128
B128-191.x.x.x/16 (255.255.0.0)16K
C192-223.x.x.x/24 (255.255.255.0)2M
Private ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.
Subnetting example: 192.168.1.0/26 → mask 255.255.255.192 → 2^6-2 = 62 hosts per subnet, 4 subnets.
IPv4 vs IPv6: 32-bit vs 128-bit; IPv6 has no NAT needed, no broadcast, built-in IPSec.
DNS, DHCP, NAT 🎯
CN
▾
Quick Recall
DNS resolves names→IP; DHCP auto-assigns IP; NAT maps private→public IP
DNS resolution flow: Browser cache → OS cache → Recursive resolver → Root NS → TLD NS (.com) → Authoritative NS → IP returned.
Record types: A (IPv4), AAAA (IPv6), CNAME (alias), MX (mail), NS (nameserver).
DHCP: DORA process — Discover → Offer → Request → Acknowledge. Leases IP for a period.
NAT: Translates private IP:port → public IP:port. Allows many devices to share one public IP. Types: Static, Dynamic, PAT (port address translation).
HTTP / HTTPS 🎯
CN
▾
Quick Recall
HTTP=stateless request-response; HTTPS=HTTP+TLS; know methods & status codes
Methods:
MethodUseIdempotent?
GETRead resourceYes
POSTCreate resourceNo
PUTReplace resourceYes
PATCHPartial updateNo
DELETERemove resourceYes
Status codes: 200 OK, 201 Created, 301 Moved, 304 Not Modified, 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 500 Server Error, 503 Unavailable.
HTTP/1.1: Keep-alive, pipelining. HTTP/2: Multiplexing, header compression, server push. HTTP/3: QUIC (UDP-based), faster handshake.
ARP & ICMP
CN
▾
Quick Recall
ARP resolves IP→MAC (broadcast who-has); ICMP for diagnostics (ping, traceroute)
ARP: "Who has 192.168.1.5? Tell 192.168.1.1" → broadcast on LAN → target replies with MAC. Cached in ARP table.
ICMP: Control/error messages. Echo request/reply (ping), Destination Unreachable, Time Exceeded (traceroute uses TTL expiry), Redirect.
Network Devices 🎯
CN
▾
Quick Recall
Hub=broadcast all; Switch=MAC-based forward; Router=IP-based forward between networks
DeviceLayerIntelligence
HubL1 PhysicalBroadcasts to all ports (dumb)
BridgeL2 Data LinkFilters by MAC, connects 2 segments
SwitchL2 Data LinkMAC table, forwards to specific port
RouterL3 NetworkIP routing between networks
GatewayL7 ApplicationProtocol translation
MAC vs IP: MAC = physical hardware address (48-bit, burned in NIC), local scope. IP = logical address, globally routable.
Network Topologies
CN
▾
Quick Recall
Star=central hub; Bus=single cable; Ring=circular; Mesh=every node connected
TopologyProsCons
StarEasy to manage, fault isolationCentral point of failure
BusSimple, cheapSingle cable failure = all down
RingEqual access, orderedOne break disrupts all
MeshHighly redundantExpensive, complex
Error Detection
CN
▾
Quick Recall
Parity=1 bit; Checksum=sum-based; CRC=polynomial division (strongest)
Parity bit: Even/odd parity — detects single-bit errors only.
Checksum: Sum of data segments; used in IP/TCP headers. Catches most errors.
CRC (Cyclic Redundancy Check): Treats data as polynomial, divides by generator polynomial — remainder is CRC. Detects burst errors. Used in Ethernet.
SSL/TLS & Encryption 🎯
CN
▾
Quick Recall
TLS handshake: agree cipher → exchange keys → symmetric encrypt data
Symmetric: Same key for encrypt/decrypt (AES). Fast. Challenge: key exchange.
Asymmetric: Public key encrypts, private key decrypts (RSA). Slow. Used for key exchange.
TLS handshake:
  1. Client Hello (supported ciphers)
  2. Server Hello (chosen cipher + certificate)
  3. Client verifies cert, generates pre-master secret, encrypts with server's public key
  4. Both derive session key → switch to symmetric encryption
HTTPS = HTTP over TLS. Ensures confidentiality, integrity, authentication.
Common Ports Table
CN
▾
Quick Recall
HTTP=80, HTTPS=443, SSH=22, DNS=53, FTP=21, SMTP=25
PortProtocolUse
20/21FTPFile transfer (data/control)
22SSHSecure shell
23TelnetRemote login (insecure)
25SMTPSend email
53DNSDomain name resolution
80HTTPWeb (unencrypted)
110POP3Receive email
143IMAPEmail access
443HTTPSWeb (encrypted)
3306MySQLDatabase
5432PostgreSQLDatabase