Computer Networks
Table of Contents
• Overview
• Network Models: OSI and TCP/IP
• Link Layer: Ethernet, Wi-Fi, and Physical Media
• Network Layer: IP Addressing, Subnetting, Routing
• Transport Layer: UDP, TCP, Congestion and Flow Control
• Application Layer Protocols: HTTP, DNS, SMTP, FTP
• Network Programming: Sockets and APIs
• Switching, Routing, and Forwarding
• Quality of Service, NAT, and Firewalls
• Wireless and Mobile Networks
• Network Security: TLS, VPNs, IDS/IPS
• Performance: Latency, Bandwidth, and Measurement
• Network Management and Monitoring
• Advanced Topics: SDN and NFV
• Exercises and Projects
• Further Reading
Overview
Computer networks enable communication between devices by defining con-
ventions for addressing, routing, transport, and application-level interactions.
Understanding networks requires both protocol theory and practical skills in
configuration, programming, and troubleshooting.
Network Models: OSI and TCP/IP
• OSI 7-layer model: Physical, Data Link, Network, Transport, Session,
Presentation, Application. Useful for conceptual separation.
• TCP/IP (Internet) stack: Link, Internet, Transport, Application.
Mapping common protocols to layers: - Link: Ethernet, ARP - Internet: IPv4,
IPv6, ICMP - Transport: TCP, UDP - Application: HTTP, DNS, SMTP
Link Layer: Ethernet, Wi-Fi, and Physical Media
• Ethernet (IEEE 802.3): MAC addresses, framing, CSMA/CD historically
for half-duplex; switched Ethernet in modern LANs.
• Wireless (IEEE 802.11): association, beaconing, CSMA/CA, contention
windows, power-save modes.
• Framing, checksums (FCS), MTU, fragmentation at link vs network layer.
• Physical media: copper (twisted pair), fiber optics, wireless RF—impacts
signal attenuation and bandwidth.
1
Network Layer: IP Addressing, Subnetting, Routing
• IPv4 addressing: classes deprecated; use CIDR (Classless Inter-Domain
Routing). Example: [Link]/24.
• IPv6 basics: 128-bit addresses, reduced NAT, link-local addresses.
• Subnetting: allocate prefixes, compute network and broadcast addresses.
• ARP for IPv4 address resolution; Neighbor Discovery in IPv6.
• Routing: static vs dynamic routing protocols (RIP, OSPF, BGP). BGP
for inter-AS routing, policy-based path selection.
Example: Determine network address for [Link]/26: - Mask /26 =>
[Link], block size 64. [Link], [Link], etc. Host 45 is in
[Link]/26.
Transport Layer: UDP, TCP, Congestion and Flow Control
• UDP: connectionless, minimal header, no reliability guarantees. Useful for
DNS, real-time audio/video.
• TCP: connection-oriented, reliable, ordered delivery, flow control (slid-
ing window), congestion control (slow start, congestion avoidance, fast
retransmit/fast recovery).
• Socket semantics: blocking vs non-blocking I/O, select/poll/epoll, asyn-
chronous frameworks.
TCP congestion control outline: 1. Slow start: exponential window growth
until threshold. 2. Congestion avoidance: linear increase. 3. Upon loss: reduce
window and set threshold.
Application Layer Protocols: HTTP, DNS, SMTP, FTP
• HTTP/HTTPS: request-response model, methods (GET, POST, PUT),
status codes, persistent connections, pipelining (historically), HTTP/2
multiplexing, HTTP/3 (QUIC over UDP).
• DNS: hierarchical name resolution with caching; query types: A, AAAA,
CNAME, MX. Recursive vs iterative queries; authoritative vs recursive
resolvers.
• Email: SMTP for sending; IMAP/POP for retrieval; use of MX records in
DNS.
Network Programming: Sockets and APIs
• Berkeley sockets API: socket(), bind(), listen(), accept(), connect(), send(),
recv(), close().
• Example TCP server (pseudo-code):
int sock = socket(AF_INET, SOCK_STREAM, 0);
bind(sock, addr);
listen(sock, backlog);
2
while (1) {
int client = accept(sock, &client_addr);
handle_client(client);
}
• Use non-blocking sockets and event loops (select/epoll/kqueue) for scalable
servers.
Switching, Routing, and Forwarding
• Switches operate at link layer and forward frames by MAC address learning.
• Routers operate at network layer and forward packets based on routing
tables.
• Forwarding plane vs control plane: forwarding is fast-path packet process-
ing; control plane runs routing protocols and administrative tasks.
Quality of Service, NAT, and Firewalls
• QoS: prioritize traffic using diffserv, queuing disciplines (FIFO, RED,
CoDel), traffic shaping and policing.
• NAT: maps private IPs to public IPs; issues: breaks end-to-end connectivity,
complicates protocols that embed IP addresses.
• Firewalls: packet filtering (stateless), stateful inspection, application-layer
gateways.
Wireless and Mobile Networks
• Cellular networks: architecture (UE, eNodeB/gNodeB, core network),
handover, mobility management.
• Wi-Fi: SSID, channels, interference, WPA2/WPA3 security.
• Ad-hoc and mesh networking basics.
Network Security: TLS, VPNs, IDS/IPS
• TLS: handshake (client hello, server hello, certs), record layer encryption,
cipher suites, certificate verification.
• VPNs: IPSec (tunnel vs transport modes), SSL/TLS-based VPNs, site-to-
site vs remote access.
• IDS/IPS: signature-based vs anomaly-based detection; placement and false
positives.
Performance: Latency, Bandwidth, and Measurement
• Latency components: propagation, transmission, processing, queueing.
• Bandwidth: link capacity measured in bits per second.
• Bandwidth-delay product determines TCP window sizing.
3
• Measurement tools: ping, traceroute, iperf, tcpdump, Wireshark for packet
capture and analysis.
Network Management and Monitoring
• SNMP, NetFlow/IPFIX for flow-level telemetry.
• Logs, metrics, and alerting; network topology discovery.
• Troubleshooting workflow: isolate layer, reproduce, capture, and analyze.
Advanced Topics: SDN and NFV
• Software-Defined Networking: separation of control and data planes; con-
trollers (OpenFlow) manage forwarding behavior programmatically.
• Network Function Virtualization: deploy firewalls, load balancers as virtu-
alized functions on commodity servers.
Exercises and Projects
1. Implement a simple TCP chat server supporting multiple clients using
select/epoll.
2. Build a small traceroute tool using raw sockets and TTL manipulation.
3. Configure a home router: set up static routes, port forwarding, and a basic
firewall.
4. Analyze a pcap capture and report the sequence of events for a TCP
connection establishment and teardown.
Further Reading
• Kurose & Ross: Computer Networking: A Top-Down Approach.
• Comer: Internetworking with TCP/IP.
• RFCs for specific protocols (e.g., RFC 791 for IPv4, RFC 793 for TCP).